diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 05838d1de..85a77a061 100644 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -22,21 +22,21 @@ use Thelia\Model\AttributeCategory as ChildAttributeCategory; use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery; use Thelia\Model\AttributeQuery as ChildAttributeQuery; use Thelia\Model\Category as ChildCategory; +use Thelia\Model\CategoryDocument as ChildCategoryDocument; +use Thelia\Model\CategoryDocumentQuery as ChildCategoryDocumentQuery; use Thelia\Model\CategoryI18n as ChildCategoryI18n; use Thelia\Model\CategoryI18nQuery as ChildCategoryI18nQuery; +use Thelia\Model\CategoryImage as ChildCategoryImage; +use Thelia\Model\CategoryImageQuery as ChildCategoryImageQuery; use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\CategoryVersion as ChildCategoryVersion; use Thelia\Model\CategoryVersionQuery as ChildCategoryVersionQuery; use Thelia\Model\ContentAssoc as ChildContentAssoc; use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; -use Thelia\Model\Document as ChildDocument; -use Thelia\Model\DocumentQuery as ChildDocumentQuery; use Thelia\Model\Feature as ChildFeature; use Thelia\Model\FeatureCategory as ChildFeatureCategory; use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; use Thelia\Model\FeatureQuery as ChildFeatureQuery; -use Thelia\Model\Image as ChildImage; -use Thelia\Model\ImageQuery as ChildImageQuery; use Thelia\Model\Product as ChildProduct; use Thelia\Model\ProductCategory as ChildProductCategory; use Thelia\Model\ProductCategoryQuery as ChildProductCategoryQuery; @@ -159,24 +159,24 @@ abstract class Category implements ActiveRecordInterface protected $collContentAssocs; protected $collContentAssocsPartial; - /** - * @var ObjectCollection|ChildImage[] Collection to store aggregation of ChildImage objects. - */ - protected $collImages; - protected $collImagesPartial; - - /** - * @var ObjectCollection|ChildDocument[] Collection to store aggregation of ChildDocument objects. - */ - protected $collDocuments; - protected $collDocumentsPartial; - /** * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. */ protected $collRewritings; protected $collRewritingsPartial; + /** + * @var ObjectCollection|ChildCategoryImage[] Collection to store aggregation of ChildCategoryImage objects. + */ + protected $collCategoryImages; + protected $collCategoryImagesPartial; + + /** + * @var ObjectCollection|ChildCategoryDocument[] Collection to store aggregation of ChildCategoryDocument objects. + */ + protected $collCategoryDocuments; + protected $collCategoryDocumentsPartial; + /** * @var ObjectCollection|ChildCategoryI18n[] Collection to store aggregation of ChildCategoryI18n objects. */ @@ -276,24 +276,24 @@ abstract class Category implements ActiveRecordInterface */ protected $contentAssocsScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $imagesScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $documentsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection */ protected $rewritingsScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $categoryImagesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $categoryDocumentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -1041,12 +1041,12 @@ abstract class Category implements ActiveRecordInterface $this->collContentAssocs = null; - $this->collImages = null; - - $this->collDocuments = null; - $this->collRewritings = null; + $this->collCategoryImages = null; + + $this->collCategoryDocuments = null; + $this->collCategoryI18ns = null; $this->collCategoryVersions = null; @@ -1348,40 +1348,6 @@ abstract class Category implements ActiveRecordInterface } } - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - \Thelia\Model\ImageQuery::create() - ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - \Thelia\Model\DocumentQuery::create() - ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { \Thelia\Model\RewritingQuery::create() @@ -1399,6 +1365,40 @@ abstract class Category implements ActiveRecordInterface } } + if ($this->categoryImagesScheduledForDeletion !== null) { + if (!$this->categoryImagesScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryImageQuery::create() + ->filterByPrimaryKeys($this->categoryImagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryImagesScheduledForDeletion = null; + } + } + + if ($this->collCategoryImages !== null) { + foreach ($this->collCategoryImages as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->categoryDocumentsScheduledForDeletion !== null) { + if (!$this->categoryDocumentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryDocumentQuery::create() + ->filterByPrimaryKeys($this->categoryDocumentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryDocumentsScheduledForDeletion = null; + } + } + + if ($this->collCategoryDocuments !== null) { + foreach ($this->collCategoryDocuments as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->categoryI18nsScheduledForDeletion !== null) { if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\CategoryI18nQuery::create() @@ -1671,15 +1671,15 @@ abstract class Category implements ActiveRecordInterface if (null !== $this->collContentAssocs) { $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collCategoryImages) { + $result['CategoryImages'] = $this->collCategoryImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCategoryDocuments) { + $result['CategoryDocuments'] = $this->collCategoryDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collCategoryI18ns) { $result['CategoryI18ns'] = $this->collCategoryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1901,24 +1901,24 @@ abstract class Category implements ActiveRecordInterface } } - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); } } + foreach ($this->getCategoryImages() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryImage($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCategoryDocuments() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryDocument($relObj->copy($deepCopy)); + } + } + foreach ($this->getCategoryI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCategoryI18n($relObj->copy($deepCopy)); @@ -1984,15 +1984,15 @@ abstract class Category implements ActiveRecordInterface if ('ContentAssoc' == $relationName) { return $this->initContentAssocs(); } - if ('Image' == $relationName) { - return $this->initImages(); - } - if ('Document' == $relationName) { - return $this->initDocuments(); - } if ('Rewriting' == $relationName) { return $this->initRewritings(); } + if ('CategoryImage' == $relationName) { + return $this->initCategoryImages(); + } + if ('CategoryDocument' == $relationName) { + return $this->initCategoryDocuments(); + } if ('CategoryI18n' == $relationName) { return $this->initCategoryI18ns(); } @@ -3001,592 +3001,6 @@ abstract class Category implements ActiveRecordInterface return $this->getContentAssocs($query, $con); } - /** - * Clears out the collImages collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collImages collection loaded partially. - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new ObjectCollection(); - $this->collImages->setModel('\Thelia\Model\Image'); - } - - /** - * Gets an array of ChildImage objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildImage[] List of ChildImage objects - * @throws PropelException - */ - public function getImages($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ChildImageQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach ($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - $collImages->getInternalIterator()->rewind(); - - return $collImages; - } - - if ($partial && $this->collImages) { - foreach ($this->collImages as $obj) { - if ($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $images A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setImages(Collection $images, ConnectionInterface $con = null) - { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - - - $this->imagesScheduledForDeletion = $imagesToDelete; - - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setCategory(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - - return $this; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getImages()); - } - - $query = ChildImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collImages); - } - - /** - * Method called to associate a ChildImage object to this object - * through the ChildImage foreign key attribute. - * - * @param ChildImage $l ChildImage - * @return \Thelia\Model\Category The current object (for fluent API support) - */ - public function addImage(ChildImage $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setCategory($this); - } - - /** - * @param Image $image The image object to remove. - * @return ChildCategory The current object (for fluent API support) - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collDocuments collection loaded partially. - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new ObjectCollection(); - $this->collDocuments->setModel('\Thelia\Model\Document'); - } - - /** - * Gets an array of ChildDocument objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCategory is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDocument[] List of ChildDocument objects - * @throws PropelException - */ - public function getDocuments($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = ChildDocumentQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach ($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - $collDocuments->getInternalIterator()->rewind(); - - return $collDocuments; - } - - if ($partial && $this->collDocuments) { - foreach ($this->collDocuments as $obj) { - if ($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $documents A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCategory The current object (for fluent API support) - */ - public function setDocuments(Collection $documents, ConnectionInterface $con = null) - { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - - - $this->documentsScheduledForDeletion = $documentsToDelete; - - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setCategory(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - - return $this; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getDocuments()); - } - - $query = ChildDocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collDocuments); - } - - /** - * Method called to associate a ChildDocument object to this object - * through the ChildDocument foreign key attribute. - * - * @param ChildDocument $l ChildDocument - * @return \Thelia\Model\Category The current object (for fluent API support) - */ - public function addDocument(ChildDocument $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setCategory($this); - } - - /** - * @param Document $document The document object to remove. - * @return ChildCategory The current object (for fluent API support) - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getDocuments($query, $con); - } - /** * Clears out the collRewritings collection * @@ -3880,6 +3294,442 @@ abstract class Category implements ActiveRecordInterface return $this->getRewritings($query, $con); } + /** + * Clears out the collCategoryImages collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryImages() + */ + public function clearCategoryImages() + { + $this->collCategoryImages = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryImages collection loaded partially. + */ + public function resetPartialCategoryImages($v = true) + { + $this->collCategoryImagesPartial = $v; + } + + /** + * Initializes the collCategoryImages collection. + * + * By default this just sets the collCategoryImages collection to an empty array (like clearcollCategoryImages()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryImages($overrideExisting = true) + { + if (null !== $this->collCategoryImages && !$overrideExisting) { + return; + } + $this->collCategoryImages = new ObjectCollection(); + $this->collCategoryImages->setModel('\Thelia\Model\CategoryImage'); + } + + /** + * Gets an array of ChildCategoryImage objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCategory is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryImage[] List of ChildCategoryImage objects + * @throws PropelException + */ + public function getCategoryImages($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryImagesPartial && !$this->isNew(); + if (null === $this->collCategoryImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryImages) { + // return empty collection + $this->initCategoryImages(); + } else { + $collCategoryImages = ChildCategoryImageQuery::create(null, $criteria) + ->filterByCategory($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryImagesPartial && count($collCategoryImages)) { + $this->initCategoryImages(false); + + foreach ($collCategoryImages as $obj) { + if (false == $this->collCategoryImages->contains($obj)) { + $this->collCategoryImages->append($obj); + } + } + + $this->collCategoryImagesPartial = true; + } + + $collCategoryImages->getInternalIterator()->rewind(); + + return $collCategoryImages; + } + + if ($partial && $this->collCategoryImages) { + foreach ($this->collCategoryImages as $obj) { + if ($obj->isNew()) { + $collCategoryImages[] = $obj; + } + } + } + + $this->collCategoryImages = $collCategoryImages; + $this->collCategoryImagesPartial = false; + } + } + + return $this->collCategoryImages; + } + + /** + * Sets a collection of CategoryImage objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryImages A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) + */ + public function setCategoryImages(Collection $categoryImages, ConnectionInterface $con = null) + { + $categoryImagesToDelete = $this->getCategoryImages(new Criteria(), $con)->diff($categoryImages); + + + $this->categoryImagesScheduledForDeletion = $categoryImagesToDelete; + + foreach ($categoryImagesToDelete as $categoryImageRemoved) { + $categoryImageRemoved->setCategory(null); + } + + $this->collCategoryImages = null; + foreach ($categoryImages as $categoryImage) { + $this->addCategoryImage($categoryImage); + } + + $this->collCategoryImages = $categoryImages; + $this->collCategoryImagesPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryImage objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryImage objects. + * @throws PropelException + */ + public function countCategoryImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryImagesPartial && !$this->isNew(); + if (null === $this->collCategoryImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryImages) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryImages()); + } + + $query = ChildCategoryImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); + } + + return count($this->collCategoryImages); + } + + /** + * Method called to associate a ChildCategoryImage object to this object + * through the ChildCategoryImage foreign key attribute. + * + * @param ChildCategoryImage $l ChildCategoryImage + * @return \Thelia\Model\Category The current object (for fluent API support) + */ + public function addCategoryImage(ChildCategoryImage $l) + { + if ($this->collCategoryImages === null) { + $this->initCategoryImages(); + $this->collCategoryImagesPartial = true; + } + + if (!in_array($l, $this->collCategoryImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryImage($l); + } + + return $this; + } + + /** + * @param CategoryImage $categoryImage The categoryImage object to add. + */ + protected function doAddCategoryImage($categoryImage) + { + $this->collCategoryImages[]= $categoryImage; + $categoryImage->setCategory($this); + } + + /** + * @param CategoryImage $categoryImage The categoryImage object to remove. + * @return ChildCategory The current object (for fluent API support) + */ + public function removeCategoryImage($categoryImage) + { + if ($this->getCategoryImages()->contains($categoryImage)) { + $this->collCategoryImages->remove($this->collCategoryImages->search($categoryImage)); + if (null === $this->categoryImagesScheduledForDeletion) { + $this->categoryImagesScheduledForDeletion = clone $this->collCategoryImages; + $this->categoryImagesScheduledForDeletion->clear(); + } + $this->categoryImagesScheduledForDeletion[]= clone $categoryImage; + $categoryImage->setCategory(null); + } + + return $this; + } + + /** + * Clears out the collCategoryDocuments collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryDocuments() + */ + public function clearCategoryDocuments() + { + $this->collCategoryDocuments = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryDocuments collection loaded partially. + */ + public function resetPartialCategoryDocuments($v = true) + { + $this->collCategoryDocumentsPartial = $v; + } + + /** + * Initializes the collCategoryDocuments collection. + * + * By default this just sets the collCategoryDocuments collection to an empty array (like clearcollCategoryDocuments()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryDocuments($overrideExisting = true) + { + if (null !== $this->collCategoryDocuments && !$overrideExisting) { + return; + } + $this->collCategoryDocuments = new ObjectCollection(); + $this->collCategoryDocuments->setModel('\Thelia\Model\CategoryDocument'); + } + + /** + * Gets an array of ChildCategoryDocument objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCategory is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryDocument[] List of ChildCategoryDocument objects + * @throws PropelException + */ + public function getCategoryDocuments($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryDocumentsPartial && !$this->isNew(); + if (null === $this->collCategoryDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryDocuments) { + // return empty collection + $this->initCategoryDocuments(); + } else { + $collCategoryDocuments = ChildCategoryDocumentQuery::create(null, $criteria) + ->filterByCategory($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryDocumentsPartial && count($collCategoryDocuments)) { + $this->initCategoryDocuments(false); + + foreach ($collCategoryDocuments as $obj) { + if (false == $this->collCategoryDocuments->contains($obj)) { + $this->collCategoryDocuments->append($obj); + } + } + + $this->collCategoryDocumentsPartial = true; + } + + $collCategoryDocuments->getInternalIterator()->rewind(); + + return $collCategoryDocuments; + } + + if ($partial && $this->collCategoryDocuments) { + foreach ($this->collCategoryDocuments as $obj) { + if ($obj->isNew()) { + $collCategoryDocuments[] = $obj; + } + } + } + + $this->collCategoryDocuments = $collCategoryDocuments; + $this->collCategoryDocumentsPartial = false; + } + } + + return $this->collCategoryDocuments; + } + + /** + * Sets a collection of CategoryDocument objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryDocuments A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) + */ + public function setCategoryDocuments(Collection $categoryDocuments, ConnectionInterface $con = null) + { + $categoryDocumentsToDelete = $this->getCategoryDocuments(new Criteria(), $con)->diff($categoryDocuments); + + + $this->categoryDocumentsScheduledForDeletion = $categoryDocumentsToDelete; + + foreach ($categoryDocumentsToDelete as $categoryDocumentRemoved) { + $categoryDocumentRemoved->setCategory(null); + } + + $this->collCategoryDocuments = null; + foreach ($categoryDocuments as $categoryDocument) { + $this->addCategoryDocument($categoryDocument); + } + + $this->collCategoryDocuments = $categoryDocuments; + $this->collCategoryDocumentsPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryDocument objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryDocument objects. + * @throws PropelException + */ + public function countCategoryDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryDocumentsPartial && !$this->isNew(); + if (null === $this->collCategoryDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryDocuments) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryDocuments()); + } + + $query = ChildCategoryDocumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategory($this) + ->count($con); + } + + return count($this->collCategoryDocuments); + } + + /** + * Method called to associate a ChildCategoryDocument object to this object + * through the ChildCategoryDocument foreign key attribute. + * + * @param ChildCategoryDocument $l ChildCategoryDocument + * @return \Thelia\Model\Category The current object (for fluent API support) + */ + public function addCategoryDocument(ChildCategoryDocument $l) + { + if ($this->collCategoryDocuments === null) { + $this->initCategoryDocuments(); + $this->collCategoryDocumentsPartial = true; + } + + if (!in_array($l, $this->collCategoryDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryDocument($l); + } + + return $this; + } + + /** + * @param CategoryDocument $categoryDocument The categoryDocument object to add. + */ + protected function doAddCategoryDocument($categoryDocument) + { + $this->collCategoryDocuments[]= $categoryDocument; + $categoryDocument->setCategory($this); + } + + /** + * @param CategoryDocument $categoryDocument The categoryDocument object to remove. + * @return ChildCategory The current object (for fluent API support) + */ + public function removeCategoryDocument($categoryDocument) + { + if ($this->getCategoryDocuments()->contains($categoryDocument)) { + $this->collCategoryDocuments->remove($this->collCategoryDocuments->search($categoryDocument)); + if (null === $this->categoryDocumentsScheduledForDeletion) { + $this->categoryDocumentsScheduledForDeletion = clone $this->collCategoryDocuments; + $this->categoryDocumentsScheduledForDeletion->clear(); + } + $this->categoryDocumentsScheduledForDeletion[]= clone $categoryDocument; + $categoryDocument->setCategory(null); + } + + return $this; + } + /** * Clears out the collCategoryI18ns collection * @@ -4929,21 +4779,21 @@ abstract class Category implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); } } + if ($this->collCategoryImages) { + foreach ($this->collCategoryImages as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCategoryDocuments) { + foreach ($this->collCategoryDocuments as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCategoryI18ns) { foreach ($this->collCategoryI18ns as $o) { $o->clearAllReferences($deep); @@ -4991,18 +4841,18 @@ abstract class Category implements ActiveRecordInterface $this->collContentAssocs->clearIterator(); } $this->collContentAssocs = null; - if ($this->collImages instanceof Collection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collDocuments instanceof Collection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; + if ($this->collCategoryImages instanceof Collection) { + $this->collCategoryImages->clearIterator(); + } + $this->collCategoryImages = null; + if ($this->collCategoryDocuments instanceof Collection) { + $this->collCategoryDocuments->clearIterator(); + } + $this->collCategoryDocuments = null; if ($this->collCategoryI18ns instanceof Collection) { $this->collCategoryI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CategoryDocument.php b/core/lib/Thelia/Model/Base/CategoryDocument.php new file mode 100644 index 000000000..165bfa492 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryDocument.php @@ -0,0 +1,1990 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryDocument instance. If + * obj is an instance of CategoryDocument, delegates to + * equals(CategoryDocument). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryDocument The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryDocument The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [category_id] column value. + * + * @return int + */ + public function getCategoryId() + { + + return $this->category_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryDocumentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [category_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = CategoryDocumentTableMap::CATEGORY_ID; + } + + if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { + $this->aCategory = null; + } + + + return $this; + } // setCategoryId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[] = CategoryDocumentTableMap::FILE; + } + + + return $this; + } // setFile() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CategoryDocumentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CategoryDocumentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CategoryDocumentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryDocumentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryDocumentTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryDocumentTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryDocumentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryDocumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryDocumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CategoryDocumentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryDocument object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { + $this->aCategory = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryDocumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategory = null; + $this->collCategoryDocumentI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryDocument::setDeleted() + * @see CategoryDocument::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryDocumentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CategoryDocumentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CategoryDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CategoryDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CategoryDocumentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCategory !== null) { + if ($this->aCategory->isModified() || $this->aCategory->isNew()) { + $affectedRows += $this->aCategory->save($con); + } + $this->setCategory($this->aCategory); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->categoryDocumentI18nsScheduledForDeletion !== null) { + if (!$this->categoryDocumentI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryDocumentI18nQuery::create() + ->filterByPrimaryKeys($this->categoryDocumentI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryDocumentI18nsScheduledForDeletion = null; + } + } + + if ($this->collCategoryDocumentI18ns !== null) { + foreach ($this->collCategoryDocumentI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CategoryDocumentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryDocumentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryDocumentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryDocumentTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(CategoryDocumentTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(CategoryDocumentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(CategoryDocumentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CategoryDocumentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO category_document (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CATEGORY_ID': + $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCategoryId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryDocument'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryDocument'][$this->getPrimaryKey()] = true; + $keys = CategoryDocumentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCategoryId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCategory) { + $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCategoryDocumentI18ns) { + $result['CategoryDocumentI18ns'] = $this->collCategoryDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCategoryId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CategoryDocumentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CategoryDocumentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryDocumentTableMap::ID)) $criteria->add(CategoryDocumentTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryDocumentTableMap::CATEGORY_ID)) $criteria->add(CategoryDocumentTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(CategoryDocumentTableMap::FILE)) $criteria->add(CategoryDocumentTableMap::FILE, $this->file); + if ($this->isColumnModified(CategoryDocumentTableMap::POSITION)) $criteria->add(CategoryDocumentTableMap::POSITION, $this->position); + if ($this->isColumnModified(CategoryDocumentTableMap::CREATED_AT)) $criteria->add(CategoryDocumentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CategoryDocumentTableMap::UPDATED_AT)) $criteria->add(CategoryDocumentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CategoryDocumentTableMap::DATABASE_NAME); + $criteria->add(CategoryDocumentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CategoryDocument (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setFile($this->getFile()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getCategoryDocumentI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryDocumentI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CategoryDocument Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $v = null) + { + if ($v === null) { + $this->setCategoryId(NULL); + } else { + $this->setCategoryId($v->getId()); + } + + $this->aCategory = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addCategoryDocument($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCategory->addCategoryDocuments($this); + */ + } + + return $this->aCategory; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CategoryDocumentI18n' == $relationName) { + return $this->initCategoryDocumentI18ns(); + } + } + + /** + * Clears out the collCategoryDocumentI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryDocumentI18ns() + */ + public function clearCategoryDocumentI18ns() + { + $this->collCategoryDocumentI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryDocumentI18ns collection loaded partially. + */ + public function resetPartialCategoryDocumentI18ns($v = true) + { + $this->collCategoryDocumentI18nsPartial = $v; + } + + /** + * Initializes the collCategoryDocumentI18ns collection. + * + * By default this just sets the collCategoryDocumentI18ns collection to an empty array (like clearcollCategoryDocumentI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryDocumentI18ns($overrideExisting = true) + { + if (null !== $this->collCategoryDocumentI18ns && !$overrideExisting) { + return; + } + $this->collCategoryDocumentI18ns = new ObjectCollection(); + $this->collCategoryDocumentI18ns->setModel('\Thelia\Model\CategoryDocumentI18n'); + } + + /** + * Gets an array of ChildCategoryDocumentI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCategoryDocument is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryDocumentI18n[] List of ChildCategoryDocumentI18n objects + * @throws PropelException + */ + public function getCategoryDocumentI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collCategoryDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryDocumentI18ns) { + // return empty collection + $this->initCategoryDocumentI18ns(); + } else { + $collCategoryDocumentI18ns = ChildCategoryDocumentI18nQuery::create(null, $criteria) + ->filterByCategoryDocument($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryDocumentI18nsPartial && count($collCategoryDocumentI18ns)) { + $this->initCategoryDocumentI18ns(false); + + foreach ($collCategoryDocumentI18ns as $obj) { + if (false == $this->collCategoryDocumentI18ns->contains($obj)) { + $this->collCategoryDocumentI18ns->append($obj); + } + } + + $this->collCategoryDocumentI18nsPartial = true; + } + + $collCategoryDocumentI18ns->getInternalIterator()->rewind(); + + return $collCategoryDocumentI18ns; + } + + if ($partial && $this->collCategoryDocumentI18ns) { + foreach ($this->collCategoryDocumentI18ns as $obj) { + if ($obj->isNew()) { + $collCategoryDocumentI18ns[] = $obj; + } + } + } + + $this->collCategoryDocumentI18ns = $collCategoryDocumentI18ns; + $this->collCategoryDocumentI18nsPartial = false; + } + } + + return $this->collCategoryDocumentI18ns; + } + + /** + * Sets a collection of CategoryDocumentI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryDocumentI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategoryDocument The current object (for fluent API support) + */ + public function setCategoryDocumentI18ns(Collection $categoryDocumentI18ns, ConnectionInterface $con = null) + { + $categoryDocumentI18nsToDelete = $this->getCategoryDocumentI18ns(new Criteria(), $con)->diff($categoryDocumentI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->categoryDocumentI18nsScheduledForDeletion = clone $categoryDocumentI18nsToDelete; + + foreach ($categoryDocumentI18nsToDelete as $categoryDocumentI18nRemoved) { + $categoryDocumentI18nRemoved->setCategoryDocument(null); + } + + $this->collCategoryDocumentI18ns = null; + foreach ($categoryDocumentI18ns as $categoryDocumentI18n) { + $this->addCategoryDocumentI18n($categoryDocumentI18n); + } + + $this->collCategoryDocumentI18ns = $categoryDocumentI18ns; + $this->collCategoryDocumentI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryDocumentI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryDocumentI18n objects. + * @throws PropelException + */ + public function countCategoryDocumentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collCategoryDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryDocumentI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryDocumentI18ns()); + } + + $query = ChildCategoryDocumentI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategoryDocument($this) + ->count($con); + } + + return count($this->collCategoryDocumentI18ns); + } + + /** + * Method called to associate a ChildCategoryDocumentI18n object to this object + * through the ChildCategoryDocumentI18n foreign key attribute. + * + * @param ChildCategoryDocumentI18n $l ChildCategoryDocumentI18n + * @return \Thelia\Model\CategoryDocument The current object (for fluent API support) + */ + public function addCategoryDocumentI18n(ChildCategoryDocumentI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collCategoryDocumentI18ns === null) { + $this->initCategoryDocumentI18ns(); + $this->collCategoryDocumentI18nsPartial = true; + } + + if (!in_array($l, $this->collCategoryDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryDocumentI18n($l); + } + + return $this; + } + + /** + * @param CategoryDocumentI18n $categoryDocumentI18n The categoryDocumentI18n object to add. + */ + protected function doAddCategoryDocumentI18n($categoryDocumentI18n) + { + $this->collCategoryDocumentI18ns[]= $categoryDocumentI18n; + $categoryDocumentI18n->setCategoryDocument($this); + } + + /** + * @param CategoryDocumentI18n $categoryDocumentI18n The categoryDocumentI18n object to remove. + * @return ChildCategoryDocument The current object (for fluent API support) + */ + public function removeCategoryDocumentI18n($categoryDocumentI18n) + { + if ($this->getCategoryDocumentI18ns()->contains($categoryDocumentI18n)) { + $this->collCategoryDocumentI18ns->remove($this->collCategoryDocumentI18ns->search($categoryDocumentI18n)); + if (null === $this->categoryDocumentI18nsScheduledForDeletion) { + $this->categoryDocumentI18nsScheduledForDeletion = clone $this->collCategoryDocumentI18ns; + $this->categoryDocumentI18nsScheduledForDeletion->clear(); + } + $this->categoryDocumentI18nsScheduledForDeletion[]= clone $categoryDocumentI18n; + $categoryDocumentI18n->setCategoryDocument(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->category_id = null; + $this->file = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collCategoryDocumentI18ns) { + foreach ($this->collCategoryDocumentI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collCategoryDocumentI18ns instanceof Collection) { + $this->collCategoryDocumentI18ns->clearIterator(); + } + $this->collCategoryDocumentI18ns = null; + $this->aCategory = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryDocumentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildCategoryDocument The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CategoryDocumentTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildCategoryDocument The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryDocumentI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collCategoryDocumentI18ns) { + foreach ($this->collCategoryDocumentI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildCategoryDocumentI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildCategoryDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addCategoryDocumentI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryDocument The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildCategoryDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collCategoryDocumentI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collCategoryDocumentI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryDocumentI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php new file mode 100644 index 000000000..db3189cc3 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CategoryDocumentI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryDocumentI18n instance. If + * obj is an instance of CategoryDocumentI18n, delegates to + * equals(CategoryDocumentI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryDocumentI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryDocumentI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryDocumentI18nTableMap::ID; + } + + if ($this->aCategoryDocument !== null && $this->aCategoryDocument->getId() !== $v) { + $this->aCategoryDocument = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CategoryDocumentI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CategoryDocumentI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CategoryDocumentI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = CategoryDocumentI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = CategoryDocumentI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryDocumentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryDocumentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryDocumentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryDocumentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryDocumentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryDocumentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CategoryDocumentI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryDocumentI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCategoryDocument !== null && $this->id !== $this->aCategoryDocument->getId()) { + $this->aCategoryDocument = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryDocumentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategoryDocument = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryDocumentI18n::setDeleted() + * @see CategoryDocumentI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryDocumentI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CategoryDocumentI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCategoryDocument !== null) { + if ($this->aCategoryDocument->isModified() || $this->aCategoryDocument->isNew()) { + $affectedRows += $this->aCategoryDocument->save($con); + } + $this->setCategoryDocument($this->aCategoryDocument); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryDocumentI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryDocumentI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(CategoryDocumentI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CategoryDocumentI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(CategoryDocumentI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(CategoryDocumentI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO category_document_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryDocumentI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryDocumentI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CategoryDocumentI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCategoryDocument) { + $result['CategoryDocument'] = $this->aCategoryDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CategoryDocumentI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CategoryDocumentI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryDocumentI18nTableMap::ID)) $criteria->add(CategoryDocumentI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryDocumentI18nTableMap::LOCALE)) $criteria->add(CategoryDocumentI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(CategoryDocumentI18nTableMap::TITLE)) $criteria->add(CategoryDocumentI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(CategoryDocumentI18nTableMap::DESCRIPTION)) $criteria->add(CategoryDocumentI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(CategoryDocumentI18nTableMap::CHAPO)) $criteria->add(CategoryDocumentI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(CategoryDocumentI18nTableMap::POSTSCRIPTUM)) $criteria->add(CategoryDocumentI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CategoryDocumentI18nTableMap::DATABASE_NAME); + $criteria->add(CategoryDocumentI18nTableMap::ID, $this->id); + $criteria->add(CategoryDocumentI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CategoryDocumentI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CategoryDocumentI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCategoryDocument object. + * + * @param ChildCategoryDocument $v + * @return \Thelia\Model\CategoryDocumentI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCategoryDocument(ChildCategoryDocument $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aCategoryDocument = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCategoryDocument object, it will not be re-added. + if ($v !== null) { + $v->addCategoryDocumentI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategoryDocument object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategoryDocument The associated ChildCategoryDocument object. + * @throws PropelException + */ + public function getCategoryDocument(ConnectionInterface $con = null) + { + if ($this->aCategoryDocument === null && ($this->id !== null)) { + $this->aCategoryDocument = ChildCategoryDocumentQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCategoryDocument->addCategoryDocumentI18ns($this); + */ + } + + return $this->aCategoryDocument; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategoryDocument = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryDocumentI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentI18nQuery.php b/core/lib/Thelia/Model/Base/CategoryDocumentI18nQuery.php new file mode 100644 index 000000000..a8c6000dc --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryDocumentI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryDocumentI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CategoryDocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryDocumentI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM category_document_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryDocumentI18n(); + $obj->hydrate($row); + CategoryDocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryDocumentI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CategoryDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CategoryDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(CategoryDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CategoryDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByCategoryDocument() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryDocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryDocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryDocumentI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryDocumentI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryDocumentI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryDocumentI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryDocumentI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryDocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\CategoryDocument object + * + * @param \Thelia\Model\CategoryDocument|ObjectCollection $categoryDocument The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function filterByCategoryDocument($categoryDocument, $comparison = null) + { + if ($categoryDocument instanceof \Thelia\Model\CategoryDocument) { + return $this + ->addUsingAlias(CategoryDocumentI18nTableMap::ID, $categoryDocument->getId(), $comparison); + } elseif ($categoryDocument instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryDocumentI18nTableMap::ID, $categoryDocument->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCategoryDocument() only accepts arguments of type \Thelia\Model\CategoryDocument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryDocument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function joinCategoryDocument($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryDocument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryDocument'); + } + + return $this; + } + + /** + * Use the CategoryDocument relation CategoryDocument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryDocumentQuery A secondary query class using the current class as primary query + */ + public function useCategoryDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCategoryDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryDocument', '\Thelia\Model\CategoryDocumentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCategoryDocumentI18n $categoryDocumentI18n Object to remove from the list of results + * + * @return ChildCategoryDocumentI18nQuery The current query, for fluid interface + */ + public function prune($categoryDocumentI18n = null) + { + if ($categoryDocumentI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(CategoryDocumentI18nTableMap::ID), $categoryDocumentI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CategoryDocumentI18nTableMap::LOCALE), $categoryDocumentI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the category_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryDocumentI18nTableMap::clearInstancePool(); + CategoryDocumentI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryDocumentI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CategoryDocumentI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryDocumentI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CategoryDocumentI18nQuery diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php b/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php new file mode 100644 index 000000000..8c0a177ac --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryDocumentQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryDocument|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CategoryDocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryDocument A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CATEGORY_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM category_document WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryDocument(); + $obj->hydrate($row); + CategoryDocumentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryDocument|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CategoryDocumentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CategoryDocumentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryDocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryDocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryDocumentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the category_id column + * + * Example usage: + * + * $query->filterByCategoryId(1234); // WHERE category_id = 1234 + * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * + * + * @see filterByCategory() + * + * @param mixed $categoryId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByCategoryId($categoryId = null, $comparison = null) + { + if (is_array($categoryId)) { + $useMinMax = false; + if (isset($categoryId['min'])) { + $this->addUsingAlias(CategoryDocumentTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($categoryId['max'])) { + $this->addUsingAlias(CategoryDocumentTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryDocumentTableMap::CATEGORY_ID, $categoryId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryDocumentTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(CategoryDocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(CategoryDocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryDocumentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(CategoryDocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(CategoryDocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryDocumentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(CategoryDocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(CategoryDocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryDocumentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Category object + * + * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByCategory($category, $comparison = null) + { + if ($category instanceof \Thelia\Model\Category) { + return $this + ->addUsingAlias(CategoryDocumentTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryDocumentTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Category relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Category'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Category'); + } + + return $this; + } + + /** + * Use the Category relation Category object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query + */ + public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CategoryDocumentI18n object + * + * @param \Thelia\Model\CategoryDocumentI18n|ObjectCollection $categoryDocumentI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function filterByCategoryDocumentI18n($categoryDocumentI18n, $comparison = null) + { + if ($categoryDocumentI18n instanceof \Thelia\Model\CategoryDocumentI18n) { + return $this + ->addUsingAlias(CategoryDocumentTableMap::ID, $categoryDocumentI18n->getId(), $comparison); + } elseif ($categoryDocumentI18n instanceof ObjectCollection) { + return $this + ->useCategoryDocumentI18nQuery() + ->filterByPrimaryKeys($categoryDocumentI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryDocumentI18n() only accepts arguments of type \Thelia\Model\CategoryDocumentI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryDocumentI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function joinCategoryDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryDocumentI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryDocumentI18n'); + } + + return $this; + } + + /** + * Use the CategoryDocumentI18n relation CategoryDocumentI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useCategoryDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCategoryDocumentI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryDocumentI18n', '\Thelia\Model\CategoryDocumentI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCategoryDocument $categoryDocument Object to remove from the list of results + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function prune($categoryDocument = null) + { + if ($categoryDocument) { + $this->addUsingAlias(CategoryDocumentTableMap::ID, $categoryDocument->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the category_document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryDocumentTableMap::clearInstancePool(); + CategoryDocumentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryDocumentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CategoryDocumentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryDocumentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CategoryDocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CategoryDocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryDocumentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryDocumentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryDocumentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryDocumentTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'CategoryDocumentI18n'; + + return $this + ->joinCategoryDocumentI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCategoryDocumentQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('CategoryDocumentI18n'); + $this->with['CategoryDocumentI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCategoryDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryDocumentI18n', '\Thelia\Model\CategoryDocumentI18nQuery'); + } + +} // CategoryDocumentQuery diff --git a/core/lib/Thelia/Model/Base/CategoryImage.php b/core/lib/Thelia/Model/Base/CategoryImage.php new file mode 100644 index 000000000..efde7b64a --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryImage.php @@ -0,0 +1,1990 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryImage instance. If + * obj is an instance of CategoryImage, delegates to + * equals(CategoryImage). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryImage The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryImage The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [category_id] column value. + * + * @return int + */ + public function getCategoryId() + { + + return $this->category_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryImageTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [category_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = CategoryImageTableMap::CATEGORY_ID; + } + + if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { + $this->aCategory = null; + } + + + return $this; + } // setCategoryId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[] = CategoryImageTableMap::FILE; + } + + + return $this; + } // setFile() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CategoryImageTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CategoryImageTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CategoryImageTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryImageTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CategoryImageTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryImage object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { + $this->aCategory = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryImageTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategory = null; + $this->collCategoryImageI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryImage::setDeleted() + * @see CategoryImage::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryImageQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CategoryImageTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CategoryImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CategoryImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CategoryImageTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCategory !== null) { + if ($this->aCategory->isModified() || $this->aCategory->isNew()) { + $affectedRows += $this->aCategory->save($con); + } + $this->setCategory($this->aCategory); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->categoryImageI18nsScheduledForDeletion !== null) { + if (!$this->categoryImageI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CategoryImageI18nQuery::create() + ->filterByPrimaryKeys($this->categoryImageI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->categoryImageI18nsScheduledForDeletion = null; + } + } + + if ($this->collCategoryImageI18ns !== null) { + foreach ($this->collCategoryImageI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CategoryImageTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryImageTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryImageTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryImageTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(CategoryImageTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(CategoryImageTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(CategoryImageTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CategoryImageTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO category_image (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CATEGORY_ID': + $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCategoryId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryImage'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryImage'][$this->getPrimaryKey()] = true; + $keys = CategoryImageTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCategoryId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCategory) { + $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collCategoryImageI18ns) { + $result['CategoryImageI18ns'] = $this->collCategoryImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCategoryId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CategoryImageTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CategoryImageTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryImageTableMap::ID)) $criteria->add(CategoryImageTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryImageTableMap::CATEGORY_ID)) $criteria->add(CategoryImageTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(CategoryImageTableMap::FILE)) $criteria->add(CategoryImageTableMap::FILE, $this->file); + if ($this->isColumnModified(CategoryImageTableMap::POSITION)) $criteria->add(CategoryImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(CategoryImageTableMap::CREATED_AT)) $criteria->add(CategoryImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CategoryImageTableMap::UPDATED_AT)) $criteria->add(CategoryImageTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CategoryImageTableMap::DATABASE_NAME); + $criteria->add(CategoryImageTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CategoryImage (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setFile($this->getFile()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getCategoryImageI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCategoryImageI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CategoryImage Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $v = null) + { + if ($v === null) { + $this->setCategoryId(NULL); + } else { + $this->setCategoryId($v->getId()); + } + + $this->aCategory = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addCategoryImage($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCategory->addCategoryImages($this); + */ + } + + return $this->aCategory; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('CategoryImageI18n' == $relationName) { + return $this->initCategoryImageI18ns(); + } + } + + /** + * Clears out the collCategoryImageI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCategoryImageI18ns() + */ + public function clearCategoryImageI18ns() + { + $this->collCategoryImageI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCategoryImageI18ns collection loaded partially. + */ + public function resetPartialCategoryImageI18ns($v = true) + { + $this->collCategoryImageI18nsPartial = $v; + } + + /** + * Initializes the collCategoryImageI18ns collection. + * + * By default this just sets the collCategoryImageI18ns collection to an empty array (like clearcollCategoryImageI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCategoryImageI18ns($overrideExisting = true) + { + if (null !== $this->collCategoryImageI18ns && !$overrideExisting) { + return; + } + $this->collCategoryImageI18ns = new ObjectCollection(); + $this->collCategoryImageI18ns->setModel('\Thelia\Model\CategoryImageI18n'); + } + + /** + * Gets an array of ChildCategoryImageI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCategoryImage is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryImageI18n[] List of ChildCategoryImageI18n objects + * @throws PropelException + */ + public function getCategoryImageI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCategoryImageI18nsPartial && !$this->isNew(); + if (null === $this->collCategoryImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryImageI18ns) { + // return empty collection + $this->initCategoryImageI18ns(); + } else { + $collCategoryImageI18ns = ChildCategoryImageI18nQuery::create(null, $criteria) + ->filterByCategoryImage($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCategoryImageI18nsPartial && count($collCategoryImageI18ns)) { + $this->initCategoryImageI18ns(false); + + foreach ($collCategoryImageI18ns as $obj) { + if (false == $this->collCategoryImageI18ns->contains($obj)) { + $this->collCategoryImageI18ns->append($obj); + } + } + + $this->collCategoryImageI18nsPartial = true; + } + + $collCategoryImageI18ns->getInternalIterator()->rewind(); + + return $collCategoryImageI18ns; + } + + if ($partial && $this->collCategoryImageI18ns) { + foreach ($this->collCategoryImageI18ns as $obj) { + if ($obj->isNew()) { + $collCategoryImageI18ns[] = $obj; + } + } + } + + $this->collCategoryImageI18ns = $collCategoryImageI18ns; + $this->collCategoryImageI18nsPartial = false; + } + } + + return $this->collCategoryImageI18ns; + } + + /** + * Sets a collection of CategoryImageI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $categoryImageI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategoryImage The current object (for fluent API support) + */ + public function setCategoryImageI18ns(Collection $categoryImageI18ns, ConnectionInterface $con = null) + { + $categoryImageI18nsToDelete = $this->getCategoryImageI18ns(new Criteria(), $con)->diff($categoryImageI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->categoryImageI18nsScheduledForDeletion = clone $categoryImageI18nsToDelete; + + foreach ($categoryImageI18nsToDelete as $categoryImageI18nRemoved) { + $categoryImageI18nRemoved->setCategoryImage(null); + } + + $this->collCategoryImageI18ns = null; + foreach ($categoryImageI18ns as $categoryImageI18n) { + $this->addCategoryImageI18n($categoryImageI18n); + } + + $this->collCategoryImageI18ns = $categoryImageI18ns; + $this->collCategoryImageI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related CategoryImageI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CategoryImageI18n objects. + * @throws PropelException + */ + public function countCategoryImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCategoryImageI18nsPartial && !$this->isNew(); + if (null === $this->collCategoryImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCategoryImageI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCategoryImageI18ns()); + } + + $query = ChildCategoryImageI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCategoryImage($this) + ->count($con); + } + + return count($this->collCategoryImageI18ns); + } + + /** + * Method called to associate a ChildCategoryImageI18n object to this object + * through the ChildCategoryImageI18n foreign key attribute. + * + * @param ChildCategoryImageI18n $l ChildCategoryImageI18n + * @return \Thelia\Model\CategoryImage The current object (for fluent API support) + */ + public function addCategoryImageI18n(ChildCategoryImageI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collCategoryImageI18ns === null) { + $this->initCategoryImageI18ns(); + $this->collCategoryImageI18nsPartial = true; + } + + if (!in_array($l, $this->collCategoryImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCategoryImageI18n($l); + } + + return $this; + } + + /** + * @param CategoryImageI18n $categoryImageI18n The categoryImageI18n object to add. + */ + protected function doAddCategoryImageI18n($categoryImageI18n) + { + $this->collCategoryImageI18ns[]= $categoryImageI18n; + $categoryImageI18n->setCategoryImage($this); + } + + /** + * @param CategoryImageI18n $categoryImageI18n The categoryImageI18n object to remove. + * @return ChildCategoryImage The current object (for fluent API support) + */ + public function removeCategoryImageI18n($categoryImageI18n) + { + if ($this->getCategoryImageI18ns()->contains($categoryImageI18n)) { + $this->collCategoryImageI18ns->remove($this->collCategoryImageI18ns->search($categoryImageI18n)); + if (null === $this->categoryImageI18nsScheduledForDeletion) { + $this->categoryImageI18nsScheduledForDeletion = clone $this->collCategoryImageI18ns; + $this->categoryImageI18nsScheduledForDeletion->clear(); + } + $this->categoryImageI18nsScheduledForDeletion[]= clone $categoryImageI18n; + $categoryImageI18n->setCategoryImage(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->category_id = null; + $this->file = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collCategoryImageI18ns) { + foreach ($this->collCategoryImageI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collCategoryImageI18ns instanceof Collection) { + $this->collCategoryImageI18ns->clearIterator(); + } + $this->collCategoryImageI18ns = null; + $this->aCategory = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryImageTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildCategoryImage The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CategoryImageTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildCategoryImage The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryImageI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collCategoryImageI18ns) { + foreach ($this->collCategoryImageI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildCategoryImageI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildCategoryImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addCategoryImageI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryImage The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildCategoryImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collCategoryImageI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collCategoryImageI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryImageI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CategoryImageI18n.php b/core/lib/Thelia/Model/Base/CategoryImageI18n.php new file mode 100644 index 000000000..ce61e9836 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryImageI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CategoryImageI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryImageI18n instance. If + * obj is an instance of CategoryImageI18n, delegates to + * equals(CategoryImageI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryImageI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryImageI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryImageI18nTableMap::ID; + } + + if ($this->aCategoryImage !== null && $this->aCategoryImage->getId() !== $v) { + $this->aCategoryImage = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CategoryImageI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CategoryImageI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CategoryImageI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = CategoryImageI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = CategoryImageI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CategoryImageI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryImageI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCategoryImage !== null && $this->id !== $this->aCategoryImage->getId()) { + $this->aCategoryImage = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategoryImage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryImageI18n::setDeleted() + * @see CategoryImageI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryImageI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CategoryImageI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCategoryImage !== null) { + if ($this->aCategoryImage->isModified() || $this->aCategoryImage->isNew()) { + $affectedRows += $this->aCategoryImage->save($con); + } + $this->setCategoryImage($this->aCategoryImage); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryImageI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryImageI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(CategoryImageI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CategoryImageI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(CategoryImageI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(CategoryImageI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO category_image_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryImageI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CategoryImageI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCategoryImage) { + $result['CategoryImage'] = $this->aCategoryImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CategoryImageI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CategoryImageI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryImageI18nTableMap::ID)) $criteria->add(CategoryImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryImageI18nTableMap::LOCALE)) $criteria->add(CategoryImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(CategoryImageI18nTableMap::TITLE)) $criteria->add(CategoryImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(CategoryImageI18nTableMap::DESCRIPTION)) $criteria->add(CategoryImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(CategoryImageI18nTableMap::CHAPO)) $criteria->add(CategoryImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(CategoryImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(CategoryImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CategoryImageI18nTableMap::DATABASE_NAME); + $criteria->add(CategoryImageI18nTableMap::ID, $this->id); + $criteria->add(CategoryImageI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CategoryImageI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CategoryImageI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCategoryImage object. + * + * @param ChildCategoryImage $v + * @return \Thelia\Model\CategoryImageI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCategoryImage(ChildCategoryImage $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aCategoryImage = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCategoryImage object, it will not be re-added. + if ($v !== null) { + $v->addCategoryImageI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategoryImage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategoryImage The associated ChildCategoryImage object. + * @throws PropelException + */ + public function getCategoryImage(ConnectionInterface $con = null) + { + if ($this->aCategoryImage === null && ($this->id !== null)) { + $this->aCategoryImage = ChildCategoryImageQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCategoryImage->addCategoryImageI18ns($this); + */ + } + + return $this->aCategoryImage; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategoryImage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryImageI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CategoryImageI18nQuery.php b/core/lib/Thelia/Model/Base/CategoryImageI18nQuery.php new file mode 100644 index 000000000..6d552e808 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryImageI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryImageI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CategoryImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryImageI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM category_image_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryImageI18n(); + $obj->hydrate($row); + CategoryImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryImageI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CategoryImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CategoryImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(CategoryImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CategoryImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByCategoryImage() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryImageI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryImageI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryImageI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryImageI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryImageI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\CategoryImage object + * + * @param \Thelia\Model\CategoryImage|ObjectCollection $categoryImage The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function filterByCategoryImage($categoryImage, $comparison = null) + { + if ($categoryImage instanceof \Thelia\Model\CategoryImage) { + return $this + ->addUsingAlias(CategoryImageI18nTableMap::ID, $categoryImage->getId(), $comparison); + } elseif ($categoryImage instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryImageI18nTableMap::ID, $categoryImage->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCategoryImage() only accepts arguments of type \Thelia\Model\CategoryImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function joinCategoryImage($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryImage'); + } + + return $this; + } + + /** + * Use the CategoryImage relation CategoryImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryImageQuery A secondary query class using the current class as primary query + */ + public function useCategoryImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCategoryImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryImage', '\Thelia\Model\CategoryImageQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCategoryImageI18n $categoryImageI18n Object to remove from the list of results + * + * @return ChildCategoryImageI18nQuery The current query, for fluid interface + */ + public function prune($categoryImageI18n = null) + { + if ($categoryImageI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(CategoryImageI18nTableMap::ID), $categoryImageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CategoryImageI18nTableMap::LOCALE), $categoryImageI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the category_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryImageI18nTableMap::clearInstancePool(); + CategoryImageI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryImageI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CategoryImageI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryImageI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CategoryImageI18nQuery diff --git a/core/lib/Thelia/Model/Base/CategoryImageQuery.php b/core/lib/Thelia/Model/Base/CategoryImageQuery.php new file mode 100644 index 000000000..2130e757b --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryImageQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCategoryImage|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CategoryImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CategoryImageTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryImage A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CATEGORY_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM category_image WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryImage(); + $obj->hydrate($row); + CategoryImageTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCategoryImage|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CategoryImageTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CategoryImageTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CategoryImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CategoryImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryImageTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the category_id column + * + * Example usage: + * + * $query->filterByCategoryId(1234); // WHERE category_id = 1234 + * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * + * + * @see filterByCategory() + * + * @param mixed $categoryId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByCategoryId($categoryId = null, $comparison = null) + { + if (is_array($categoryId)) { + $useMinMax = false; + if (isset($categoryId['min'])) { + $this->addUsingAlias(CategoryImageTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($categoryId['max'])) { + $this->addUsingAlias(CategoryImageTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryImageTableMap::CATEGORY_ID, $categoryId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CategoryImageTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(CategoryImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(CategoryImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryImageTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(CategoryImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(CategoryImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryImageTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(CategoryImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(CategoryImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CategoryImageTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Category object + * + * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByCategory($category, $comparison = null) + { + if ($category instanceof \Thelia\Model\Category) { + return $this + ->addUsingAlias(CategoryImageTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CategoryImageTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Category relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Category'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Category'); + } + + return $this; + } + + /** + * Use the Category relation Category object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query + */ + public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CategoryImageI18n object + * + * @param \Thelia\Model\CategoryImageI18n|ObjectCollection $categoryImageI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function filterByCategoryImageI18n($categoryImageI18n, $comparison = null) + { + if ($categoryImageI18n instanceof \Thelia\Model\CategoryImageI18n) { + return $this + ->addUsingAlias(CategoryImageTableMap::ID, $categoryImageI18n->getId(), $comparison); + } elseif ($categoryImageI18n instanceof ObjectCollection) { + return $this + ->useCategoryImageI18nQuery() + ->filterByPrimaryKeys($categoryImageI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryImageI18n() only accepts arguments of type \Thelia\Model\CategoryImageI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryImageI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function joinCategoryImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryImageI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryImageI18n'); + } + + return $this; + } + + /** + * Use the CategoryImageI18n relation CategoryImageI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryImageI18nQuery A secondary query class using the current class as primary query + */ + public function useCategoryImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCategoryImageI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryImageI18n', '\Thelia\Model\CategoryImageI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCategoryImage $categoryImage Object to remove from the list of results + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function prune($categoryImage = null) + { + if ($categoryImage) { + $this->addUsingAlias(CategoryImageTableMap::ID, $categoryImage->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the category_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryImageTableMap::clearInstancePool(); + CategoryImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryImageTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CategoryImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CategoryImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CategoryImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryImageTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryImageTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryImageTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'CategoryImageI18n'; + + return $this + ->joinCategoryImageI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCategoryImageQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('CategoryImageI18n'); + $this->with['CategoryImageI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCategoryImageI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryImageI18n', '\Thelia\Model\CategoryImageI18nQuery'); + } + +} // CategoryImageQuery diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index c5b7156e4..0b7df33dd 100644 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -62,18 +62,18 @@ use Thelia\Model\Map\CategoryTableMap; * @method ChildCategoryQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation * @method ChildCategoryQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation * - * @method ChildCategoryQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation - * @method ChildCategoryQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation - * @method ChildCategoryQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation - * - * @method ChildCategoryQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method ChildCategoryQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method ChildCategoryQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation - * * @method ChildCategoryQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ChildCategoryQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ChildCategoryQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation * + * @method ChildCategoryQuery leftJoinCategoryImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryImage relation + * @method ChildCategoryQuery rightJoinCategoryImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryImage relation + * @method ChildCategoryQuery innerJoinCategoryImage($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryImage relation + * + * @method ChildCategoryQuery leftJoinCategoryDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryDocument relation + * @method ChildCategoryQuery rightJoinCategoryDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryDocument relation + * @method ChildCategoryQuery innerJoinCategoryDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryDocument relation + * * @method ChildCategoryQuery leftJoinCategoryI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CategoryI18n relation * @method ChildCategoryQuery rightJoinCategoryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CategoryI18n relation * @method ChildCategoryQuery innerJoinCategoryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CategoryI18n relation @@ -943,152 +943,6 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); } - /** - * Filter the query by a related \Thelia\Model\Image object - * - * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof \Thelia\Model\Image) { - return $this - ->addUsingAlias(CategoryTableMap::ID, $image->getCategoryId(), $comparison); - } elseif ($image instanceof ObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Document object - * - * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof \Thelia\Model\Document) { - return $this - ->addUsingAlias(CategoryTableMap::ID, $document->getCategoryId(), $comparison); - } elseif ($document instanceof ObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCategoryQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - /** * Filter the query by a related \Thelia\Model\Rewriting object * @@ -1162,6 +1016,152 @@ abstract class CategoryQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); } + /** + * Filter the query by a related \Thelia\Model\CategoryImage object + * + * @param \Thelia\Model\CategoryImage|ObjectCollection $categoryImage the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function filterByCategoryImage($categoryImage, $comparison = null) + { + if ($categoryImage instanceof \Thelia\Model\CategoryImage) { + return $this + ->addUsingAlias(CategoryTableMap::ID, $categoryImage->getCategoryId(), $comparison); + } elseif ($categoryImage instanceof ObjectCollection) { + return $this + ->useCategoryImageQuery() + ->filterByPrimaryKeys($categoryImage->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryImage() only accepts arguments of type \Thelia\Model\CategoryImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function joinCategoryImage($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryImage'); + } + + return $this; + } + + /** + * Use the CategoryImage relation CategoryImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryImageQuery A secondary query class using the current class as primary query + */ + public function useCategoryImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategoryImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryImage', '\Thelia\Model\CategoryImageQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\CategoryDocument object + * + * @param \Thelia\Model\CategoryDocument|ObjectCollection $categoryDocument the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function filterByCategoryDocument($categoryDocument, $comparison = null) + { + if ($categoryDocument instanceof \Thelia\Model\CategoryDocument) { + return $this + ->addUsingAlias(CategoryTableMap::ID, $categoryDocument->getCategoryId(), $comparison); + } elseif ($categoryDocument instanceof ObjectCollection) { + return $this + ->useCategoryDocumentQuery() + ->filterByPrimaryKeys($categoryDocument->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCategoryDocument() only accepts arguments of type \Thelia\Model\CategoryDocument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CategoryDocument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function joinCategoryDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CategoryDocument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CategoryDocument'); + } + + return $this; + } + + /** + * Use the CategoryDocument relation CategoryDocument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CategoryDocumentQuery A secondary query class using the current class as primary query + */ + public function useCategoryDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCategoryDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CategoryDocument', '\Thelia\Model\CategoryDocumentQuery'); + } + /** * Filter the query by a related \Thelia\Model\CategoryI18n object * diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index abe90ea5c..96ea69eef 100644 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -20,19 +20,19 @@ use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Content as ChildContent; use Thelia\Model\ContentAssoc as ChildContentAssoc; use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; +use Thelia\Model\ContentDocument as ChildContentDocument; +use Thelia\Model\ContentDocumentQuery as ChildContentDocumentQuery; use Thelia\Model\ContentFolder as ChildContentFolder; use Thelia\Model\ContentFolderQuery as ChildContentFolderQuery; use Thelia\Model\ContentI18n as ChildContentI18n; use Thelia\Model\ContentI18nQuery as ChildContentI18nQuery; +use Thelia\Model\ContentImage as ChildContentImage; +use Thelia\Model\ContentImageQuery as ChildContentImageQuery; use Thelia\Model\ContentQuery as ChildContentQuery; use Thelia\Model\ContentVersion as ChildContentVersion; use Thelia\Model\ContentVersionQuery as ChildContentVersionQuery; -use Thelia\Model\Document as ChildDocument; -use Thelia\Model\DocumentQuery as ChildDocumentQuery; use Thelia\Model\Folder as ChildFolder; use Thelia\Model\FolderQuery as ChildFolderQuery; -use Thelia\Model\Image as ChildImage; -use Thelia\Model\ImageQuery as ChildImageQuery; use Thelia\Model\Rewriting as ChildRewriting; use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\Map\ContentTableMap; @@ -127,18 +127,6 @@ abstract class Content implements ActiveRecordInterface protected $collContentAssocs; protected $collContentAssocsPartial; - /** - * @var ObjectCollection|ChildImage[] Collection to store aggregation of ChildImage objects. - */ - protected $collImages; - protected $collImagesPartial; - - /** - * @var ObjectCollection|ChildDocument[] Collection to store aggregation of ChildDocument objects. - */ - protected $collDocuments; - protected $collDocumentsPartial; - /** * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. */ @@ -151,6 +139,18 @@ abstract class Content implements ActiveRecordInterface protected $collContentFolders; protected $collContentFoldersPartial; + /** + * @var ObjectCollection|ChildContentImage[] Collection to store aggregation of ChildContentImage objects. + */ + protected $collContentImages; + protected $collContentImagesPartial; + + /** + * @var ObjectCollection|ChildContentDocument[] Collection to store aggregation of ChildContentDocument objects. + */ + protected $collContentDocuments; + protected $collContentDocumentsPartial; + /** * @var ObjectCollection|ChildContentI18n[] Collection to store aggregation of ChildContentI18n objects. */ @@ -210,18 +210,6 @@ abstract class Content implements ActiveRecordInterface */ protected $contentAssocsScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $imagesScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $documentsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -234,6 +222,18 @@ abstract class Content implements ActiveRecordInterface */ protected $contentFoldersScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $contentImagesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $contentDocumentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -940,14 +940,14 @@ abstract class Content implements ActiveRecordInterface $this->collContentAssocs = null; - $this->collImages = null; - - $this->collDocuments = null; - $this->collRewritings = null; $this->collContentFolders = null; + $this->collContentImages = null; + + $this->collContentDocuments = null; + $this->collContentI18ns = null; $this->collContentVersions = null; @@ -1142,40 +1142,6 @@ abstract class Content implements ActiveRecordInterface } } - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - \Thelia\Model\ImageQuery::create() - ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - \Thelia\Model\DocumentQuery::create() - ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { \Thelia\Model\RewritingQuery::create() @@ -1210,6 +1176,40 @@ abstract class Content implements ActiveRecordInterface } } + if ($this->contentImagesScheduledForDeletion !== null) { + if (!$this->contentImagesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ContentImageQuery::create() + ->filterByPrimaryKeys($this->contentImagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->contentImagesScheduledForDeletion = null; + } + } + + if ($this->collContentImages !== null) { + foreach ($this->collContentImages as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->contentDocumentsScheduledForDeletion !== null) { + if (!$this->contentDocumentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ContentDocumentQuery::create() + ->filterByPrimaryKeys($this->contentDocumentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->contentDocumentsScheduledForDeletion = null; + } + } + + if ($this->collContentDocuments !== null) { + foreach ($this->collContentDocuments as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->contentI18nsScheduledForDeletion !== null) { if (!$this->contentI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\ContentI18nQuery::create() @@ -1463,18 +1463,18 @@ abstract class Content implements ActiveRecordInterface if (null !== $this->collContentAssocs) { $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collContentFolders) { $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collContentImages) { + $result['ContentImages'] = $this->collContentImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collContentDocuments) { + $result['ContentDocuments'] = $this->collContentDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collContentI18ns) { $result['ContentI18ns'] = $this->collContentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1672,18 +1672,6 @@ abstract class Content implements ActiveRecordInterface } } - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); @@ -1696,6 +1684,18 @@ abstract class Content implements ActiveRecordInterface } } + foreach ($this->getContentImages() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addContentImage($relObj->copy($deepCopy)); + } + } + + foreach ($this->getContentDocuments() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addContentDocument($relObj->copy($deepCopy)); + } + } + foreach ($this->getContentI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addContentI18n($relObj->copy($deepCopy)); @@ -1752,18 +1752,18 @@ abstract class Content implements ActiveRecordInterface if ('ContentAssoc' == $relationName) { return $this->initContentAssocs(); } - if ('Image' == $relationName) { - return $this->initImages(); - } - if ('Document' == $relationName) { - return $this->initDocuments(); - } if ('Rewriting' == $relationName) { return $this->initRewritings(); } if ('ContentFolder' == $relationName) { return $this->initContentFolders(); } + if ('ContentImage' == $relationName) { + return $this->initContentImages(); + } + if ('ContentDocument' == $relationName) { + return $this->initContentDocuments(); + } if ('ContentI18n' == $relationName) { return $this->initContentI18ns(); } @@ -2040,592 +2040,6 @@ abstract class Content implements ActiveRecordInterface return $this->getContentAssocs($query, $con); } - /** - * Clears out the collImages collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collImages collection loaded partially. - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new ObjectCollection(); - $this->collImages->setModel('\Thelia\Model\Image'); - } - - /** - * Gets an array of ChildImage objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildContent is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildImage[] List of ChildImage objects - * @throws PropelException - */ - public function getImages($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ChildImageQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach ($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - $collImages->getInternalIterator()->rewind(); - - return $collImages; - } - - if ($partial && $this->collImages) { - foreach ($this->collImages as $obj) { - if ($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $images A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildContent The current object (for fluent API support) - */ - public function setImages(Collection $images, ConnectionInterface $con = null) - { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - - - $this->imagesScheduledForDeletion = $imagesToDelete; - - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setContent(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - - return $this; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getImages()); - } - - $query = ChildImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collImages); - } - - /** - * Method called to associate a ChildImage object to this object - * through the ChildImage foreign key attribute. - * - * @param ChildImage $l ChildImage - * @return \Thelia\Model\Content The current object (for fluent API support) - */ - public function addImage(ChildImage $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setContent($this); - } - - /** - * @param Image $image The image object to remove. - * @return ChildContent The current object (for fluent API support) - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collDocuments collection loaded partially. - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new ObjectCollection(); - $this->collDocuments->setModel('\Thelia\Model\Document'); - } - - /** - * Gets an array of ChildDocument objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildContent is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDocument[] List of ChildDocument objects - * @throws PropelException - */ - public function getDocuments($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = ChildDocumentQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach ($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - $collDocuments->getInternalIterator()->rewind(); - - return $collDocuments; - } - - if ($partial && $this->collDocuments) { - foreach ($this->collDocuments as $obj) { - if ($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $documents A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildContent The current object (for fluent API support) - */ - public function setDocuments(Collection $documents, ConnectionInterface $con = null) - { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - - - $this->documentsScheduledForDeletion = $documentsToDelete; - - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setContent(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - - return $this; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getDocuments()); - } - - $query = ChildDocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collDocuments); - } - - /** - * Method called to associate a ChildDocument object to this object - * through the ChildDocument foreign key attribute. - * - * @param ChildDocument $l ChildDocument - * @return \Thelia\Model\Content The current object (for fluent API support) - */ - public function addDocument(ChildDocument $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setContent($this); - } - - /** - * @param Document $document The document object to remove. - * @return ChildContent The current object (for fluent API support) - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getDocuments($query, $con); - } - /** * Clears out the collRewritings collection * @@ -3165,6 +2579,442 @@ abstract class Content implements ActiveRecordInterface return $this->getContentFolders($query, $con); } + /** + * Clears out the collContentImages collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addContentImages() + */ + public function clearContentImages() + { + $this->collContentImages = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collContentImages collection loaded partially. + */ + public function resetPartialContentImages($v = true) + { + $this->collContentImagesPartial = $v; + } + + /** + * Initializes the collContentImages collection. + * + * By default this just sets the collContentImages collection to an empty array (like clearcollContentImages()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initContentImages($overrideExisting = true) + { + if (null !== $this->collContentImages && !$overrideExisting) { + return; + } + $this->collContentImages = new ObjectCollection(); + $this->collContentImages->setModel('\Thelia\Model\ContentImage'); + } + + /** + * Gets an array of ChildContentImage objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildContent is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentImage[] List of ChildContentImage objects + * @throws PropelException + */ + public function getContentImages($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collContentImagesPartial && !$this->isNew(); + if (null === $this->collContentImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentImages) { + // return empty collection + $this->initContentImages(); + } else { + $collContentImages = ChildContentImageQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collContentImagesPartial && count($collContentImages)) { + $this->initContentImages(false); + + foreach ($collContentImages as $obj) { + if (false == $this->collContentImages->contains($obj)) { + $this->collContentImages->append($obj); + } + } + + $this->collContentImagesPartial = true; + } + + $collContentImages->getInternalIterator()->rewind(); + + return $collContentImages; + } + + if ($partial && $this->collContentImages) { + foreach ($this->collContentImages as $obj) { + if ($obj->isNew()) { + $collContentImages[] = $obj; + } + } + } + + $this->collContentImages = $collContentImages; + $this->collContentImagesPartial = false; + } + } + + return $this->collContentImages; + } + + /** + * Sets a collection of ContentImage objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $contentImages A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) + */ + public function setContentImages(Collection $contentImages, ConnectionInterface $con = null) + { + $contentImagesToDelete = $this->getContentImages(new Criteria(), $con)->diff($contentImages); + + + $this->contentImagesScheduledForDeletion = $contentImagesToDelete; + + foreach ($contentImagesToDelete as $contentImageRemoved) { + $contentImageRemoved->setContent(null); + } + + $this->collContentImages = null; + foreach ($contentImages as $contentImage) { + $this->addContentImage($contentImage); + } + + $this->collContentImages = $contentImages; + $this->collContentImagesPartial = false; + + return $this; + } + + /** + * Returns the number of related ContentImage objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ContentImage objects. + * @throws PropelException + */ + public function countContentImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collContentImagesPartial && !$this->isNew(); + if (null === $this->collContentImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentImages) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getContentImages()); + } + + $query = ChildContentImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); + } + + return count($this->collContentImages); + } + + /** + * Method called to associate a ChildContentImage object to this object + * through the ChildContentImage foreign key attribute. + * + * @param ChildContentImage $l ChildContentImage + * @return \Thelia\Model\Content The current object (for fluent API support) + */ + public function addContentImage(ChildContentImage $l) + { + if ($this->collContentImages === null) { + $this->initContentImages(); + $this->collContentImagesPartial = true; + } + + if (!in_array($l, $this->collContentImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddContentImage($l); + } + + return $this; + } + + /** + * @param ContentImage $contentImage The contentImage object to add. + */ + protected function doAddContentImage($contentImage) + { + $this->collContentImages[]= $contentImage; + $contentImage->setContent($this); + } + + /** + * @param ContentImage $contentImage The contentImage object to remove. + * @return ChildContent The current object (for fluent API support) + */ + public function removeContentImage($contentImage) + { + if ($this->getContentImages()->contains($contentImage)) { + $this->collContentImages->remove($this->collContentImages->search($contentImage)); + if (null === $this->contentImagesScheduledForDeletion) { + $this->contentImagesScheduledForDeletion = clone $this->collContentImages; + $this->contentImagesScheduledForDeletion->clear(); + } + $this->contentImagesScheduledForDeletion[]= clone $contentImage; + $contentImage->setContent(null); + } + + return $this; + } + + /** + * Clears out the collContentDocuments collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addContentDocuments() + */ + public function clearContentDocuments() + { + $this->collContentDocuments = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collContentDocuments collection loaded partially. + */ + public function resetPartialContentDocuments($v = true) + { + $this->collContentDocumentsPartial = $v; + } + + /** + * Initializes the collContentDocuments collection. + * + * By default this just sets the collContentDocuments collection to an empty array (like clearcollContentDocuments()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initContentDocuments($overrideExisting = true) + { + if (null !== $this->collContentDocuments && !$overrideExisting) { + return; + } + $this->collContentDocuments = new ObjectCollection(); + $this->collContentDocuments->setModel('\Thelia\Model\ContentDocument'); + } + + /** + * Gets an array of ChildContentDocument objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildContent is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentDocument[] List of ChildContentDocument objects + * @throws PropelException + */ + public function getContentDocuments($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collContentDocumentsPartial && !$this->isNew(); + if (null === $this->collContentDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentDocuments) { + // return empty collection + $this->initContentDocuments(); + } else { + $collContentDocuments = ChildContentDocumentQuery::create(null, $criteria) + ->filterByContent($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collContentDocumentsPartial && count($collContentDocuments)) { + $this->initContentDocuments(false); + + foreach ($collContentDocuments as $obj) { + if (false == $this->collContentDocuments->contains($obj)) { + $this->collContentDocuments->append($obj); + } + } + + $this->collContentDocumentsPartial = true; + } + + $collContentDocuments->getInternalIterator()->rewind(); + + return $collContentDocuments; + } + + if ($partial && $this->collContentDocuments) { + foreach ($this->collContentDocuments as $obj) { + if ($obj->isNew()) { + $collContentDocuments[] = $obj; + } + } + } + + $this->collContentDocuments = $collContentDocuments; + $this->collContentDocumentsPartial = false; + } + } + + return $this->collContentDocuments; + } + + /** + * Sets a collection of ContentDocument objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $contentDocuments A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) + */ + public function setContentDocuments(Collection $contentDocuments, ConnectionInterface $con = null) + { + $contentDocumentsToDelete = $this->getContentDocuments(new Criteria(), $con)->diff($contentDocuments); + + + $this->contentDocumentsScheduledForDeletion = $contentDocumentsToDelete; + + foreach ($contentDocumentsToDelete as $contentDocumentRemoved) { + $contentDocumentRemoved->setContent(null); + } + + $this->collContentDocuments = null; + foreach ($contentDocuments as $contentDocument) { + $this->addContentDocument($contentDocument); + } + + $this->collContentDocuments = $contentDocuments; + $this->collContentDocumentsPartial = false; + + return $this; + } + + /** + * Returns the number of related ContentDocument objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ContentDocument objects. + * @throws PropelException + */ + public function countContentDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collContentDocumentsPartial && !$this->isNew(); + if (null === $this->collContentDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentDocuments) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getContentDocuments()); + } + + $query = ChildContentDocumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContent($this) + ->count($con); + } + + return count($this->collContentDocuments); + } + + /** + * Method called to associate a ChildContentDocument object to this object + * through the ChildContentDocument foreign key attribute. + * + * @param ChildContentDocument $l ChildContentDocument + * @return \Thelia\Model\Content The current object (for fluent API support) + */ + public function addContentDocument(ChildContentDocument $l) + { + if ($this->collContentDocuments === null) { + $this->initContentDocuments(); + $this->collContentDocumentsPartial = true; + } + + if (!in_array($l, $this->collContentDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddContentDocument($l); + } + + return $this; + } + + /** + * @param ContentDocument $contentDocument The contentDocument object to add. + */ + protected function doAddContentDocument($contentDocument) + { + $this->collContentDocuments[]= $contentDocument; + $contentDocument->setContent($this); + } + + /** + * @param ContentDocument $contentDocument The contentDocument object to remove. + * @return ChildContent The current object (for fluent API support) + */ + public function removeContentDocument($contentDocument) + { + if ($this->getContentDocuments()->contains($contentDocument)) { + $this->collContentDocuments->remove($this->collContentDocuments->search($contentDocument)); + if (null === $this->contentDocumentsScheduledForDeletion) { + $this->contentDocumentsScheduledForDeletion = clone $this->collContentDocuments; + $this->contentDocumentsScheduledForDeletion->clear(); + } + $this->contentDocumentsScheduledForDeletion[]= clone $contentDocument; + $contentDocument->setContent(null); + } + + return $this; + } + /** * Clears out the collContentI18ns collection * @@ -3832,16 +3682,6 @@ abstract class Content implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); @@ -3852,6 +3692,16 @@ abstract class Content implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collContentImages) { + foreach ($this->collContentImages as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collContentDocuments) { + foreach ($this->collContentDocuments as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collContentI18ns) { foreach ($this->collContentI18ns as $o) { $o->clearAllReferences($deep); @@ -3877,14 +3727,6 @@ abstract class Content implements ActiveRecordInterface $this->collContentAssocs->clearIterator(); } $this->collContentAssocs = null; - if ($this->collImages instanceof Collection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collDocuments instanceof Collection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } @@ -3893,6 +3735,14 @@ abstract class Content implements ActiveRecordInterface $this->collContentFolders->clearIterator(); } $this->collContentFolders = null; + if ($this->collContentImages instanceof Collection) { + $this->collContentImages->clearIterator(); + } + $this->collContentImages = null; + if ($this->collContentDocuments instanceof Collection) { + $this->collContentDocuments->clearIterator(); + } + $this->collContentDocuments = null; if ($this->collContentI18ns instanceof Collection) { $this->collContentI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ContentDocument.php b/core/lib/Thelia/Model/Base/ContentDocument.php new file mode 100644 index 000000000..990fc4a9f --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentDocument.php @@ -0,0 +1,1990 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ContentDocument instance. If + * obj is an instance of ContentDocument, delegates to + * equals(ContentDocument). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ContentDocument The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ContentDocument The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [content_id] column value. + * + * @return int + */ + public function getContentId() + { + + return $this->content_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ContentDocumentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [content_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[] = ContentDocumentTableMap::CONTENT_ID; + } + + if ($this->aContent !== null && $this->aContent->getId() !== $v) { + $this->aContent = null; + } + + + return $this; + } // setContentId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[] = ContentDocumentTableMap::FILE; + } + + + return $this; + } // setFile() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = ContentDocumentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ContentDocumentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ContentDocumentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentDocumentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentDocumentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentDocumentTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentDocumentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentDocumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentDocumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ContentDocumentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ContentDocument object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { + $this->aContent = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ContentDocumentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildContentDocumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aContent = null; + $this->collContentDocumentI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ContentDocument::setDeleted() + * @see ContentDocument::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildContentDocumentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ContentDocumentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ContentDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ContentDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ContentDocumentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aContent !== null) { + if ($this->aContent->isModified() || $this->aContent->isNew()) { + $affectedRows += $this->aContent->save($con); + } + $this->setContent($this->aContent); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->contentDocumentI18nsScheduledForDeletion !== null) { + if (!$this->contentDocumentI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ContentDocumentI18nQuery::create() + ->filterByPrimaryKeys($this->contentDocumentI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->contentDocumentI18nsScheduledForDeletion = null; + } + } + + if ($this->collContentDocumentI18ns !== null) { + foreach ($this->collContentDocumentI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ContentDocumentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentDocumentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ContentDocumentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ContentDocumentTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(ContentDocumentTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(ContentDocumentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(ContentDocumentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ContentDocumentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO content_document (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CONTENT_ID': + $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getContentId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ContentDocument'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ContentDocument'][$this->getPrimaryKey()] = true; + $keys = ContentDocumentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getContentId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aContent) { + $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collContentDocumentI18ns) { + $result['ContentDocumentI18ns'] = $this->collContentDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setContentId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ContentDocumentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setContentId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ContentDocumentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ContentDocumentTableMap::ID)) $criteria->add(ContentDocumentTableMap::ID, $this->id); + if ($this->isColumnModified(ContentDocumentTableMap::CONTENT_ID)) $criteria->add(ContentDocumentTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(ContentDocumentTableMap::FILE)) $criteria->add(ContentDocumentTableMap::FILE, $this->file); + if ($this->isColumnModified(ContentDocumentTableMap::POSITION)) $criteria->add(ContentDocumentTableMap::POSITION, $this->position); + if ($this->isColumnModified(ContentDocumentTableMap::CREATED_AT)) $criteria->add(ContentDocumentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ContentDocumentTableMap::UPDATED_AT)) $criteria->add(ContentDocumentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ContentDocumentTableMap::DATABASE_NAME); + $criteria->add(ContentDocumentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ContentDocument (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setContentId($this->getContentId()); + $copyObj->setFile($this->getFile()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getContentDocumentI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addContentDocumentI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ContentDocument Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $v = null) + { + if ($v === null) { + $this->setContentId(NULL); + } else { + $this->setContentId($v->getId()); + } + + $this->aContent = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addContentDocument($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aContent->addContentDocuments($this); + */ + } + + return $this->aContent; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('ContentDocumentI18n' == $relationName) { + return $this->initContentDocumentI18ns(); + } + } + + /** + * Clears out the collContentDocumentI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addContentDocumentI18ns() + */ + public function clearContentDocumentI18ns() + { + $this->collContentDocumentI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collContentDocumentI18ns collection loaded partially. + */ + public function resetPartialContentDocumentI18ns($v = true) + { + $this->collContentDocumentI18nsPartial = $v; + } + + /** + * Initializes the collContentDocumentI18ns collection. + * + * By default this just sets the collContentDocumentI18ns collection to an empty array (like clearcollContentDocumentI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initContentDocumentI18ns($overrideExisting = true) + { + if (null !== $this->collContentDocumentI18ns && !$overrideExisting) { + return; + } + $this->collContentDocumentI18ns = new ObjectCollection(); + $this->collContentDocumentI18ns->setModel('\Thelia\Model\ContentDocumentI18n'); + } + + /** + * Gets an array of ChildContentDocumentI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildContentDocument is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentDocumentI18n[] List of ChildContentDocumentI18n objects + * @throws PropelException + */ + public function getContentDocumentI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collContentDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collContentDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentDocumentI18ns) { + // return empty collection + $this->initContentDocumentI18ns(); + } else { + $collContentDocumentI18ns = ChildContentDocumentI18nQuery::create(null, $criteria) + ->filterByContentDocument($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collContentDocumentI18nsPartial && count($collContentDocumentI18ns)) { + $this->initContentDocumentI18ns(false); + + foreach ($collContentDocumentI18ns as $obj) { + if (false == $this->collContentDocumentI18ns->contains($obj)) { + $this->collContentDocumentI18ns->append($obj); + } + } + + $this->collContentDocumentI18nsPartial = true; + } + + $collContentDocumentI18ns->getInternalIterator()->rewind(); + + return $collContentDocumentI18ns; + } + + if ($partial && $this->collContentDocumentI18ns) { + foreach ($this->collContentDocumentI18ns as $obj) { + if ($obj->isNew()) { + $collContentDocumentI18ns[] = $obj; + } + } + } + + $this->collContentDocumentI18ns = $collContentDocumentI18ns; + $this->collContentDocumentI18nsPartial = false; + } + } + + return $this->collContentDocumentI18ns; + } + + /** + * Sets a collection of ContentDocumentI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $contentDocumentI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContentDocument The current object (for fluent API support) + */ + public function setContentDocumentI18ns(Collection $contentDocumentI18ns, ConnectionInterface $con = null) + { + $contentDocumentI18nsToDelete = $this->getContentDocumentI18ns(new Criteria(), $con)->diff($contentDocumentI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->contentDocumentI18nsScheduledForDeletion = clone $contentDocumentI18nsToDelete; + + foreach ($contentDocumentI18nsToDelete as $contentDocumentI18nRemoved) { + $contentDocumentI18nRemoved->setContentDocument(null); + } + + $this->collContentDocumentI18ns = null; + foreach ($contentDocumentI18ns as $contentDocumentI18n) { + $this->addContentDocumentI18n($contentDocumentI18n); + } + + $this->collContentDocumentI18ns = $contentDocumentI18ns; + $this->collContentDocumentI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related ContentDocumentI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ContentDocumentI18n objects. + * @throws PropelException + */ + public function countContentDocumentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collContentDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collContentDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentDocumentI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getContentDocumentI18ns()); + } + + $query = ChildContentDocumentI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByContentDocument($this) + ->count($con); + } + + return count($this->collContentDocumentI18ns); + } + + /** + * Method called to associate a ChildContentDocumentI18n object to this object + * through the ChildContentDocumentI18n foreign key attribute. + * + * @param ChildContentDocumentI18n $l ChildContentDocumentI18n + * @return \Thelia\Model\ContentDocument The current object (for fluent API support) + */ + public function addContentDocumentI18n(ChildContentDocumentI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collContentDocumentI18ns === null) { + $this->initContentDocumentI18ns(); + $this->collContentDocumentI18nsPartial = true; + } + + if (!in_array($l, $this->collContentDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddContentDocumentI18n($l); + } + + return $this; + } + + /** + * @param ContentDocumentI18n $contentDocumentI18n The contentDocumentI18n object to add. + */ + protected function doAddContentDocumentI18n($contentDocumentI18n) + { + $this->collContentDocumentI18ns[]= $contentDocumentI18n; + $contentDocumentI18n->setContentDocument($this); + } + + /** + * @param ContentDocumentI18n $contentDocumentI18n The contentDocumentI18n object to remove. + * @return ChildContentDocument The current object (for fluent API support) + */ + public function removeContentDocumentI18n($contentDocumentI18n) + { + if ($this->getContentDocumentI18ns()->contains($contentDocumentI18n)) { + $this->collContentDocumentI18ns->remove($this->collContentDocumentI18ns->search($contentDocumentI18n)); + if (null === $this->contentDocumentI18nsScheduledForDeletion) { + $this->contentDocumentI18nsScheduledForDeletion = clone $this->collContentDocumentI18ns; + $this->contentDocumentI18nsScheduledForDeletion->clear(); + } + $this->contentDocumentI18nsScheduledForDeletion[]= clone $contentDocumentI18n; + $contentDocumentI18n->setContentDocument(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->content_id = null; + $this->file = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collContentDocumentI18ns) { + foreach ($this->collContentDocumentI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collContentDocumentI18ns instanceof Collection) { + $this->collContentDocumentI18ns->clearIterator(); + } + $this->collContentDocumentI18ns = null; + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ContentDocumentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildContentDocument The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ContentDocumentTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildContentDocument The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildContentDocumentI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collContentDocumentI18ns) { + foreach ($this->collContentDocumentI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildContentDocumentI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildContentDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addContentDocumentI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildContentDocument The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildContentDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collContentDocumentI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collContentDocumentI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildContentDocumentI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php new file mode 100644 index 000000000..2cfc367b0 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ContentDocumentI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ContentDocumentI18n instance. If + * obj is an instance of ContentDocumentI18n, delegates to + * equals(ContentDocumentI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ContentDocumentI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ContentDocumentI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ContentDocumentI18nTableMap::ID; + } + + if ($this->aContentDocument !== null && $this->aContentDocument->getId() !== $v) { + $this->aContentDocument = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ContentDocumentI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ContentDocumentI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ContentDocumentI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ContentDocumentI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ContentDocumentI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentDocumentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentDocumentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentDocumentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentDocumentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentDocumentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentDocumentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ContentDocumentI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ContentDocumentI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aContentDocument !== null && $this->id !== $this->aContentDocument->getId()) { + $this->aContentDocument = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildContentDocumentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aContentDocument = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ContentDocumentI18n::setDeleted() + * @see ContentDocumentI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildContentDocumentI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ContentDocumentI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aContentDocument !== null) { + if ($this->aContentDocument->isModified() || $this->aContentDocument->isNew()) { + $affectedRows += $this->aContentDocument->save($con); + } + $this->setContentDocument($this->aContentDocument); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ContentDocumentI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ContentDocumentI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ContentDocumentI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ContentDocumentI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ContentDocumentI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ContentDocumentI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO content_document_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ContentDocumentI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ContentDocumentI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ContentDocumentI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aContentDocument) { + $result['ContentDocument'] = $this->aContentDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ContentDocumentI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ContentDocumentI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ContentDocumentI18nTableMap::ID)) $criteria->add(ContentDocumentI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ContentDocumentI18nTableMap::LOCALE)) $criteria->add(ContentDocumentI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ContentDocumentI18nTableMap::TITLE)) $criteria->add(ContentDocumentI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ContentDocumentI18nTableMap::DESCRIPTION)) $criteria->add(ContentDocumentI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ContentDocumentI18nTableMap::CHAPO)) $criteria->add(ContentDocumentI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ContentDocumentI18nTableMap::POSTSCRIPTUM)) $criteria->add(ContentDocumentI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ContentDocumentI18nTableMap::DATABASE_NAME); + $criteria->add(ContentDocumentI18nTableMap::ID, $this->id); + $criteria->add(ContentDocumentI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ContentDocumentI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ContentDocumentI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildContentDocument object. + * + * @param ChildContentDocument $v + * @return \Thelia\Model\ContentDocumentI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setContentDocument(ChildContentDocument $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aContentDocument = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildContentDocument object, it will not be re-added. + if ($v !== null) { + $v->addContentDocumentI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContentDocument object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContentDocument The associated ChildContentDocument object. + * @throws PropelException + */ + public function getContentDocument(ConnectionInterface $con = null) + { + if ($this->aContentDocument === null && ($this->id !== null)) { + $this->aContentDocument = ChildContentDocumentQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aContentDocument->addContentDocumentI18ns($this); + */ + } + + return $this->aContentDocument; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aContentDocument = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ContentDocumentI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ContentDocumentI18nQuery.php b/core/lib/Thelia/Model/Base/ContentDocumentI18nQuery.php new file mode 100644 index 000000000..e88858892 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentDocumentI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildContentDocumentI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ContentDocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentDocumentI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM content_document_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentDocumentI18n(); + $obj->hydrate($row); + ContentDocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentDocumentI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(ContentDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ContentDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(ContentDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ContentDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByContentDocument() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentDocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentDocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentDocumentI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentDocumentI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentDocumentI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentDocumentI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentDocumentI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentDocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\ContentDocument object + * + * @param \Thelia\Model\ContentDocument|ObjectCollection $contentDocument The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function filterByContentDocument($contentDocument, $comparison = null) + { + if ($contentDocument instanceof \Thelia\Model\ContentDocument) { + return $this + ->addUsingAlias(ContentDocumentI18nTableMap::ID, $contentDocument->getId(), $comparison); + } elseif ($contentDocument instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ContentDocumentI18nTableMap::ID, $contentDocument->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContentDocument() only accepts arguments of type \Thelia\Model\ContentDocument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentDocument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function joinContentDocument($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentDocument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentDocument'); + } + + return $this; + } + + /** + * Use the ContentDocument relation ContentDocument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentDocumentQuery A secondary query class using the current class as primary query + */ + public function useContentDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinContentDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentDocument', '\Thelia\Model\ContentDocumentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildContentDocumentI18n $contentDocumentI18n Object to remove from the list of results + * + * @return ChildContentDocumentI18nQuery The current query, for fluid interface + */ + public function prune($contentDocumentI18n = null) + { + if ($contentDocumentI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(ContentDocumentI18nTableMap::ID), $contentDocumentI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ContentDocumentI18nTableMap::LOCALE), $contentDocumentI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the content_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentDocumentI18nTableMap::clearInstancePool(); + ContentDocumentI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentDocumentI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ContentDocumentI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentDocumentI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ContentDocumentI18nQuery diff --git a/core/lib/Thelia/Model/Base/ContentDocumentQuery.php b/core/lib/Thelia/Model/Base/ContentDocumentQuery.php new file mode 100644 index 000000000..89cf5d48b --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentDocumentQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildContentDocument|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ContentDocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ContentDocumentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentDocument A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CONTENT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM content_document WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentDocument(); + $obj->hydrate($row); + ContentDocumentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentDocument|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ContentDocumentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ContentDocumentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentDocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentDocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentDocumentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the content_id column + * + * Example usage: + * + * $query->filterByContentId(1234); // WHERE content_id = 1234 + * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * + * + * @see filterByContent() + * + * @param mixed $contentId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByContentId($contentId = null, $comparison = null) + { + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(ContentDocumentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(ContentDocumentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentDocumentTableMap::CONTENT_ID, $contentId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentDocumentTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(ContentDocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(ContentDocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentDocumentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ContentDocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ContentDocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentDocumentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ContentDocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ContentDocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentDocumentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Content object + * + * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByContent($content, $comparison = null) + { + if ($content instanceof \Thelia\Model\Content) { + return $this + ->addUsingAlias(ContentDocumentTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ContentDocumentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Content relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Content'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Content'); + } + + return $this; + } + + /** + * Use the Content relation Content object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query + */ + public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ContentDocumentI18n object + * + * @param \Thelia\Model\ContentDocumentI18n|ObjectCollection $contentDocumentI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function filterByContentDocumentI18n($contentDocumentI18n, $comparison = null) + { + if ($contentDocumentI18n instanceof \Thelia\Model\ContentDocumentI18n) { + return $this + ->addUsingAlias(ContentDocumentTableMap::ID, $contentDocumentI18n->getId(), $comparison); + } elseif ($contentDocumentI18n instanceof ObjectCollection) { + return $this + ->useContentDocumentI18nQuery() + ->filterByPrimaryKeys($contentDocumentI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentDocumentI18n() only accepts arguments of type \Thelia\Model\ContentDocumentI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentDocumentI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function joinContentDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentDocumentI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentDocumentI18n'); + } + + return $this; + } + + /** + * Use the ContentDocumentI18n relation ContentDocumentI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useContentDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinContentDocumentI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentDocumentI18n', '\Thelia\Model\ContentDocumentI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildContentDocument $contentDocument Object to remove from the list of results + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function prune($contentDocument = null) + { + if ($contentDocument) { + $this->addUsingAlias(ContentDocumentTableMap::ID, $contentDocument->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the content_document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentDocumentTableMap::clearInstancePool(); + ContentDocumentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentDocumentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ContentDocumentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentDocumentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ContentDocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ContentDocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentDocumentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentDocumentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ContentDocumentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ContentDocumentTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'ContentDocumentI18n'; + + return $this + ->joinContentDocumentI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildContentDocumentQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('ContentDocumentI18n'); + $this->with['ContentDocumentI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildContentDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentDocumentI18n', '\Thelia\Model\ContentDocumentI18nQuery'); + } + +} // ContentDocumentQuery diff --git a/core/lib/Thelia/Model/Base/Document.php b/core/lib/Thelia/Model/Base/ContentImage.php similarity index 65% rename from core/lib/Thelia/Model/Base/Document.php rename to core/lib/Thelia/Model/Base/ContentImage.php index 10ee4e818..22c4bed10 100644 --- a/core/lib/Thelia/Model/Base/Document.php +++ b/core/lib/Thelia/Model/Base/ContentImage.php @@ -17,26 +17,20 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; -use Thelia\Model\Category as ChildCategory; -use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\Content as ChildContent; +use Thelia\Model\ContentImage as ChildContentImage; +use Thelia\Model\ContentImageI18n as ChildContentImageI18n; +use Thelia\Model\ContentImageI18nQuery as ChildContentImageI18nQuery; +use Thelia\Model\ContentImageQuery as ChildContentImageQuery; use Thelia\Model\ContentQuery as ChildContentQuery; -use Thelia\Model\Document as ChildDocument; -use Thelia\Model\DocumentI18n as ChildDocumentI18n; -use Thelia\Model\DocumentI18nQuery as ChildDocumentI18nQuery; -use Thelia\Model\DocumentQuery as ChildDocumentQuery; -use Thelia\Model\Folder as ChildFolder; -use Thelia\Model\FolderQuery as ChildFolderQuery; -use Thelia\Model\Product as ChildProduct; -use Thelia\Model\ProductQuery as ChildProductQuery; -use Thelia\Model\Map\DocumentTableMap; +use Thelia\Model\Map\ContentImageTableMap; -abstract class Document implements ActiveRecordInterface +abstract class ContentImage implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\DocumentTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\ContentImageTableMap'; /** @@ -71,24 +65,6 @@ abstract class Document implements ActiveRecordInterface */ protected $id; - /** - * The value for the product_id field. - * @var int - */ - protected $product_id; - - /** - * The value for the category_id field. - * @var int - */ - protected $category_id; - - /** - * The value for the folder_id field. - * @var int - */ - protected $folder_id; - /** * The value for the content_id field. * @var int @@ -119,31 +95,16 @@ abstract class Document implements ActiveRecordInterface */ protected $updated_at; - /** - * @var Product - */ - protected $aProduct; - - /** - * @var Category - */ - protected $aCategory; - /** * @var Content */ protected $aContent; /** - * @var Folder + * @var ObjectCollection|ChildContentImageI18n[] Collection to store aggregation of ChildContentImageI18n objects. */ - protected $aFolder; - - /** - * @var ObjectCollection|ChildDocumentI18n[] Collection to store aggregation of ChildDocumentI18n objects. - */ - protected $collDocumentI18ns; - protected $collDocumentI18nsPartial; + protected $collContentImageI18ns; + protected $collContentImageI18nsPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -163,7 +124,7 @@ abstract class Document implements ActiveRecordInterface /** * Current translation objects - * @var array[ChildDocumentI18n] + * @var array[ChildContentImageI18n] */ protected $currentTranslations; @@ -171,10 +132,10 @@ abstract class Document implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $documentI18nsScheduledForDeletion = null; + protected $contentImageI18nsScheduledForDeletion = null; /** - * Initializes internal state of Thelia\Model\Base\Document object. + * Initializes internal state of Thelia\Model\Base\ContentImage object. */ public function __construct() { @@ -269,9 +230,9 @@ abstract class Document implements ActiveRecordInterface } /** - * Compares this with another Document instance. If - * obj is an instance of Document, delegates to - * equals(Document). Otherwise, returns false. + * Compares this with another ContentImage instance. If + * obj is an instance of ContentImage, delegates to + * equals(ContentImage). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -352,7 +313,7 @@ abstract class Document implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return Document The current object, for fluid interface + * @return ContentImage The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -384,7 +345,7 @@ abstract class Document implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return Document The current object, for fluid interface + * @return ContentImage The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -438,39 +399,6 @@ abstract class Document implements ActiveRecordInterface return $this->id; } - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - - return $this->product_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - - return $this->category_id; - } - - /** - * Get the [folder_id] column value. - * - * @return int - */ - public function getFolderId() - { - - return $this->folder_id; - } - /** * Get the [content_id] column value. * @@ -548,7 +476,7 @@ abstract class Document implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\Document The current object (for fluent API support) + * @return \Thelia\Model\ContentImage The current object (for fluent API support) */ public function setId($v) { @@ -558,93 +486,18 @@ abstract class Document implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = DocumentTableMap::ID; + $this->modifiedColumns[] = ContentImageTableMap::ID; } return $this; } // setId() - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Document The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = DocumentTableMap::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Document The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = DocumentTableMap::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [folder_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Document The current object (for fluent API support) - */ - public function setFolderId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->folder_id !== $v) { - $this->folder_id = $v; - $this->modifiedColumns[] = DocumentTableMap::FOLDER_ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setFolderId() - /** * Set the value of [content_id] column. * * @param int $v new value - * @return \Thelia\Model\Document The current object (for fluent API support) + * @return \Thelia\Model\ContentImage The current object (for fluent API support) */ public function setContentId($v) { @@ -654,7 +507,7 @@ abstract class Document implements ActiveRecordInterface if ($this->content_id !== $v) { $this->content_id = $v; - $this->modifiedColumns[] = DocumentTableMap::CONTENT_ID; + $this->modifiedColumns[] = ContentImageTableMap::CONTENT_ID; } if ($this->aContent !== null && $this->aContent->getId() !== $v) { @@ -669,7 +522,7 @@ abstract class Document implements ActiveRecordInterface * Set the value of [file] column. * * @param string $v new value - * @return \Thelia\Model\Document The current object (for fluent API support) + * @return \Thelia\Model\ContentImage The current object (for fluent API support) */ public function setFile($v) { @@ -679,7 +532,7 @@ abstract class Document implements ActiveRecordInterface if ($this->file !== $v) { $this->file = $v; - $this->modifiedColumns[] = DocumentTableMap::FILE; + $this->modifiedColumns[] = ContentImageTableMap::FILE; } @@ -690,7 +543,7 @@ abstract class Document implements ActiveRecordInterface * Set the value of [position] column. * * @param int $v new value - * @return \Thelia\Model\Document The current object (for fluent API support) + * @return \Thelia\Model\ContentImage The current object (for fluent API support) */ public function setPosition($v) { @@ -700,7 +553,7 @@ abstract class Document implements ActiveRecordInterface if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = DocumentTableMap::POSITION; + $this->modifiedColumns[] = ContentImageTableMap::POSITION; } @@ -712,7 +565,7 @@ abstract class Document implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Document The current object (for fluent API support) + * @return \Thelia\Model\ContentImage The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -720,7 +573,7 @@ abstract class Document implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = DocumentTableMap::CREATED_AT; + $this->modifiedColumns[] = ContentImageTableMap::CREATED_AT; } } // if either are not null @@ -733,7 +586,7 @@ abstract class Document implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Document The current object (for fluent API support) + * @return \Thelia\Model\ContentImage The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -741,7 +594,7 @@ abstract class Document implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = DocumentTableMap::UPDATED_AT; + $this->modifiedColumns[] = ContentImageTableMap::UPDATED_AT; } } // if either are not null @@ -786,34 +639,25 @@ abstract class Document implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DocumentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DocumentTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->product_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DocumentTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DocumentTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->folder_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DocumentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentImageTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; $this->content_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : DocumentTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; $this->file = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : DocumentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : DocumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : DocumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -826,10 +670,10 @@ abstract class Document implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 9; // 9 = DocumentTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ContentImageTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Document object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\ContentImage object", 0, $e); } } @@ -848,15 +692,6 @@ abstract class Document implements ActiveRecordInterface */ public function ensureConsistency() { - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { - $this->aFolder = null; - } if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { $this->aContent = null; } @@ -883,13 +718,13 @@ abstract class Document implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DocumentTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(ContentImageTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildDocumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildContentImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -899,11 +734,8 @@ abstract class Document implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aProduct = null; - $this->aCategory = null; $this->aContent = null; - $this->aFolder = null; - $this->collDocumentI18ns = null; + $this->collContentImageI18ns = null; } // if (deep) } @@ -914,8 +746,8 @@ abstract class Document implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see Document::setDeleted() - * @see Document::isDeleted() + * @see ContentImage::setDeleted() + * @see ContentImage::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -924,12 +756,12 @@ abstract class Document implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildDocumentQuery::create() + $deleteQuery = ChildContentImageQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -966,7 +798,7 @@ abstract class Document implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -976,16 +808,16 @@ abstract class Document implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(DocumentTableMap::CREATED_AT)) { + if (!$this->isColumnModified(ContentImageTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(DocumentTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(ContentImageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(DocumentTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ContentImageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -997,7 +829,7 @@ abstract class Document implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - DocumentTableMap::addInstanceToPool($this); + ContentImageTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1032,20 +864,6 @@ abstract class Document implements ActiveRecordInterface // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - if ($this->aContent !== null) { if ($this->aContent->isModified() || $this->aContent->isNew()) { $affectedRows += $this->aContent->save($con); @@ -1053,13 +871,6 @@ abstract class Document implements ActiveRecordInterface $this->setContent($this->aContent); } - if ($this->aFolder !== null) { - if ($this->aFolder->isModified() || $this->aFolder->isNew()) { - $affectedRows += $this->aFolder->save($con); - } - $this->setFolder($this->aFolder); - } - if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1071,17 +882,17 @@ abstract class Document implements ActiveRecordInterface $this->resetModified(); } - if ($this->documentI18nsScheduledForDeletion !== null) { - if (!$this->documentI18nsScheduledForDeletion->isEmpty()) { - \Thelia\Model\DocumentI18nQuery::create() - ->filterByPrimaryKeys($this->documentI18nsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->contentImageI18nsScheduledForDeletion !== null) { + if (!$this->contentImageI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ContentImageI18nQuery::create() + ->filterByPrimaryKeys($this->contentImageI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->documentI18nsScheduledForDeletion = null; + $this->contentImageI18nsScheduledForDeletion = null; } } - if ($this->collDocumentI18ns !== null) { - foreach ($this->collDocumentI18ns as $referrerFK) { + if ($this->collContentImageI18ns !== null) { + foreach ($this->collContentImageI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1108,42 +919,33 @@ abstract class Document implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = DocumentTableMap::ID; + $this->modifiedColumns[] = ContentImageTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentImageTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DocumentTableMap::ID)) { + if ($this->isColumnModified(ContentImageTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(DocumentTableMap::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; - } - if ($this->isColumnModified(DocumentTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; - } - if ($this->isColumnModified(DocumentTableMap::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; - } - if ($this->isColumnModified(DocumentTableMap::CONTENT_ID)) { + if ($this->isColumnModified(ContentImageTableMap::CONTENT_ID)) { $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; } - if ($this->isColumnModified(DocumentTableMap::FILE)) { + if ($this->isColumnModified(ContentImageTableMap::FILE)) { $modifiedColumns[':p' . $index++] = 'FILE'; } - if ($this->isColumnModified(DocumentTableMap::POSITION)) { + if ($this->isColumnModified(ContentImageTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(DocumentTableMap::CREATED_AT)) { + if ($this->isColumnModified(ContentImageTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(DocumentTableMap::UPDATED_AT)) { + if ($this->isColumnModified(ContentImageTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO document (%s) VALUES (%s)', + 'INSERT INTO content_image (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1155,15 +957,6 @@ abstract class Document implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case 'PRODUCT_ID': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case 'FOLDER_ID': - $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); - break; case 'CONTENT_ID': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; @@ -1225,7 +1018,7 @@ abstract class Document implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = DocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ContentImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1245,27 +1038,18 @@ abstract class Document implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getProductId(); - break; - case 2: - return $this->getCategoryId(); - break; - case 3: - return $this->getFolderId(); - break; - case 4: return $this->getContentId(); break; - case 5: + case 2: return $this->getFile(); break; - case 6: + case 3: return $this->getPosition(); break; - case 7: + case 4: return $this->getCreatedAt(); break; - case 8: + case 5: return $this->getUpdatedAt(); break; default: @@ -1291,21 +1075,18 @@ abstract class Document implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['Document'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['ContentImage'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['Document'][$this->getPrimaryKey()] = true; - $keys = DocumentTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['ContentImage'][$this->getPrimaryKey()] = true; + $keys = ContentImageTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getProductId(), - $keys[2] => $this->getCategoryId(), - $keys[3] => $this->getFolderId(), - $keys[4] => $this->getContentId(), - $keys[5] => $this->getFile(), - $keys[6] => $this->getPosition(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), + $keys[1] => $this->getContentId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1314,20 +1095,11 @@ abstract class Document implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } if (null !== $this->aContent) { $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aFolder) { - $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collDocumentI18ns) { - $result['DocumentI18ns'] = $this->collDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collContentImageI18ns) { + $result['ContentImageI18ns'] = $this->collContentImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1347,7 +1119,7 @@ abstract class Document implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = DocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ContentImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1367,27 +1139,18 @@ abstract class Document implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setProductId($value); - break; - case 2: - $this->setCategoryId($value); - break; - case 3: - $this->setFolderId($value); - break; - case 4: $this->setContentId($value); break; - case 5: + case 2: $this->setFile($value); break; - case 6: + case 3: $this->setPosition($value); break; - case 7: + case 4: $this->setCreatedAt($value); break; - case 8: + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1412,17 +1175,14 @@ abstract class Document implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = DocumentTableMap::getFieldNames($keyType); + $keys = ContentImageTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[1], $arr)) $this->setContentId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1432,17 +1192,14 @@ abstract class Document implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(DocumentTableMap::DATABASE_NAME); + $criteria = new Criteria(ContentImageTableMap::DATABASE_NAME); - if ($this->isColumnModified(DocumentTableMap::ID)) $criteria->add(DocumentTableMap::ID, $this->id); - if ($this->isColumnModified(DocumentTableMap::PRODUCT_ID)) $criteria->add(DocumentTableMap::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(DocumentTableMap::CATEGORY_ID)) $criteria->add(DocumentTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(DocumentTableMap::FOLDER_ID)) $criteria->add(DocumentTableMap::FOLDER_ID, $this->folder_id); - if ($this->isColumnModified(DocumentTableMap::CONTENT_ID)) $criteria->add(DocumentTableMap::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(DocumentTableMap::FILE)) $criteria->add(DocumentTableMap::FILE, $this->file); - if ($this->isColumnModified(DocumentTableMap::POSITION)) $criteria->add(DocumentTableMap::POSITION, $this->position); - if ($this->isColumnModified(DocumentTableMap::CREATED_AT)) $criteria->add(DocumentTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(DocumentTableMap::UPDATED_AT)) $criteria->add(DocumentTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(ContentImageTableMap::ID)) $criteria->add(ContentImageTableMap::ID, $this->id); + if ($this->isColumnModified(ContentImageTableMap::CONTENT_ID)) $criteria->add(ContentImageTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(ContentImageTableMap::FILE)) $criteria->add(ContentImageTableMap::FILE, $this->file); + if ($this->isColumnModified(ContentImageTableMap::POSITION)) $criteria->add(ContentImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(ContentImageTableMap::CREATED_AT)) $criteria->add(ContentImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ContentImageTableMap::UPDATED_AT)) $criteria->add(ContentImageTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1457,8 +1214,8 @@ abstract class Document implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(DocumentTableMap::DATABASE_NAME); - $criteria->add(DocumentTableMap::ID, $this->id); + $criteria = new Criteria(ContentImageTableMap::DATABASE_NAME); + $criteria->add(ContentImageTableMap::ID, $this->id); return $criteria; } @@ -1499,16 +1256,13 @@ abstract class Document implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\Document (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\ContentImage (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setProductId($this->getProductId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setFolderId($this->getFolderId()); $copyObj->setContentId($this->getContentId()); $copyObj->setFile($this->getFile()); $copyObj->setPosition($this->getPosition()); @@ -1520,9 +1274,9 @@ abstract class Document implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getDocumentI18ns() as $relObj) { + foreach ($this->getContentImageI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocumentI18n($relObj->copy($deepCopy)); + $copyObj->addContentImageI18n($relObj->copy($deepCopy)); } } @@ -1543,7 +1297,7 @@ abstract class Document implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Document Clone of current object. + * @return \Thelia\Model\ContentImage Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1556,113 +1310,11 @@ abstract class Document implements ActiveRecordInterface return $copyObj; } - /** - * Declares an association between this object and a ChildProduct object. - * - * @param ChildProduct $v - * @return \Thelia\Model\Document The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(ChildProduct $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildProduct object, it will not be re-added. - if ($v !== null) { - $v->addDocument($this); - } - - - return $this; - } - - - /** - * Get the associated ChildProduct object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildProduct The associated ChildProduct object. - * @throws PropelException - */ - public function getProduct(ConnectionInterface $con = null) - { - if ($this->aProduct === null && ($this->product_id !== null)) { - $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addDocuments($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\Document The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addDocument($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addDocuments($this); - */ - } - - return $this->aCategory; - } - /** * Declares an association between this object and a ChildContent object. * * @param ChildContent $v - * @return \Thelia\Model\Document The current object (for fluent API support) + * @return \Thelia\Model\ContentImage The current object (for fluent API support) * @throws PropelException */ public function setContent(ChildContent $v = null) @@ -1678,7 +1330,7 @@ abstract class Document implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildContent object, it will not be re-added. if ($v !== null) { - $v->addDocument($this); + $v->addContentImage($this); } @@ -1702,64 +1354,13 @@ abstract class Document implements ActiveRecordInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aContent->addDocuments($this); + $this->aContent->addContentImages($this); */ } return $this->aContent; } - /** - * Declares an association between this object and a ChildFolder object. - * - * @param ChildFolder $v - * @return \Thelia\Model\Document The current object (for fluent API support) - * @throws PropelException - */ - public function setFolder(ChildFolder $v = null) - { - if ($v === null) { - $this->setFolderId(NULL); - } else { - $this->setFolderId($v->getId()); - } - - $this->aFolder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildFolder object, it will not be re-added. - if ($v !== null) { - $v->addDocument($this); - } - - - return $this; - } - - - /** - * Get the associated ChildFolder object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildFolder The associated ChildFolder object. - * @throws PropelException - */ - public function getFolder(ConnectionInterface $con = null) - { - if ($this->aFolder === null && ($this->folder_id !== null)) { - $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFolder->addDocuments($this); - */ - } - - return $this->aFolder; - } - /** * Initializes a collection based on the name of a relation. @@ -1771,37 +1372,37 @@ abstract class Document implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('DocumentI18n' == $relationName) { - return $this->initDocumentI18ns(); + if ('ContentImageI18n' == $relationName) { + return $this->initContentImageI18ns(); } } /** - * Clears out the collDocumentI18ns collection + * Clears out the collContentImageI18ns collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addDocumentI18ns() + * @see addContentImageI18ns() */ - public function clearDocumentI18ns() + public function clearContentImageI18ns() { - $this->collDocumentI18ns = null; // important to set this to NULL since that means it is uninitialized + $this->collContentImageI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collDocumentI18ns collection loaded partially. + * Reset is the collContentImageI18ns collection loaded partially. */ - public function resetPartialDocumentI18ns($v = true) + public function resetPartialContentImageI18ns($v = true) { - $this->collDocumentI18nsPartial = $v; + $this->collContentImageI18nsPartial = $v; } /** - * Initializes the collDocumentI18ns collection. + * Initializes the collContentImageI18ns collection. * - * By default this just sets the collDocumentI18ns collection to an empty array (like clearcollDocumentI18ns()); + * By default this just sets the collContentImageI18ns collection to an empty array (like clearcollContentImageI18ns()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1810,192 +1411,192 @@ abstract class Document implements ActiveRecordInterface * * @return void */ - public function initDocumentI18ns($overrideExisting = true) + public function initContentImageI18ns($overrideExisting = true) { - if (null !== $this->collDocumentI18ns && !$overrideExisting) { + if (null !== $this->collContentImageI18ns && !$overrideExisting) { return; } - $this->collDocumentI18ns = new ObjectCollection(); - $this->collDocumentI18ns->setModel('\Thelia\Model\DocumentI18n'); + $this->collContentImageI18ns = new ObjectCollection(); + $this->collContentImageI18ns->setModel('\Thelia\Model\ContentImageI18n'); } /** - * Gets an array of ChildDocumentI18n objects which contain a foreign key that references this object. + * Gets an array of ChildContentImageI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildDocument is new, it will return + * If this ChildContentImage is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDocumentI18n[] List of ChildDocumentI18n objects + * @return Collection|ChildContentImageI18n[] List of ChildContentImageI18n objects * @throws PropelException */ - public function getDocumentI18ns($criteria = null, ConnectionInterface $con = null) + public function getContentImageI18ns($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collDocumentI18nsPartial && !$this->isNew(); - if (null === $this->collDocumentI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocumentI18ns) { + $partial = $this->collContentImageI18nsPartial && !$this->isNew(); + if (null === $this->collContentImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentImageI18ns) { // return empty collection - $this->initDocumentI18ns(); + $this->initContentImageI18ns(); } else { - $collDocumentI18ns = ChildDocumentI18nQuery::create(null, $criteria) - ->filterByDocument($this) + $collContentImageI18ns = ChildContentImageI18nQuery::create(null, $criteria) + ->filterByContentImage($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collDocumentI18nsPartial && count($collDocumentI18ns)) { - $this->initDocumentI18ns(false); + if (false !== $this->collContentImageI18nsPartial && count($collContentImageI18ns)) { + $this->initContentImageI18ns(false); - foreach ($collDocumentI18ns as $obj) { - if (false == $this->collDocumentI18ns->contains($obj)) { - $this->collDocumentI18ns->append($obj); + foreach ($collContentImageI18ns as $obj) { + if (false == $this->collContentImageI18ns->contains($obj)) { + $this->collContentImageI18ns->append($obj); } } - $this->collDocumentI18nsPartial = true; + $this->collContentImageI18nsPartial = true; } - $collDocumentI18ns->getInternalIterator()->rewind(); + $collContentImageI18ns->getInternalIterator()->rewind(); - return $collDocumentI18ns; + return $collContentImageI18ns; } - if ($partial && $this->collDocumentI18ns) { - foreach ($this->collDocumentI18ns as $obj) { + if ($partial && $this->collContentImageI18ns) { + foreach ($this->collContentImageI18ns as $obj) { if ($obj->isNew()) { - $collDocumentI18ns[] = $obj; + $collContentImageI18ns[] = $obj; } } } - $this->collDocumentI18ns = $collDocumentI18ns; - $this->collDocumentI18nsPartial = false; + $this->collContentImageI18ns = $collContentImageI18ns; + $this->collContentImageI18nsPartial = false; } } - return $this->collDocumentI18ns; + return $this->collContentImageI18ns; } /** - * Sets a collection of DocumentI18n objects related by a one-to-many relationship + * Sets a collection of ContentImageI18n objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $documentI18ns A Propel collection. + * @param Collection $contentImageI18ns A Propel collection. * @param ConnectionInterface $con Optional connection object - * @return ChildDocument The current object (for fluent API support) + * @return ChildContentImage The current object (for fluent API support) */ - public function setDocumentI18ns(Collection $documentI18ns, ConnectionInterface $con = null) + public function setContentImageI18ns(Collection $contentImageI18ns, ConnectionInterface $con = null) { - $documentI18nsToDelete = $this->getDocumentI18ns(new Criteria(), $con)->diff($documentI18ns); + $contentImageI18nsToDelete = $this->getContentImageI18ns(new Criteria(), $con)->diff($contentImageI18ns); //since at least one column in the foreign key is at the same time a PK //we can not just set a PK to NULL in the lines below. We have to store //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->documentI18nsScheduledForDeletion = clone $documentI18nsToDelete; + $this->contentImageI18nsScheduledForDeletion = clone $contentImageI18nsToDelete; - foreach ($documentI18nsToDelete as $documentI18nRemoved) { - $documentI18nRemoved->setDocument(null); + foreach ($contentImageI18nsToDelete as $contentImageI18nRemoved) { + $contentImageI18nRemoved->setContentImage(null); } - $this->collDocumentI18ns = null; - foreach ($documentI18ns as $documentI18n) { - $this->addDocumentI18n($documentI18n); + $this->collContentImageI18ns = null; + foreach ($contentImageI18ns as $contentImageI18n) { + $this->addContentImageI18n($contentImageI18n); } - $this->collDocumentI18ns = $documentI18ns; - $this->collDocumentI18nsPartial = false; + $this->collContentImageI18ns = $contentImageI18ns; + $this->collContentImageI18nsPartial = false; return $this; } /** - * Returns the number of related DocumentI18n objects. + * Returns the number of related ContentImageI18n objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related DocumentI18n objects. + * @return int Count of related ContentImageI18n objects. * @throws PropelException */ - public function countDocumentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countContentImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collDocumentI18nsPartial && !$this->isNew(); - if (null === $this->collDocumentI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocumentI18ns) { + $partial = $this->collContentImageI18nsPartial && !$this->isNew(); + if (null === $this->collContentImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collContentImageI18ns) { return 0; } if ($partial && !$criteria) { - return count($this->getDocumentI18ns()); + return count($this->getContentImageI18ns()); } - $query = ChildDocumentI18nQuery::create(null, $criteria); + $query = ChildContentImageI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query - ->filterByDocument($this) + ->filterByContentImage($this) ->count($con); } - return count($this->collDocumentI18ns); + return count($this->collContentImageI18ns); } /** - * Method called to associate a ChildDocumentI18n object to this object - * through the ChildDocumentI18n foreign key attribute. + * Method called to associate a ChildContentImageI18n object to this object + * through the ChildContentImageI18n foreign key attribute. * - * @param ChildDocumentI18n $l ChildDocumentI18n - * @return \Thelia\Model\Document The current object (for fluent API support) + * @param ChildContentImageI18n $l ChildContentImageI18n + * @return \Thelia\Model\ContentImage The current object (for fluent API support) */ - public function addDocumentI18n(ChildDocumentI18n $l) + public function addContentImageI18n(ChildContentImageI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); $this->currentTranslations[$locale] = $l; } - if ($this->collDocumentI18ns === null) { - $this->initDocumentI18ns(); - $this->collDocumentI18nsPartial = true; + if ($this->collContentImageI18ns === null) { + $this->initContentImageI18ns(); + $this->collContentImageI18nsPartial = true; } - if (!in_array($l, $this->collDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocumentI18n($l); + if (!in_array($l, $this->collContentImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddContentImageI18n($l); } return $this; } /** - * @param DocumentI18n $documentI18n The documentI18n object to add. + * @param ContentImageI18n $contentImageI18n The contentImageI18n object to add. */ - protected function doAddDocumentI18n($documentI18n) + protected function doAddContentImageI18n($contentImageI18n) { - $this->collDocumentI18ns[]= $documentI18n; - $documentI18n->setDocument($this); + $this->collContentImageI18ns[]= $contentImageI18n; + $contentImageI18n->setContentImage($this); } /** - * @param DocumentI18n $documentI18n The documentI18n object to remove. - * @return ChildDocument The current object (for fluent API support) + * @param ContentImageI18n $contentImageI18n The contentImageI18n object to remove. + * @return ChildContentImage The current object (for fluent API support) */ - public function removeDocumentI18n($documentI18n) + public function removeContentImageI18n($contentImageI18n) { - if ($this->getDocumentI18ns()->contains($documentI18n)) { - $this->collDocumentI18ns->remove($this->collDocumentI18ns->search($documentI18n)); - if (null === $this->documentI18nsScheduledForDeletion) { - $this->documentI18nsScheduledForDeletion = clone $this->collDocumentI18ns; - $this->documentI18nsScheduledForDeletion->clear(); + if ($this->getContentImageI18ns()->contains($contentImageI18n)) { + $this->collContentImageI18ns->remove($this->collContentImageI18ns->search($contentImageI18n)); + if (null === $this->contentImageI18nsScheduledForDeletion) { + $this->contentImageI18nsScheduledForDeletion = clone $this->collContentImageI18ns; + $this->contentImageI18nsScheduledForDeletion->clear(); } - $this->documentI18nsScheduledForDeletion[]= clone $documentI18n; - $documentI18n->setDocument(null); + $this->contentImageI18nsScheduledForDeletion[]= clone $contentImageI18n; + $contentImageI18n->setContentImage(null); } return $this; @@ -2007,9 +1608,6 @@ abstract class Document implements ActiveRecordInterface public function clear() { $this->id = null; - $this->product_id = null; - $this->category_id = null; - $this->folder_id = null; $this->content_id = null; $this->file = null; $this->position = null; @@ -2034,8 +1632,8 @@ abstract class Document implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collDocumentI18ns) { - foreach ($this->collDocumentI18ns as $o) { + if ($this->collContentImageI18ns) { + foreach ($this->collContentImageI18ns as $o) { $o->clearAllReferences($deep); } } @@ -2045,14 +1643,11 @@ abstract class Document implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; - if ($this->collDocumentI18ns instanceof Collection) { - $this->collDocumentI18ns->clearIterator(); + if ($this->collContentImageI18ns instanceof Collection) { + $this->collContentImageI18ns->clearIterator(); } - $this->collDocumentI18ns = null; - $this->aProduct = null; - $this->aCategory = null; + $this->collContentImageI18ns = null; $this->aContent = null; - $this->aFolder = null; } /** @@ -2062,7 +1657,7 @@ abstract class Document implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(DocumentTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(ContentImageTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2070,11 +1665,11 @@ abstract class Document implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildDocument The current object (for fluent API support) + * @return ChildContentImage The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = DocumentTableMap::UPDATED_AT; + $this->modifiedColumns[] = ContentImageTableMap::UPDATED_AT; return $this; } @@ -2086,7 +1681,7 @@ abstract class Document implements ActiveRecordInterface * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return ChildDocument The current object (for fluent API support) + * @return ChildContentImage The current object (for fluent API support) */ public function setLocale($locale = 'en_US') { @@ -2111,12 +1706,12 @@ abstract class Document implements ActiveRecordInterface * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param ConnectionInterface $con an optional connection object * - * @return ChildDocumentI18n */ + * @return ChildContentImageI18n */ public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collDocumentI18ns) { - foreach ($this->collDocumentI18ns as $translation) { + if (null !== $this->collContentImageI18ns) { + foreach ($this->collContentImageI18ns as $translation) { if ($translation->getLocale() == $locale) { $this->currentTranslations[$locale] = $translation; @@ -2125,15 +1720,15 @@ abstract class Document implements ActiveRecordInterface } } if ($this->isNew()) { - $translation = new ChildDocumentI18n(); + $translation = new ChildContentImageI18n(); $translation->setLocale($locale); } else { - $translation = ChildDocumentI18nQuery::create() + $translation = ChildContentImageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; } - $this->addDocumentI18n($translation); + $this->addContentImageI18n($translation); } return $this->currentTranslations[$locale]; @@ -2145,21 +1740,21 @@ abstract class Document implements ActiveRecordInterface * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param ConnectionInterface $con an optional connection object * - * @return ChildDocument The current object (for fluent API support) + * @return ChildContentImage The current object (for fluent API support) */ public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { - ChildDocumentI18nQuery::create() + ChildContentImageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } if (isset($this->currentTranslations[$locale])) { unset($this->currentTranslations[$locale]); } - foreach ($this->collDocumentI18ns as $key => $translation) { + foreach ($this->collContentImageI18ns as $key => $translation) { if ($translation->getLocale() == $locale) { - unset($this->collDocumentI18ns[$key]); + unset($this->collContentImageI18ns[$key]); break; } } @@ -2172,7 +1767,7 @@ abstract class Document implements ActiveRecordInterface * * @param ConnectionInterface $con an optional connection object * - * @return ChildDocumentI18n */ + * @return ChildContentImageI18n */ public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); @@ -2194,7 +1789,7 @@ abstract class Document implements ActiveRecordInterface * Set the value of [title] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2218,7 +1813,7 @@ abstract class Document implements ActiveRecordInterface * Set the value of [description] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2242,7 +1837,7 @@ abstract class Document implements ActiveRecordInterface * Set the value of [chapo] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2266,7 +1861,7 @@ abstract class Document implements ActiveRecordInterface * Set the value of [postscriptum] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); diff --git a/core/lib/Thelia/Model/Base/ContentImageI18n.php b/core/lib/Thelia/Model/Base/ContentImageI18n.php new file mode 100644 index 000000000..d655dec53 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentImageI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ContentImageI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ContentImageI18n instance. If + * obj is an instance of ContentImageI18n, delegates to + * equals(ContentImageI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ContentImageI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ContentImageI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ContentImageI18nTableMap::ID; + } + + if ($this->aContentImage !== null && $this->aContentImage->getId() !== $v) { + $this->aContentImage = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ContentImageI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ContentImageI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ContentImageI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ContentImageI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ContentImageI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ContentImageI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ContentImageI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aContentImage !== null && $this->id !== $this->aContentImage->getId()) { + $this->aContentImage = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildContentImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aContentImage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ContentImageI18n::setDeleted() + * @see ContentImageI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildContentImageI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ContentImageI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aContentImage !== null) { + if ($this->aContentImage->isModified() || $this->aContentImage->isNew()) { + $affectedRows += $this->aContentImage->save($con); + } + $this->setContentImage($this->aContentImage); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ContentImageI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ContentImageI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ContentImageI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ContentImageI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ContentImageI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ContentImageI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO content_image_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ContentImageI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ContentImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ContentImageI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aContentImage) { + $result['ContentImage'] = $this->aContentImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ContentImageI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ContentImageI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ContentImageI18nTableMap::ID)) $criteria->add(ContentImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ContentImageI18nTableMap::LOCALE)) $criteria->add(ContentImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ContentImageI18nTableMap::TITLE)) $criteria->add(ContentImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ContentImageI18nTableMap::DESCRIPTION)) $criteria->add(ContentImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ContentImageI18nTableMap::CHAPO)) $criteria->add(ContentImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ContentImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(ContentImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ContentImageI18nTableMap::DATABASE_NAME); + $criteria->add(ContentImageI18nTableMap::ID, $this->id); + $criteria->add(ContentImageI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ContentImageI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ContentImageI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildContentImage object. + * + * @param ChildContentImage $v + * @return \Thelia\Model\ContentImageI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setContentImage(ChildContentImage $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aContentImage = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildContentImage object, it will not be re-added. + if ($v !== null) { + $v->addContentImageI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContentImage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContentImage The associated ChildContentImage object. + * @throws PropelException + */ + public function getContentImage(ConnectionInterface $con = null) + { + if ($this->aContentImage === null && ($this->id !== null)) { + $this->aContentImage = ChildContentImageQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aContentImage->addContentImageI18ns($this); + */ + } + + return $this->aContentImage; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aContentImage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ContentImageI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ContentImageI18nQuery.php b/core/lib/Thelia/Model/Base/ContentImageI18nQuery.php new file mode 100644 index 000000000..1807c5bb7 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentImageI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildContentImageI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ContentImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentImageI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM content_image_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentImageI18n(); + $obj->hydrate($row); + ContentImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentImageI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(ContentImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ContentImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(ContentImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ContentImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByContentImage() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentImageI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentImageI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentImageI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentImageI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentImageI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\ContentImage object + * + * @param \Thelia\Model\ContentImage|ObjectCollection $contentImage The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function filterByContentImage($contentImage, $comparison = null) + { + if ($contentImage instanceof \Thelia\Model\ContentImage) { + return $this + ->addUsingAlias(ContentImageI18nTableMap::ID, $contentImage->getId(), $comparison); + } elseif ($contentImage instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ContentImageI18nTableMap::ID, $contentImage->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContentImage() only accepts arguments of type \Thelia\Model\ContentImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function joinContentImage($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentImage'); + } + + return $this; + } + + /** + * Use the ContentImage relation ContentImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentImageQuery A secondary query class using the current class as primary query + */ + public function useContentImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinContentImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentImage', '\Thelia\Model\ContentImageQuery'); + } + + /** + * Exclude object from result + * + * @param ChildContentImageI18n $contentImageI18n Object to remove from the list of results + * + * @return ChildContentImageI18nQuery The current query, for fluid interface + */ + public function prune($contentImageI18n = null) + { + if ($contentImageI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(ContentImageI18nTableMap::ID), $contentImageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ContentImageI18nTableMap::LOCALE), $contentImageI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the content_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentImageI18nTableMap::clearInstancePool(); + ContentImageI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentImageI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ContentImageI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentImageI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ContentImageI18nQuery diff --git a/core/lib/Thelia/Model/Base/ContentImageQuery.php b/core/lib/Thelia/Model/Base/ContentImageQuery.php new file mode 100644 index 000000000..f69464dd7 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentImageQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildContentImage|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ContentImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ContentImageTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentImage A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CONTENT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM content_image WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentImage(); + $obj->hydrate($row); + ContentImageTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildContentImage|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ContentImageTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ContentImageTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ContentImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ContentImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentImageTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the content_id column + * + * Example usage: + * + * $query->filterByContentId(1234); // WHERE content_id = 1234 + * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 + * + * + * @see filterByContent() + * + * @param mixed $contentId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByContentId($contentId = null, $comparison = null) + { + if (is_array($contentId)) { + $useMinMax = false; + if (isset($contentId['min'])) { + $this->addUsingAlias(ContentImageTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($contentId['max'])) { + $this->addUsingAlias(ContentImageTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentImageTableMap::CONTENT_ID, $contentId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ContentImageTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(ContentImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(ContentImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentImageTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ContentImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ContentImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentImageTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ContentImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ContentImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ContentImageTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Content object + * + * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByContent($content, $comparison = null) + { + if ($content instanceof \Thelia\Model\Content) { + return $this + ->addUsingAlias(ContentImageTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ContentImageTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Content relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Content'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Content'); + } + + return $this; + } + + /** + * Use the Content relation Content object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query + */ + public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContent($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ContentImageI18n object + * + * @param \Thelia\Model\ContentImageI18n|ObjectCollection $contentImageI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function filterByContentImageI18n($contentImageI18n, $comparison = null) + { + if ($contentImageI18n instanceof \Thelia\Model\ContentImageI18n) { + return $this + ->addUsingAlias(ContentImageTableMap::ID, $contentImageI18n->getId(), $comparison); + } elseif ($contentImageI18n instanceof ObjectCollection) { + return $this + ->useContentImageI18nQuery() + ->filterByPrimaryKeys($contentImageI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentImageI18n() only accepts arguments of type \Thelia\Model\ContentImageI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentImageI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function joinContentImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentImageI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentImageI18n'); + } + + return $this; + } + + /** + * Use the ContentImageI18n relation ContentImageI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentImageI18nQuery A secondary query class using the current class as primary query + */ + public function useContentImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinContentImageI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentImageI18n', '\Thelia\Model\ContentImageI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildContentImage $contentImage Object to remove from the list of results + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function prune($contentImage = null) + { + if ($contentImage) { + $this->addUsingAlias(ContentImageTableMap::ID, $contentImage->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the content_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentImageTableMap::clearInstancePool(); + ContentImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentImageTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ContentImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ContentImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ContentImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentImageTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ContentImageTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ContentImageTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'ContentImageI18n'; + + return $this + ->joinContentImageI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildContentImageQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('ContentImageI18n'); + $this->with['ContentImageI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildContentImageI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentImageI18n', '\Thelia\Model\ContentImageI18nQuery'); + } + +} // ContentImageQuery diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php index aec6e3678..2cbbe109b 100644 --- a/core/lib/Thelia/Model/Base/ContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -48,14 +48,6 @@ use Thelia\Model\Map\ContentTableMap; * @method ChildContentQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation * @method ChildContentQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation * - * @method ChildContentQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation - * @method ChildContentQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation - * @method ChildContentQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation - * - * @method ChildContentQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method ChildContentQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method ChildContentQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation - * * @method ChildContentQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ChildContentQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ChildContentQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation @@ -64,6 +56,14 @@ use Thelia\Model\Map\ContentTableMap; * @method ChildContentQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation * @method ChildContentQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation * + * @method ChildContentQuery leftJoinContentImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentImage relation + * @method ChildContentQuery rightJoinContentImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentImage relation + * @method ChildContentQuery innerJoinContentImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentImage relation + * + * @method ChildContentQuery leftJoinContentDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentDocument relation + * @method ChildContentQuery rightJoinContentDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentDocument relation + * @method ChildContentQuery innerJoinContentDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentDocument relation + * * @method ChildContentQuery leftJoinContentI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentI18n relation * @method ChildContentQuery rightJoinContentI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentI18n relation * @method ChildContentQuery innerJoinContentI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentI18n relation @@ -671,152 +671,6 @@ abstract class ContentQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); } - /** - * Filter the query by a related \Thelia\Model\Image object - * - * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof \Thelia\Model\Image) { - return $this - ->addUsingAlias(ContentTableMap::ID, $image->getContentId(), $comparison); - } elseif ($image instanceof ObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Document object - * - * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof \Thelia\Model\Document) { - return $this - ->addUsingAlias(ContentTableMap::ID, $document->getContentId(), $comparison); - } elseif ($document instanceof ObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildContentQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - /** * Filter the query by a related \Thelia\Model\Rewriting object * @@ -963,6 +817,152 @@ abstract class ContentQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); } + /** + * Filter the query by a related \Thelia\Model\ContentImage object + * + * @param \Thelia\Model\ContentImage|ObjectCollection $contentImage the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function filterByContentImage($contentImage, $comparison = null) + { + if ($contentImage instanceof \Thelia\Model\ContentImage) { + return $this + ->addUsingAlias(ContentTableMap::ID, $contentImage->getContentId(), $comparison); + } elseif ($contentImage instanceof ObjectCollection) { + return $this + ->useContentImageQuery() + ->filterByPrimaryKeys($contentImage->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentImage() only accepts arguments of type \Thelia\Model\ContentImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function joinContentImage($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentImage'); + } + + return $this; + } + + /** + * Use the ContentImage relation ContentImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentImageQuery A secondary query class using the current class as primary query + */ + public function useContentImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContentImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentImage', '\Thelia\Model\ContentImageQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ContentDocument object + * + * @param \Thelia\Model\ContentDocument|ObjectCollection $contentDocument the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function filterByContentDocument($contentDocument, $comparison = null) + { + if ($contentDocument instanceof \Thelia\Model\ContentDocument) { + return $this + ->addUsingAlias(ContentTableMap::ID, $contentDocument->getContentId(), $comparison); + } elseif ($contentDocument instanceof ObjectCollection) { + return $this + ->useContentDocumentQuery() + ->filterByPrimaryKeys($contentDocument->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByContentDocument() only accepts arguments of type \Thelia\Model\ContentDocument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ContentDocument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function joinContentDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ContentDocument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ContentDocument'); + } + + return $this; + } + + /** + * Use the ContentDocument relation ContentDocument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ContentDocumentQuery A secondary query class using the current class as primary query + */ + public function useContentDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinContentDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ContentDocument', '\Thelia\Model\ContentDocumentQuery'); + } + /** * Filter the query by a related \Thelia\Model\ContentI18n object * diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php index bbb83bb92..5ab40a742 100644 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -93,12 +93,6 @@ abstract class Currency implements ActiveRecordInterface */ protected $by_default; - /** - * The value for the position field. - * @var int - */ - protected $position; - /** * The value for the created_at field. * @var string @@ -490,17 +484,6 @@ abstract class Currency implements ActiveRecordInterface return $this->by_default; } - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - - return $this->position; - } - /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -646,27 +629,6 @@ abstract class Currency implements ActiveRecordInterface return $this; } // setByDefault() - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return \Thelia\Model\Currency The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = CurrencyTableMap::POSITION; - } - - - return $this; - } // setPosition() - /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -761,16 +723,13 @@ abstract class Currency implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CurrencyTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; $this->by_default = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; - $this->position = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -783,7 +742,7 @@ abstract class Currency implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 8; // 8 = CurrencyTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 7; // 7 = CurrencyTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Currency object", 0, $e); @@ -1096,9 +1055,6 @@ abstract class Currency implements ActiveRecordInterface if ($this->isColumnModified(CurrencyTableMap::BY_DEFAULT)) { $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; } - if ($this->isColumnModified(CurrencyTableMap::POSITION)) { - $modifiedColumns[':p' . $index++] = 'POSITION'; - } if ($this->isColumnModified(CurrencyTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1131,9 +1087,6 @@ abstract class Currency implements ActiveRecordInterface case 'BY_DEFAULT': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; - case 'POSITION': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1218,12 +1171,9 @@ abstract class Currency implements ActiveRecordInterface return $this->getByDefault(); break; case 5: - return $this->getPosition(); - break; - case 6: return $this->getCreatedAt(); break; - case 7: + case 6: return $this->getUpdatedAt(); break; default: @@ -1260,9 +1210,8 @@ abstract class Currency implements ActiveRecordInterface $keys[2] => $this->getSymbol(), $keys[3] => $this->getRate(), $keys[4] => $this->getByDefault(), - $keys[5] => $this->getPosition(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1333,12 +1282,9 @@ abstract class Currency implements ActiveRecordInterface $this->setByDefault($value); break; case 5: - $this->setPosition($value); - break; - case 6: $this->setCreatedAt($value); break; - case 7: + case 6: $this->setUpdatedAt($value); break; } // switch() @@ -1370,9 +1316,8 @@ abstract class Currency implements ActiveRecordInterface if (array_key_exists($keys[2], $arr)) $this->setSymbol($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setRate($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); } /** @@ -1389,7 +1334,6 @@ abstract class Currency implements ActiveRecordInterface if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) $criteria->add(CurrencyTableMap::SYMBOL, $this->symbol); if ($this->isColumnModified(CurrencyTableMap::RATE)) $criteria->add(CurrencyTableMap::RATE, $this->rate); if ($this->isColumnModified(CurrencyTableMap::BY_DEFAULT)) $criteria->add(CurrencyTableMap::BY_DEFAULT, $this->by_default); - if ($this->isColumnModified(CurrencyTableMap::POSITION)) $criteria->add(CurrencyTableMap::POSITION, $this->position); if ($this->isColumnModified(CurrencyTableMap::CREATED_AT)) $criteria->add(CurrencyTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CurrencyTableMap::UPDATED_AT)) $criteria->add(CurrencyTableMap::UPDATED_AT, $this->updated_at); @@ -1459,7 +1403,6 @@ abstract class Currency implements ActiveRecordInterface $copyObj->setSymbol($this->getSymbol()); $copyObj->setRate($this->getRate()); $copyObj->setByDefault($this->getByDefault()); - $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2636,7 +2579,6 @@ abstract class Currency implements ActiveRecordInterface $this->symbol = null; $this->rate = null; $this->by_default = null; - $this->position = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/CurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php index 7aba3317e..140b70463 100644 --- a/core/lib/Thelia/Model/Base/CurrencyQuery.php +++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php @@ -27,7 +27,6 @@ use Thelia\Model\Map\CurrencyTableMap; * @method ChildCurrencyQuery orderBySymbol($order = Criteria::ASC) Order by the symbol column * @method ChildCurrencyQuery orderByRate($order = Criteria::ASC) Order by the rate column * @method ChildCurrencyQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column - * @method ChildCurrencyQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildCurrencyQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCurrencyQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -36,7 +35,6 @@ use Thelia\Model\Map\CurrencyTableMap; * @method ChildCurrencyQuery groupBySymbol() Group by the symbol column * @method ChildCurrencyQuery groupByRate() Group by the rate column * @method ChildCurrencyQuery groupByByDefault() Group by the by_default column - * @method ChildCurrencyQuery groupByPosition() Group by the position column * @method ChildCurrencyQuery groupByCreatedAt() Group by the created_at column * @method ChildCurrencyQuery groupByUpdatedAt() Group by the updated_at column * @@ -68,7 +66,6 @@ use Thelia\Model\Map\CurrencyTableMap; * @method ChildCurrency findOneBySymbol(string $symbol) Return the first ChildCurrency filtered by the symbol column * @method ChildCurrency findOneByRate(double $rate) Return the first ChildCurrency filtered by the rate column * @method ChildCurrency findOneByByDefault(int $by_default) Return the first ChildCurrency filtered by the by_default column - * @method ChildCurrency findOneByPosition(int $position) Return the first ChildCurrency filtered by the position column * @method ChildCurrency findOneByCreatedAt(string $created_at) Return the first ChildCurrency filtered by the created_at column * @method ChildCurrency findOneByUpdatedAt(string $updated_at) Return the first ChildCurrency filtered by the updated_at column * @@ -77,7 +74,6 @@ use Thelia\Model\Map\CurrencyTableMap; * @method array findBySymbol(string $symbol) Return ChildCurrency objects filtered by the symbol column * @method array findByRate(double $rate) Return ChildCurrency objects filtered by the rate column * @method array findByByDefault(int $by_default) Return ChildCurrency objects filtered by the by_default column - * @method array findByPosition(int $position) Return ChildCurrency objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildCurrency objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCurrency objects filtered by the updated_at column * @@ -168,7 +164,7 @@ abstract class CurrencyQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, SYMBOL, RATE, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM currency WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, SYMBOL, RATE, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM currency WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -438,47 +434,6 @@ abstract class CurrencyQuery extends ModelCriteria return $this->addUsingAlias(CurrencyTableMap::BY_DEFAULT, $byDefault, $comparison); } - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCurrencyQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(CurrencyTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(CurrencyTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CurrencyTableMap::POSITION, $position, $comparison); - } - /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/DocumentQuery.php b/core/lib/Thelia/Model/Base/DocumentQuery.php deleted file mode 100644 index 94a9e0670..000000000 --- a/core/lib/Thelia/Model/Base/DocumentQuery.php +++ /dev/null @@ -1,1224 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildDocument|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = DocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DocumentTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildDocument A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, PRODUCT_ID, CATEGORY_ID, FOLDER_ID, CONTENT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM document WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildDocument(); - $obj->hydrate($row); - DocumentTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildDocument|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(DocumentTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(DocumentTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(DocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(DocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the folder_id column - * - * Example usage: - * - * $query->filterByFolderId(1234); // WHERE folder_id = 1234 - * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 - * - * - * @see filterByFolder() - * - * @param mixed $folderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByFolderId($folderId = null, $comparison = null) - { - if (is_array($folderId)) { - $useMinMax = false; - if (isset($folderId['min'])) { - $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($folderId['max'])) { - $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the file column - * - * Example usage: - * - * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' - * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' - * - * - * @param string $file The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByFile($file = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($file)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $file)) { - $file = str_replace('*', '%', $file); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DocumentTableMap::FILE, $file, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(DocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(DocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Product object - * - * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof \Thelia\Model\Product) { - return $this - ->addUsingAlias(DocumentTableMap::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Category object - * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof \Thelia\Model\Category) { - return $this - ->addUsingAlias(DocumentTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Content object - * - * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof \Thelia\Model\Content) { - return $this - ->addUsingAlias(DocumentTableMap::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Folder object - * - * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByFolder($folder, $comparison = null) - { - if ($folder instanceof \Thelia\Model\Folder) { - return $this - ->addUsingAlias(DocumentTableMap::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Folder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\DocumentI18n object - * - * @param \Thelia\Model\DocumentI18n|ObjectCollection $documentI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function filterByDocumentI18n($documentI18n, $comparison = null) - { - if ($documentI18n instanceof \Thelia\Model\DocumentI18n) { - return $this - ->addUsingAlias(DocumentTableMap::ID, $documentI18n->getId(), $comparison); - } elseif ($documentI18n instanceof ObjectCollection) { - return $this - ->useDocumentI18nQuery() - ->filterByPrimaryKeys($documentI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocumentI18n() only accepts arguments of type \Thelia\Model\DocumentI18n or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the DocumentI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function joinDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('DocumentI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'DocumentI18n'); - } - - return $this; - } - - /** - * Use the DocumentI18n relation DocumentI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentI18nQuery A secondary query class using the current class as primary query - */ - public function useDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinDocumentI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', '\Thelia\Model\DocumentI18nQuery'); - } - - /** - * Exclude object from result - * - * @param ChildDocument $document Object to remove from the list of results - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function prune($document = null) - { - if ($document) { - $this->addUsingAlias(DocumentTableMap::ID, $document->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the document table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - DocumentTableMap::clearInstancePool(); - DocumentTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildDocument or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildDocument object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(DocumentTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - DocumentTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - DocumentTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(DocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(DocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(DocumentTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(DocumentTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(DocumentTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(DocumentTableMap::CREATED_AT); - } - - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'DocumentI18n'; - - return $this - ->joinDocumentI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildDocumentQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('DocumentI18n'); - $this->with['DocumentI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildDocumentI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', '\Thelia\Model\DocumentI18nQuery'); - } - -} // DocumentQuery diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index b246b9e34..6ee28e7ff 100644 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -21,16 +21,16 @@ use Thelia\Model\Content as ChildContent; use Thelia\Model\ContentFolder as ChildContentFolder; use Thelia\Model\ContentFolderQuery as ChildContentFolderQuery; use Thelia\Model\ContentQuery as ChildContentQuery; -use Thelia\Model\Document as ChildDocument; -use Thelia\Model\DocumentQuery as ChildDocumentQuery; use Thelia\Model\Folder as ChildFolder; +use Thelia\Model\FolderDocument as ChildFolderDocument; +use Thelia\Model\FolderDocumentQuery as ChildFolderDocumentQuery; use Thelia\Model\FolderI18n as ChildFolderI18n; use Thelia\Model\FolderI18nQuery as ChildFolderI18nQuery; +use Thelia\Model\FolderImage as ChildFolderImage; +use Thelia\Model\FolderImageQuery as ChildFolderImageQuery; use Thelia\Model\FolderQuery as ChildFolderQuery; use Thelia\Model\FolderVersion as ChildFolderVersion; use Thelia\Model\FolderVersionQuery as ChildFolderVersionQuery; -use Thelia\Model\Image as ChildImage; -use Thelia\Model\ImageQuery as ChildImageQuery; use Thelia\Model\Rewriting as ChildRewriting; use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\Map\FolderTableMap; @@ -125,18 +125,6 @@ abstract class Folder implements ActiveRecordInterface */ protected $version_created_by; - /** - * @var ObjectCollection|ChildImage[] Collection to store aggregation of ChildImage objects. - */ - protected $collImages; - protected $collImagesPartial; - - /** - * @var ObjectCollection|ChildDocument[] Collection to store aggregation of ChildDocument objects. - */ - protected $collDocuments; - protected $collDocumentsPartial; - /** * @var ObjectCollection|ChildRewriting[] Collection to store aggregation of ChildRewriting objects. */ @@ -149,6 +137,18 @@ abstract class Folder implements ActiveRecordInterface protected $collContentFolders; protected $collContentFoldersPartial; + /** + * @var ObjectCollection|ChildFolderImage[] Collection to store aggregation of ChildFolderImage objects. + */ + protected $collFolderImages; + protected $collFolderImagesPartial; + + /** + * @var ObjectCollection|ChildFolderDocument[] Collection to store aggregation of ChildFolderDocument objects. + */ + protected $collFolderDocuments; + protected $collFolderDocumentsPartial; + /** * @var ObjectCollection|ChildFolderI18n[] Collection to store aggregation of ChildFolderI18n objects. */ @@ -202,18 +202,6 @@ abstract class Folder implements ActiveRecordInterface */ protected $contentsScheduledForDeletion = null; - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $imagesScheduledForDeletion = null; - - /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $documentsScheduledForDeletion = null; - /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -226,6 +214,18 @@ abstract class Folder implements ActiveRecordInterface */ protected $contentFoldersScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $folderImagesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $folderDocumentsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -965,14 +965,14 @@ abstract class Folder implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collImages = null; - - $this->collDocuments = null; - $this->collRewritings = null; $this->collContentFolders = null; + $this->collFolderImages = null; + + $this->collFolderDocuments = null; + $this->collFolderI18ns = null; $this->collFolderVersions = null; @@ -1150,40 +1150,6 @@ abstract class Folder implements ActiveRecordInterface } } - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - \Thelia\Model\ImageQuery::create() - ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - \Thelia\Model\DocumentQuery::create() - ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - if ($this->rewritingsScheduledForDeletion !== null) { if (!$this->rewritingsScheduledForDeletion->isEmpty()) { \Thelia\Model\RewritingQuery::create() @@ -1218,6 +1184,40 @@ abstract class Folder implements ActiveRecordInterface } } + if ($this->folderImagesScheduledForDeletion !== null) { + if (!$this->folderImagesScheduledForDeletion->isEmpty()) { + \Thelia\Model\FolderImageQuery::create() + ->filterByPrimaryKeys($this->folderImagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->folderImagesScheduledForDeletion = null; + } + } + + if ($this->collFolderImages !== null) { + foreach ($this->collFolderImages as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->folderDocumentsScheduledForDeletion !== null) { + if (!$this->folderDocumentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\FolderDocumentQuery::create() + ->filterByPrimaryKeys($this->folderDocumentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->folderDocumentsScheduledForDeletion = null; + } + } + + if ($this->collFolderDocuments !== null) { + foreach ($this->collFolderDocuments as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->folderI18nsScheduledForDeletion !== null) { if (!$this->folderI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\FolderI18nQuery::create() @@ -1478,18 +1478,18 @@ abstract class Folder implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collContentFolders) { $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collFolderImages) { + $result['FolderImages'] = $this->collFolderImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collFolderDocuments) { + $result['FolderDocuments'] = $this->collFolderDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collFolderI18ns) { $result['FolderI18ns'] = $this->collFolderI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1687,18 +1687,6 @@ abstract class Folder implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - foreach ($this->getRewritings() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addRewriting($relObj->copy($deepCopy)); @@ -1711,6 +1699,18 @@ abstract class Folder implements ActiveRecordInterface } } + foreach ($this->getFolderImages() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFolderImage($relObj->copy($deepCopy)); + } + } + + foreach ($this->getFolderDocuments() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFolderDocument($relObj->copy($deepCopy)); + } + } + foreach ($this->getFolderI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addFolderI18n($relObj->copy($deepCopy)); @@ -1764,18 +1764,18 @@ abstract class Folder implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('Image' == $relationName) { - return $this->initImages(); - } - if ('Document' == $relationName) { - return $this->initDocuments(); - } if ('Rewriting' == $relationName) { return $this->initRewritings(); } if ('ContentFolder' == $relationName) { return $this->initContentFolders(); } + if ('FolderImage' == $relationName) { + return $this->initFolderImages(); + } + if ('FolderDocument' == $relationName) { + return $this->initFolderDocuments(); + } if ('FolderI18n' == $relationName) { return $this->initFolderI18ns(); } @@ -1784,592 +1784,6 @@ abstract class Folder implements ActiveRecordInterface } } - /** - * Clears out the collImages collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collImages collection loaded partially. - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new ObjectCollection(); - $this->collImages->setModel('\Thelia\Model\Image'); - } - - /** - * Gets an array of ChildImage objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildFolder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildImage[] List of ChildImage objects - * @throws PropelException - */ - public function getImages($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ChildImageQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach ($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - $collImages->getInternalIterator()->rewind(); - - return $collImages; - } - - if ($partial && $this->collImages) { - foreach ($this->collImages as $obj) { - if ($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $images A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildFolder The current object (for fluent API support) - */ - public function setImages(Collection $images, ConnectionInterface $con = null) - { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - - - $this->imagesScheduledForDeletion = $imagesToDelete; - - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setFolder(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - - return $this; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getImages()); - } - - $query = ChildImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collImages); - } - - /** - * Method called to associate a ChildImage object to this object - * through the ChildImage foreign key attribute. - * - * @param ChildImage $l ChildImage - * @return \Thelia\Model\Folder The current object (for fluent API support) - */ - public function addImage(ChildImage $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setFolder($this); - } - - /** - * @param Image $image The image object to remove. - * @return ChildFolder The current object (for fluent API support) - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setFolder(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collDocuments collection loaded partially. - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new ObjectCollection(); - $this->collDocuments->setModel('\Thelia\Model\Document'); - } - - /** - * Gets an array of ChildDocument objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildFolder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDocument[] List of ChildDocument objects - * @throws PropelException - */ - public function getDocuments($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = ChildDocumentQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach ($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - $collDocuments->getInternalIterator()->rewind(); - - return $collDocuments; - } - - if ($partial && $this->collDocuments) { - foreach ($this->collDocuments as $obj) { - if ($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $documents A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildFolder The current object (for fluent API support) - */ - public function setDocuments(Collection $documents, ConnectionInterface $con = null) - { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - - - $this->documentsScheduledForDeletion = $documentsToDelete; - - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setFolder(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - - return $this; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getDocuments()); - } - - $query = ChildDocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collDocuments); - } - - /** - * Method called to associate a ChildDocument object to this object - * through the ChildDocument foreign key attribute. - * - * @param ChildDocument $l ChildDocument - * @return \Thelia\Model\Folder The current object (for fluent API support) - */ - public function addDocument(ChildDocument $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setFolder($this); - } - - /** - * @param Document $document The document object to remove. - * @return ChildFolder The current object (for fluent API support) - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setFolder(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getDocuments($query, $con); - } - /** * Clears out the collRewritings collection * @@ -2909,6 +2323,442 @@ abstract class Folder implements ActiveRecordInterface return $this->getContentFolders($query, $con); } + /** + * Clears out the collFolderImages collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addFolderImages() + */ + public function clearFolderImages() + { + $this->collFolderImages = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collFolderImages collection loaded partially. + */ + public function resetPartialFolderImages($v = true) + { + $this->collFolderImagesPartial = $v; + } + + /** + * Initializes the collFolderImages collection. + * + * By default this just sets the collFolderImages collection to an empty array (like clearcollFolderImages()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFolderImages($overrideExisting = true) + { + if (null !== $this->collFolderImages && !$overrideExisting) { + return; + } + $this->collFolderImages = new ObjectCollection(); + $this->collFolderImages->setModel('\Thelia\Model\FolderImage'); + } + + /** + * Gets an array of ChildFolderImage objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildFolder is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFolderImage[] List of ChildFolderImage objects + * @throws PropelException + */ + public function getFolderImages($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collFolderImagesPartial && !$this->isNew(); + if (null === $this->collFolderImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderImages) { + // return empty collection + $this->initFolderImages(); + } else { + $collFolderImages = ChildFolderImageQuery::create(null, $criteria) + ->filterByFolder($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collFolderImagesPartial && count($collFolderImages)) { + $this->initFolderImages(false); + + foreach ($collFolderImages as $obj) { + if (false == $this->collFolderImages->contains($obj)) { + $this->collFolderImages->append($obj); + } + } + + $this->collFolderImagesPartial = true; + } + + $collFolderImages->getInternalIterator()->rewind(); + + return $collFolderImages; + } + + if ($partial && $this->collFolderImages) { + foreach ($this->collFolderImages as $obj) { + if ($obj->isNew()) { + $collFolderImages[] = $obj; + } + } + } + + $this->collFolderImages = $collFolderImages; + $this->collFolderImagesPartial = false; + } + } + + return $this->collFolderImages; + } + + /** + * Sets a collection of FolderImage objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $folderImages A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) + */ + public function setFolderImages(Collection $folderImages, ConnectionInterface $con = null) + { + $folderImagesToDelete = $this->getFolderImages(new Criteria(), $con)->diff($folderImages); + + + $this->folderImagesScheduledForDeletion = $folderImagesToDelete; + + foreach ($folderImagesToDelete as $folderImageRemoved) { + $folderImageRemoved->setFolder(null); + } + + $this->collFolderImages = null; + foreach ($folderImages as $folderImage) { + $this->addFolderImage($folderImage); + } + + $this->collFolderImages = $folderImages; + $this->collFolderImagesPartial = false; + + return $this; + } + + /** + * Returns the number of related FolderImage objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related FolderImage objects. + * @throws PropelException + */ + public function countFolderImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collFolderImagesPartial && !$this->isNew(); + if (null === $this->collFolderImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderImages) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getFolderImages()); + } + + $query = ChildFolderImageQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); + } + + return count($this->collFolderImages); + } + + /** + * Method called to associate a ChildFolderImage object to this object + * through the ChildFolderImage foreign key attribute. + * + * @param ChildFolderImage $l ChildFolderImage + * @return \Thelia\Model\Folder The current object (for fluent API support) + */ + public function addFolderImage(ChildFolderImage $l) + { + if ($this->collFolderImages === null) { + $this->initFolderImages(); + $this->collFolderImagesPartial = true; + } + + if (!in_array($l, $this->collFolderImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddFolderImage($l); + } + + return $this; + } + + /** + * @param FolderImage $folderImage The folderImage object to add. + */ + protected function doAddFolderImage($folderImage) + { + $this->collFolderImages[]= $folderImage; + $folderImage->setFolder($this); + } + + /** + * @param FolderImage $folderImage The folderImage object to remove. + * @return ChildFolder The current object (for fluent API support) + */ + public function removeFolderImage($folderImage) + { + if ($this->getFolderImages()->contains($folderImage)) { + $this->collFolderImages->remove($this->collFolderImages->search($folderImage)); + if (null === $this->folderImagesScheduledForDeletion) { + $this->folderImagesScheduledForDeletion = clone $this->collFolderImages; + $this->folderImagesScheduledForDeletion->clear(); + } + $this->folderImagesScheduledForDeletion[]= clone $folderImage; + $folderImage->setFolder(null); + } + + return $this; + } + + /** + * Clears out the collFolderDocuments collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addFolderDocuments() + */ + public function clearFolderDocuments() + { + $this->collFolderDocuments = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collFolderDocuments collection loaded partially. + */ + public function resetPartialFolderDocuments($v = true) + { + $this->collFolderDocumentsPartial = $v; + } + + /** + * Initializes the collFolderDocuments collection. + * + * By default this just sets the collFolderDocuments collection to an empty array (like clearcollFolderDocuments()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFolderDocuments($overrideExisting = true) + { + if (null !== $this->collFolderDocuments && !$overrideExisting) { + return; + } + $this->collFolderDocuments = new ObjectCollection(); + $this->collFolderDocuments->setModel('\Thelia\Model\FolderDocument'); + } + + /** + * Gets an array of ChildFolderDocument objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildFolder is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFolderDocument[] List of ChildFolderDocument objects + * @throws PropelException + */ + public function getFolderDocuments($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collFolderDocumentsPartial && !$this->isNew(); + if (null === $this->collFolderDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderDocuments) { + // return empty collection + $this->initFolderDocuments(); + } else { + $collFolderDocuments = ChildFolderDocumentQuery::create(null, $criteria) + ->filterByFolder($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collFolderDocumentsPartial && count($collFolderDocuments)) { + $this->initFolderDocuments(false); + + foreach ($collFolderDocuments as $obj) { + if (false == $this->collFolderDocuments->contains($obj)) { + $this->collFolderDocuments->append($obj); + } + } + + $this->collFolderDocumentsPartial = true; + } + + $collFolderDocuments->getInternalIterator()->rewind(); + + return $collFolderDocuments; + } + + if ($partial && $this->collFolderDocuments) { + foreach ($this->collFolderDocuments as $obj) { + if ($obj->isNew()) { + $collFolderDocuments[] = $obj; + } + } + } + + $this->collFolderDocuments = $collFolderDocuments; + $this->collFolderDocumentsPartial = false; + } + } + + return $this->collFolderDocuments; + } + + /** + * Sets a collection of FolderDocument objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $folderDocuments A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) + */ + public function setFolderDocuments(Collection $folderDocuments, ConnectionInterface $con = null) + { + $folderDocumentsToDelete = $this->getFolderDocuments(new Criteria(), $con)->diff($folderDocuments); + + + $this->folderDocumentsScheduledForDeletion = $folderDocumentsToDelete; + + foreach ($folderDocumentsToDelete as $folderDocumentRemoved) { + $folderDocumentRemoved->setFolder(null); + } + + $this->collFolderDocuments = null; + foreach ($folderDocuments as $folderDocument) { + $this->addFolderDocument($folderDocument); + } + + $this->collFolderDocuments = $folderDocuments; + $this->collFolderDocumentsPartial = false; + + return $this; + } + + /** + * Returns the number of related FolderDocument objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related FolderDocument objects. + * @throws PropelException + */ + public function countFolderDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collFolderDocumentsPartial && !$this->isNew(); + if (null === $this->collFolderDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderDocuments) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getFolderDocuments()); + } + + $query = ChildFolderDocumentQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolder($this) + ->count($con); + } + + return count($this->collFolderDocuments); + } + + /** + * Method called to associate a ChildFolderDocument object to this object + * through the ChildFolderDocument foreign key attribute. + * + * @param ChildFolderDocument $l ChildFolderDocument + * @return \Thelia\Model\Folder The current object (for fluent API support) + */ + public function addFolderDocument(ChildFolderDocument $l) + { + if ($this->collFolderDocuments === null) { + $this->initFolderDocuments(); + $this->collFolderDocumentsPartial = true; + } + + if (!in_array($l, $this->collFolderDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddFolderDocument($l); + } + + return $this; + } + + /** + * @param FolderDocument $folderDocument The folderDocument object to add. + */ + protected function doAddFolderDocument($folderDocument) + { + $this->collFolderDocuments[]= $folderDocument; + $folderDocument->setFolder($this); + } + + /** + * @param FolderDocument $folderDocument The folderDocument object to remove. + * @return ChildFolder The current object (for fluent API support) + */ + public function removeFolderDocument($folderDocument) + { + if ($this->getFolderDocuments()->contains($folderDocument)) { + $this->collFolderDocuments->remove($this->collFolderDocuments->search($folderDocument)); + if (null === $this->folderDocumentsScheduledForDeletion) { + $this->folderDocumentsScheduledForDeletion = clone $this->collFolderDocuments; + $this->folderDocumentsScheduledForDeletion->clear(); + } + $this->folderDocumentsScheduledForDeletion[]= clone $folderDocument; + $folderDocument->setFolder(null); + } + + return $this; + } + /** * Clears out the collFolderI18ns collection * @@ -3572,16 +3422,6 @@ abstract class Folder implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } if ($this->collRewritings) { foreach ($this->collRewritings as $o) { $o->clearAllReferences($deep); @@ -3592,6 +3432,16 @@ abstract class Folder implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collFolderImages) { + foreach ($this->collFolderImages as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collFolderDocuments) { + foreach ($this->collFolderDocuments as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collFolderI18ns) { foreach ($this->collFolderI18ns as $o) { $o->clearAllReferences($deep); @@ -3613,14 +3463,6 @@ abstract class Folder implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; - if ($this->collImages instanceof Collection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collDocuments instanceof Collection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } @@ -3629,6 +3471,14 @@ abstract class Folder implements ActiveRecordInterface $this->collContentFolders->clearIterator(); } $this->collContentFolders = null; + if ($this->collFolderImages instanceof Collection) { + $this->collFolderImages->clearIterator(); + } + $this->collFolderImages = null; + if ($this->collFolderDocuments instanceof Collection) { + $this->collFolderDocuments->clearIterator(); + } + $this->collFolderDocuments = null; if ($this->collFolderI18ns instanceof Collection) { $this->collFolderI18ns->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/FolderDocument.php b/core/lib/Thelia/Model/Base/FolderDocument.php new file mode 100644 index 000000000..31e7c57a6 --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderDocument.php @@ -0,0 +1,1990 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FolderDocument instance. If + * obj is an instance of FolderDocument, delegates to + * equals(FolderDocument). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FolderDocument The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FolderDocument The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [folder_id] column value. + * + * @return int + */ + public function getFolderId() + { + + return $this->folder_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FolderDocumentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [folder_id] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + */ + public function setFolderId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->folder_id !== $v) { + $this->folder_id = $v; + $this->modifiedColumns[] = FolderDocumentTableMap::FOLDER_ID; + } + + if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { + $this->aFolder = null; + } + + + return $this; + } // setFolderId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[] = FolderDocumentTableMap::FILE; + } + + + return $this; + } // setFile() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = FolderDocumentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FolderDocumentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FolderDocumentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderDocumentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderDocumentTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->folder_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderDocumentTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderDocumentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderDocumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderDocumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = FolderDocumentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FolderDocument object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { + $this->aFolder = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(FolderDocumentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFolderDocumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aFolder = null; + $this->collFolderDocumentI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see FolderDocument::setDeleted() + * @see FolderDocument::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFolderDocumentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FolderDocumentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FolderDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FolderDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + FolderDocumentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aFolder !== null) { + if ($this->aFolder->isModified() || $this->aFolder->isNew()) { + $affectedRows += $this->aFolder->save($con); + } + $this->setFolder($this->aFolder); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->folderDocumentI18nsScheduledForDeletion !== null) { + if (!$this->folderDocumentI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\FolderDocumentI18nQuery::create() + ->filterByPrimaryKeys($this->folderDocumentI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->folderDocumentI18nsScheduledForDeletion = null; + } + } + + if ($this->collFolderDocumentI18ns !== null) { + foreach ($this->collFolderDocumentI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = FolderDocumentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderDocumentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FolderDocumentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FolderDocumentTableMap::FOLDER_ID)) { + $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; + } + if ($this->isColumnModified(FolderDocumentTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(FolderDocumentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(FolderDocumentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(FolderDocumentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO folder_document (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'FOLDER_ID': + $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getFolderId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FolderDocument'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FolderDocument'][$this->getPrimaryKey()] = true; + $keys = FolderDocumentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getFolderId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aFolder) { + $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collFolderDocumentI18ns) { + $result['FolderDocumentI18ns'] = $this->collFolderDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setFolderId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = FolderDocumentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(FolderDocumentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FolderDocumentTableMap::ID)) $criteria->add(FolderDocumentTableMap::ID, $this->id); + if ($this->isColumnModified(FolderDocumentTableMap::FOLDER_ID)) $criteria->add(FolderDocumentTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(FolderDocumentTableMap::FILE)) $criteria->add(FolderDocumentTableMap::FILE, $this->file); + if ($this->isColumnModified(FolderDocumentTableMap::POSITION)) $criteria->add(FolderDocumentTableMap::POSITION, $this->position); + if ($this->isColumnModified(FolderDocumentTableMap::CREATED_AT)) $criteria->add(FolderDocumentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FolderDocumentTableMap::UPDATED_AT)) $criteria->add(FolderDocumentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(FolderDocumentTableMap::DATABASE_NAME); + $criteria->add(FolderDocumentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\FolderDocument (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setFolderId($this->getFolderId()); + $copyObj->setFile($this->getFile()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getFolderDocumentI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFolderDocumentI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\FolderDocument Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildFolder object. + * + * @param ChildFolder $v + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + * @throws PropelException + */ + public function setFolder(ChildFolder $v = null) + { + if ($v === null) { + $this->setFolderId(NULL); + } else { + $this->setFolderId($v->getId()); + } + + $this->aFolder = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildFolder object, it will not be re-added. + if ($v !== null) { + $v->addFolderDocument($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFolder object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. + * @throws PropelException + */ + public function getFolder(ConnectionInterface $con = null) + { + if ($this->aFolder === null && ($this->folder_id !== null)) { + $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aFolder->addFolderDocuments($this); + */ + } + + return $this->aFolder; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('FolderDocumentI18n' == $relationName) { + return $this->initFolderDocumentI18ns(); + } + } + + /** + * Clears out the collFolderDocumentI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addFolderDocumentI18ns() + */ + public function clearFolderDocumentI18ns() + { + $this->collFolderDocumentI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collFolderDocumentI18ns collection loaded partially. + */ + public function resetPartialFolderDocumentI18ns($v = true) + { + $this->collFolderDocumentI18nsPartial = $v; + } + + /** + * Initializes the collFolderDocumentI18ns collection. + * + * By default this just sets the collFolderDocumentI18ns collection to an empty array (like clearcollFolderDocumentI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFolderDocumentI18ns($overrideExisting = true) + { + if (null !== $this->collFolderDocumentI18ns && !$overrideExisting) { + return; + } + $this->collFolderDocumentI18ns = new ObjectCollection(); + $this->collFolderDocumentI18ns->setModel('\Thelia\Model\FolderDocumentI18n'); + } + + /** + * Gets an array of ChildFolderDocumentI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildFolderDocument is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFolderDocumentI18n[] List of ChildFolderDocumentI18n objects + * @throws PropelException + */ + public function getFolderDocumentI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collFolderDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collFolderDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderDocumentI18ns) { + // return empty collection + $this->initFolderDocumentI18ns(); + } else { + $collFolderDocumentI18ns = ChildFolderDocumentI18nQuery::create(null, $criteria) + ->filterByFolderDocument($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collFolderDocumentI18nsPartial && count($collFolderDocumentI18ns)) { + $this->initFolderDocumentI18ns(false); + + foreach ($collFolderDocumentI18ns as $obj) { + if (false == $this->collFolderDocumentI18ns->contains($obj)) { + $this->collFolderDocumentI18ns->append($obj); + } + } + + $this->collFolderDocumentI18nsPartial = true; + } + + $collFolderDocumentI18ns->getInternalIterator()->rewind(); + + return $collFolderDocumentI18ns; + } + + if ($partial && $this->collFolderDocumentI18ns) { + foreach ($this->collFolderDocumentI18ns as $obj) { + if ($obj->isNew()) { + $collFolderDocumentI18ns[] = $obj; + } + } + } + + $this->collFolderDocumentI18ns = $collFolderDocumentI18ns; + $this->collFolderDocumentI18nsPartial = false; + } + } + + return $this->collFolderDocumentI18ns; + } + + /** + * Sets a collection of FolderDocumentI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $folderDocumentI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolderDocument The current object (for fluent API support) + */ + public function setFolderDocumentI18ns(Collection $folderDocumentI18ns, ConnectionInterface $con = null) + { + $folderDocumentI18nsToDelete = $this->getFolderDocumentI18ns(new Criteria(), $con)->diff($folderDocumentI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->folderDocumentI18nsScheduledForDeletion = clone $folderDocumentI18nsToDelete; + + foreach ($folderDocumentI18nsToDelete as $folderDocumentI18nRemoved) { + $folderDocumentI18nRemoved->setFolderDocument(null); + } + + $this->collFolderDocumentI18ns = null; + foreach ($folderDocumentI18ns as $folderDocumentI18n) { + $this->addFolderDocumentI18n($folderDocumentI18n); + } + + $this->collFolderDocumentI18ns = $folderDocumentI18ns; + $this->collFolderDocumentI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related FolderDocumentI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related FolderDocumentI18n objects. + * @throws PropelException + */ + public function countFolderDocumentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collFolderDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collFolderDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderDocumentI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getFolderDocumentI18ns()); + } + + $query = ChildFolderDocumentI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolderDocument($this) + ->count($con); + } + + return count($this->collFolderDocumentI18ns); + } + + /** + * Method called to associate a ChildFolderDocumentI18n object to this object + * through the ChildFolderDocumentI18n foreign key attribute. + * + * @param ChildFolderDocumentI18n $l ChildFolderDocumentI18n + * @return \Thelia\Model\FolderDocument The current object (for fluent API support) + */ + public function addFolderDocumentI18n(ChildFolderDocumentI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collFolderDocumentI18ns === null) { + $this->initFolderDocumentI18ns(); + $this->collFolderDocumentI18nsPartial = true; + } + + if (!in_array($l, $this->collFolderDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddFolderDocumentI18n($l); + } + + return $this; + } + + /** + * @param FolderDocumentI18n $folderDocumentI18n The folderDocumentI18n object to add. + */ + protected function doAddFolderDocumentI18n($folderDocumentI18n) + { + $this->collFolderDocumentI18ns[]= $folderDocumentI18n; + $folderDocumentI18n->setFolderDocument($this); + } + + /** + * @param FolderDocumentI18n $folderDocumentI18n The folderDocumentI18n object to remove. + * @return ChildFolderDocument The current object (for fluent API support) + */ + public function removeFolderDocumentI18n($folderDocumentI18n) + { + if ($this->getFolderDocumentI18ns()->contains($folderDocumentI18n)) { + $this->collFolderDocumentI18ns->remove($this->collFolderDocumentI18ns->search($folderDocumentI18n)); + if (null === $this->folderDocumentI18nsScheduledForDeletion) { + $this->folderDocumentI18nsScheduledForDeletion = clone $this->collFolderDocumentI18ns; + $this->folderDocumentI18nsScheduledForDeletion->clear(); + } + $this->folderDocumentI18nsScheduledForDeletion[]= clone $folderDocumentI18n; + $folderDocumentI18n->setFolderDocument(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->folder_id = null; + $this->file = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collFolderDocumentI18ns) { + foreach ($this->collFolderDocumentI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collFolderDocumentI18ns instanceof Collection) { + $this->collFolderDocumentI18ns->clearIterator(); + } + $this->collFolderDocumentI18ns = null; + $this->aFolder = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FolderDocumentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildFolderDocument The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FolderDocumentTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildFolderDocument The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderDocumentI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collFolderDocumentI18ns) { + foreach ($this->collFolderDocumentI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildFolderDocumentI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildFolderDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addFolderDocumentI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderDocument The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildFolderDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collFolderDocumentI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collFolderDocumentI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderDocumentI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php new file mode 100644 index 000000000..d39a49af7 --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\FolderDocumentI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FolderDocumentI18n instance. If + * obj is an instance of FolderDocumentI18n, delegates to + * equals(FolderDocumentI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FolderDocumentI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FolderDocumentI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FolderDocumentI18nTableMap::ID; + } + + if ($this->aFolderDocument !== null && $this->aFolderDocument->getId() !== $v) { + $this->aFolderDocument = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = FolderDocumentI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = FolderDocumentI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = FolderDocumentI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = FolderDocumentI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = FolderDocumentI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderDocumentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderDocumentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderDocumentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderDocumentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderDocumentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderDocumentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = FolderDocumentI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FolderDocumentI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aFolderDocument !== null && $this->id !== $this->aFolderDocument->getId()) { + $this->aFolderDocument = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFolderDocumentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aFolderDocument = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see FolderDocumentI18n::setDeleted() + * @see FolderDocumentI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFolderDocumentI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + FolderDocumentI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aFolderDocument !== null) { + if ($this->aFolderDocument->isModified() || $this->aFolderDocument->isNew()) { + $affectedRows += $this->aFolderDocument->save($con); + } + $this->setFolderDocument($this->aFolderDocument); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FolderDocumentI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FolderDocumentI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(FolderDocumentI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(FolderDocumentI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(FolderDocumentI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(FolderDocumentI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO folder_document_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FolderDocumentI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FolderDocumentI18n'][serialize($this->getPrimaryKey())] = true; + $keys = FolderDocumentI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aFolderDocument) { + $result['FolderDocument'] = $this->aFolderDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = FolderDocumentI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(FolderDocumentI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FolderDocumentI18nTableMap::ID)) $criteria->add(FolderDocumentI18nTableMap::ID, $this->id); + if ($this->isColumnModified(FolderDocumentI18nTableMap::LOCALE)) $criteria->add(FolderDocumentI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(FolderDocumentI18nTableMap::TITLE)) $criteria->add(FolderDocumentI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(FolderDocumentI18nTableMap::DESCRIPTION)) $criteria->add(FolderDocumentI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(FolderDocumentI18nTableMap::CHAPO)) $criteria->add(FolderDocumentI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(FolderDocumentI18nTableMap::POSTSCRIPTUM)) $criteria->add(FolderDocumentI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(FolderDocumentI18nTableMap::DATABASE_NAME); + $criteria->add(FolderDocumentI18nTableMap::ID, $this->id); + $criteria->add(FolderDocumentI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\FolderDocumentI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\FolderDocumentI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildFolderDocument object. + * + * @param ChildFolderDocument $v + * @return \Thelia\Model\FolderDocumentI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setFolderDocument(ChildFolderDocument $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aFolderDocument = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildFolderDocument object, it will not be re-added. + if ($v !== null) { + $v->addFolderDocumentI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFolderDocument object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolderDocument The associated ChildFolderDocument object. + * @throws PropelException + */ + public function getFolderDocument(ConnectionInterface $con = null) + { + if ($this->aFolderDocument === null && ($this->id !== null)) { + $this->aFolderDocument = ChildFolderDocumentQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aFolderDocument->addFolderDocumentI18ns($this); + */ + } + + return $this->aFolderDocument; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aFolderDocument = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FolderDocumentI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/FolderDocumentI18nQuery.php b/core/lib/Thelia/Model/Base/FolderDocumentI18nQuery.php new file mode 100644 index 000000000..073cef92e --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderDocumentI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderDocumentI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = FolderDocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildFolderDocumentI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM folder_document_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFolderDocumentI18n(); + $obj->hydrate($row); + FolderDocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildFolderDocumentI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(FolderDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(FolderDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(FolderDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(FolderDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByFolderDocument() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FolderDocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FolderDocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderDocumentI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderDocumentI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderDocumentI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderDocumentI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderDocumentI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderDocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\FolderDocument object + * + * @param \Thelia\Model\FolderDocument|ObjectCollection $folderDocument The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function filterByFolderDocument($folderDocument, $comparison = null) + { + if ($folderDocument instanceof \Thelia\Model\FolderDocument) { + return $this + ->addUsingAlias(FolderDocumentI18nTableMap::ID, $folderDocument->getId(), $comparison); + } elseif ($folderDocument instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(FolderDocumentI18nTableMap::ID, $folderDocument->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByFolderDocument() only accepts arguments of type \Thelia\Model\FolderDocument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the FolderDocument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function joinFolderDocument($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FolderDocument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FolderDocument'); + } + + return $this; + } + + /** + * Use the FolderDocument relation FolderDocument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FolderDocumentQuery A secondary query class using the current class as primary query + */ + public function useFolderDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinFolderDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderDocument', '\Thelia\Model\FolderDocumentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildFolderDocumentI18n $folderDocumentI18n Object to remove from the list of results + * + * @return ChildFolderDocumentI18nQuery The current query, for fluid interface + */ + public function prune($folderDocumentI18n = null) + { + if ($folderDocumentI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(FolderDocumentI18nTableMap::ID), $folderDocumentI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(FolderDocumentI18nTableMap::LOCALE), $folderDocumentI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the folder_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FolderDocumentI18nTableMap::clearInstancePool(); + FolderDocumentI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFolderDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFolderDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FolderDocumentI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + FolderDocumentI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FolderDocumentI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // FolderDocumentI18nQuery diff --git a/core/lib/Thelia/Model/Base/FolderDocumentQuery.php b/core/lib/Thelia/Model/Base/FolderDocumentQuery.php new file mode 100644 index 000000000..b1c41a29e --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderDocumentQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderDocument|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = FolderDocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(FolderDocumentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildFolderDocument A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, FOLDER_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM folder_document WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFolderDocument(); + $obj->hydrate($row); + FolderDocumentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildFolderDocument|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(FolderDocumentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(FolderDocumentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FolderDocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FolderDocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderDocumentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the folder_id column + * + * Example usage: + * + * $query->filterByFolderId(1234); // WHERE folder_id = 1234 + * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 + * + * + * @see filterByFolder() + * + * @param mixed $folderId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByFolderId($folderId = null, $comparison = null) + { + if (is_array($folderId)) { + $useMinMax = false; + if (isset($folderId['min'])) { + $this->addUsingAlias(FolderDocumentTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($folderId['max'])) { + $this->addUsingAlias(FolderDocumentTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderDocumentTableMap::FOLDER_ID, $folderId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderDocumentTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(FolderDocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(FolderDocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderDocumentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(FolderDocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(FolderDocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderDocumentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(FolderDocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(FolderDocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderDocumentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Folder object + * + * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByFolder($folder, $comparison = null) + { + if ($folder instanceof \Thelia\Model\Folder) { + return $this + ->addUsingAlias(FolderDocumentTableMap::FOLDER_ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(FolderDocumentTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Folder relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Folder'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Folder'); + } + + return $this; + } + + /** + * Use the Folder relation Folder object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query + */ + public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFolder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\FolderDocumentI18n object + * + * @param \Thelia\Model\FolderDocumentI18n|ObjectCollection $folderDocumentI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function filterByFolderDocumentI18n($folderDocumentI18n, $comparison = null) + { + if ($folderDocumentI18n instanceof \Thelia\Model\FolderDocumentI18n) { + return $this + ->addUsingAlias(FolderDocumentTableMap::ID, $folderDocumentI18n->getId(), $comparison); + } elseif ($folderDocumentI18n instanceof ObjectCollection) { + return $this + ->useFolderDocumentI18nQuery() + ->filterByPrimaryKeys($folderDocumentI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFolderDocumentI18n() only accepts arguments of type \Thelia\Model\FolderDocumentI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the FolderDocumentI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function joinFolderDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FolderDocumentI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FolderDocumentI18n'); + } + + return $this; + } + + /** + * Use the FolderDocumentI18n relation FolderDocumentI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FolderDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useFolderDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinFolderDocumentI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderDocumentI18n', '\Thelia\Model\FolderDocumentI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildFolderDocument $folderDocument Object to remove from the list of results + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function prune($folderDocument = null) + { + if ($folderDocument) { + $this->addUsingAlias(FolderDocumentTableMap::ID, $folderDocument->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the folder_document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FolderDocumentTableMap::clearInstancePool(); + FolderDocumentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFolderDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFolderDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FolderDocumentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + FolderDocumentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FolderDocumentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FolderDocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FolderDocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FolderDocumentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FolderDocumentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FolderDocumentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FolderDocumentTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'FolderDocumentI18n'; + + return $this + ->joinFolderDocumentI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildFolderDocumentQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('FolderDocumentI18n'); + $this->with['FolderDocumentI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildFolderDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderDocumentI18n', '\Thelia\Model\FolderDocumentI18nQuery'); + } + +} // FolderDocumentQuery diff --git a/core/lib/Thelia/Model/Base/FolderImage.php b/core/lib/Thelia/Model/Base/FolderImage.php new file mode 100644 index 000000000..46c39060d --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderImage.php @@ -0,0 +1,1990 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FolderImage instance. If + * obj is an instance of FolderImage, delegates to + * equals(FolderImage). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FolderImage The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FolderImage The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [folder_id] column value. + * + * @return int + */ + public function getFolderId() + { + + return $this->folder_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FolderImageTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [folder_id] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + */ + public function setFolderId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->folder_id !== $v) { + $this->folder_id = $v; + $this->modifiedColumns[] = FolderImageTableMap::FOLDER_ID; + } + + if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { + $this->aFolder = null; + } + + + return $this; + } // setFolderId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[] = FolderImageTableMap::FILE; + } + + + return $this; + } // setFile() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = FolderImageTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FolderImageTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FolderImageTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderImageTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->folder_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = FolderImageTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FolderImage object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { + $this->aFolder = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(FolderImageTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFolderImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aFolder = null; + $this->collFolderImageI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see FolderImage::setDeleted() + * @see FolderImage::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFolderImageQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FolderImageTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FolderImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FolderImageTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + FolderImageTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aFolder !== null) { + if ($this->aFolder->isModified() || $this->aFolder->isNew()) { + $affectedRows += $this->aFolder->save($con); + } + $this->setFolder($this->aFolder); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->folderImageI18nsScheduledForDeletion !== null) { + if (!$this->folderImageI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\FolderImageI18nQuery::create() + ->filterByPrimaryKeys($this->folderImageI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->folderImageI18nsScheduledForDeletion = null; + } + } + + if ($this->collFolderImageI18ns !== null) { + foreach ($this->collFolderImageI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = FolderImageTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderImageTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FolderImageTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FolderImageTableMap::FOLDER_ID)) { + $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; + } + if ($this->isColumnModified(FolderImageTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(FolderImageTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(FolderImageTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(FolderImageTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO folder_image (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'FOLDER_ID': + $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getFolderId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FolderImage'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FolderImage'][$this->getPrimaryKey()] = true; + $keys = FolderImageTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getFolderId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aFolder) { + $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collFolderImageI18ns) { + $result['FolderImageI18ns'] = $this->collFolderImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setFolderId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = FolderImageTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(FolderImageTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FolderImageTableMap::ID)) $criteria->add(FolderImageTableMap::ID, $this->id); + if ($this->isColumnModified(FolderImageTableMap::FOLDER_ID)) $criteria->add(FolderImageTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(FolderImageTableMap::FILE)) $criteria->add(FolderImageTableMap::FILE, $this->file); + if ($this->isColumnModified(FolderImageTableMap::POSITION)) $criteria->add(FolderImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(FolderImageTableMap::CREATED_AT)) $criteria->add(FolderImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FolderImageTableMap::UPDATED_AT)) $criteria->add(FolderImageTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(FolderImageTableMap::DATABASE_NAME); + $criteria->add(FolderImageTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\FolderImage (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setFolderId($this->getFolderId()); + $copyObj->setFile($this->getFile()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getFolderImageI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addFolderImageI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\FolderImage Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildFolder object. + * + * @param ChildFolder $v + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + * @throws PropelException + */ + public function setFolder(ChildFolder $v = null) + { + if ($v === null) { + $this->setFolderId(NULL); + } else { + $this->setFolderId($v->getId()); + } + + $this->aFolder = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildFolder object, it will not be re-added. + if ($v !== null) { + $v->addFolderImage($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFolder object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. + * @throws PropelException + */ + public function getFolder(ConnectionInterface $con = null) + { + if ($this->aFolder === null && ($this->folder_id !== null)) { + $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aFolder->addFolderImages($this); + */ + } + + return $this->aFolder; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('FolderImageI18n' == $relationName) { + return $this->initFolderImageI18ns(); + } + } + + /** + * Clears out the collFolderImageI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addFolderImageI18ns() + */ + public function clearFolderImageI18ns() + { + $this->collFolderImageI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collFolderImageI18ns collection loaded partially. + */ + public function resetPartialFolderImageI18ns($v = true) + { + $this->collFolderImageI18nsPartial = $v; + } + + /** + * Initializes the collFolderImageI18ns collection. + * + * By default this just sets the collFolderImageI18ns collection to an empty array (like clearcollFolderImageI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initFolderImageI18ns($overrideExisting = true) + { + if (null !== $this->collFolderImageI18ns && !$overrideExisting) { + return; + } + $this->collFolderImageI18ns = new ObjectCollection(); + $this->collFolderImageI18ns->setModel('\Thelia\Model\FolderImageI18n'); + } + + /** + * Gets an array of ChildFolderImageI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildFolderImage is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFolderImageI18n[] List of ChildFolderImageI18n objects + * @throws PropelException + */ + public function getFolderImageI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collFolderImageI18nsPartial && !$this->isNew(); + if (null === $this->collFolderImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderImageI18ns) { + // return empty collection + $this->initFolderImageI18ns(); + } else { + $collFolderImageI18ns = ChildFolderImageI18nQuery::create(null, $criteria) + ->filterByFolderImage($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collFolderImageI18nsPartial && count($collFolderImageI18ns)) { + $this->initFolderImageI18ns(false); + + foreach ($collFolderImageI18ns as $obj) { + if (false == $this->collFolderImageI18ns->contains($obj)) { + $this->collFolderImageI18ns->append($obj); + } + } + + $this->collFolderImageI18nsPartial = true; + } + + $collFolderImageI18ns->getInternalIterator()->rewind(); + + return $collFolderImageI18ns; + } + + if ($partial && $this->collFolderImageI18ns) { + foreach ($this->collFolderImageI18ns as $obj) { + if ($obj->isNew()) { + $collFolderImageI18ns[] = $obj; + } + } + } + + $this->collFolderImageI18ns = $collFolderImageI18ns; + $this->collFolderImageI18nsPartial = false; + } + } + + return $this->collFolderImageI18ns; + } + + /** + * Sets a collection of FolderImageI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $folderImageI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolderImage The current object (for fluent API support) + */ + public function setFolderImageI18ns(Collection $folderImageI18ns, ConnectionInterface $con = null) + { + $folderImageI18nsToDelete = $this->getFolderImageI18ns(new Criteria(), $con)->diff($folderImageI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->folderImageI18nsScheduledForDeletion = clone $folderImageI18nsToDelete; + + foreach ($folderImageI18nsToDelete as $folderImageI18nRemoved) { + $folderImageI18nRemoved->setFolderImage(null); + } + + $this->collFolderImageI18ns = null; + foreach ($folderImageI18ns as $folderImageI18n) { + $this->addFolderImageI18n($folderImageI18n); + } + + $this->collFolderImageI18ns = $folderImageI18ns; + $this->collFolderImageI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related FolderImageI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related FolderImageI18n objects. + * @throws PropelException + */ + public function countFolderImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collFolderImageI18nsPartial && !$this->isNew(); + if (null === $this->collFolderImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFolderImageI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getFolderImageI18ns()); + } + + $query = ChildFolderImageI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByFolderImage($this) + ->count($con); + } + + return count($this->collFolderImageI18ns); + } + + /** + * Method called to associate a ChildFolderImageI18n object to this object + * through the ChildFolderImageI18n foreign key attribute. + * + * @param ChildFolderImageI18n $l ChildFolderImageI18n + * @return \Thelia\Model\FolderImage The current object (for fluent API support) + */ + public function addFolderImageI18n(ChildFolderImageI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collFolderImageI18ns === null) { + $this->initFolderImageI18ns(); + $this->collFolderImageI18nsPartial = true; + } + + if (!in_array($l, $this->collFolderImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddFolderImageI18n($l); + } + + return $this; + } + + /** + * @param FolderImageI18n $folderImageI18n The folderImageI18n object to add. + */ + protected function doAddFolderImageI18n($folderImageI18n) + { + $this->collFolderImageI18ns[]= $folderImageI18n; + $folderImageI18n->setFolderImage($this); + } + + /** + * @param FolderImageI18n $folderImageI18n The folderImageI18n object to remove. + * @return ChildFolderImage The current object (for fluent API support) + */ + public function removeFolderImageI18n($folderImageI18n) + { + if ($this->getFolderImageI18ns()->contains($folderImageI18n)) { + $this->collFolderImageI18ns->remove($this->collFolderImageI18ns->search($folderImageI18n)); + if (null === $this->folderImageI18nsScheduledForDeletion) { + $this->folderImageI18nsScheduledForDeletion = clone $this->collFolderImageI18ns; + $this->folderImageI18nsScheduledForDeletion->clear(); + } + $this->folderImageI18nsScheduledForDeletion[]= clone $folderImageI18n; + $folderImageI18n->setFolderImage(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->folder_id = null; + $this->file = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collFolderImageI18ns) { + foreach ($this->collFolderImageI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collFolderImageI18ns instanceof Collection) { + $this->collFolderImageI18ns->clearIterator(); + } + $this->collFolderImageI18ns = null; + $this->aFolder = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FolderImageTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildFolderImage The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FolderImageTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildFolderImage The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderImageI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collFolderImageI18ns) { + foreach ($this->collFolderImageI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildFolderImageI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildFolderImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addFolderImageI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderImage The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildFolderImageI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collFolderImageI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collFolderImageI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderImageI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ImageI18n.php b/core/lib/Thelia/Model/Base/FolderImageI18n.php similarity index 84% rename from core/lib/Thelia/Model/Base/ImageI18n.php rename to core/lib/Thelia/Model/Base/FolderImageI18n.php index 945605968..d5cc004d1 100644 --- a/core/lib/Thelia/Model/Base/ImageI18n.php +++ b/core/lib/Thelia/Model/Base/FolderImageI18n.php @@ -14,17 +14,17 @@ use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; -use Thelia\Model\Image as ChildImage; -use Thelia\Model\ImageI18nQuery as ChildImageI18nQuery; -use Thelia\Model\ImageQuery as ChildImageQuery; -use Thelia\Model\Map\ImageI18nTableMap; +use Thelia\Model\FolderImage as ChildFolderImage; +use Thelia\Model\FolderImageI18nQuery as ChildFolderImageI18nQuery; +use Thelia\Model\FolderImageQuery as ChildFolderImageQuery; +use Thelia\Model\Map\FolderImageI18nTableMap; -abstract class ImageI18n implements ActiveRecordInterface +abstract class FolderImageI18n implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\ImageI18nTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\FolderImageI18nTableMap'; /** @@ -91,9 +91,9 @@ abstract class ImageI18n implements ActiveRecordInterface protected $postscriptum; /** - * @var Image + * @var FolderImage */ - protected $aImage; + protected $aFolderImage; /** * Flag to prevent endless save loop, if this object is referenced @@ -115,7 +115,7 @@ abstract class ImageI18n implements ActiveRecordInterface } /** - * Initializes internal state of Thelia\Model\Base\ImageI18n object. + * Initializes internal state of Thelia\Model\Base\FolderImageI18n object. * @see applyDefaults() */ public function __construct() @@ -212,9 +212,9 @@ abstract class ImageI18n implements ActiveRecordInterface } /** - * Compares this with another ImageI18n instance. If - * obj is an instance of ImageI18n, delegates to - * equals(ImageI18n). Otherwise, returns false. + * Compares this with another FolderImageI18n instance. If + * obj is an instance of FolderImageI18n, delegates to + * equals(FolderImageI18n). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -295,7 +295,7 @@ abstract class ImageI18n implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return ImageI18n The current object, for fluid interface + * @return FolderImageI18n The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -327,7 +327,7 @@ abstract class ImageI18n implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return ImageI18n The current object, for fluid interface + * @return FolderImageI18n The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -440,7 +440,7 @@ abstract class ImageI18n implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) */ public function setId($v) { @@ -450,11 +450,11 @@ abstract class ImageI18n implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ImageI18nTableMap::ID; + $this->modifiedColumns[] = FolderImageI18nTableMap::ID; } - if ($this->aImage !== null && $this->aImage->getId() !== $v) { - $this->aImage = null; + if ($this->aFolderImage !== null && $this->aFolderImage->getId() !== $v) { + $this->aFolderImage = null; } @@ -465,7 +465,7 @@ abstract class ImageI18n implements ActiveRecordInterface * Set the value of [locale] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) */ public function setLocale($v) { @@ -475,7 +475,7 @@ abstract class ImageI18n implements ActiveRecordInterface if ($this->locale !== $v) { $this->locale = $v; - $this->modifiedColumns[] = ImageI18nTableMap::LOCALE; + $this->modifiedColumns[] = FolderImageI18nTableMap::LOCALE; } @@ -486,7 +486,7 @@ abstract class ImageI18n implements ActiveRecordInterface * Set the value of [title] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) */ public function setTitle($v) { @@ -496,7 +496,7 @@ abstract class ImageI18n implements ActiveRecordInterface if ($this->title !== $v) { $this->title = $v; - $this->modifiedColumns[] = ImageI18nTableMap::TITLE; + $this->modifiedColumns[] = FolderImageI18nTableMap::TITLE; } @@ -507,7 +507,7 @@ abstract class ImageI18n implements ActiveRecordInterface * Set the value of [description] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) */ public function setDescription($v) { @@ -517,7 +517,7 @@ abstract class ImageI18n implements ActiveRecordInterface if ($this->description !== $v) { $this->description = $v; - $this->modifiedColumns[] = ImageI18nTableMap::DESCRIPTION; + $this->modifiedColumns[] = FolderImageI18nTableMap::DESCRIPTION; } @@ -528,7 +528,7 @@ abstract class ImageI18n implements ActiveRecordInterface * Set the value of [chapo] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) */ public function setChapo($v) { @@ -538,7 +538,7 @@ abstract class ImageI18n implements ActiveRecordInterface if ($this->chapo !== $v) { $this->chapo = $v; - $this->modifiedColumns[] = ImageI18nTableMap::CHAPO; + $this->modifiedColumns[] = FolderImageI18nTableMap::CHAPO; } @@ -549,7 +549,7 @@ abstract class ImageI18n implements ActiveRecordInterface * Set the value of [postscriptum] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) */ public function setPostscriptum($v) { @@ -559,7 +559,7 @@ abstract class ImageI18n implements ActiveRecordInterface if ($this->postscriptum !== $v) { $this->postscriptum = $v; - $this->modifiedColumns[] = ImageI18nTableMap::POSTSCRIPTUM; + $this->modifiedColumns[] = FolderImageI18nTableMap::POSTSCRIPTUM; } @@ -607,22 +607,22 @@ abstract class ImageI18n implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; $this->locale = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; $this->title = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; $this->description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; $this->chapo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; $this->postscriptum = (null !== $col) ? (string) $col : null; $this->resetModified(); @@ -632,10 +632,10 @@ abstract class ImageI18n implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 6; // 6 = ImageI18nTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = FolderImageI18nTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\ImageI18n object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\FolderImageI18n object", 0, $e); } } @@ -654,8 +654,8 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function ensureConsistency() { - if ($this->aImage !== null && $this->id !== $this->aImage->getId()) { - $this->aImage = null; + if ($this->aFolderImage !== null && $this->id !== $this->aFolderImage->getId()) { + $this->aFolderImage = null; } } // ensureConsistency @@ -680,13 +680,13 @@ abstract class ImageI18n implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(FolderImageI18nTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildFolderImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -696,7 +696,7 @@ abstract class ImageI18n implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aImage = null; + $this->aFolderImage = null; } // if (deep) } @@ -706,8 +706,8 @@ abstract class ImageI18n implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see ImageI18n::setDeleted() - * @see ImageI18n::isDeleted() + * @see FolderImageI18n::setDeleted() + * @see FolderImageI18n::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -716,12 +716,12 @@ abstract class ImageI18n implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageI18nTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildImageI18nQuery::create() + $deleteQuery = ChildFolderImageI18nQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -758,7 +758,7 @@ abstract class ImageI18n implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageI18nTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -778,7 +778,7 @@ abstract class ImageI18n implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - ImageI18nTableMap::addInstanceToPool($this); + FolderImageI18nTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -813,11 +813,11 @@ abstract class ImageI18n implements ActiveRecordInterface // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aImage !== null) { - if ($this->aImage->isModified() || $this->aImage->isNew()) { - $affectedRows += $this->aImage->save($con); + if ($this->aFolderImage !== null) { + if ($this->aFolderImage->isModified() || $this->aFolderImage->isNew()) { + $affectedRows += $this->aFolderImage->save($con); } - $this->setImage($this->aImage); + $this->setFolderImage($this->aFolderImage); } if ($this->isNew() || $this->isModified()) { @@ -853,27 +853,27 @@ abstract class ImageI18n implements ActiveRecordInterface // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ImageI18nTableMap::ID)) { + if ($this->isColumnModified(FolderImageI18nTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ImageI18nTableMap::LOCALE)) { + if ($this->isColumnModified(FolderImageI18nTableMap::LOCALE)) { $modifiedColumns[':p' . $index++] = 'LOCALE'; } - if ($this->isColumnModified(ImageI18nTableMap::TITLE)) { + if ($this->isColumnModified(FolderImageI18nTableMap::TITLE)) { $modifiedColumns[':p' . $index++] = 'TITLE'; } - if ($this->isColumnModified(ImageI18nTableMap::DESCRIPTION)) { + if ($this->isColumnModified(FolderImageI18nTableMap::DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(ImageI18nTableMap::CHAPO)) { + if ($this->isColumnModified(FolderImageI18nTableMap::CHAPO)) { $modifiedColumns[':p' . $index++] = 'CHAPO'; } - if ($this->isColumnModified(ImageI18nTableMap::POSTSCRIPTUM)) { + if ($this->isColumnModified(FolderImageI18nTableMap::POSTSCRIPTUM)) { $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } $sql = sprintf( - 'INSERT INTO image_i18n (%s) VALUES (%s)', + 'INSERT INTO folder_image_i18n (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -939,7 +939,7 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = FolderImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -996,11 +996,11 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['ImageI18n'][serialize($this->getPrimaryKey())])) { + if (isset($alreadyDumpedObjects['FolderImageI18n'][serialize($this->getPrimaryKey())])) { return '*RECURSION*'; } - $alreadyDumpedObjects['ImageI18n'][serialize($this->getPrimaryKey())] = true; - $keys = ImageI18nTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['FolderImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = FolderImageI18nTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getLocale(), @@ -1016,8 +1016,8 @@ abstract class ImageI18n implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aImage) { - $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aFolderImage) { + $result['FolderImage'] = $this->aFolderImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } @@ -1037,7 +1037,7 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = FolderImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1093,7 +1093,7 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ImageI18nTableMap::getFieldNames($keyType); + $keys = FolderImageI18nTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); @@ -1110,14 +1110,14 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(ImageI18nTableMap::DATABASE_NAME); + $criteria = new Criteria(FolderImageI18nTableMap::DATABASE_NAME); - if ($this->isColumnModified(ImageI18nTableMap::ID)) $criteria->add(ImageI18nTableMap::ID, $this->id); - if ($this->isColumnModified(ImageI18nTableMap::LOCALE)) $criteria->add(ImageI18nTableMap::LOCALE, $this->locale); - if ($this->isColumnModified(ImageI18nTableMap::TITLE)) $criteria->add(ImageI18nTableMap::TITLE, $this->title); - if ($this->isColumnModified(ImageI18nTableMap::DESCRIPTION)) $criteria->add(ImageI18nTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(ImageI18nTableMap::CHAPO)) $criteria->add(ImageI18nTableMap::CHAPO, $this->chapo); - if ($this->isColumnModified(ImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(ImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(FolderImageI18nTableMap::ID)) $criteria->add(FolderImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(FolderImageI18nTableMap::LOCALE)) $criteria->add(FolderImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(FolderImageI18nTableMap::TITLE)) $criteria->add(FolderImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(FolderImageI18nTableMap::DESCRIPTION)) $criteria->add(FolderImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(FolderImageI18nTableMap::CHAPO)) $criteria->add(FolderImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(FolderImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(FolderImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); return $criteria; } @@ -1132,9 +1132,9 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(ImageI18nTableMap::DATABASE_NAME); - $criteria->add(ImageI18nTableMap::ID, $this->id); - $criteria->add(ImageI18nTableMap::LOCALE, $this->locale); + $criteria = new Criteria(FolderImageI18nTableMap::DATABASE_NAME); + $criteria->add(FolderImageI18nTableMap::ID, $this->id); + $criteria->add(FolderImageI18nTableMap::LOCALE, $this->locale); return $criteria; } @@ -1181,7 +1181,7 @@ abstract class ImageI18n implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\ImageI18n (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\FolderImageI18n (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -1208,7 +1208,7 @@ abstract class ImageI18n implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\ImageI18n Clone of current object. + * @return \Thelia\Model\FolderImageI18n Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1222,13 +1222,13 @@ abstract class ImageI18n implements ActiveRecordInterface } /** - * Declares an association between this object and a ChildImage object. + * Declares an association between this object and a ChildFolderImage object. * - * @param ChildImage $v - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @param ChildFolderImage $v + * @return \Thelia\Model\FolderImageI18n The current object (for fluent API support) * @throws PropelException */ - public function setImage(ChildImage $v = null) + public function setFolderImage(ChildFolderImage $v = null) { if ($v === null) { $this->setId(NULL); @@ -1236,12 +1236,12 @@ abstract class ImageI18n implements ActiveRecordInterface $this->setId($v->getId()); } - $this->aImage = $v; + $this->aFolderImage = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildImage object, it will not be re-added. + // If this object has already been added to the ChildFolderImage object, it will not be re-added. if ($v !== null) { - $v->addImageI18n($this); + $v->addFolderImageI18n($this); } @@ -1250,26 +1250,26 @@ abstract class ImageI18n implements ActiveRecordInterface /** - * Get the associated ChildImage object + * Get the associated ChildFolderImage object * * @param ConnectionInterface $con Optional Connection object. - * @return ChildImage The associated ChildImage object. + * @return ChildFolderImage The associated ChildFolderImage object. * @throws PropelException */ - public function getImage(ConnectionInterface $con = null) + public function getFolderImage(ConnectionInterface $con = null) { - if ($this->aImage === null && ($this->id !== null)) { - $this->aImage = ChildImageQuery::create()->findPk($this->id, $con); + if ($this->aFolderImage === null && ($this->id !== null)) { + $this->aFolderImage = ChildFolderImageQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aImage->addImageI18ns($this); + $this->aFolderImage->addFolderImageI18ns($this); */ } - return $this->aImage; + return $this->aFolderImage; } /** @@ -1305,7 +1305,7 @@ abstract class ImageI18n implements ActiveRecordInterface if ($deep) { } // if ($deep) - $this->aImage = null; + $this->aFolderImage = null; } /** @@ -1315,7 +1315,7 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(ImageI18nTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(FolderImageI18nTableMap::DEFAULT_STRING_FORMAT); } /** diff --git a/core/lib/Thelia/Model/Base/ImageI18nQuery.php b/core/lib/Thelia/Model/Base/FolderImageI18nQuery.php similarity index 62% rename from core/lib/Thelia/Model/Base/ImageI18nQuery.php rename to core/lib/Thelia/Model/Base/FolderImageI18nQuery.php index 92fa1d878..0e7e0ab55 100644 --- a/core/lib/Thelia/Model/Base/ImageI18nQuery.php +++ b/core/lib/Thelia/Model/Base/FolderImageI18nQuery.php @@ -12,84 +12,84 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\ImageI18n as ChildImageI18n; -use Thelia\Model\ImageI18nQuery as ChildImageI18nQuery; -use Thelia\Model\Map\ImageI18nTableMap; +use Thelia\Model\FolderImageI18n as ChildFolderImageI18n; +use Thelia\Model\FolderImageI18nQuery as ChildFolderImageI18nQuery; +use Thelia\Model\Map\FolderImageI18nTableMap; /** - * Base class that represents a query for the 'image_i18n' table. + * Base class that represents a query for the 'folder_image_i18n' table. * * * - * @method ChildImageI18nQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildImageI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column - * @method ChildImageI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column - * @method ChildImageI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column - * @method ChildImageI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column - * @method ChildImageI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column + * @method ChildFolderImageI18nQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildFolderImageI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column + * @method ChildFolderImageI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column + * @method ChildFolderImageI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column + * @method ChildFolderImageI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column + * @method ChildFolderImageI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column * - * @method ChildImageI18nQuery groupById() Group by the id column - * @method ChildImageI18nQuery groupByLocale() Group by the locale column - * @method ChildImageI18nQuery groupByTitle() Group by the title column - * @method ChildImageI18nQuery groupByDescription() Group by the description column - * @method ChildImageI18nQuery groupByChapo() Group by the chapo column - * @method ChildImageI18nQuery groupByPostscriptum() Group by the postscriptum column + * @method ChildFolderImageI18nQuery groupById() Group by the id column + * @method ChildFolderImageI18nQuery groupByLocale() Group by the locale column + * @method ChildFolderImageI18nQuery groupByTitle() Group by the title column + * @method ChildFolderImageI18nQuery groupByDescription() Group by the description column + * @method ChildFolderImageI18nQuery groupByChapo() Group by the chapo column + * @method ChildFolderImageI18nQuery groupByPostscriptum() Group by the postscriptum column * - * @method ChildImageI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildImageI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildImageI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildFolderImageI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildFolderImageI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildFolderImageI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildImageI18nQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation - * @method ChildImageI18nQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation - * @method ChildImageI18nQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation + * @method ChildFolderImageI18nQuery leftJoinFolderImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the FolderImage relation + * @method ChildFolderImageI18nQuery rightJoinFolderImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FolderImage relation + * @method ChildFolderImageI18nQuery innerJoinFolderImage($relationAlias = null) Adds a INNER JOIN clause to the query using the FolderImage relation * - * @method ChildImageI18n findOne(ConnectionInterface $con = null) Return the first ChildImageI18n matching the query - * @method ChildImageI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildImageI18n matching the query, or a new ChildImageI18n object populated from the query conditions when no match is found + * @method ChildFolderImageI18n findOne(ConnectionInterface $con = null) Return the first ChildFolderImageI18n matching the query + * @method ChildFolderImageI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildFolderImageI18n matching the query, or a new ChildFolderImageI18n object populated from the query conditions when no match is found * - * @method ChildImageI18n findOneById(int $id) Return the first ChildImageI18n filtered by the id column - * @method ChildImageI18n findOneByLocale(string $locale) Return the first ChildImageI18n filtered by the locale column - * @method ChildImageI18n findOneByTitle(string $title) Return the first ChildImageI18n filtered by the title column - * @method ChildImageI18n findOneByDescription(string $description) Return the first ChildImageI18n filtered by the description column - * @method ChildImageI18n findOneByChapo(string $chapo) Return the first ChildImageI18n filtered by the chapo column - * @method ChildImageI18n findOneByPostscriptum(string $postscriptum) Return the first ChildImageI18n filtered by the postscriptum column + * @method ChildFolderImageI18n findOneById(int $id) Return the first ChildFolderImageI18n filtered by the id column + * @method ChildFolderImageI18n findOneByLocale(string $locale) Return the first ChildFolderImageI18n filtered by the locale column + * @method ChildFolderImageI18n findOneByTitle(string $title) Return the first ChildFolderImageI18n filtered by the title column + * @method ChildFolderImageI18n findOneByDescription(string $description) Return the first ChildFolderImageI18n filtered by the description column + * @method ChildFolderImageI18n findOneByChapo(string $chapo) Return the first ChildFolderImageI18n filtered by the chapo column + * @method ChildFolderImageI18n findOneByPostscriptum(string $postscriptum) Return the first ChildFolderImageI18n filtered by the postscriptum column * - * @method array findById(int $id) Return ChildImageI18n objects filtered by the id column - * @method array findByLocale(string $locale) Return ChildImageI18n objects filtered by the locale column - * @method array findByTitle(string $title) Return ChildImageI18n objects filtered by the title column - * @method array findByDescription(string $description) Return ChildImageI18n objects filtered by the description column - * @method array findByChapo(string $chapo) Return ChildImageI18n objects filtered by the chapo column - * @method array findByPostscriptum(string $postscriptum) Return ChildImageI18n objects filtered by the postscriptum column + * @method array findById(int $id) Return ChildFolderImageI18n objects filtered by the id column + * @method array findByLocale(string $locale) Return ChildFolderImageI18n objects filtered by the locale column + * @method array findByTitle(string $title) Return ChildFolderImageI18n objects filtered by the title column + * @method array findByDescription(string $description) Return ChildFolderImageI18n objects filtered by the description column + * @method array findByChapo(string $chapo) Return ChildFolderImageI18n objects filtered by the chapo column + * @method array findByPostscriptum(string $postscriptum) Return ChildFolderImageI18n objects filtered by the postscriptum column * */ -abstract class ImageI18nQuery extends ModelCriteria +abstract class FolderImageI18nQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\ImageI18nQuery object. + * Initializes internal state of \Thelia\Model\Base\FolderImageI18nQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\ImageI18n', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\FolderImageI18n', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildImageI18nQuery object. + * Returns a new ChildFolderImageI18nQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildImageI18nQuery + * @return ChildFolderImageI18nQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\ImageI18nQuery) { + if ($criteria instanceof \Thelia\Model\FolderImageI18nQuery) { return $criteria; } - $query = new \Thelia\Model\ImageI18nQuery(); + $query = new \Thelia\Model\FolderImageI18nQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -112,19 +112,19 @@ abstract class ImageI18nQuery extends ModelCriteria * @param array[$id, $locale] $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildImageI18n|array|mixed the result, formatted by the current formatter + * @return ChildFolderImageI18n|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = ImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + if ((null !== ($obj = FolderImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(FolderImageI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,11 +143,11 @@ abstract class ImageI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildImageI18n A model object, or null if the key is not found + * @return ChildFolderImageI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM image_i18n WHERE ID = :p0 AND LOCALE = :p1'; + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM folder_image_i18n WHERE ID = :p0 AND LOCALE = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -159,9 +159,9 @@ abstract class ImageI18nQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildImageI18n(); + $obj = new ChildFolderImageI18n(); $obj->hydrate($row); - ImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + FolderImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -174,7 +174,7 @@ abstract class ImageI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildImageI18n|array|mixed the result, formatted by the current formatter + * @return ChildFolderImageI18n|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -216,12 +216,12 @@ abstract class ImageI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - $this->addUsingAlias(ImageI18nTableMap::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $this->addUsingAlias(FolderImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(FolderImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -231,7 +231,7 @@ abstract class ImageI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -239,8 +239,8 @@ abstract class ImageI18nQuery extends ModelCriteria return $this->add(null, '1<>1', Criteria::CUSTOM); } foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(ImageI18nTableMap::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0 = $this->getNewCriterion(FolderImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(FolderImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,7 +258,7 @@ abstract class ImageI18nQuery extends ModelCriteria * $query->filterById(array('min' => 12)); // WHERE id > 12 * * - * @see filterByImage() + * @see filterByFolderImage() * * @param mixed $id The value to use as filter. * Use scalar values for equality. @@ -266,18 +266,18 @@ abstract class ImageI18nQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterById($id = null, $comparison = null) { if (is_array($id)) { $useMinMax = false; if (isset($id['min'])) { - $this->addUsingAlias(ImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(FolderImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -288,7 +288,7 @@ abstract class ImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nTableMap::ID, $id, $comparison); + return $this->addUsingAlias(FolderImageI18nTableMap::ID, $id, $comparison); } /** @@ -304,7 +304,7 @@ abstract class ImageI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -317,7 +317,7 @@ abstract class ImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nTableMap::LOCALE, $locale, $comparison); + return $this->addUsingAlias(FolderImageI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -333,7 +333,7 @@ abstract class ImageI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -346,7 +346,7 @@ abstract class ImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nTableMap::TITLE, $title, $comparison); + return $this->addUsingAlias(FolderImageI18nTableMap::TITLE, $title, $comparison); } /** @@ -362,7 +362,7 @@ abstract class ImageI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -375,7 +375,7 @@ abstract class ImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nTableMap::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(FolderImageI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -391,7 +391,7 @@ abstract class ImageI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -404,7 +404,7 @@ abstract class ImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nTableMap::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(FolderImageI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -420,7 +420,7 @@ abstract class ImageI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -433,46 +433,46 @@ abstract class ImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(FolderImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related \Thelia\Model\Image object + * Filter the query by a related \Thelia\Model\FolderImage object * - * @param \Thelia\Model\Image|ObjectCollection $image The related object(s) to use as filter + * @param \Thelia\Model\FolderImage|ObjectCollection $folderImage The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ - public function filterByImage($image, $comparison = null) + public function filterByFolderImage($folderImage, $comparison = null) { - if ($image instanceof \Thelia\Model\Image) { + if ($folderImage instanceof \Thelia\Model\FolderImage) { return $this - ->addUsingAlias(ImageI18nTableMap::ID, $image->getId(), $comparison); - } elseif ($image instanceof ObjectCollection) { + ->addUsingAlias(FolderImageI18nTableMap::ID, $folderImage->getId(), $comparison); + } elseif ($folderImage instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ImageI18nTableMap::ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FolderImageI18nTableMap::ID, $folderImage->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); + throw new PropelException('filterByFolderImage() only accepts arguments of type \Thelia\Model\FolderImage or Collection'); } } /** - * Adds a JOIN clause to the query using the Image relation + * Adds a JOIN clause to the query using the FolderImage relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ - public function joinImage($relationAlias = null, $joinType = 'LEFT JOIN') + public function joinFolderImage($relationAlias = null, $joinType = 'LEFT JOIN') { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); + $relationMap = $tableMap->getRelation('FolderImage'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -487,14 +487,14 @@ abstract class ImageI18nQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Image'); + $this->addJoinObject($join, 'FolderImage'); } return $this; } /** - * Use the Image relation Image object + * Use the FolderImage relation FolderImage object * * @see useQuery() * @@ -502,27 +502,27 @@ abstract class ImageI18nQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\FolderImageQuery A secondary query class using the current class as primary query */ - public function useImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') + public function useFolderImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); + ->joinFolderImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderImage', '\Thelia\Model\FolderImageQuery'); } /** * Exclude object from result * - * @param ChildImageI18n $imageI18n Object to remove from the list of results + * @param ChildFolderImageI18n $folderImageI18n Object to remove from the list of results * - * @return ChildImageI18nQuery The current query, for fluid interface + * @return ChildFolderImageI18nQuery The current query, for fluid interface */ - public function prune($imageI18n = null) + public function prune($folderImageI18n = null) { - if ($imageI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(ImageI18nTableMap::ID), $imageI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ImageI18nTableMap::LOCALE), $imageI18n->getLocale(), Criteria::NOT_EQUAL); + if ($folderImageI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(FolderImageI18nTableMap::ID), $folderImageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(FolderImageI18nTableMap::LOCALE), $folderImageI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } @@ -530,7 +530,7 @@ abstract class ImageI18nQuery extends ModelCriteria } /** - * Deletes all rows from the image_i18n table. + * Deletes all rows from the folder_image_i18n table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -538,7 +538,7 @@ abstract class ImageI18nQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageI18nTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -549,8 +549,8 @@ abstract class ImageI18nQuery extends ModelCriteria // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - ImageI18nTableMap::clearInstancePool(); - ImageI18nTableMap::clearRelatedInstancePool(); + FolderImageI18nTableMap::clearInstancePool(); + FolderImageI18nTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -562,9 +562,9 @@ abstract class ImageI18nQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildImageI18n or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildFolderImageI18n or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildImageI18n object or primary key or array of primary keys + * @param mixed $values Criteria or ChildFolderImageI18n object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -575,13 +575,13 @@ abstract class ImageI18nQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageI18nTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(ImageI18nTableMap::DATABASE_NAME); + $criteria->setDbName(FolderImageI18nTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -591,10 +591,10 @@ abstract class ImageI18nQuery extends ModelCriteria $con->beginTransaction(); - ImageI18nTableMap::removeInstanceFromPool($criteria); + FolderImageI18nTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - ImageI18nTableMap::clearRelatedInstancePool(); + FolderImageI18nTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -604,4 +604,4 @@ abstract class ImageI18nQuery extends ModelCriteria } } -} // ImageI18nQuery +} // FolderImageI18nQuery diff --git a/core/lib/Thelia/Model/Base/FolderImageQuery.php b/core/lib/Thelia/Model/Base/FolderImageQuery.php new file mode 100644 index 000000000..ca12e098e --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderImageQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildFolderImage|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = FolderImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(FolderImageTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildFolderImage A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, FOLDER_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM folder_image WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFolderImage(); + $obj->hydrate($row); + FolderImageTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildFolderImage|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(FolderImageTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(FolderImageTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(FolderImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(FolderImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderImageTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the folder_id column + * + * Example usage: + * + * $query->filterByFolderId(1234); // WHERE folder_id = 1234 + * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 + * + * + * @see filterByFolder() + * + * @param mixed $folderId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByFolderId($folderId = null, $comparison = null) + { + if (is_array($folderId)) { + $useMinMax = false; + if (isset($folderId['min'])) { + $this->addUsingAlias(FolderImageTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($folderId['max'])) { + $this->addUsingAlias(FolderImageTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderImageTableMap::FOLDER_ID, $folderId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(FolderImageTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(FolderImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(FolderImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderImageTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(FolderImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(FolderImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderImageTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(FolderImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(FolderImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FolderImageTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Folder object + * + * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByFolder($folder, $comparison = null) + { + if ($folder instanceof \Thelia\Model\Folder) { + return $this + ->addUsingAlias(FolderImageTableMap::FOLDER_ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(FolderImageTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Folder relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Folder'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Folder'); + } + + return $this; + } + + /** + * Use the Folder relation Folder object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query + */ + public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFolder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\FolderImageI18n object + * + * @param \Thelia\Model\FolderImageI18n|ObjectCollection $folderImageI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function filterByFolderImageI18n($folderImageI18n, $comparison = null) + { + if ($folderImageI18n instanceof \Thelia\Model\FolderImageI18n) { + return $this + ->addUsingAlias(FolderImageTableMap::ID, $folderImageI18n->getId(), $comparison); + } elseif ($folderImageI18n instanceof ObjectCollection) { + return $this + ->useFolderImageI18nQuery() + ->filterByPrimaryKeys($folderImageI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFolderImageI18n() only accepts arguments of type \Thelia\Model\FolderImageI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the FolderImageI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function joinFolderImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FolderImageI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FolderImageI18n'); + } + + return $this; + } + + /** + * Use the FolderImageI18n relation FolderImageI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FolderImageI18nQuery A secondary query class using the current class as primary query + */ + public function useFolderImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinFolderImageI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderImageI18n', '\Thelia\Model\FolderImageI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildFolderImage $folderImage Object to remove from the list of results + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function prune($folderImage = null) + { + if ($folderImage) { + $this->addUsingAlias(FolderImageTableMap::ID, $folderImage->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the folder_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FolderImageTableMap::clearInstancePool(); + FolderImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFolderImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFolderImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FolderImageTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + FolderImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FolderImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(FolderImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(FolderImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FolderImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FolderImageTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(FolderImageTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(FolderImageTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'FolderImageI18n'; + + return $this + ->joinFolderImageI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildFolderImageQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('FolderImageI18n'); + $this->with['FolderImageI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildFolderImageI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderImageI18n', '\Thelia\Model\FolderImageI18nQuery'); + } + +} // FolderImageQuery diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php index 6c7d91701..893bb9819 100644 --- a/core/lib/Thelia/Model/Base/FolderQuery.php +++ b/core/lib/Thelia/Model/Base/FolderQuery.php @@ -46,14 +46,6 @@ use Thelia\Model\Map\FolderTableMap; * @method ChildFolderQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildFolderQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildFolderQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation - * @method ChildFolderQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation - * @method ChildFolderQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation - * - * @method ChildFolderQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method ChildFolderQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method ChildFolderQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation - * * @method ChildFolderQuery leftJoinRewriting($relationAlias = null) Adds a LEFT JOIN clause to the query using the Rewriting relation * @method ChildFolderQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation * @method ChildFolderQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation @@ -62,6 +54,14 @@ use Thelia\Model\Map\FolderTableMap; * @method ChildFolderQuery rightJoinContentFolder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentFolder relation * @method ChildFolderQuery innerJoinContentFolder($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentFolder relation * + * @method ChildFolderQuery leftJoinFolderImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the FolderImage relation + * @method ChildFolderQuery rightJoinFolderImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FolderImage relation + * @method ChildFolderQuery innerJoinFolderImage($relationAlias = null) Adds a INNER JOIN clause to the query using the FolderImage relation + * + * @method ChildFolderQuery leftJoinFolderDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the FolderDocument relation + * @method ChildFolderQuery rightJoinFolderDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FolderDocument relation + * @method ChildFolderQuery innerJoinFolderDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the FolderDocument relation + * * @method ChildFolderQuery leftJoinFolderI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the FolderI18n relation * @method ChildFolderQuery rightJoinFolderI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FolderI18n relation * @method ChildFolderQuery innerJoinFolderI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the FolderI18n relation @@ -639,152 +639,6 @@ abstract class FolderQuery extends ModelCriteria return $this->addUsingAlias(FolderTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } - /** - * Filter the query by a related \Thelia\Model\Image object - * - * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildFolderQuery The current query, for fluid interface - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof \Thelia\Model\Image) { - return $this - ->addUsingAlias(FolderTableMap::ID, $image->getFolderId(), $comparison); - } elseif ($image instanceof ObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildFolderQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Document object - * - * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildFolderQuery The current query, for fluid interface - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof \Thelia\Model\Document) { - return $this - ->addUsingAlias(FolderTableMap::ID, $document->getFolderId(), $comparison); - } elseif ($document instanceof ObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildFolderQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - /** * Filter the query by a related \Thelia\Model\Rewriting object * @@ -931,6 +785,152 @@ abstract class FolderQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); } + /** + * Filter the query by a related \Thelia\Model\FolderImage object + * + * @param \Thelia\Model\FolderImage|ObjectCollection $folderImage the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderQuery The current query, for fluid interface + */ + public function filterByFolderImage($folderImage, $comparison = null) + { + if ($folderImage instanceof \Thelia\Model\FolderImage) { + return $this + ->addUsingAlias(FolderTableMap::ID, $folderImage->getFolderId(), $comparison); + } elseif ($folderImage instanceof ObjectCollection) { + return $this + ->useFolderImageQuery() + ->filterByPrimaryKeys($folderImage->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFolderImage() only accepts arguments of type \Thelia\Model\FolderImage or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the FolderImage relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFolderQuery The current query, for fluid interface + */ + public function joinFolderImage($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FolderImage'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FolderImage'); + } + + return $this; + } + + /** + * Use the FolderImage relation FolderImage object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FolderImageQuery A secondary query class using the current class as primary query + */ + public function useFolderImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFolderImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderImage', '\Thelia\Model\FolderImageQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\FolderDocument object + * + * @param \Thelia\Model\FolderDocument|ObjectCollection $folderDocument the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildFolderQuery The current query, for fluid interface + */ + public function filterByFolderDocument($folderDocument, $comparison = null) + { + if ($folderDocument instanceof \Thelia\Model\FolderDocument) { + return $this + ->addUsingAlias(FolderTableMap::ID, $folderDocument->getFolderId(), $comparison); + } elseif ($folderDocument instanceof ObjectCollection) { + return $this + ->useFolderDocumentQuery() + ->filterByPrimaryKeys($folderDocument->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByFolderDocument() only accepts arguments of type \Thelia\Model\FolderDocument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the FolderDocument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildFolderQuery The current query, for fluid interface + */ + public function joinFolderDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('FolderDocument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'FolderDocument'); + } + + return $this; + } + + /** + * Use the FolderDocument relation FolderDocument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\FolderDocumentQuery A secondary query class using the current class as primary query + */ + public function useFolderDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinFolderDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'FolderDocument', '\Thelia\Model\FolderDocumentQuery'); + } + /** * Filter the query by a related \Thelia\Model\FolderI18n object * diff --git a/core/lib/Thelia/Model/Base/ImageQuery.php b/core/lib/Thelia/Model/Base/ImageQuery.php deleted file mode 100644 index b5b4bfd90..000000000 --- a/core/lib/Thelia/Model/Base/ImageQuery.php +++ /dev/null @@ -1,1224 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildImage|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(ImageTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildImage A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, PRODUCT_ID, CATEGORY_ID, FOLDER_ID, CONTENT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM image WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildImage(); - $obj->hydrate($row); - ImageTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildImage|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ImageTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ImageTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the folder_id column - * - * Example usage: - * - * $query->filterByFolderId(1234); // WHERE folder_id = 1234 - * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 - * - * - * @see filterByFolder() - * - * @param mixed $folderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByFolderId($folderId = null, $comparison = null) - { - if (is_array($folderId)) { - $useMinMax = false; - if (isset($folderId['min'])) { - $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($folderId['max'])) { - $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the file column - * - * Example usage: - * - * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' - * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' - * - * - * @param string $file The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByFile($file = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($file)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $file)) { - $file = str_replace('*', '%', $file); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ImageTableMap::FILE, $file, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(ImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(ImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Product object - * - * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof \Thelia\Model\Product) { - return $this - ->addUsingAlias(ImageTableMap::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImageTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Category object - * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof \Thelia\Model\Category) { - return $this - ->addUsingAlias(ImageTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImageTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Content object - * - * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof \Thelia\Model\Content) { - return $this - ->addUsingAlias(ImageTableMap::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImageTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Folder object - * - * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByFolder($folder, $comparison = null) - { - if ($folder instanceof \Thelia\Model\Folder) { - return $this - ->addUsingAlias(ImageTableMap::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImageTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Folder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\ImageI18n object - * - * @param \Thelia\Model\ImageI18n|ObjectCollection $imageI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function filterByImageI18n($imageI18n, $comparison = null) - { - if ($imageI18n instanceof \Thelia\Model\ImageI18n) { - return $this - ->addUsingAlias(ImageTableMap::ID, $imageI18n->getId(), $comparison); - } elseif ($imageI18n instanceof ObjectCollection) { - return $this - ->useImageI18nQuery() - ->filterByPrimaryKeys($imageI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImageI18n() only accepts arguments of type \Thelia\Model\ImageI18n or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the ImageI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function joinImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ImageI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ImageI18n'); - } - - return $this; - } - - /** - * Use the ImageI18n relation ImageI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageI18nQuery A secondary query class using the current class as primary query - */ - public function useImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinImageI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', '\Thelia\Model\ImageI18nQuery'); - } - - /** - * Exclude object from result - * - * @param ChildImage $image Object to remove from the list of results - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function prune($image = null) - { - if ($image) { - $this->addUsingAlias(ImageTableMap::ID, $image->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the image table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ImageTableMap::clearInstancePool(); - ImageTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildImage or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildImage object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(ImageTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - ImageTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - ImageTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ImageTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ImageTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ImageTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ImageTableMap::CREATED_AT); - } - - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'ImageI18n'; - - return $this - ->joinImageI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildImageQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('ImageI18n'); - $this->with['ImageI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildImageI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', '\Thelia\Model\ImageI18nQuery'); - } - -} // ImageQuery diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php index 63a3c1b8d..694f86bc5 100644 --- a/core/lib/Thelia/Model/Base/Lang.php +++ b/core/lib/Thelia/Model/Base/Lang.php @@ -90,12 +90,6 @@ abstract class Lang implements ActiveRecordInterface */ protected $by_default; - /** - * The value for the position field. - * @var int - */ - protected $position; - /** * The value for the created_at field. * @var string @@ -436,17 +430,6 @@ abstract class Lang implements ActiveRecordInterface return $this->by_default; } - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - - return $this->position; - } - /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -613,27 +596,6 @@ abstract class Lang implements ActiveRecordInterface return $this; } // setByDefault() - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return \Thelia\Model\Lang The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = LangTableMap::POSITION; - } - - - return $this; - } // setPosition() - /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -731,16 +693,13 @@ abstract class Lang implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : LangTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; $this->by_default = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : LangTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; - $this->position = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : LangTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : LangTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : LangTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : LangTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -753,7 +712,7 @@ abstract class Lang implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 9; // 9 = LangTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 8; // 8 = LangTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Lang object", 0, $e); @@ -991,9 +950,6 @@ abstract class Lang implements ActiveRecordInterface if ($this->isColumnModified(LangTableMap::BY_DEFAULT)) { $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; } - if ($this->isColumnModified(LangTableMap::POSITION)) { - $modifiedColumns[':p' . $index++] = 'POSITION'; - } if ($this->isColumnModified(LangTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1029,9 +985,6 @@ abstract class Lang implements ActiveRecordInterface case 'BY_DEFAULT': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; - case 'POSITION': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1119,12 +1072,9 @@ abstract class Lang implements ActiveRecordInterface return $this->getByDefault(); break; case 6: - return $this->getPosition(); - break; - case 7: return $this->getCreatedAt(); break; - case 8: + case 7: return $this->getUpdatedAt(); break; default: @@ -1161,9 +1111,8 @@ abstract class Lang implements ActiveRecordInterface $keys[3] => $this->getLocale(), $keys[4] => $this->getUrl(), $keys[5] => $this->getByDefault(), - $keys[6] => $this->getPosition(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1223,12 +1172,9 @@ abstract class Lang implements ActiveRecordInterface $this->setByDefault($value); break; case 6: - $this->setPosition($value); - break; - case 7: $this->setCreatedAt($value); break; - case 8: + case 7: $this->setUpdatedAt($value); break; } // switch() @@ -1261,9 +1207,8 @@ abstract class Lang implements ActiveRecordInterface if (array_key_exists($keys[3], $arr)) $this->setLocale($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUrl($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); } /** @@ -1281,7 +1226,6 @@ abstract class Lang implements ActiveRecordInterface if ($this->isColumnModified(LangTableMap::LOCALE)) $criteria->add(LangTableMap::LOCALE, $this->locale); if ($this->isColumnModified(LangTableMap::URL)) $criteria->add(LangTableMap::URL, $this->url); if ($this->isColumnModified(LangTableMap::BY_DEFAULT)) $criteria->add(LangTableMap::BY_DEFAULT, $this->by_default); - if ($this->isColumnModified(LangTableMap::POSITION)) $criteria->add(LangTableMap::POSITION, $this->position); if ($this->isColumnModified(LangTableMap::CREATED_AT)) $criteria->add(LangTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(LangTableMap::UPDATED_AT)) $criteria->add(LangTableMap::UPDATED_AT, $this->updated_at); @@ -1352,7 +1296,6 @@ abstract class Lang implements ActiveRecordInterface $copyObj->setLocale($this->getLocale()); $copyObj->setUrl($this->getUrl()); $copyObj->setByDefault($this->getByDefault()); - $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1394,7 +1337,6 @@ abstract class Lang implements ActiveRecordInterface $this->locale = null; $this->url = null; $this->by_default = null; - $this->position = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/LangQuery.php b/core/lib/Thelia/Model/Base/LangQuery.php index 6223bea61..1a99ff28a 100644 --- a/core/lib/Thelia/Model/Base/LangQuery.php +++ b/core/lib/Thelia/Model/Base/LangQuery.php @@ -24,7 +24,6 @@ use Thelia\Model\Map\LangTableMap; * @method ChildLangQuery orderByLocale($order = Criteria::ASC) Order by the locale column * @method ChildLangQuery orderByUrl($order = Criteria::ASC) Order by the url column * @method ChildLangQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column - * @method ChildLangQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildLangQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildLangQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -34,7 +33,6 @@ use Thelia\Model\Map\LangTableMap; * @method ChildLangQuery groupByLocale() Group by the locale column * @method ChildLangQuery groupByUrl() Group by the url column * @method ChildLangQuery groupByByDefault() Group by the by_default column - * @method ChildLangQuery groupByPosition() Group by the position column * @method ChildLangQuery groupByCreatedAt() Group by the created_at column * @method ChildLangQuery groupByUpdatedAt() Group by the updated_at column * @@ -51,7 +49,6 @@ use Thelia\Model\Map\LangTableMap; * @method ChildLang findOneByLocale(string $locale) Return the first ChildLang filtered by the locale column * @method ChildLang findOneByUrl(string $url) Return the first ChildLang filtered by the url column * @method ChildLang findOneByByDefault(int $by_default) Return the first ChildLang filtered by the by_default column - * @method ChildLang findOneByPosition(int $position) Return the first ChildLang filtered by the position column * @method ChildLang findOneByCreatedAt(string $created_at) Return the first ChildLang filtered by the created_at column * @method ChildLang findOneByUpdatedAt(string $updated_at) Return the first ChildLang filtered by the updated_at column * @@ -61,7 +58,6 @@ use Thelia\Model\Map\LangTableMap; * @method array findByLocale(string $locale) Return ChildLang objects filtered by the locale column * @method array findByUrl(string $url) Return ChildLang objects filtered by the url column * @method array findByByDefault(int $by_default) Return ChildLang objects filtered by the by_default column - * @method array findByPosition(int $position) Return ChildLang objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildLang objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildLang objects filtered by the updated_at column * @@ -152,7 +148,7 @@ abstract class LangQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, TITLE, CODE, LOCALE, URL, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM lang WHERE ID = :p0'; + $sql = 'SELECT ID, TITLE, CODE, LOCALE, URL, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM lang WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -439,47 +435,6 @@ abstract class LangQuery extends ModelCriteria return $this->addUsingAlias(LangTableMap::BY_DEFAULT, $byDefault, $comparison); } - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildLangQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(LangTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(LangTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(LangTableMap::POSITION, $position, $comparison); - } - /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index d8ca1d36b..854c88ccb 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -25,15 +25,13 @@ use Thelia\Model\Category as ChildCategory; use Thelia\Model\CategoryQuery as ChildCategoryQuery; use Thelia\Model\ContentAssoc as ChildContentAssoc; use Thelia\Model\ContentAssocQuery as ChildContentAssocQuery; -use Thelia\Model\Document as ChildDocument; -use Thelia\Model\DocumentQuery as ChildDocumentQuery; use Thelia\Model\FeatureProduct as ChildFeatureProduct; use Thelia\Model\FeatureProductQuery as ChildFeatureProductQuery; -use Thelia\Model\Image as ChildImage; -use Thelia\Model\ImageQuery as ChildImageQuery; use Thelia\Model\Product as ChildProduct; use Thelia\Model\ProductCategory as ChildProductCategory; use Thelia\Model\ProductCategoryQuery as ChildProductCategoryQuery; +use Thelia\Model\ProductDocument as ChildProductDocument; +use Thelia\Model\ProductDocumentQuery as ChildProductDocumentQuery; use Thelia\Model\ProductI18n as ChildProductI18n; use Thelia\Model\ProductI18nQuery as ChildProductI18nQuery; use Thelia\Model\ProductQuery as ChildProductQuery; @@ -41,6 +39,8 @@ use Thelia\Model\ProductSaleElements as ChildProductSaleElements; use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; use Thelia\Model\ProductVersion as ChildProductVersion; use Thelia\Model\ProductVersionQuery as ChildProductVersionQuery; +use Thelia\Model\ProdutImage as ChildProdutImage; +use Thelia\Model\ProdutImageQuery as ChildProdutImageQuery; use Thelia\Model\Rewriting as ChildRewriting; use Thelia\Model\RewritingQuery as ChildRewritingQuery; use Thelia\Model\TaxRule as ChildTaxRule; @@ -174,16 +174,16 @@ abstract class Product implements ActiveRecordInterface protected $collContentAssocsPartial; /** - * @var ObjectCollection|ChildImage[] Collection to store aggregation of ChildImage objects. + * @var ObjectCollection|ChildProdutImage[] Collection to store aggregation of ChildProdutImage objects. */ - protected $collImages; - protected $collImagesPartial; + protected $collProdutImages; + protected $collProdutImagesPartial; /** - * @var ObjectCollection|ChildDocument[] Collection to store aggregation of ChildDocument objects. + * @var ObjectCollection|ChildProductDocument[] Collection to store aggregation of ChildProductDocument objects. */ - protected $collDocuments; - protected $collDocumentsPartial; + protected $collProductDocuments; + protected $collProductDocumentsPartial; /** * @var ObjectCollection|ChildAccessory[] Collection to store aggregation of ChildAccessory objects. @@ -312,13 +312,13 @@ abstract class Product implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $imagesScheduledForDeletion = null; + protected $produtImagesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $documentsScheduledForDeletion = null; + protected $productDocumentsScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -1139,9 +1139,9 @@ abstract class Product implements ActiveRecordInterface $this->collContentAssocs = null; - $this->collImages = null; + $this->collProdutImages = null; - $this->collDocuments = null; + $this->collProductDocuments = null; $this->collAccessoriesRelatedByProductId = null; @@ -1464,34 +1464,34 @@ abstract class Product implements ActiveRecordInterface } } - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - \Thelia\Model\ImageQuery::create() - ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->produtImagesScheduledForDeletion !== null) { + if (!$this->produtImagesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProdutImageQuery::create() + ->filterByPrimaryKeys($this->produtImagesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->imagesScheduledForDeletion = null; + $this->produtImagesScheduledForDeletion = null; } } - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { + if ($this->collProdutImages !== null) { + foreach ($this->collProdutImages as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - \Thelia\Model\DocumentQuery::create() - ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->productDocumentsScheduledForDeletion !== null) { + if (!$this->productDocumentsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductDocumentQuery::create() + ->filterByPrimaryKeys($this->productDocumentsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->documentsScheduledForDeletion = null; + $this->productDocumentsScheduledForDeletion = null; } } - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + if ($this->collProductDocuments !== null) { + foreach ($this->collProductDocuments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1851,11 +1851,11 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->collContentAssocs) { $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProdutImages) { + $result['ProdutImages'] = $this->collProdutImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProductDocuments) { + $result['ProductDocuments'] = $this->collProductDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collAccessoriesRelatedByProductId) { $result['AccessoriesRelatedByProductId'] = $this->collAccessoriesRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -2096,15 +2096,15 @@ abstract class Product implements ActiveRecordInterface } } - foreach ($this->getImages() as $relObj) { + foreach ($this->getProdutImages() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); + $copyObj->addProdutImage($relObj->copy($deepCopy)); } } - foreach ($this->getDocuments() as $relObj) { + foreach ($this->getProductDocuments() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); + $copyObj->addProductDocument($relObj->copy($deepCopy)); } } @@ -2248,11 +2248,11 @@ abstract class Product implements ActiveRecordInterface if ('ContentAssoc' == $relationName) { return $this->initContentAssocs(); } - if ('Image' == $relationName) { - return $this->initImages(); + if ('ProdutImage' == $relationName) { + return $this->initProdutImages(); } - if ('Document' == $relationName) { - return $this->initDocuments(); + if ('ProductDocument' == $relationName) { + return $this->initProductDocuments(); } if ('AccessoryRelatedByProductId' == $relationName) { return $this->initAccessoriesRelatedByProductId(); @@ -3275,31 +3275,31 @@ abstract class Product implements ActiveRecordInterface } /** - * Clears out the collImages collection + * Clears out the collProdutImages collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addImages() + * @see addProdutImages() */ - public function clearImages() + public function clearProdutImages() { - $this->collImages = null; // important to set this to NULL since that means it is uninitialized + $this->collProdutImages = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collImages collection loaded partially. + * Reset is the collProdutImages collection loaded partially. */ - public function resetPartialImages($v = true) + public function resetPartialProdutImages($v = true) { - $this->collImagesPartial = $v; + $this->collProdutImagesPartial = $v; } /** - * Initializes the collImages collection. + * Initializes the collProdutImages collection. * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); + * By default this just sets the collProdutImages collection to an empty array (like clearcollProdutImages()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -3308,17 +3308,17 @@ abstract class Product implements ActiveRecordInterface * * @return void */ - public function initImages($overrideExisting = true) + public function initProdutImages($overrideExisting = true) { - if (null !== $this->collImages && !$overrideExisting) { + if (null !== $this->collProdutImages && !$overrideExisting) { return; } - $this->collImages = new ObjectCollection(); - $this->collImages->setModel('\Thelia\Model\Image'); + $this->collProdutImages = new ObjectCollection(); + $this->collProdutImages->setModel('\Thelia\Model\ProdutImage'); } /** - * Gets an array of ChildImage objects which contain a foreign key that references this object. + * Gets an array of ChildProdutImage objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -3328,109 +3328,109 @@ abstract class Product implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildImage[] List of ChildImage objects + * @return Collection|ChildProdutImage[] List of ChildProdutImage objects * @throws PropelException */ - public function getImages($criteria = null, ConnectionInterface $con = null) + public function getProdutImages($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { + $partial = $this->collProdutImagesPartial && !$this->isNew(); + if (null === $this->collProdutImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProdutImages) { // return empty collection - $this->initImages(); + $this->initProdutImages(); } else { - $collImages = ChildImageQuery::create(null, $criteria) + $collProdutImages = ChildProdutImageQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); + if (false !== $this->collProdutImagesPartial && count($collProdutImages)) { + $this->initProdutImages(false); - foreach ($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); + foreach ($collProdutImages as $obj) { + if (false == $this->collProdutImages->contains($obj)) { + $this->collProdutImages->append($obj); } } - $this->collImagesPartial = true; + $this->collProdutImagesPartial = true; } - $collImages->getInternalIterator()->rewind(); + $collProdutImages->getInternalIterator()->rewind(); - return $collImages; + return $collProdutImages; } - if ($partial && $this->collImages) { - foreach ($this->collImages as $obj) { + if ($partial && $this->collProdutImages) { + foreach ($this->collProdutImages as $obj) { if ($obj->isNew()) { - $collImages[] = $obj; + $collProdutImages[] = $obj; } } } - $this->collImages = $collImages; - $this->collImagesPartial = false; + $this->collProdutImages = $collProdutImages; + $this->collProdutImagesPartial = false; } } - return $this->collImages; + return $this->collProdutImages; } /** - * Sets a collection of Image objects related by a one-to-many relationship + * Sets a collection of ProdutImage objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $images A Propel collection. + * @param Collection $produtImages A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildProduct The current object (for fluent API support) */ - public function setImages(Collection $images, ConnectionInterface $con = null) + public function setProdutImages(Collection $produtImages, ConnectionInterface $con = null) { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); + $produtImagesToDelete = $this->getProdutImages(new Criteria(), $con)->diff($produtImages); - $this->imagesScheduledForDeletion = $imagesToDelete; + $this->produtImagesScheduledForDeletion = $produtImagesToDelete; - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setProduct(null); + foreach ($produtImagesToDelete as $produtImageRemoved) { + $produtImageRemoved->setProduct(null); } - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); + $this->collProdutImages = null; + foreach ($produtImages as $produtImage) { + $this->addProdutImage($produtImage); } - $this->collImages = $images; - $this->collImagesPartial = false; + $this->collProdutImages = $produtImages; + $this->collProdutImagesPartial = false; return $this; } /** - * Returns the number of related Image objects. + * Returns the number of related ProdutImage objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related Image objects. + * @return int Count of related ProdutImage objects. * @throws PropelException */ - public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProdutImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { + $partial = $this->collProdutImagesPartial && !$this->isNew(); + if (null === $this->collProdutImages || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProdutImages) { return 0; } if ($partial && !$criteria) { - return count($this->getImages()); + return count($this->getProdutImages()); } - $query = ChildImageQuery::create(null, $criteria); + $query = ChildProdutImageQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3440,159 +3440,84 @@ abstract class Product implements ActiveRecordInterface ->count($con); } - return count($this->collImages); + return count($this->collProdutImages); } /** - * Method called to associate a ChildImage object to this object - * through the ChildImage foreign key attribute. + * Method called to associate a ChildProdutImage object to this object + * through the ChildProdutImage foreign key attribute. * - * @param ChildImage $l ChildImage + * @param ChildProdutImage $l ChildProdutImage * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addImage(ChildImage $l) + public function addProdutImage(ChildProdutImage $l) { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; + if ($this->collProdutImages === null) { + $this->initProdutImages(); + $this->collProdutImagesPartial = true; } - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); + if (!in_array($l, $this->collProdutImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProdutImage($l); } return $this; } /** - * @param Image $image The image object to add. + * @param ProdutImage $produtImage The produtImage object to add. */ - protected function doAddImage($image) + protected function doAddProdutImage($produtImage) { - $this->collImages[]= $image; - $image->setProduct($this); + $this->collProdutImages[]= $produtImage; + $produtImage->setProduct($this); } /** - * @param Image $image The image object to remove. + * @param ProdutImage $produtImage The produtImage object to remove. * @return ChildProduct The current object (for fluent API support) */ - public function removeImage($image) + public function removeProdutImage($produtImage) { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); + if ($this->getProdutImages()->contains($produtImage)) { + $this->collProdutImages->remove($this->collProdutImages->search($produtImage)); + if (null === $this->produtImagesScheduledForDeletion) { + $this->produtImagesScheduledForDeletion = clone $this->collProdutImages; + $this->produtImagesScheduledForDeletion->clear(); } - $this->imagesScheduledForDeletion[]= $image; - $image->setProduct(null); + $this->produtImagesScheduledForDeletion[]= clone $produtImage; + $produtImage->setProduct(null); } return $this; } - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildImage[] List of ChildImage objects - */ - public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildImageQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection + * Clears out the collProductDocuments collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addDocuments() + * @see addProductDocuments() */ - public function clearDocuments() + public function clearProductDocuments() { - $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized + $this->collProductDocuments = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collDocuments collection loaded partially. + * Reset is the collProductDocuments collection loaded partially. */ - public function resetPartialDocuments($v = true) + public function resetPartialProductDocuments($v = true) { - $this->collDocumentsPartial = $v; + $this->collProductDocumentsPartial = $v; } /** - * Initializes the collDocuments collection. + * Initializes the collProductDocuments collection. * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); + * By default this just sets the collProductDocuments collection to an empty array (like clearcollProductDocuments()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -3601,17 +3526,17 @@ abstract class Product implements ActiveRecordInterface * * @return void */ - public function initDocuments($overrideExisting = true) + public function initProductDocuments($overrideExisting = true) { - if (null !== $this->collDocuments && !$overrideExisting) { + if (null !== $this->collProductDocuments && !$overrideExisting) { return; } - $this->collDocuments = new ObjectCollection(); - $this->collDocuments->setModel('\Thelia\Model\Document'); + $this->collProductDocuments = new ObjectCollection(); + $this->collProductDocuments->setModel('\Thelia\Model\ProductDocument'); } /** - * Gets an array of ChildDocument objects which contain a foreign key that references this object. + * Gets an array of ChildProductDocument objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -3621,109 +3546,109 @@ abstract class Product implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDocument[] List of ChildDocument objects + * @return Collection|ChildProductDocument[] List of ChildProductDocument objects * @throws PropelException */ - public function getDocuments($criteria = null, ConnectionInterface $con = null) + public function getProductDocuments($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { + $partial = $this->collProductDocumentsPartial && !$this->isNew(); + if (null === $this->collProductDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductDocuments) { // return empty collection - $this->initDocuments(); + $this->initProductDocuments(); } else { - $collDocuments = ChildDocumentQuery::create(null, $criteria) + $collProductDocuments = ChildProductDocumentQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); + if (false !== $this->collProductDocumentsPartial && count($collProductDocuments)) { + $this->initProductDocuments(false); - foreach ($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); + foreach ($collProductDocuments as $obj) { + if (false == $this->collProductDocuments->contains($obj)) { + $this->collProductDocuments->append($obj); } } - $this->collDocumentsPartial = true; + $this->collProductDocumentsPartial = true; } - $collDocuments->getInternalIterator()->rewind(); + $collProductDocuments->getInternalIterator()->rewind(); - return $collDocuments; + return $collProductDocuments; } - if ($partial && $this->collDocuments) { - foreach ($this->collDocuments as $obj) { + if ($partial && $this->collProductDocuments) { + foreach ($this->collProductDocuments as $obj) { if ($obj->isNew()) { - $collDocuments[] = $obj; + $collProductDocuments[] = $obj; } } } - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; + $this->collProductDocuments = $collProductDocuments; + $this->collProductDocumentsPartial = false; } } - return $this->collDocuments; + return $this->collProductDocuments; } /** - * Sets a collection of Document objects related by a one-to-many relationship + * Sets a collection of ProductDocument objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $documents A Propel collection. + * @param Collection $productDocuments A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildProduct The current object (for fluent API support) */ - public function setDocuments(Collection $documents, ConnectionInterface $con = null) + public function setProductDocuments(Collection $productDocuments, ConnectionInterface $con = null) { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); + $productDocumentsToDelete = $this->getProductDocuments(new Criteria(), $con)->diff($productDocuments); - $this->documentsScheduledForDeletion = $documentsToDelete; + $this->productDocumentsScheduledForDeletion = $productDocumentsToDelete; - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setProduct(null); + foreach ($productDocumentsToDelete as $productDocumentRemoved) { + $productDocumentRemoved->setProduct(null); } - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); + $this->collProductDocuments = null; + foreach ($productDocuments as $productDocument) { + $this->addProductDocument($productDocument); } - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; + $this->collProductDocuments = $productDocuments; + $this->collProductDocumentsPartial = false; return $this; } /** - * Returns the number of related Document objects. + * Returns the number of related ProductDocument objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related Document objects. + * @return int Count of related ProductDocument objects. * @throws PropelException */ - public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProductDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { + $partial = $this->collProductDocumentsPartial && !$this->isNew(); + if (null === $this->collProductDocuments || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductDocuments) { return 0; } if ($partial && !$criteria) { - return count($this->getDocuments()); + return count($this->getProductDocuments()); } - $query = ChildDocumentQuery::create(null, $criteria); + $query = ChildProductDocumentQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3733,133 +3658,58 @@ abstract class Product implements ActiveRecordInterface ->count($con); } - return count($this->collDocuments); + return count($this->collProductDocuments); } /** - * Method called to associate a ChildDocument object to this object - * through the ChildDocument foreign key attribute. + * Method called to associate a ChildProductDocument object to this object + * through the ChildProductDocument foreign key attribute. * - * @param ChildDocument $l ChildDocument + * @param ChildProductDocument $l ChildProductDocument * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addDocument(ChildDocument $l) + public function addProductDocument(ChildProductDocument $l) { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; + if ($this->collProductDocuments === null) { + $this->initProductDocuments(); + $this->collProductDocumentsPartial = true; } - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); + if (!in_array($l, $this->collProductDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProductDocument($l); } return $this; } /** - * @param Document $document The document object to add. + * @param ProductDocument $productDocument The productDocument object to add. */ - protected function doAddDocument($document) + protected function doAddProductDocument($productDocument) { - $this->collDocuments[]= $document; - $document->setProduct($this); + $this->collProductDocuments[]= $productDocument; + $productDocument->setProduct($this); } /** - * @param Document $document The document object to remove. + * @param ProductDocument $productDocument The productDocument object to remove. * @return ChildProduct The current object (for fluent API support) */ - public function removeDocument($document) + public function removeProductDocument($productDocument) { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); + if ($this->getProductDocuments()->contains($productDocument)) { + $this->collProductDocuments->remove($this->collProductDocuments->search($productDocument)); + if (null === $this->productDocumentsScheduledForDeletion) { + $this->productDocumentsScheduledForDeletion = clone $this->collProductDocuments; + $this->productDocumentsScheduledForDeletion->clear(); } - $this->documentsScheduledForDeletion[]= $document; - $document->setProduct(null); + $this->productDocumentsScheduledForDeletion[]= clone $productDocument; + $productDocument->setProduct(null); } return $this; } - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Category', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Content', $joinBehavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildDocument[] List of ChildDocument objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildDocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $joinBehavior); - - return $this->getDocuments($query, $con); - } - /** * Clears out the collAccessoriesRelatedByProductId collection * @@ -5907,13 +5757,13 @@ abstract class Product implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collImages) { - foreach ($this->collImages as $o) { + if ($this->collProdutImages) { + foreach ($this->collProdutImages as $o) { $o->clearAllReferences($deep); } } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { + if ($this->collProductDocuments) { + foreach ($this->collProductDocuments as $o) { $o->clearAllReferences($deep); } } @@ -5984,14 +5834,14 @@ abstract class Product implements ActiveRecordInterface $this->collContentAssocs->clearIterator(); } $this->collContentAssocs = null; - if ($this->collImages instanceof Collection) { - $this->collImages->clearIterator(); + if ($this->collProdutImages instanceof Collection) { + $this->collProdutImages->clearIterator(); } - $this->collImages = null; - if ($this->collDocuments instanceof Collection) { - $this->collDocuments->clearIterator(); + $this->collProdutImages = null; + if ($this->collProductDocuments instanceof Collection) { + $this->collProductDocuments->clearIterator(); } - $this->collDocuments = null; + $this->collProductDocuments = null; if ($this->collAccessoriesRelatedByProductId instanceof Collection) { $this->collAccessoriesRelatedByProductId->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ProductDocument.php b/core/lib/Thelia/Model/Base/ProductDocument.php new file mode 100644 index 000000000..58c9999ed --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductDocument.php @@ -0,0 +1,1990 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProductDocument instance. If + * obj is an instance of ProductDocument, delegates to + * equals(ProductDocument). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProductDocument The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProductDocument The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [product_id] column value. + * + * @return int + */ + public function getProductId() + { + + return $this->product_id; + } + + /** + * Get the [file] column value. + * + * @return string + */ + public function getFile() + { + + return $this->file; + } + + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProductDocumentTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[] = ProductDocumentTableMap::PRODUCT_ID; + } + + if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { + $this->aProduct = null; + } + + + return $this; + } // setProductId() + + /** + * Set the value of [file] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + */ + public function setFile($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->file !== $v) { + $this->file = $v; + $this->modifiedColumns[] = ProductDocumentTableMap::FILE; + } + + + return $this; + } // setFile() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = ProductDocumentTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProductDocumentTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProductDocumentTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductDocumentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductDocumentTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductDocumentTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductDocumentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductDocumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductDocumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ProductDocumentTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProductDocument object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { + $this->aProduct = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductDocumentTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProductDocumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProduct = null; + $this->collProductDocumentI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProductDocument::setDeleted() + * @see ProductDocument::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProductDocumentQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProductDocumentTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProductDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProductDocumentTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProductDocumentTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProduct !== null) { + if ($this->aProduct->isModified() || $this->aProduct->isNew()) { + $affectedRows += $this->aProduct->save($con); + } + $this->setProduct($this->aProduct); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->productDocumentI18nsScheduledForDeletion !== null) { + if (!$this->productDocumentI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductDocumentI18nQuery::create() + ->filterByPrimaryKeys($this->productDocumentI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->productDocumentI18nsScheduledForDeletion = null; + } + } + + if ($this->collProductDocumentI18ns !== null) { + foreach ($this->collProductDocumentI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ProductDocumentTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductDocumentTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProductDocumentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProductDocumentTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(ProductDocumentTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; + } + if ($this->isColumnModified(ProductDocumentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(ProductDocumentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ProductDocumentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO product_document (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'PRODUCT_ID': + $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); + break; + case 'FILE': + $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); + break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getProductId(); + break; + case 2: + return $this->getFile(); + break; + case 3: + return $this->getPosition(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProductDocument'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProductDocument'][$this->getPrimaryKey()] = true; + $keys = ProductDocumentTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getProductId(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProduct) { + $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collProductDocumentI18ns) { + $result['ProductDocumentI18ns'] = $this->collProductDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductDocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setProductId($value); + break; + case 2: + $this->setFile($value); + break; + case 3: + $this->setPosition($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProductDocumentTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProductDocumentTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProductDocumentTableMap::ID)) $criteria->add(ProductDocumentTableMap::ID, $this->id); + if ($this->isColumnModified(ProductDocumentTableMap::PRODUCT_ID)) $criteria->add(ProductDocumentTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ProductDocumentTableMap::FILE)) $criteria->add(ProductDocumentTableMap::FILE, $this->file); + if ($this->isColumnModified(ProductDocumentTableMap::POSITION)) $criteria->add(ProductDocumentTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProductDocumentTableMap::CREATED_AT)) $criteria->add(ProductDocumentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductDocumentTableMap::UPDATED_AT)) $criteria->add(ProductDocumentTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProductDocumentTableMap::DATABASE_NAME); + $criteria->add(ProductDocumentTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ProductDocument (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setProductId($this->getProductId()); + $copyObj->setFile($this->getFile()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getProductDocumentI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProductDocumentI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProductDocument Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $v = null) + { + if ($v === null) { + $this->setProductId(NULL); + } else { + $this->setProductId($v->getId()); + } + + $this->aProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addProductDocument($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProduct->addProductDocuments($this); + */ + } + + return $this->aProduct; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('ProductDocumentI18n' == $relationName) { + return $this->initProductDocumentI18ns(); + } + } + + /** + * Clears out the collProductDocumentI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProductDocumentI18ns() + */ + public function clearProductDocumentI18ns() + { + $this->collProductDocumentI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProductDocumentI18ns collection loaded partially. + */ + public function resetPartialProductDocumentI18ns($v = true) + { + $this->collProductDocumentI18nsPartial = $v; + } + + /** + * Initializes the collProductDocumentI18ns collection. + * + * By default this just sets the collProductDocumentI18ns collection to an empty array (like clearcollProductDocumentI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProductDocumentI18ns($overrideExisting = true) + { + if (null !== $this->collProductDocumentI18ns && !$overrideExisting) { + return; + } + $this->collProductDocumentI18ns = new ObjectCollection(); + $this->collProductDocumentI18ns->setModel('\Thelia\Model\ProductDocumentI18n'); + } + + /** + * Gets an array of ChildProductDocumentI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProductDocument is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductDocumentI18n[] List of ChildProductDocumentI18n objects + * @throws PropelException + */ + public function getProductDocumentI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProductDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collProductDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductDocumentI18ns) { + // return empty collection + $this->initProductDocumentI18ns(); + } else { + $collProductDocumentI18ns = ChildProductDocumentI18nQuery::create(null, $criteria) + ->filterByProductDocument($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProductDocumentI18nsPartial && count($collProductDocumentI18ns)) { + $this->initProductDocumentI18ns(false); + + foreach ($collProductDocumentI18ns as $obj) { + if (false == $this->collProductDocumentI18ns->contains($obj)) { + $this->collProductDocumentI18ns->append($obj); + } + } + + $this->collProductDocumentI18nsPartial = true; + } + + $collProductDocumentI18ns->getInternalIterator()->rewind(); + + return $collProductDocumentI18ns; + } + + if ($partial && $this->collProductDocumentI18ns) { + foreach ($this->collProductDocumentI18ns as $obj) { + if ($obj->isNew()) { + $collProductDocumentI18ns[] = $obj; + } + } + } + + $this->collProductDocumentI18ns = $collProductDocumentI18ns; + $this->collProductDocumentI18nsPartial = false; + } + } + + return $this->collProductDocumentI18ns; + } + + /** + * Sets a collection of ProductDocumentI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $productDocumentI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProductDocument The current object (for fluent API support) + */ + public function setProductDocumentI18ns(Collection $productDocumentI18ns, ConnectionInterface $con = null) + { + $productDocumentI18nsToDelete = $this->getProductDocumentI18ns(new Criteria(), $con)->diff($productDocumentI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->productDocumentI18nsScheduledForDeletion = clone $productDocumentI18nsToDelete; + + foreach ($productDocumentI18nsToDelete as $productDocumentI18nRemoved) { + $productDocumentI18nRemoved->setProductDocument(null); + } + + $this->collProductDocumentI18ns = null; + foreach ($productDocumentI18ns as $productDocumentI18n) { + $this->addProductDocumentI18n($productDocumentI18n); + } + + $this->collProductDocumentI18ns = $productDocumentI18ns; + $this->collProductDocumentI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related ProductDocumentI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProductDocumentI18n objects. + * @throws PropelException + */ + public function countProductDocumentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProductDocumentI18nsPartial && !$this->isNew(); + if (null === $this->collProductDocumentI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductDocumentI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProductDocumentI18ns()); + } + + $query = ChildProductDocumentI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProductDocument($this) + ->count($con); + } + + return count($this->collProductDocumentI18ns); + } + + /** + * Method called to associate a ChildProductDocumentI18n object to this object + * through the ChildProductDocumentI18n foreign key attribute. + * + * @param ChildProductDocumentI18n $l ChildProductDocumentI18n + * @return \Thelia\Model\ProductDocument The current object (for fluent API support) + */ + public function addProductDocumentI18n(ChildProductDocumentI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collProductDocumentI18ns === null) { + $this->initProductDocumentI18ns(); + $this->collProductDocumentI18nsPartial = true; + } + + if (!in_array($l, $this->collProductDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProductDocumentI18n($l); + } + + return $this; + } + + /** + * @param ProductDocumentI18n $productDocumentI18n The productDocumentI18n object to add. + */ + protected function doAddProductDocumentI18n($productDocumentI18n) + { + $this->collProductDocumentI18ns[]= $productDocumentI18n; + $productDocumentI18n->setProductDocument($this); + } + + /** + * @param ProductDocumentI18n $productDocumentI18n The productDocumentI18n object to remove. + * @return ChildProductDocument The current object (for fluent API support) + */ + public function removeProductDocumentI18n($productDocumentI18n) + { + if ($this->getProductDocumentI18ns()->contains($productDocumentI18n)) { + $this->collProductDocumentI18ns->remove($this->collProductDocumentI18ns->search($productDocumentI18n)); + if (null === $this->productDocumentI18nsScheduledForDeletion) { + $this->productDocumentI18nsScheduledForDeletion = clone $this->collProductDocumentI18ns; + $this->productDocumentI18nsScheduledForDeletion->clear(); + } + $this->productDocumentI18nsScheduledForDeletion[]= clone $productDocumentI18n; + $productDocumentI18n->setProductDocument(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->product_id = null; + $this->file = null; + $this->position = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collProductDocumentI18ns) { + foreach ($this->collProductDocumentI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collProductDocumentI18ns instanceof Collection) { + $this->collProductDocumentI18ns->clearIterator(); + } + $this->collProductDocumentI18ns = null; + $this->aProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProductDocumentTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildProductDocument The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProductDocumentTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildProductDocument The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProductDocumentI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collProductDocumentI18ns) { + foreach ($this->collProductDocumentI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildProductDocumentI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildProductDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addProductDocumentI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProductDocument The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildProductDocumentI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collProductDocumentI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collProductDocumentI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProductDocumentI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php new file mode 100644 index 000000000..2c5ca4d0c --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ProductDocumentI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProductDocumentI18n instance. If + * obj is an instance of ProductDocumentI18n, delegates to + * equals(ProductDocumentI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProductDocumentI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProductDocumentI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProductDocumentI18nTableMap::ID; + } + + if ($this->aProductDocument !== null && $this->aProductDocument->getId() !== $v) { + $this->aProductDocument = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ProductDocumentI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ProductDocumentI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ProductDocumentI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ProductDocumentI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ProductDocumentI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductDocumentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductDocumentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductDocumentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductDocumentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductDocumentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductDocumentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ProductDocumentI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProductDocumentI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProductDocument !== null && $this->id !== $this->aProductDocument->getId()) { + $this->aProductDocument = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProductDocumentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProductDocument = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProductDocumentI18n::setDeleted() + * @see ProductDocumentI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProductDocumentI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProductDocumentI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProductDocument !== null) { + if ($this->aProductDocument->isModified() || $this->aProductDocument->isNew()) { + $affectedRows += $this->aProductDocument->save($con); + } + $this->setProductDocument($this->aProductDocument); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProductDocumentI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProductDocumentI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ProductDocumentI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ProductDocumentI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ProductDocumentI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ProductDocumentI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO product_document_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProductDocumentI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProductDocumentI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ProductDocumentI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProductDocument) { + $result['ProductDocument'] = $this->aProductDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductDocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProductDocumentI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProductDocumentI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProductDocumentI18nTableMap::ID)) $criteria->add(ProductDocumentI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ProductDocumentI18nTableMap::LOCALE)) $criteria->add(ProductDocumentI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ProductDocumentI18nTableMap::TITLE)) $criteria->add(ProductDocumentI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ProductDocumentI18nTableMap::DESCRIPTION)) $criteria->add(ProductDocumentI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ProductDocumentI18nTableMap::CHAPO)) $criteria->add(ProductDocumentI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ProductDocumentI18nTableMap::POSTSCRIPTUM)) $criteria->add(ProductDocumentI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProductDocumentI18nTableMap::DATABASE_NAME); + $criteria->add(ProductDocumentI18nTableMap::ID, $this->id); + $criteria->add(ProductDocumentI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ProductDocumentI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProductDocumentI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProductDocument object. + * + * @param ChildProductDocument $v + * @return \Thelia\Model\ProductDocumentI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setProductDocument(ChildProductDocument $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aProductDocument = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProductDocument object, it will not be re-added. + if ($v !== null) { + $v->addProductDocumentI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProductDocument object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProductDocument The associated ChildProductDocument object. + * @throws PropelException + */ + public function getProductDocument(ConnectionInterface $con = null) + { + if ($this->aProductDocument === null && ($this->id !== null)) { + $this->aProductDocument = ChildProductDocumentQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProductDocument->addProductDocumentI18ns($this); + */ + } + + return $this->aProductDocument; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProductDocument = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProductDocumentI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProductDocumentI18nQuery.php b/core/lib/Thelia/Model/Base/ProductDocumentI18nQuery.php new file mode 100644 index 000000000..5bd94d297 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductDocumentI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProductDocumentI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProductDocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductDocumentI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM product_document_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProductDocumentI18n(); + $obj->hydrate($row); + ProductDocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductDocumentI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(ProductDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProductDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(ProductDocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProductDocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByProductDocument() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProductDocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProductDocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductDocumentI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductDocumentI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductDocumentI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductDocumentI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductDocumentI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductDocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\ProductDocument object + * + * @param \Thelia\Model\ProductDocument|ObjectCollection $productDocument The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function filterByProductDocument($productDocument, $comparison = null) + { + if ($productDocument instanceof \Thelia\Model\ProductDocument) { + return $this + ->addUsingAlias(ProductDocumentI18nTableMap::ID, $productDocument->getId(), $comparison); + } elseif ($productDocument instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProductDocumentI18nTableMap::ID, $productDocument->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProductDocument() only accepts arguments of type \Thelia\Model\ProductDocument or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductDocument relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function joinProductDocument($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductDocument'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductDocument'); + } + + return $this; + } + + /** + * Use the ProductDocument relation ProductDocument object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductDocumentQuery A secondary query class using the current class as primary query + */ + public function useProductDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinProductDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductDocument', '\Thelia\Model\ProductDocumentQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProductDocumentI18n $productDocumentI18n Object to remove from the list of results + * + * @return ChildProductDocumentI18nQuery The current query, for fluid interface + */ + public function prune($productDocumentI18n = null) + { + if ($productDocumentI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(ProductDocumentI18nTableMap::ID), $productDocumentI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProductDocumentI18nTableMap::LOCALE), $productDocumentI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the product_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductDocumentI18nTableMap::clearInstancePool(); + ProductDocumentI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProductDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProductDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductDocumentI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProductDocumentI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductDocumentI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ProductDocumentI18nQuery diff --git a/core/lib/Thelia/Model/Base/ProductDocumentQuery.php b/core/lib/Thelia/Model/Base/ProductDocumentQuery.php new file mode 100644 index 000000000..06af05a9c --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductDocumentQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProductDocument|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProductDocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProductDocumentTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductDocument A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PRODUCT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM product_document WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProductDocument(); + $obj->hydrate($row); + ProductDocumentTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProductDocument|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ProductDocumentTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ProductDocumentTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProductDocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProductDocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductDocumentTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the product_id column + * + * Example usage: + * + * $query->filterByProductId(1234); // WHERE product_id = 1234 + * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * + * + * @see filterByProduct() + * + * @param mixed $productId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByProductId($productId = null, $comparison = null) + { + if (is_array($productId)) { + $useMinMax = false; + if (isset($productId['min'])) { + $this->addUsingAlias(ProductDocumentTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($productId['max'])) { + $this->addUsingAlias(ProductDocumentTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductDocumentTableMap::PRODUCT_ID, $productId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductDocumentTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(ProductDocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(ProductDocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductDocumentTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProductDocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProductDocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductDocumentTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProductDocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProductDocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProductDocumentTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Product object + * + * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByProduct($product, $comparison = null) + { + if ($product instanceof \Thelia\Model\Product) { + return $this + ->addUsingAlias(ProductDocumentTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProductDocumentTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Product relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Product'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Product'); + } + + return $this; + } + + /** + * Use the Product relation Product object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query + */ + public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ProductDocumentI18n object + * + * @param \Thelia\Model\ProductDocumentI18n|ObjectCollection $productDocumentI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function filterByProductDocumentI18n($productDocumentI18n, $comparison = null) + { + if ($productDocumentI18n instanceof \Thelia\Model\ProductDocumentI18n) { + return $this + ->addUsingAlias(ProductDocumentTableMap::ID, $productDocumentI18n->getId(), $comparison); + } elseif ($productDocumentI18n instanceof ObjectCollection) { + return $this + ->useProductDocumentI18nQuery() + ->filterByPrimaryKeys($productDocumentI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProductDocumentI18n() only accepts arguments of type \Thelia\Model\ProductDocumentI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProductDocumentI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function joinProductDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProductDocumentI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProductDocumentI18n'); + } + + return $this; + } + + /** + * Use the ProductDocumentI18n relation ProductDocumentI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useProductDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinProductDocumentI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductDocumentI18n', '\Thelia\Model\ProductDocumentI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProductDocument $productDocument Object to remove from the list of results + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function prune($productDocument = null) + { + if ($productDocument) { + $this->addUsingAlias(ProductDocumentTableMap::ID, $productDocument->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the product_document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductDocumentTableMap::clearInstancePool(); + ProductDocumentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProductDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProductDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductDocumentTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProductDocumentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductDocumentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProductDocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProductDocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductDocumentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductDocumentTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProductDocumentTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProductDocumentTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'ProductDocumentI18n'; + + return $this + ->joinProductDocumentI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProductDocumentQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('ProductDocumentI18n'); + $this->with['ProductDocumentI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProductDocumentI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductDocumentI18n', '\Thelia\Model\ProductDocumentI18nQuery'); + } + +} // ProductDocumentQuery diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 37371c4b0..3b3ca6309 100644 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -68,13 +68,13 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation * @method ChildProductQuery innerJoinContentAssoc($relationAlias = null) Adds a INNER JOIN clause to the query using the ContentAssoc relation * - * @method ChildProductQuery leftJoinImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the Image relation - * @method ChildProductQuery rightJoinImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Image relation - * @method ChildProductQuery innerJoinImage($relationAlias = null) Adds a INNER JOIN clause to the query using the Image relation + * @method ChildProductQuery leftJoinProdutImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProdutImage relation + * @method ChildProductQuery rightJoinProdutImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProdutImage relation + * @method ChildProductQuery innerJoinProdutImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ProdutImage relation * - * @method ChildProductQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method ChildProductQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method ChildProductQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation + * @method ChildProductQuery leftJoinProductDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductDocument relation + * @method ChildProductQuery rightJoinProductDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductDocument relation + * @method ChildProductQuery innerJoinProductDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductDocument relation * * @method ChildProductQuery leftJoinAccessoryRelatedByProductId($relationAlias = null) Adds a LEFT JOIN clause to the query using the AccessoryRelatedByProductId relation * @method ChildProductQuery rightJoinAccessoryRelatedByProductId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AccessoryRelatedByProductId relation @@ -1070,40 +1070,40 @@ abstract class ProductQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Image object + * Filter the query by a related \Thelia\Model\ProdutImage object * - * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter + * @param \Thelia\Model\ProdutImage|ObjectCollection $produtImage the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProductQuery The current query, for fluid interface */ - public function filterByImage($image, $comparison = null) + public function filterByProdutImage($produtImage, $comparison = null) { - if ($image instanceof \Thelia\Model\Image) { + if ($produtImage instanceof \Thelia\Model\ProdutImage) { return $this - ->addUsingAlias(ProductTableMap::ID, $image->getProductId(), $comparison); - } elseif ($image instanceof ObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $produtImage->getProductId(), $comparison); + } elseif ($produtImage instanceof ObjectCollection) { return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) + ->useProdutImageQuery() + ->filterByPrimaryKeys($produtImage->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); + throw new PropelException('filterByProdutImage() only accepts arguments of type \Thelia\Model\ProdutImage or Collection'); } } /** - * Adds a JOIN clause to the query using the Image relation + * Adds a JOIN clause to the query using the ProdutImage relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildProductQuery The current query, for fluid interface */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinProdutImage($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); + $relationMap = $tableMap->getRelation('ProdutImage'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1118,14 +1118,14 @@ abstract class ProductQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Image'); + $this->addJoinObject($join, 'ProdutImage'); } return $this; } /** - * Use the Image relation Image object + * Use the ProdutImage relation ProdutImage object * * @see useQuery() * @@ -1133,50 +1133,50 @@ abstract class ProductQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProdutImageQuery A secondary query class using the current class as primary query */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useProdutImageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); + ->joinProdutImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProdutImage', '\Thelia\Model\ProdutImageQuery'); } /** - * Filter the query by a related \Thelia\Model\Document object + * Filter the query by a related \Thelia\Model\ProductDocument object * - * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter + * @param \Thelia\Model\ProductDocument|ObjectCollection $productDocument the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProductQuery The current query, for fluid interface */ - public function filterByDocument($document, $comparison = null) + public function filterByProductDocument($productDocument, $comparison = null) { - if ($document instanceof \Thelia\Model\Document) { + if ($productDocument instanceof \Thelia\Model\ProductDocument) { return $this - ->addUsingAlias(ProductTableMap::ID, $document->getProductId(), $comparison); - } elseif ($document instanceof ObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $productDocument->getProductId(), $comparison); + } elseif ($productDocument instanceof ObjectCollection) { return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) + ->useProductDocumentQuery() + ->filterByPrimaryKeys($productDocument->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); + throw new PropelException('filterByProductDocument() only accepts arguments of type \Thelia\Model\ProductDocument or Collection'); } } /** - * Adds a JOIN clause to the query using the Document relation + * Adds a JOIN clause to the query using the ProductDocument relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildProductQuery The current query, for fluid interface */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinProductDocument($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); + $relationMap = $tableMap->getRelation('ProductDocument'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1191,14 +1191,14 @@ abstract class ProductQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Document'); + $this->addJoinObject($join, 'ProductDocument'); } return $this; } /** - * Use the Document relation Document object + * Use the ProductDocument relation ProductDocument object * * @see useQuery() * @@ -1206,13 +1206,13 @@ abstract class ProductQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProductDocumentQuery A secondary query class using the current class as primary query */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useProductDocumentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); + ->joinProductDocument($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductDocument', '\Thelia\Model\ProductDocumentQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/Image.php b/core/lib/Thelia/Model/Base/ProdutImage.php similarity index 65% rename from core/lib/Thelia/Model/Base/Image.php rename to core/lib/Thelia/Model/Base/ProdutImage.php index d19b557ab..99a39d319 100644 --- a/core/lib/Thelia/Model/Base/Image.php +++ b/core/lib/Thelia/Model/Base/ProdutImage.php @@ -17,26 +17,20 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; -use Thelia\Model\Category as ChildCategory; -use Thelia\Model\CategoryQuery as ChildCategoryQuery; -use Thelia\Model\Content as ChildContent; -use Thelia\Model\ContentQuery as ChildContentQuery; -use Thelia\Model\Folder as ChildFolder; -use Thelia\Model\FolderQuery as ChildFolderQuery; -use Thelia\Model\Image as ChildImage; -use Thelia\Model\ImageI18n as ChildImageI18n; -use Thelia\Model\ImageI18nQuery as ChildImageI18nQuery; -use Thelia\Model\ImageQuery as ChildImageQuery; use Thelia\Model\Product as ChildProduct; use Thelia\Model\ProductQuery as ChildProductQuery; -use Thelia\Model\Map\ImageTableMap; +use Thelia\Model\ProdutImage as ChildProdutImage; +use Thelia\Model\ProdutImageI18n as ChildProdutImageI18n; +use Thelia\Model\ProdutImageI18nQuery as ChildProdutImageI18nQuery; +use Thelia\Model\ProdutImageQuery as ChildProdutImageQuery; +use Thelia\Model\Map\ProdutImageTableMap; -abstract class Image implements ActiveRecordInterface +abstract class ProdutImage implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\ImageTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\ProdutImageTableMap'; /** @@ -77,24 +71,6 @@ abstract class Image implements ActiveRecordInterface */ protected $product_id; - /** - * The value for the category_id field. - * @var int - */ - protected $category_id; - - /** - * The value for the folder_id field. - * @var int - */ - protected $folder_id; - - /** - * The value for the content_id field. - * @var int - */ - protected $content_id; - /** * The value for the file field. * @var string @@ -125,25 +101,10 @@ abstract class Image implements ActiveRecordInterface protected $aProduct; /** - * @var Category + * @var ObjectCollection|ChildProdutImageI18n[] Collection to store aggregation of ChildProdutImageI18n objects. */ - protected $aCategory; - - /** - * @var Content - */ - protected $aContent; - - /** - * @var Folder - */ - protected $aFolder; - - /** - * @var ObjectCollection|ChildImageI18n[] Collection to store aggregation of ChildImageI18n objects. - */ - protected $collImageI18ns; - protected $collImageI18nsPartial; + protected $collProdutImageI18ns; + protected $collProdutImageI18nsPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -163,7 +124,7 @@ abstract class Image implements ActiveRecordInterface /** * Current translation objects - * @var array[ChildImageI18n] + * @var array[ChildProdutImageI18n] */ protected $currentTranslations; @@ -171,10 +132,10 @@ abstract class Image implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $imageI18nsScheduledForDeletion = null; + protected $produtImageI18nsScheduledForDeletion = null; /** - * Initializes internal state of Thelia\Model\Base\Image object. + * Initializes internal state of Thelia\Model\Base\ProdutImage object. */ public function __construct() { @@ -269,9 +230,9 @@ abstract class Image implements ActiveRecordInterface } /** - * Compares this with another Image instance. If - * obj is an instance of Image, delegates to - * equals(Image). Otherwise, returns false. + * Compares this with another ProdutImage instance. If + * obj is an instance of ProdutImage, delegates to + * equals(ProdutImage). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -352,7 +313,7 @@ abstract class Image implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return Image The current object, for fluid interface + * @return ProdutImage The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -384,7 +345,7 @@ abstract class Image implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return Image The current object, for fluid interface + * @return ProdutImage The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -449,39 +410,6 @@ abstract class Image implements ActiveRecordInterface return $this->product_id; } - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - - return $this->category_id; - } - - /** - * Get the [folder_id] column value. - * - * @return int - */ - public function getFolderId() - { - - return $this->folder_id; - } - - /** - * Get the [content_id] column value. - * - * @return int - */ - public function getContentId() - { - - return $this->content_id; - } - /** * Get the [file] column value. * @@ -548,7 +476,7 @@ abstract class Image implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\Image The current object (for fluent API support) + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) */ public function setId($v) { @@ -558,7 +486,7 @@ abstract class Image implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ImageTableMap::ID; + $this->modifiedColumns[] = ProdutImageTableMap::ID; } @@ -569,7 +497,7 @@ abstract class Image implements ActiveRecordInterface * Set the value of [product_id] column. * * @param int $v new value - * @return \Thelia\Model\Image The current object (for fluent API support) + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) */ public function setProductId($v) { @@ -579,7 +507,7 @@ abstract class Image implements ActiveRecordInterface if ($this->product_id !== $v) { $this->product_id = $v; - $this->modifiedColumns[] = ImageTableMap::PRODUCT_ID; + $this->modifiedColumns[] = ProdutImageTableMap::PRODUCT_ID; } if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { @@ -590,86 +518,11 @@ abstract class Image implements ActiveRecordInterface return $this; } // setProductId() - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Image The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = ImageTableMap::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [folder_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Image The current object (for fluent API support) - */ - public function setFolderId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->folder_id !== $v) { - $this->folder_id = $v; - $this->modifiedColumns[] = ImageTableMap::FOLDER_ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setFolderId() - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return \Thelia\Model\Image The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = ImageTableMap::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - /** * Set the value of [file] column. * * @param string $v new value - * @return \Thelia\Model\Image The current object (for fluent API support) + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) */ public function setFile($v) { @@ -679,7 +532,7 @@ abstract class Image implements ActiveRecordInterface if ($this->file !== $v) { $this->file = $v; - $this->modifiedColumns[] = ImageTableMap::FILE; + $this->modifiedColumns[] = ProdutImageTableMap::FILE; } @@ -690,7 +543,7 @@ abstract class Image implements ActiveRecordInterface * Set the value of [position] column. * * @param int $v new value - * @return \Thelia\Model\Image The current object (for fluent API support) + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) */ public function setPosition($v) { @@ -700,7 +553,7 @@ abstract class Image implements ActiveRecordInterface if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = ImageTableMap::POSITION; + $this->modifiedColumns[] = ProdutImageTableMap::POSITION; } @@ -712,7 +565,7 @@ abstract class Image implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Image The current object (for fluent API support) + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -720,7 +573,7 @@ abstract class Image implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = ImageTableMap::CREATED_AT; + $this->modifiedColumns[] = ProdutImageTableMap::CREATED_AT; } } // if either are not null @@ -733,7 +586,7 @@ abstract class Image implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Image The current object (for fluent API support) + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -741,7 +594,7 @@ abstract class Image implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = ImageTableMap::UPDATED_AT; + $this->modifiedColumns[] = ProdutImageTableMap::UPDATED_AT; } } // if either are not null @@ -786,34 +639,25 @@ abstract class Image implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProdutImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ImageTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProdutImageTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; $this->product_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ImageTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImageTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->folder_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImageTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->content_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProdutImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; $this->file = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProdutImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProdutImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProdutImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -826,10 +670,10 @@ abstract class Image implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 9; // 9 = ImageTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ProdutImageTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Image object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\ProdutImage object", 0, $e); } } @@ -851,15 +695,6 @@ abstract class Image implements ActiveRecordInterface if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { - $this->aFolder = null; - } - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } } // ensureConsistency /** @@ -883,13 +718,13 @@ abstract class Image implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(ImageTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(ProdutImageTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildProdutImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -900,10 +735,7 @@ abstract class Image implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aProduct = null; - $this->aCategory = null; - $this->aContent = null; - $this->aFolder = null; - $this->collImageI18ns = null; + $this->collProdutImageI18ns = null; } // if (deep) } @@ -914,8 +746,8 @@ abstract class Image implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see Image::setDeleted() - * @see Image::isDeleted() + * @see ProdutImage::setDeleted() + * @see ProdutImage::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -924,12 +756,12 @@ abstract class Image implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildImageQuery::create() + $deleteQuery = ChildProdutImageQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -966,7 +798,7 @@ abstract class Image implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -976,16 +808,16 @@ abstract class Image implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(ImageTableMap::CREATED_AT)) { + if (!$this->isColumnModified(ProdutImageTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(ImageTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(ProdutImageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ImageTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ProdutImageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -997,7 +829,7 @@ abstract class Image implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - ImageTableMap::addInstanceToPool($this); + ProdutImageTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1039,27 +871,6 @@ abstract class Image implements ActiveRecordInterface $this->setProduct($this->aProduct); } - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->aFolder !== null) { - if ($this->aFolder->isModified() || $this->aFolder->isNew()) { - $affectedRows += $this->aFolder->save($con); - } - $this->setFolder($this->aFolder); - } - if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1071,17 +882,17 @@ abstract class Image implements ActiveRecordInterface $this->resetModified(); } - if ($this->imageI18nsScheduledForDeletion !== null) { - if (!$this->imageI18nsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ImageI18nQuery::create() - ->filterByPrimaryKeys($this->imageI18nsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->produtImageI18nsScheduledForDeletion !== null) { + if (!$this->produtImageI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProdutImageI18nQuery::create() + ->filterByPrimaryKeys($this->produtImageI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->imageI18nsScheduledForDeletion = null; + $this->produtImageI18nsScheduledForDeletion = null; } } - if ($this->collImageI18ns !== null) { - foreach ($this->collImageI18ns as $referrerFK) { + if ($this->collProdutImageI18ns !== null) { + foreach ($this->collProdutImageI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1108,42 +919,33 @@ abstract class Image implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ImageTableMap::ID; + $this->modifiedColumns[] = ProdutImageTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ImageTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProdutImageTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ImageTableMap::ID)) { + if ($this->isColumnModified(ProdutImageTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ImageTableMap::PRODUCT_ID)) { + if ($this->isColumnModified(ProdutImageTableMap::PRODUCT_ID)) { $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; } - if ($this->isColumnModified(ImageTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; - } - if ($this->isColumnModified(ImageTableMap::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; - } - if ($this->isColumnModified(ImageTableMap::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; - } - if ($this->isColumnModified(ImageTableMap::FILE)) { + if ($this->isColumnModified(ProdutImageTableMap::FILE)) { $modifiedColumns[':p' . $index++] = 'FILE'; } - if ($this->isColumnModified(ImageTableMap::POSITION)) { + if ($this->isColumnModified(ProdutImageTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(ImageTableMap::CREATED_AT)) { + if ($this->isColumnModified(ProdutImageTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ImageTableMap::UPDATED_AT)) { + if ($this->isColumnModified(ProdutImageTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO image (%s) VALUES (%s)', + 'INSERT INTO produt_image (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1158,15 +960,6 @@ abstract class Image implements ActiveRecordInterface case 'PRODUCT_ID': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case 'FOLDER_ID': - $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); - break; - case 'CONTENT_ID': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; case 'FILE': $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); break; @@ -1225,7 +1018,7 @@ abstract class Image implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ProdutImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1248,24 +1041,15 @@ abstract class Image implements ActiveRecordInterface return $this->getProductId(); break; case 2: - return $this->getCategoryId(); - break; - case 3: - return $this->getFolderId(); - break; - case 4: - return $this->getContentId(); - break; - case 5: return $this->getFile(); break; - case 6: + case 3: return $this->getPosition(); break; - case 7: + case 4: return $this->getCreatedAt(); break; - case 8: + case 5: return $this->getUpdatedAt(); break; default: @@ -1291,21 +1075,18 @@ abstract class Image implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['Image'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['ProdutImage'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['Image'][$this->getPrimaryKey()] = true; - $keys = ImageTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['ProdutImage'][$this->getPrimaryKey()] = true; + $keys = ProdutImageTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getProductId(), - $keys[2] => $this->getCategoryId(), - $keys[3] => $this->getFolderId(), - $keys[4] => $this->getContentId(), - $keys[5] => $this->getFile(), - $keys[6] => $this->getPosition(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), + $keys[2] => $this->getFile(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1317,17 +1098,8 @@ abstract class Image implements ActiveRecordInterface if (null !== $this->aProduct) { $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFolder) { - $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collImageI18ns) { - $result['ImageI18ns'] = $this->collImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProdutImageI18ns) { + $result['ProdutImageI18ns'] = $this->collProdutImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1347,7 +1119,7 @@ abstract class Image implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ProdutImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1370,24 +1142,15 @@ abstract class Image implements ActiveRecordInterface $this->setProductId($value); break; case 2: - $this->setCategoryId($value); - break; - case 3: - $this->setFolderId($value); - break; - case 4: - $this->setContentId($value); - break; - case 5: $this->setFile($value); break; - case 6: + case 3: $this->setPosition($value); break; - case 7: + case 4: $this->setCreatedAt($value); break; - case 8: + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1412,17 +1175,14 @@ abstract class Image implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ImageTableMap::getFieldNames($keyType); + $keys = ProdutImageTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1432,17 +1192,14 @@ abstract class Image implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(ImageTableMap::DATABASE_NAME); + $criteria = new Criteria(ProdutImageTableMap::DATABASE_NAME); - if ($this->isColumnModified(ImageTableMap::ID)) $criteria->add(ImageTableMap::ID, $this->id); - if ($this->isColumnModified(ImageTableMap::PRODUCT_ID)) $criteria->add(ImageTableMap::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(ImageTableMap::CATEGORY_ID)) $criteria->add(ImageTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(ImageTableMap::FOLDER_ID)) $criteria->add(ImageTableMap::FOLDER_ID, $this->folder_id); - if ($this->isColumnModified(ImageTableMap::CONTENT_ID)) $criteria->add(ImageTableMap::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(ImageTableMap::FILE)) $criteria->add(ImageTableMap::FILE, $this->file); - if ($this->isColumnModified(ImageTableMap::POSITION)) $criteria->add(ImageTableMap::POSITION, $this->position); - if ($this->isColumnModified(ImageTableMap::CREATED_AT)) $criteria->add(ImageTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ImageTableMap::UPDATED_AT)) $criteria->add(ImageTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(ProdutImageTableMap::ID)) $criteria->add(ProdutImageTableMap::ID, $this->id); + if ($this->isColumnModified(ProdutImageTableMap::PRODUCT_ID)) $criteria->add(ProdutImageTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ProdutImageTableMap::FILE)) $criteria->add(ProdutImageTableMap::FILE, $this->file); + if ($this->isColumnModified(ProdutImageTableMap::POSITION)) $criteria->add(ProdutImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProdutImageTableMap::CREATED_AT)) $criteria->add(ProdutImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProdutImageTableMap::UPDATED_AT)) $criteria->add(ProdutImageTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1457,8 +1214,8 @@ abstract class Image implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(ImageTableMap::DATABASE_NAME); - $criteria->add(ImageTableMap::ID, $this->id); + $criteria = new Criteria(ProdutImageTableMap::DATABASE_NAME); + $criteria->add(ProdutImageTableMap::ID, $this->id); return $criteria; } @@ -1499,7 +1256,7 @@ abstract class Image implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\Image (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\ProdutImage (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -1507,9 +1264,6 @@ abstract class Image implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setProductId($this->getProductId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setFolderId($this->getFolderId()); - $copyObj->setContentId($this->getContentId()); $copyObj->setFile($this->getFile()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); @@ -1520,9 +1274,9 @@ abstract class Image implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getImageI18ns() as $relObj) { + foreach ($this->getProdutImageI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImageI18n($relObj->copy($deepCopy)); + $copyObj->addProdutImageI18n($relObj->copy($deepCopy)); } } @@ -1543,7 +1297,7 @@ abstract class Image implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Image Clone of current object. + * @return \Thelia\Model\ProdutImage Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1560,7 +1314,7 @@ abstract class Image implements ActiveRecordInterface * Declares an association between this object and a ChildProduct object. * * @param ChildProduct $v - * @return \Thelia\Model\Image The current object (for fluent API support) + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) * @throws PropelException */ public function setProduct(ChildProduct $v = null) @@ -1576,7 +1330,7 @@ abstract class Image implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildProduct object, it will not be re-added. if ($v !== null) { - $v->addImage($this); + $v->addProdutImage($this); } @@ -1600,166 +1354,13 @@ abstract class Image implements ActiveRecordInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aProduct->addImages($this); + $this->aProduct->addProdutImages($this); */ } return $this->aProduct; } - /** - * Declares an association between this object and a ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\Image The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addImage($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addImages($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a ChildContent object. - * - * @param ChildContent $v - * @return \Thelia\Model\Image The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(ChildContent $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildContent object, it will not be re-added. - if ($v !== null) { - $v->addImage($this); - } - - - return $this; - } - - - /** - * Get the associated ChildContent object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildContent The associated ChildContent object. - * @throws PropelException - */ - public function getContent(ConnectionInterface $con = null) - { - if ($this->aContent === null && ($this->content_id !== null)) { - $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addImages($this); - */ - } - - return $this->aContent; - } - - /** - * Declares an association between this object and a ChildFolder object. - * - * @param ChildFolder $v - * @return \Thelia\Model\Image The current object (for fluent API support) - * @throws PropelException - */ - public function setFolder(ChildFolder $v = null) - { - if ($v === null) { - $this->setFolderId(NULL); - } else { - $this->setFolderId($v->getId()); - } - - $this->aFolder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildFolder object, it will not be re-added. - if ($v !== null) { - $v->addImage($this); - } - - - return $this; - } - - - /** - * Get the associated ChildFolder object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildFolder The associated ChildFolder object. - * @throws PropelException - */ - public function getFolder(ConnectionInterface $con = null) - { - if ($this->aFolder === null && ($this->folder_id !== null)) { - $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFolder->addImages($this); - */ - } - - return $this->aFolder; - } - /** * Initializes a collection based on the name of a relation. @@ -1771,37 +1372,37 @@ abstract class Image implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('ImageI18n' == $relationName) { - return $this->initImageI18ns(); + if ('ProdutImageI18n' == $relationName) { + return $this->initProdutImageI18ns(); } } /** - * Clears out the collImageI18ns collection + * Clears out the collProdutImageI18ns collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addImageI18ns() + * @see addProdutImageI18ns() */ - public function clearImageI18ns() + public function clearProdutImageI18ns() { - $this->collImageI18ns = null; // important to set this to NULL since that means it is uninitialized + $this->collProdutImageI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collImageI18ns collection loaded partially. + * Reset is the collProdutImageI18ns collection loaded partially. */ - public function resetPartialImageI18ns($v = true) + public function resetPartialProdutImageI18ns($v = true) { - $this->collImageI18nsPartial = $v; + $this->collProdutImageI18nsPartial = $v; } /** - * Initializes the collImageI18ns collection. + * Initializes the collProdutImageI18ns collection. * - * By default this just sets the collImageI18ns collection to an empty array (like clearcollImageI18ns()); + * By default this just sets the collProdutImageI18ns collection to an empty array (like clearcollProdutImageI18ns()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1810,192 +1411,192 @@ abstract class Image implements ActiveRecordInterface * * @return void */ - public function initImageI18ns($overrideExisting = true) + public function initProdutImageI18ns($overrideExisting = true) { - if (null !== $this->collImageI18ns && !$overrideExisting) { + if (null !== $this->collProdutImageI18ns && !$overrideExisting) { return; } - $this->collImageI18ns = new ObjectCollection(); - $this->collImageI18ns->setModel('\Thelia\Model\ImageI18n'); + $this->collProdutImageI18ns = new ObjectCollection(); + $this->collProdutImageI18ns->setModel('\Thelia\Model\ProdutImageI18n'); } /** - * Gets an array of ChildImageI18n objects which contain a foreign key that references this object. + * Gets an array of ChildProdutImageI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildImage is new, it will return + * If this ChildProdutImage is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildImageI18n[] List of ChildImageI18n objects + * @return Collection|ChildProdutImageI18n[] List of ChildProdutImageI18n objects * @throws PropelException */ - public function getImageI18ns($criteria = null, ConnectionInterface $con = null) + public function getProdutImageI18ns($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collImageI18nsPartial && !$this->isNew(); - if (null === $this->collImageI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImageI18ns) { + $partial = $this->collProdutImageI18nsPartial && !$this->isNew(); + if (null === $this->collProdutImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProdutImageI18ns) { // return empty collection - $this->initImageI18ns(); + $this->initProdutImageI18ns(); } else { - $collImageI18ns = ChildImageI18nQuery::create(null, $criteria) - ->filterByImage($this) + $collProdutImageI18ns = ChildProdutImageI18nQuery::create(null, $criteria) + ->filterByProdutImage($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collImageI18nsPartial && count($collImageI18ns)) { - $this->initImageI18ns(false); + if (false !== $this->collProdutImageI18nsPartial && count($collProdutImageI18ns)) { + $this->initProdutImageI18ns(false); - foreach ($collImageI18ns as $obj) { - if (false == $this->collImageI18ns->contains($obj)) { - $this->collImageI18ns->append($obj); + foreach ($collProdutImageI18ns as $obj) { + if (false == $this->collProdutImageI18ns->contains($obj)) { + $this->collProdutImageI18ns->append($obj); } } - $this->collImageI18nsPartial = true; + $this->collProdutImageI18nsPartial = true; } - $collImageI18ns->getInternalIterator()->rewind(); + $collProdutImageI18ns->getInternalIterator()->rewind(); - return $collImageI18ns; + return $collProdutImageI18ns; } - if ($partial && $this->collImageI18ns) { - foreach ($this->collImageI18ns as $obj) { + if ($partial && $this->collProdutImageI18ns) { + foreach ($this->collProdutImageI18ns as $obj) { if ($obj->isNew()) { - $collImageI18ns[] = $obj; + $collProdutImageI18ns[] = $obj; } } } - $this->collImageI18ns = $collImageI18ns; - $this->collImageI18nsPartial = false; + $this->collProdutImageI18ns = $collProdutImageI18ns; + $this->collProdutImageI18nsPartial = false; } } - return $this->collImageI18ns; + return $this->collProdutImageI18ns; } /** - * Sets a collection of ImageI18n objects related by a one-to-many relationship + * Sets a collection of ProdutImageI18n objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $imageI18ns A Propel collection. + * @param Collection $produtImageI18ns A Propel collection. * @param ConnectionInterface $con Optional connection object - * @return ChildImage The current object (for fluent API support) + * @return ChildProdutImage The current object (for fluent API support) */ - public function setImageI18ns(Collection $imageI18ns, ConnectionInterface $con = null) + public function setProdutImageI18ns(Collection $produtImageI18ns, ConnectionInterface $con = null) { - $imageI18nsToDelete = $this->getImageI18ns(new Criteria(), $con)->diff($imageI18ns); + $produtImageI18nsToDelete = $this->getProdutImageI18ns(new Criteria(), $con)->diff($produtImageI18ns); //since at least one column in the foreign key is at the same time a PK //we can not just set a PK to NULL in the lines below. We have to store //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->imageI18nsScheduledForDeletion = clone $imageI18nsToDelete; + $this->produtImageI18nsScheduledForDeletion = clone $produtImageI18nsToDelete; - foreach ($imageI18nsToDelete as $imageI18nRemoved) { - $imageI18nRemoved->setImage(null); + foreach ($produtImageI18nsToDelete as $produtImageI18nRemoved) { + $produtImageI18nRemoved->setProdutImage(null); } - $this->collImageI18ns = null; - foreach ($imageI18ns as $imageI18n) { - $this->addImageI18n($imageI18n); + $this->collProdutImageI18ns = null; + foreach ($produtImageI18ns as $produtImageI18n) { + $this->addProdutImageI18n($produtImageI18n); } - $this->collImageI18ns = $imageI18ns; - $this->collImageI18nsPartial = false; + $this->collProdutImageI18ns = $produtImageI18ns; + $this->collProdutImageI18nsPartial = false; return $this; } /** - * Returns the number of related ImageI18n objects. + * Returns the number of related ProdutImageI18n objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related ImageI18n objects. + * @return int Count of related ProdutImageI18n objects. * @throws PropelException */ - public function countImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProdutImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collImageI18nsPartial && !$this->isNew(); - if (null === $this->collImageI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImageI18ns) { + $partial = $this->collProdutImageI18nsPartial && !$this->isNew(); + if (null === $this->collProdutImageI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProdutImageI18ns) { return 0; } if ($partial && !$criteria) { - return count($this->getImageI18ns()); + return count($this->getProdutImageI18ns()); } - $query = ChildImageI18nQuery::create(null, $criteria); + $query = ChildProdutImageI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query - ->filterByImage($this) + ->filterByProdutImage($this) ->count($con); } - return count($this->collImageI18ns); + return count($this->collProdutImageI18ns); } /** - * Method called to associate a ChildImageI18n object to this object - * through the ChildImageI18n foreign key attribute. + * Method called to associate a ChildProdutImageI18n object to this object + * through the ChildProdutImageI18n foreign key attribute. * - * @param ChildImageI18n $l ChildImageI18n - * @return \Thelia\Model\Image The current object (for fluent API support) + * @param ChildProdutImageI18n $l ChildProdutImageI18n + * @return \Thelia\Model\ProdutImage The current object (for fluent API support) */ - public function addImageI18n(ChildImageI18n $l) + public function addProdutImageI18n(ChildProdutImageI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); $this->currentTranslations[$locale] = $l; } - if ($this->collImageI18ns === null) { - $this->initImageI18ns(); - $this->collImageI18nsPartial = true; + if ($this->collProdutImageI18ns === null) { + $this->initProdutImageI18ns(); + $this->collProdutImageI18nsPartial = true; } - if (!in_array($l, $this->collImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImageI18n($l); + if (!in_array($l, $this->collProdutImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProdutImageI18n($l); } return $this; } /** - * @param ImageI18n $imageI18n The imageI18n object to add. + * @param ProdutImageI18n $produtImageI18n The produtImageI18n object to add. */ - protected function doAddImageI18n($imageI18n) + protected function doAddProdutImageI18n($produtImageI18n) { - $this->collImageI18ns[]= $imageI18n; - $imageI18n->setImage($this); + $this->collProdutImageI18ns[]= $produtImageI18n; + $produtImageI18n->setProdutImage($this); } /** - * @param ImageI18n $imageI18n The imageI18n object to remove. - * @return ChildImage The current object (for fluent API support) + * @param ProdutImageI18n $produtImageI18n The produtImageI18n object to remove. + * @return ChildProdutImage The current object (for fluent API support) */ - public function removeImageI18n($imageI18n) + public function removeProdutImageI18n($produtImageI18n) { - if ($this->getImageI18ns()->contains($imageI18n)) { - $this->collImageI18ns->remove($this->collImageI18ns->search($imageI18n)); - if (null === $this->imageI18nsScheduledForDeletion) { - $this->imageI18nsScheduledForDeletion = clone $this->collImageI18ns; - $this->imageI18nsScheduledForDeletion->clear(); + if ($this->getProdutImageI18ns()->contains($produtImageI18n)) { + $this->collProdutImageI18ns->remove($this->collProdutImageI18ns->search($produtImageI18n)); + if (null === $this->produtImageI18nsScheduledForDeletion) { + $this->produtImageI18nsScheduledForDeletion = clone $this->collProdutImageI18ns; + $this->produtImageI18nsScheduledForDeletion->clear(); } - $this->imageI18nsScheduledForDeletion[]= clone $imageI18n; - $imageI18n->setImage(null); + $this->produtImageI18nsScheduledForDeletion[]= clone $produtImageI18n; + $produtImageI18n->setProdutImage(null); } return $this; @@ -2008,9 +1609,6 @@ abstract class Image implements ActiveRecordInterface { $this->id = null; $this->product_id = null; - $this->category_id = null; - $this->folder_id = null; - $this->content_id = null; $this->file = null; $this->position = null; $this->created_at = null; @@ -2034,8 +1632,8 @@ abstract class Image implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collImageI18ns) { - foreach ($this->collImageI18ns as $o) { + if ($this->collProdutImageI18ns) { + foreach ($this->collProdutImageI18ns as $o) { $o->clearAllReferences($deep); } } @@ -2045,14 +1643,11 @@ abstract class Image implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; - if ($this->collImageI18ns instanceof Collection) { - $this->collImageI18ns->clearIterator(); + if ($this->collProdutImageI18ns instanceof Collection) { + $this->collProdutImageI18ns->clearIterator(); } - $this->collImageI18ns = null; + $this->collProdutImageI18ns = null; $this->aProduct = null; - $this->aCategory = null; - $this->aContent = null; - $this->aFolder = null; } /** @@ -2062,7 +1657,7 @@ abstract class Image implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(ImageTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(ProdutImageTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2070,11 +1665,11 @@ abstract class Image implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildImage The current object (for fluent API support) + * @return ChildProdutImage The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = ImageTableMap::UPDATED_AT; + $this->modifiedColumns[] = ProdutImageTableMap::UPDATED_AT; return $this; } @@ -2086,7 +1681,7 @@ abstract class Image implements ActiveRecordInterface * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return ChildImage The current object (for fluent API support) + * @return ChildProdutImage The current object (for fluent API support) */ public function setLocale($locale = 'en_US') { @@ -2111,12 +1706,12 @@ abstract class Image implements ActiveRecordInterface * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param ConnectionInterface $con an optional connection object * - * @return ChildImageI18n */ + * @return ChildProdutImageI18n */ public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collImageI18ns) { - foreach ($this->collImageI18ns as $translation) { + if (null !== $this->collProdutImageI18ns) { + foreach ($this->collProdutImageI18ns as $translation) { if ($translation->getLocale() == $locale) { $this->currentTranslations[$locale] = $translation; @@ -2125,15 +1720,15 @@ abstract class Image implements ActiveRecordInterface } } if ($this->isNew()) { - $translation = new ChildImageI18n(); + $translation = new ChildProdutImageI18n(); $translation->setLocale($locale); } else { - $translation = ChildImageI18nQuery::create() + $translation = ChildProdutImageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; } - $this->addImageI18n($translation); + $this->addProdutImageI18n($translation); } return $this->currentTranslations[$locale]; @@ -2145,21 +1740,21 @@ abstract class Image implements ActiveRecordInterface * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param ConnectionInterface $con an optional connection object * - * @return ChildImage The current object (for fluent API support) + * @return ChildProdutImage The current object (for fluent API support) */ public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { - ChildImageI18nQuery::create() + ChildProdutImageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } if (isset($this->currentTranslations[$locale])) { unset($this->currentTranslations[$locale]); } - foreach ($this->collImageI18ns as $key => $translation) { + foreach ($this->collProdutImageI18ns as $key => $translation) { if ($translation->getLocale() == $locale) { - unset($this->collImageI18ns[$key]); + unset($this->collProdutImageI18ns[$key]); break; } } @@ -2172,7 +1767,7 @@ abstract class Image implements ActiveRecordInterface * * @param ConnectionInterface $con an optional connection object * - * @return ChildImageI18n */ + * @return ChildProdutImageI18n */ public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); @@ -2194,7 +1789,7 @@ abstract class Image implements ActiveRecordInterface * Set the value of [title] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2218,7 +1813,7 @@ abstract class Image implements ActiveRecordInterface * Set the value of [description] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2242,7 +1837,7 @@ abstract class Image implements ActiveRecordInterface * Set the value of [chapo] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2266,7 +1861,7 @@ abstract class Image implements ActiveRecordInterface * Set the value of [postscriptum] column. * * @param string $v new value - * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); diff --git a/core/lib/Thelia/Model/Base/DocumentI18n.php b/core/lib/Thelia/Model/Base/ProdutImageI18n.php similarity index 84% rename from core/lib/Thelia/Model/Base/DocumentI18n.php rename to core/lib/Thelia/Model/Base/ProdutImageI18n.php index 9c3b7376e..819081db2 100644 --- a/core/lib/Thelia/Model/Base/DocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ProdutImageI18n.php @@ -14,17 +14,17 @@ use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; -use Thelia\Model\Document as ChildDocument; -use Thelia\Model\DocumentI18nQuery as ChildDocumentI18nQuery; -use Thelia\Model\DocumentQuery as ChildDocumentQuery; -use Thelia\Model\Map\DocumentI18nTableMap; +use Thelia\Model\ProdutImage as ChildProdutImage; +use Thelia\Model\ProdutImageI18nQuery as ChildProdutImageI18nQuery; +use Thelia\Model\ProdutImageQuery as ChildProdutImageQuery; +use Thelia\Model\Map\ProdutImageI18nTableMap; -abstract class DocumentI18n implements ActiveRecordInterface +abstract class ProdutImageI18n implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\DocumentI18nTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\ProdutImageI18nTableMap'; /** @@ -91,9 +91,9 @@ abstract class DocumentI18n implements ActiveRecordInterface protected $postscriptum; /** - * @var Document + * @var ProdutImage */ - protected $aDocument; + protected $aProdutImage; /** * Flag to prevent endless save loop, if this object is referenced @@ -115,7 +115,7 @@ abstract class DocumentI18n implements ActiveRecordInterface } /** - * Initializes internal state of Thelia\Model\Base\DocumentI18n object. + * Initializes internal state of Thelia\Model\Base\ProdutImageI18n object. * @see applyDefaults() */ public function __construct() @@ -212,9 +212,9 @@ abstract class DocumentI18n implements ActiveRecordInterface } /** - * Compares this with another DocumentI18n instance. If - * obj is an instance of DocumentI18n, delegates to - * equals(DocumentI18n). Otherwise, returns false. + * Compares this with another ProdutImageI18n instance. If + * obj is an instance of ProdutImageI18n, delegates to + * equals(ProdutImageI18n). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -295,7 +295,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return DocumentI18n The current object, for fluid interface + * @return ProdutImageI18n The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -327,7 +327,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return DocumentI18n The current object, for fluid interface + * @return ProdutImageI18n The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -440,7 +440,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setId($v) { @@ -450,11 +450,11 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = DocumentI18nTableMap::ID; + $this->modifiedColumns[] = ProdutImageI18nTableMap::ID; } - if ($this->aDocument !== null && $this->aDocument->getId() !== $v) { - $this->aDocument = null; + if ($this->aProdutImage !== null && $this->aProdutImage->getId() !== $v) { + $this->aProdutImage = null; } @@ -465,7 +465,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * Set the value of [locale] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setLocale($v) { @@ -475,7 +475,7 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($this->locale !== $v) { $this->locale = $v; - $this->modifiedColumns[] = DocumentI18nTableMap::LOCALE; + $this->modifiedColumns[] = ProdutImageI18nTableMap::LOCALE; } @@ -486,7 +486,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * Set the value of [title] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setTitle($v) { @@ -496,7 +496,7 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($this->title !== $v) { $this->title = $v; - $this->modifiedColumns[] = DocumentI18nTableMap::TITLE; + $this->modifiedColumns[] = ProdutImageI18nTableMap::TITLE; } @@ -507,7 +507,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * Set the value of [description] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setDescription($v) { @@ -517,7 +517,7 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($this->description !== $v) { $this->description = $v; - $this->modifiedColumns[] = DocumentI18nTableMap::DESCRIPTION; + $this->modifiedColumns[] = ProdutImageI18nTableMap::DESCRIPTION; } @@ -528,7 +528,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * Set the value of [chapo] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setChapo($v) { @@ -538,7 +538,7 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($this->chapo !== $v) { $this->chapo = $v; - $this->modifiedColumns[] = DocumentI18nTableMap::CHAPO; + $this->modifiedColumns[] = ProdutImageI18nTableMap::CHAPO; } @@ -549,7 +549,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * Set the value of [postscriptum] column. * * @param string $v new value - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) */ public function setPostscriptum($v) { @@ -559,7 +559,7 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($this->postscriptum !== $v) { $this->postscriptum = $v; - $this->modifiedColumns[] = DocumentI18nTableMap::POSTSCRIPTUM; + $this->modifiedColumns[] = ProdutImageI18nTableMap::POSTSCRIPTUM; } @@ -607,22 +607,22 @@ abstract class DocumentI18n implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DocumentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProdutImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DocumentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProdutImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; $this->locale = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DocumentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProdutImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; $this->title = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DocumentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProdutImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; $this->description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DocumentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProdutImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; $this->chapo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : DocumentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProdutImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; $this->postscriptum = (null !== $col) ? (string) $col : null; $this->resetModified(); @@ -632,10 +632,10 @@ abstract class DocumentI18n implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 6; // 6 = DocumentI18nTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = ProdutImageI18nTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\DocumentI18n object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\ProdutImageI18n object", 0, $e); } } @@ -654,8 +654,8 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function ensureConsistency() { - if ($this->aDocument !== null && $this->id !== $this->aDocument->getId()) { - $this->aDocument = null; + if ($this->aProdutImage !== null && $this->id !== $this->aProdutImage->getId()) { + $this->aProdutImage = null; } } // ensureConsistency @@ -680,13 +680,13 @@ abstract class DocumentI18n implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(ProdutImageI18nTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildDocumentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildProdutImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -696,7 +696,7 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aDocument = null; + $this->aProdutImage = null; } // if (deep) } @@ -706,8 +706,8 @@ abstract class DocumentI18n implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see DocumentI18n::setDeleted() - * @see DocumentI18n::isDeleted() + * @see ProdutImageI18n::setDeleted() + * @see ProdutImageI18n::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -716,12 +716,12 @@ abstract class DocumentI18n implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageI18nTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildDocumentI18nQuery::create() + $deleteQuery = ChildProdutImageI18nQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -758,7 +758,7 @@ abstract class DocumentI18n implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageI18nTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -778,7 +778,7 @@ abstract class DocumentI18n implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - DocumentI18nTableMap::addInstanceToPool($this); + ProdutImageI18nTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -813,11 +813,11 @@ abstract class DocumentI18n implements ActiveRecordInterface // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aDocument !== null) { - if ($this->aDocument->isModified() || $this->aDocument->isNew()) { - $affectedRows += $this->aDocument->save($con); + if ($this->aProdutImage !== null) { + if ($this->aProdutImage->isModified() || $this->aProdutImage->isNew()) { + $affectedRows += $this->aProdutImage->save($con); } - $this->setDocument($this->aDocument); + $this->setProdutImage($this->aProdutImage); } if ($this->isNew() || $this->isModified()) { @@ -853,27 +853,27 @@ abstract class DocumentI18n implements ActiveRecordInterface // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DocumentI18nTableMap::ID)) { + if ($this->isColumnModified(ProdutImageI18nTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(DocumentI18nTableMap::LOCALE)) { + if ($this->isColumnModified(ProdutImageI18nTableMap::LOCALE)) { $modifiedColumns[':p' . $index++] = 'LOCALE'; } - if ($this->isColumnModified(DocumentI18nTableMap::TITLE)) { + if ($this->isColumnModified(ProdutImageI18nTableMap::TITLE)) { $modifiedColumns[':p' . $index++] = 'TITLE'; } - if ($this->isColumnModified(DocumentI18nTableMap::DESCRIPTION)) { + if ($this->isColumnModified(ProdutImageI18nTableMap::DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(DocumentI18nTableMap::CHAPO)) { + if ($this->isColumnModified(ProdutImageI18nTableMap::CHAPO)) { $modifiedColumns[':p' . $index++] = 'CHAPO'; } - if ($this->isColumnModified(DocumentI18nTableMap::POSTSCRIPTUM)) { + if ($this->isColumnModified(ProdutImageI18nTableMap::POSTSCRIPTUM)) { $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } $sql = sprintf( - 'INSERT INTO document_i18n (%s) VALUES (%s)', + 'INSERT INTO produt_image_i18n (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -939,7 +939,7 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = DocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ProdutImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -996,11 +996,11 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['DocumentI18n'][serialize($this->getPrimaryKey())])) { + if (isset($alreadyDumpedObjects['ProdutImageI18n'][serialize($this->getPrimaryKey())])) { return '*RECURSION*'; } - $alreadyDumpedObjects['DocumentI18n'][serialize($this->getPrimaryKey())] = true; - $keys = DocumentI18nTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['ProdutImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ProdutImageI18nTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getLocale(), @@ -1016,8 +1016,8 @@ abstract class DocumentI18n implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aDocument) { - $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aProdutImage) { + $result['ProdutImage'] = $this->aProdutImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } @@ -1037,7 +1037,7 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = DocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ProdutImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1093,7 +1093,7 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = DocumentI18nTableMap::getFieldNames($keyType); + $keys = ProdutImageI18nTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); @@ -1110,14 +1110,14 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(DocumentI18nTableMap::DATABASE_NAME); + $criteria = new Criteria(ProdutImageI18nTableMap::DATABASE_NAME); - if ($this->isColumnModified(DocumentI18nTableMap::ID)) $criteria->add(DocumentI18nTableMap::ID, $this->id); - if ($this->isColumnModified(DocumentI18nTableMap::LOCALE)) $criteria->add(DocumentI18nTableMap::LOCALE, $this->locale); - if ($this->isColumnModified(DocumentI18nTableMap::TITLE)) $criteria->add(DocumentI18nTableMap::TITLE, $this->title); - if ($this->isColumnModified(DocumentI18nTableMap::DESCRIPTION)) $criteria->add(DocumentI18nTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(DocumentI18nTableMap::CHAPO)) $criteria->add(DocumentI18nTableMap::CHAPO, $this->chapo); - if ($this->isColumnModified(DocumentI18nTableMap::POSTSCRIPTUM)) $criteria->add(DocumentI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(ProdutImageI18nTableMap::ID)) $criteria->add(ProdutImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ProdutImageI18nTableMap::LOCALE)) $criteria->add(ProdutImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ProdutImageI18nTableMap::TITLE)) $criteria->add(ProdutImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ProdutImageI18nTableMap::DESCRIPTION)) $criteria->add(ProdutImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ProdutImageI18nTableMap::CHAPO)) $criteria->add(ProdutImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ProdutImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(ProdutImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum); return $criteria; } @@ -1132,9 +1132,9 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(DocumentI18nTableMap::DATABASE_NAME); - $criteria->add(DocumentI18nTableMap::ID, $this->id); - $criteria->add(DocumentI18nTableMap::LOCALE, $this->locale); + $criteria = new Criteria(ProdutImageI18nTableMap::DATABASE_NAME); + $criteria->add(ProdutImageI18nTableMap::ID, $this->id); + $criteria->add(ProdutImageI18nTableMap::LOCALE, $this->locale); return $criteria; } @@ -1181,7 +1181,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\DocumentI18n (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\ProdutImageI18n (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -1208,7 +1208,7 @@ abstract class DocumentI18n implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\DocumentI18n Clone of current object. + * @return \Thelia\Model\ProdutImageI18n Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1222,13 +1222,13 @@ abstract class DocumentI18n implements ActiveRecordInterface } /** - * Declares an association between this object and a ChildDocument object. + * Declares an association between this object and a ChildProdutImage object. * - * @param ChildDocument $v - * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @param ChildProdutImage $v + * @return \Thelia\Model\ProdutImageI18n The current object (for fluent API support) * @throws PropelException */ - public function setDocument(ChildDocument $v = null) + public function setProdutImage(ChildProdutImage $v = null) { if ($v === null) { $this->setId(NULL); @@ -1236,12 +1236,12 @@ abstract class DocumentI18n implements ActiveRecordInterface $this->setId($v->getId()); } - $this->aDocument = $v; + $this->aProdutImage = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildDocument object, it will not be re-added. + // If this object has already been added to the ChildProdutImage object, it will not be re-added. if ($v !== null) { - $v->addDocumentI18n($this); + $v->addProdutImageI18n($this); } @@ -1250,26 +1250,26 @@ abstract class DocumentI18n implements ActiveRecordInterface /** - * Get the associated ChildDocument object + * Get the associated ChildProdutImage object * * @param ConnectionInterface $con Optional Connection object. - * @return ChildDocument The associated ChildDocument object. + * @return ChildProdutImage The associated ChildProdutImage object. * @throws PropelException */ - public function getDocument(ConnectionInterface $con = null) + public function getProdutImage(ConnectionInterface $con = null) { - if ($this->aDocument === null && ($this->id !== null)) { - $this->aDocument = ChildDocumentQuery::create()->findPk($this->id, $con); + if ($this->aProdutImage === null && ($this->id !== null)) { + $this->aProdutImage = ChildProdutImageQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aDocument->addDocumentI18ns($this); + $this->aProdutImage->addProdutImageI18ns($this); */ } - return $this->aDocument; + return $this->aProdutImage; } /** @@ -1305,7 +1305,7 @@ abstract class DocumentI18n implements ActiveRecordInterface if ($deep) { } // if ($deep) - $this->aDocument = null; + $this->aProdutImage = null; } /** @@ -1315,7 +1315,7 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(DocumentI18nTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(ProdutImageI18nTableMap::DEFAULT_STRING_FORMAT); } /** diff --git a/core/lib/Thelia/Model/Base/DocumentI18nQuery.php b/core/lib/Thelia/Model/Base/ProdutImageI18nQuery.php similarity index 62% rename from core/lib/Thelia/Model/Base/DocumentI18nQuery.php rename to core/lib/Thelia/Model/Base/ProdutImageI18nQuery.php index 47b598bf0..438a7d91b 100644 --- a/core/lib/Thelia/Model/Base/DocumentI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ProdutImageI18nQuery.php @@ -12,84 +12,84 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\DocumentI18n as ChildDocumentI18n; -use Thelia\Model\DocumentI18nQuery as ChildDocumentI18nQuery; -use Thelia\Model\Map\DocumentI18nTableMap; +use Thelia\Model\ProdutImageI18n as ChildProdutImageI18n; +use Thelia\Model\ProdutImageI18nQuery as ChildProdutImageI18nQuery; +use Thelia\Model\Map\ProdutImageI18nTableMap; /** - * Base class that represents a query for the 'document_i18n' table. + * Base class that represents a query for the 'produt_image_i18n' table. * * * - * @method ChildDocumentI18nQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildDocumentI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column - * @method ChildDocumentI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column - * @method ChildDocumentI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column - * @method ChildDocumentI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column - * @method ChildDocumentI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column + * @method ChildProdutImageI18nQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildProdutImageI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column + * @method ChildProdutImageI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column + * @method ChildProdutImageI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column + * @method ChildProdutImageI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column + * @method ChildProdutImageI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column * - * @method ChildDocumentI18nQuery groupById() Group by the id column - * @method ChildDocumentI18nQuery groupByLocale() Group by the locale column - * @method ChildDocumentI18nQuery groupByTitle() Group by the title column - * @method ChildDocumentI18nQuery groupByDescription() Group by the description column - * @method ChildDocumentI18nQuery groupByChapo() Group by the chapo column - * @method ChildDocumentI18nQuery groupByPostscriptum() Group by the postscriptum column + * @method ChildProdutImageI18nQuery groupById() Group by the id column + * @method ChildProdutImageI18nQuery groupByLocale() Group by the locale column + * @method ChildProdutImageI18nQuery groupByTitle() Group by the title column + * @method ChildProdutImageI18nQuery groupByDescription() Group by the description column + * @method ChildProdutImageI18nQuery groupByChapo() Group by the chapo column + * @method ChildProdutImageI18nQuery groupByPostscriptum() Group by the postscriptum column * - * @method ChildDocumentI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildDocumentI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildDocumentI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildProdutImageI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildProdutImageI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildProdutImageI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildDocumentI18nQuery leftJoinDocument($relationAlias = null) Adds a LEFT JOIN clause to the query using the Document relation - * @method ChildDocumentI18nQuery rightJoinDocument($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Document relation - * @method ChildDocumentI18nQuery innerJoinDocument($relationAlias = null) Adds a INNER JOIN clause to the query using the Document relation + * @method ChildProdutImageI18nQuery leftJoinProdutImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProdutImage relation + * @method ChildProdutImageI18nQuery rightJoinProdutImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProdutImage relation + * @method ChildProdutImageI18nQuery innerJoinProdutImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ProdutImage relation * - * @method ChildDocumentI18n findOne(ConnectionInterface $con = null) Return the first ChildDocumentI18n matching the query - * @method ChildDocumentI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildDocumentI18n matching the query, or a new ChildDocumentI18n object populated from the query conditions when no match is found + * @method ChildProdutImageI18n findOne(ConnectionInterface $con = null) Return the first ChildProdutImageI18n matching the query + * @method ChildProdutImageI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildProdutImageI18n matching the query, or a new ChildProdutImageI18n object populated from the query conditions when no match is found * - * @method ChildDocumentI18n findOneById(int $id) Return the first ChildDocumentI18n filtered by the id column - * @method ChildDocumentI18n findOneByLocale(string $locale) Return the first ChildDocumentI18n filtered by the locale column - * @method ChildDocumentI18n findOneByTitle(string $title) Return the first ChildDocumentI18n filtered by the title column - * @method ChildDocumentI18n findOneByDescription(string $description) Return the first ChildDocumentI18n filtered by the description column - * @method ChildDocumentI18n findOneByChapo(string $chapo) Return the first ChildDocumentI18n filtered by the chapo column - * @method ChildDocumentI18n findOneByPostscriptum(string $postscriptum) Return the first ChildDocumentI18n filtered by the postscriptum column + * @method ChildProdutImageI18n findOneById(int $id) Return the first ChildProdutImageI18n filtered by the id column + * @method ChildProdutImageI18n findOneByLocale(string $locale) Return the first ChildProdutImageI18n filtered by the locale column + * @method ChildProdutImageI18n findOneByTitle(string $title) Return the first ChildProdutImageI18n filtered by the title column + * @method ChildProdutImageI18n findOneByDescription(string $description) Return the first ChildProdutImageI18n filtered by the description column + * @method ChildProdutImageI18n findOneByChapo(string $chapo) Return the first ChildProdutImageI18n filtered by the chapo column + * @method ChildProdutImageI18n findOneByPostscriptum(string $postscriptum) Return the first ChildProdutImageI18n filtered by the postscriptum column * - * @method array findById(int $id) Return ChildDocumentI18n objects filtered by the id column - * @method array findByLocale(string $locale) Return ChildDocumentI18n objects filtered by the locale column - * @method array findByTitle(string $title) Return ChildDocumentI18n objects filtered by the title column - * @method array findByDescription(string $description) Return ChildDocumentI18n objects filtered by the description column - * @method array findByChapo(string $chapo) Return ChildDocumentI18n objects filtered by the chapo column - * @method array findByPostscriptum(string $postscriptum) Return ChildDocumentI18n objects filtered by the postscriptum column + * @method array findById(int $id) Return ChildProdutImageI18n objects filtered by the id column + * @method array findByLocale(string $locale) Return ChildProdutImageI18n objects filtered by the locale column + * @method array findByTitle(string $title) Return ChildProdutImageI18n objects filtered by the title column + * @method array findByDescription(string $description) Return ChildProdutImageI18n objects filtered by the description column + * @method array findByChapo(string $chapo) Return ChildProdutImageI18n objects filtered by the chapo column + * @method array findByPostscriptum(string $postscriptum) Return ChildProdutImageI18n objects filtered by the postscriptum column * */ -abstract class DocumentI18nQuery extends ModelCriteria +abstract class ProdutImageI18nQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\DocumentI18nQuery object. + * Initializes internal state of \Thelia\Model\Base\ProdutImageI18nQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\DocumentI18n', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\ProdutImageI18n', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildDocumentI18nQuery object. + * Returns a new ChildProdutImageI18nQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildDocumentI18nQuery + * @return ChildProdutImageI18nQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\DocumentI18nQuery) { + if ($criteria instanceof \Thelia\Model\ProdutImageI18nQuery) { return $criteria; } - $query = new \Thelia\Model\DocumentI18nQuery(); + $query = new \Thelia\Model\ProdutImageI18nQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -112,19 +112,19 @@ abstract class DocumentI18nQuery extends ModelCriteria * @param array[$id, $locale] $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildDocumentI18n|array|mixed the result, formatted by the current formatter + * @return ChildProdutImageI18n|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = DocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + if ((null !== ($obj = ProdutImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(ProdutImageI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,11 +143,11 @@ abstract class DocumentI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildDocumentI18n A model object, or null if the key is not found + * @return ChildProdutImageI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM document_i18n WHERE ID = :p0 AND LOCALE = :p1'; + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM produt_image_i18n WHERE ID = :p0 AND LOCALE = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -159,9 +159,9 @@ abstract class DocumentI18nQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildDocumentI18n(); + $obj = new ChildProdutImageI18n(); $obj->hydrate($row); - DocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ProdutImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -174,7 +174,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildDocumentI18n|array|mixed the result, formatted by the current formatter + * @return ChildProdutImageI18n|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -216,12 +216,12 @@ abstract class DocumentI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - $this->addUsingAlias(DocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(DocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $this->addUsingAlias(ProdutImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProdutImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -231,7 +231,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -239,8 +239,8 @@ abstract class DocumentI18nQuery extends ModelCriteria return $this->add(null, '1<>1', Criteria::CUSTOM); } foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(DocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(DocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0 = $this->getNewCriterion(ProdutImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProdutImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,7 +258,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * $query->filterById(array('min' => 12)); // WHERE id > 12 * * - * @see filterByDocument() + * @see filterByProdutImage() * * @param mixed $id The value to use as filter. * Use scalar values for equality. @@ -266,18 +266,18 @@ abstract class DocumentI18nQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterById($id = null, $comparison = null) { if (is_array($id)) { $useMinMax = false; if (isset($id['min'])) { - $this->addUsingAlias(DocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProdutImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(DocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProdutImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -288,7 +288,7 @@ abstract class DocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nTableMap::ID, $id, $comparison); + return $this->addUsingAlias(ProdutImageI18nTableMap::ID, $id, $comparison); } /** @@ -304,7 +304,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -317,7 +317,7 @@ abstract class DocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nTableMap::LOCALE, $locale, $comparison); + return $this->addUsingAlias(ProdutImageI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -333,7 +333,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -346,7 +346,7 @@ abstract class DocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nTableMap::TITLE, $title, $comparison); + return $this->addUsingAlias(ProdutImageI18nTableMap::TITLE, $title, $comparison); } /** @@ -362,7 +362,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -375,7 +375,7 @@ abstract class DocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nTableMap::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(ProdutImageI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -391,7 +391,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -404,7 +404,7 @@ abstract class DocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nTableMap::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(ProdutImageI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -420,7 +420,7 @@ abstract class DocumentI18nQuery extends ModelCriteria * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -433,46 +433,46 @@ abstract class DocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(ProdutImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related \Thelia\Model\Document object + * Filter the query by a related \Thelia\Model\ProdutImage object * - * @param \Thelia\Model\Document|ObjectCollection $document The related object(s) to use as filter + * @param \Thelia\Model\ProdutImage|ObjectCollection $produtImage The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ - public function filterByDocument($document, $comparison = null) + public function filterByProdutImage($produtImage, $comparison = null) { - if ($document instanceof \Thelia\Model\Document) { + if ($produtImage instanceof \Thelia\Model\ProdutImage) { return $this - ->addUsingAlias(DocumentI18nTableMap::ID, $document->getId(), $comparison); - } elseif ($document instanceof ObjectCollection) { + ->addUsingAlias(ProdutImageI18nTableMap::ID, $produtImage->getId(), $comparison); + } elseif ($produtImage instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DocumentI18nTableMap::ID, $document->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProdutImageI18nTableMap::ID, $produtImage->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); + throw new PropelException('filterByProdutImage() only accepts arguments of type \Thelia\Model\ProdutImage or Collection'); } } /** - * Adds a JOIN clause to the query using the Document relation + * Adds a JOIN clause to the query using the ProdutImage relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ - public function joinDocument($relationAlias = null, $joinType = 'LEFT JOIN') + public function joinProdutImage($relationAlias = null, $joinType = 'LEFT JOIN') { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); + $relationMap = $tableMap->getRelation('ProdutImage'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -487,14 +487,14 @@ abstract class DocumentI18nQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Document'); + $this->addJoinObject($join, 'ProdutImage'); } return $this; } /** - * Use the Document relation Document object + * Use the ProdutImage relation ProdutImage object * * @see useQuery() * @@ -502,27 +502,27 @@ abstract class DocumentI18nQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProdutImageQuery A secondary query class using the current class as primary query */ - public function useDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN') + public function useProdutImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); + ->joinProdutImage($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProdutImage', '\Thelia\Model\ProdutImageQuery'); } /** * Exclude object from result * - * @param ChildDocumentI18n $documentI18n Object to remove from the list of results + * @param ChildProdutImageI18n $produtImageI18n Object to remove from the list of results * - * @return ChildDocumentI18nQuery The current query, for fluid interface + * @return ChildProdutImageI18nQuery The current query, for fluid interface */ - public function prune($documentI18n = null) + public function prune($produtImageI18n = null) { - if ($documentI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(DocumentI18nTableMap::ID), $documentI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(DocumentI18nTableMap::LOCALE), $documentI18n->getLocale(), Criteria::NOT_EQUAL); + if ($produtImageI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(ProdutImageI18nTableMap::ID), $produtImageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProdutImageI18nTableMap::LOCALE), $produtImageI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } @@ -530,7 +530,7 @@ abstract class DocumentI18nQuery extends ModelCriteria } /** - * Deletes all rows from the document_i18n table. + * Deletes all rows from the produt_image_i18n table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -538,7 +538,7 @@ abstract class DocumentI18nQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageI18nTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -549,8 +549,8 @@ abstract class DocumentI18nQuery extends ModelCriteria // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - DocumentI18nTableMap::clearInstancePool(); - DocumentI18nTableMap::clearRelatedInstancePool(); + ProdutImageI18nTableMap::clearInstancePool(); + ProdutImageI18nTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -562,9 +562,9 @@ abstract class DocumentI18nQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildDocumentI18n or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildProdutImageI18n or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildDocumentI18n object or primary key or array of primary keys + * @param mixed $values Criteria or ChildProdutImageI18n object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -575,13 +575,13 @@ abstract class DocumentI18nQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageI18nTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(DocumentI18nTableMap::DATABASE_NAME); + $criteria->setDbName(ProdutImageI18nTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -591,10 +591,10 @@ abstract class DocumentI18nQuery extends ModelCriteria $con->beginTransaction(); - DocumentI18nTableMap::removeInstanceFromPool($criteria); + ProdutImageI18nTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - DocumentI18nTableMap::clearRelatedInstancePool(); + ProdutImageI18nTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -604,4 +604,4 @@ abstract class DocumentI18nQuery extends ModelCriteria } } -} // DocumentI18nQuery +} // ProdutImageI18nQuery diff --git a/core/lib/Thelia/Model/Base/ProdutImageQuery.php b/core/lib/Thelia/Model/Base/ProdutImageQuery.php new file mode 100644 index 000000000..65376b641 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProdutImageQuery.php @@ -0,0 +1,846 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProdutImage|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProdutImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProdutImageTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProdutImage A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PRODUCT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM produt_image WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProdutImage(); + $obj->hydrate($row); + ProdutImageTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProdutImage|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ProdutImageTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ProdutImageTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProdutImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProdutImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProdutImageTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the product_id column + * + * Example usage: + * + * $query->filterByProductId(1234); // WHERE product_id = 1234 + * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 + * + * + * @see filterByProduct() + * + * @param mixed $productId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByProductId($productId = null, $comparison = null) + { + if (is_array($productId)) { + $useMinMax = false; + if (isset($productId['min'])) { + $this->addUsingAlias(ProdutImageTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($productId['max'])) { + $this->addUsingAlias(ProdutImageTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProdutImageTableMap::PRODUCT_ID, $productId, $comparison); + } + + /** + * Filter the query on the file column + * + * Example usage: + * + * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' + * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' + * + * + * @param string $file The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByFile($file = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($file)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $file)) { + $file = str_replace('*', '%', $file); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProdutImageTableMap::FILE, $file, $comparison); + } + + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(ProdutImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(ProdutImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProdutImageTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProdutImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProdutImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProdutImageTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProdutImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProdutImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProdutImageTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Product object + * + * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByProduct($product, $comparison = null) + { + if ($product instanceof \Thelia\Model\Product) { + return $this + ->addUsingAlias(ProdutImageTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProdutImageTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Product relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Product'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Product'); + } + + return $this; + } + + /** + * Use the Product relation Product object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query + */ + public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ProdutImageI18n object + * + * @param \Thelia\Model\ProdutImageI18n|ObjectCollection $produtImageI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function filterByProdutImageI18n($produtImageI18n, $comparison = null) + { + if ($produtImageI18n instanceof \Thelia\Model\ProdutImageI18n) { + return $this + ->addUsingAlias(ProdutImageTableMap::ID, $produtImageI18n->getId(), $comparison); + } elseif ($produtImageI18n instanceof ObjectCollection) { + return $this + ->useProdutImageI18nQuery() + ->filterByPrimaryKeys($produtImageI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProdutImageI18n() only accepts arguments of type \Thelia\Model\ProdutImageI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProdutImageI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function joinProdutImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProdutImageI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProdutImageI18n'); + } + + return $this; + } + + /** + * Use the ProdutImageI18n relation ProdutImageI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProdutImageI18nQuery A secondary query class using the current class as primary query + */ + public function useProdutImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinProdutImageI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProdutImageI18n', '\Thelia\Model\ProdutImageI18nQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProdutImage $produtImage Object to remove from the list of results + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function prune($produtImage = null) + { + if ($produtImage) { + $this->addUsingAlias(ProdutImageTableMap::ID, $produtImage->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the produt_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProdutImageTableMap::clearInstancePool(); + ProdutImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProdutImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProdutImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProdutImageTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProdutImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProdutImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProdutImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProdutImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProdutImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProdutImageTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProdutImageTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProdutImageTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'ProdutImageI18n'; + + return $this + ->joinProdutImageI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProdutImageQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('ProdutImageI18n'); + $this->with['ProdutImageI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProdutImageI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProdutImageI18n', '\Thelia\Model\ProdutImageI18nQuery'); + } + +} // ProdutImageQuery diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php new file mode 100644 index 000000000..bd86f1d1e --- /dev/null +++ b/core/lib/Thelia/Model/CategoryDocument.php @@ -0,0 +1,10 @@ +setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('TOKEN', 'Token', 'VARCHAR', true, 255, null); + $this->addColumn('TOKEN', 'Token', 'VARCHAR', false, 255, null); $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', false, null, null); $this->addForeignKey('ADDRESS_DELIVERY_ID', 'AddressDeliveryId', 'INTEGER', 'address', 'ID', false, null, null); $this->addForeignKey('ADDRESS_INVOICE_ID', 'AddressInvoiceId', 'INTEGER', 'address', 'ID', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php new file mode 100644 index 000000000..956afae4a --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryDocumentI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(CategoryDocumentI18nTableMap::ID, CategoryDocumentI18nTableMap::LOCALE, CategoryDocumentI18nTableMap::TITLE, CategoryDocumentI18nTableMap::DESCRIPTION, CategoryDocumentI18nTableMap::CHAPO, CategoryDocumentI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(CategoryDocumentI18nTableMap::ID => 0, CategoryDocumentI18nTableMap::LOCALE => 1, CategoryDocumentI18nTableMap::TITLE => 2, CategoryDocumentI18nTableMap::DESCRIPTION => 3, CategoryDocumentI18nTableMap::CHAPO => 4, CategoryDocumentI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('category_document_i18n'); + $this->setPhpName('CategoryDocumentI18n'); + $this->setClassName('\\Thelia\\Model\\CategoryDocumentI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category_document', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CategoryDocument', '\\Thelia\\Model\\CategoryDocument', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CategoryDocumentI18n $obj A \Thelia\Model\CategoryDocumentI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\CategoryDocumentI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\CategoryDocumentI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CategoryDocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryDocumentI18nTableMap::CLASS_DEFAULT : CategoryDocumentI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CategoryDocumentI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryDocumentI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryDocumentI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryDocumentI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CategoryDocumentI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CategoryDocumentI18nTableMap::ID); + $criteria->addSelectColumn(CategoryDocumentI18nTableMap::LOCALE); + $criteria->addSelectColumn(CategoryDocumentI18nTableMap::TITLE); + $criteria->addSelectColumn(CategoryDocumentI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(CategoryDocumentI18nTableMap::CHAPO); + $criteria->addSelectColumn(CategoryDocumentI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CategoryDocumentI18nTableMap::DATABASE_NAME)->getTable(CategoryDocumentI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryDocumentI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryDocumentI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryDocumentI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CategoryDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CategoryDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryDocumentI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryDocumentI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(CategoryDocumentI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CategoryDocumentI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CategoryDocumentI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryDocumentI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryDocumentI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryDocumentI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryDocumentI18n or Criteria object. + * + * @param mixed $criteria Criteria or CategoryDocumentI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryDocumentI18n object + } + + + // Set the correct dbName + $query = CategoryDocumentI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryDocumentI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryDocumentI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php b/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php new file mode 100644 index 000000000..8b307ea1e --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryDocumentTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'CategoryId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CategoryDocumentTableMap::ID, CategoryDocumentTableMap::CATEGORY_ID, CategoryDocumentTableMap::FILE, CategoryDocumentTableMap::POSITION, CategoryDocumentTableMap::CREATED_AT, CategoryDocumentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'category_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(CategoryDocumentTableMap::ID => 0, CategoryDocumentTableMap::CATEGORY_ID => 1, CategoryDocumentTableMap::FILE => 2, CategoryDocumentTableMap::POSITION => 3, CategoryDocumentTableMap::CREATED_AT => 4, CategoryDocumentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('category_document'); + $this->setPhpName('CategoryDocument'); + $this->setClassName('\\Thelia\\Model\\CategoryDocument'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('CategoryDocumentI18n', '\\Thelia\\Model\\CategoryDocumentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryDocumentI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to category_document * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CategoryDocumentI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryDocumentTableMap::CLASS_DEFAULT : CategoryDocumentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CategoryDocument object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryDocumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryDocumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryDocumentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryDocumentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryDocumentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryDocumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryDocumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CategoryDocumentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CategoryDocumentTableMap::ID); + $criteria->addSelectColumn(CategoryDocumentTableMap::CATEGORY_ID); + $criteria->addSelectColumn(CategoryDocumentTableMap::FILE); + $criteria->addSelectColumn(CategoryDocumentTableMap::POSITION); + $criteria->addSelectColumn(CategoryDocumentTableMap::CREATED_AT); + $criteria->addSelectColumn(CategoryDocumentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CATEGORY_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CategoryDocumentTableMap::DATABASE_NAME)->getTable(CategoryDocumentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryDocumentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryDocumentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryDocumentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CategoryDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CategoryDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryDocument) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryDocumentTableMap::DATABASE_NAME); + $criteria->add(CategoryDocumentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CategoryDocumentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryDocumentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryDocumentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryDocumentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryDocument or Criteria object. + * + * @param mixed $criteria Criteria or CategoryDocument object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryDocumentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryDocument object + } + + if ($criteria->containsKey(CategoryDocumentTableMap::ID) && $criteria->keyContainsValue(CategoryDocumentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryDocumentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CategoryDocumentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryDocumentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryDocumentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php new file mode 100644 index 000000000..1d27e16ad --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryImageI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(CategoryImageI18nTableMap::ID, CategoryImageI18nTableMap::LOCALE, CategoryImageI18nTableMap::TITLE, CategoryImageI18nTableMap::DESCRIPTION, CategoryImageI18nTableMap::CHAPO, CategoryImageI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(CategoryImageI18nTableMap::ID => 0, CategoryImageI18nTableMap::LOCALE => 1, CategoryImageI18nTableMap::TITLE => 2, CategoryImageI18nTableMap::DESCRIPTION => 3, CategoryImageI18nTableMap::CHAPO => 4, CategoryImageI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('category_image_i18n'); + $this->setPhpName('CategoryImageI18n'); + $this->setClassName('\\Thelia\\Model\\CategoryImageI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category_image', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('CategoryImage', '\\Thelia\\Model\\CategoryImage', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CategoryImageI18n $obj A \Thelia\Model\CategoryImageI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\CategoryImageI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\CategoryImageI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CategoryImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryImageI18nTableMap::CLASS_DEFAULT : CategoryImageI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CategoryImageI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryImageI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryImageI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryImageI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CategoryImageI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CategoryImageI18nTableMap::ID); + $criteria->addSelectColumn(CategoryImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(CategoryImageI18nTableMap::TITLE); + $criteria->addSelectColumn(CategoryImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(CategoryImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(CategoryImageI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CategoryImageI18nTableMap::DATABASE_NAME)->getTable(CategoryImageI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryImageI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CategoryImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CategoryImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryImageI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryImageI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(CategoryImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CategoryImageI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CategoryImageI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryImageI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryImageI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryImageI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryImageI18n or Criteria object. + * + * @param mixed $criteria Criteria or CategoryImageI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryImageI18n object + } + + + // Set the correct dbName + $query = CategoryImageI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryImageI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryImageI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryImageTableMap.php b/core/lib/Thelia/Model/Map/CategoryImageTableMap.php new file mode 100644 index 000000000..1c7694d05 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryImageTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'CategoryId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CategoryImageTableMap::ID, CategoryImageTableMap::CATEGORY_ID, CategoryImageTableMap::FILE, CategoryImageTableMap::POSITION, CategoryImageTableMap::CREATED_AT, CategoryImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'category_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(CategoryImageTableMap::ID => 0, CategoryImageTableMap::CATEGORY_ID => 1, CategoryImageTableMap::FILE => 2, CategoryImageTableMap::POSITION => 3, CategoryImageTableMap::CREATED_AT => 4, CategoryImageTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('category_image'); + $this->setPhpName('CategoryImage'); + $this->setClassName('\\Thelia\\Model\\CategoryImage'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('CategoryImageI18n', '\\Thelia\\Model\\CategoryImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryImageI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to category_image * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CategoryImageI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryImageTableMap::CLASS_DEFAULT : CategoryImageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (CategoryImage object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryImageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryImageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryImageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + CategoryImageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(CategoryImageTableMap::ID); + $criteria->addSelectColumn(CategoryImageTableMap::CATEGORY_ID); + $criteria->addSelectColumn(CategoryImageTableMap::FILE); + $criteria->addSelectColumn(CategoryImageTableMap::POSITION); + $criteria->addSelectColumn(CategoryImageTableMap::CREATED_AT); + $criteria->addSelectColumn(CategoryImageTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CATEGORY_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(CategoryImageTableMap::DATABASE_NAME)->getTable(CategoryImageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryImageTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a CategoryImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or CategoryImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryImage) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryImageTableMap::DATABASE_NAME); + $criteria->add(CategoryImageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CategoryImageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryImageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryImageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryImageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryImage or Criteria object. + * + * @param mixed $criteria Criteria or CategoryImage object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryImageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryImage object + } + + if ($criteria->containsKey(CategoryImageTableMap::ID) && $criteria->keyContainsValue(CategoryImageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryImageTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CategoryImageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryImageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryImageTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index 0a7247fee..5e02d04c5 100644 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -194,9 +194,9 @@ class CategoryTableMap extends TableMap $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories'); $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories'); $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); - $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Documents'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); + $this->addRelation('CategoryImage', '\\Thelia\\Model\\CategoryImage', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryImages'); + $this->addRelation('CategoryDocument', '\\Thelia\\Model\\CategoryDocument', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'CategoryDocuments'); $this->addRelation('CategoryI18n', '\\Thelia\\Model\\CategoryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryI18ns'); $this->addRelation('CategoryVersion', '\\Thelia\\Model\\CategoryVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryVersions'); $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Products'); @@ -229,9 +229,9 @@ class CategoryTableMap extends TableMap FeatureCategoryTableMap::clearInstancePool(); AttributeCategoryTableMap::clearInstancePool(); ContentAssocTableMap::clearInstancePool(); - ImageTableMap::clearInstancePool(); - DocumentTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); + CategoryImageTableMap::clearInstancePool(); + CategoryDocumentTableMap::clearInstancePool(); CategoryI18nTableMap::clearInstancePool(); CategoryVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php new file mode 100644 index 000000000..7ebde93e6 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentDocumentI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ContentDocumentI18nTableMap::ID, ContentDocumentI18nTableMap::LOCALE, ContentDocumentI18nTableMap::TITLE, ContentDocumentI18nTableMap::DESCRIPTION, ContentDocumentI18nTableMap::CHAPO, ContentDocumentI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ContentDocumentI18nTableMap::ID => 0, ContentDocumentI18nTableMap::LOCALE => 1, ContentDocumentI18nTableMap::TITLE => 2, ContentDocumentI18nTableMap::DESCRIPTION => 3, ContentDocumentI18nTableMap::CHAPO => 4, ContentDocumentI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('content_document_i18n'); + $this->setPhpName('ContentDocumentI18n'); + $this->setClassName('\\Thelia\\Model\\ContentDocumentI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_document', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('ContentDocument', '\\Thelia\\Model\\ContentDocument', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ContentDocumentI18n $obj A \Thelia\Model\ContentDocumentI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\ContentDocumentI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\ContentDocumentI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentDocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentDocumentI18nTableMap::CLASS_DEFAULT : ContentDocumentI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ContentDocumentI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentDocumentI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentDocumentI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentDocumentI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ContentDocumentI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ContentDocumentI18nTableMap::ID); + $criteria->addSelectColumn(ContentDocumentI18nTableMap::LOCALE); + $criteria->addSelectColumn(ContentDocumentI18nTableMap::TITLE); + $criteria->addSelectColumn(ContentDocumentI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ContentDocumentI18nTableMap::CHAPO); + $criteria->addSelectColumn(ContentDocumentI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ContentDocumentI18nTableMap::DATABASE_NAME)->getTable(ContentDocumentI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentDocumentI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentDocumentI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentDocumentI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ContentDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ContentDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentDocumentI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentDocumentI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(ContentDocumentI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ContentDocumentI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ContentDocumentI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentDocumentI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentDocumentI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentDocumentI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentDocumentI18n or Criteria object. + * + * @param mixed $criteria Criteria or ContentDocumentI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentDocumentI18n object + } + + + // Set the correct dbName + $query = ContentDocumentI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentDocumentI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentDocumentI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php b/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php new file mode 100644 index 000000000..3d876a570 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentDocumentTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ContentDocumentTableMap::ID, ContentDocumentTableMap::CONTENT_ID, ContentDocumentTableMap::FILE, ContentDocumentTableMap::POSITION, ContentDocumentTableMap::CREATED_AT, ContentDocumentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ContentId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'contentId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ContentDocumentTableMap::ID => 0, ContentDocumentTableMap::CONTENT_ID => 1, ContentDocumentTableMap::FILE => 2, ContentDocumentTableMap::POSITION => 3, ContentDocumentTableMap::CREATED_AT => 4, ContentDocumentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CONTENT_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'content_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('content_document'); + $this->setPhpName('ContentDocument'); + $this->setClassName('\\Thelia\\Model\\ContentDocument'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('ContentDocumentI18n', '\\Thelia\\Model\\ContentDocumentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentDocumentI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to content_document * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ContentDocumentI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentDocumentTableMap::CLASS_DEFAULT : ContentDocumentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ContentDocument object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentDocumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentDocumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentDocumentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentDocumentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentDocumentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentDocumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentDocumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ContentDocumentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ContentDocumentTableMap::ID); + $criteria->addSelectColumn(ContentDocumentTableMap::CONTENT_ID); + $criteria->addSelectColumn(ContentDocumentTableMap::FILE); + $criteria->addSelectColumn(ContentDocumentTableMap::POSITION); + $criteria->addSelectColumn(ContentDocumentTableMap::CREATED_AT); + $criteria->addSelectColumn(ContentDocumentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CONTENT_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ContentDocumentTableMap::DATABASE_NAME)->getTable(ContentDocumentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentDocumentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentDocumentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentDocumentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ContentDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ContentDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentDocument) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentDocumentTableMap::DATABASE_NAME); + $criteria->add(ContentDocumentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ContentDocumentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentDocumentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentDocumentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentDocumentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentDocument or Criteria object. + * + * @param mixed $criteria Criteria or ContentDocument object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentDocumentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentDocument object + } + + if ($criteria->containsKey(ContentDocumentTableMap::ID) && $criteria->keyContainsValue(ContentDocumentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentDocumentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ContentDocumentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentDocumentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentDocumentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php new file mode 100644 index 000000000..759349d27 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentImageI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ContentImageI18nTableMap::ID, ContentImageI18nTableMap::LOCALE, ContentImageI18nTableMap::TITLE, ContentImageI18nTableMap::DESCRIPTION, ContentImageI18nTableMap::CHAPO, ContentImageI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ContentImageI18nTableMap::ID => 0, ContentImageI18nTableMap::LOCALE => 1, ContentImageI18nTableMap::TITLE => 2, ContentImageI18nTableMap::DESCRIPTION => 3, ContentImageI18nTableMap::CHAPO => 4, ContentImageI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('content_image_i18n'); + $this->setPhpName('ContentImageI18n'); + $this->setClassName('\\Thelia\\Model\\ContentImageI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content_image', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('ContentImage', '\\Thelia\\Model\\ContentImage', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ContentImageI18n $obj A \Thelia\Model\ContentImageI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\ContentImageI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\ContentImageI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentImageI18nTableMap::CLASS_DEFAULT : ContentImageI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ContentImageI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentImageI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentImageI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentImageI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ContentImageI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ContentImageI18nTableMap::ID); + $criteria->addSelectColumn(ContentImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(ContentImageI18nTableMap::TITLE); + $criteria->addSelectColumn(ContentImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ContentImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(ContentImageI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ContentImageI18nTableMap::DATABASE_NAME)->getTable(ContentImageI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentImageI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ContentImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ContentImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentImageI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentImageI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(ContentImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ContentImageI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ContentImageI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentImageI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentImageI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentImageI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentImageI18n or Criteria object. + * + * @param mixed $criteria Criteria or ContentImageI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentImageI18n object + } + + + // Set the correct dbName + $query = ContentImageI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentImageI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentImageI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentImageTableMap.php b/core/lib/Thelia/Model/Map/ContentImageTableMap.php new file mode 100644 index 000000000..f731c51a8 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentImageTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ContentImageTableMap::ID, ContentImageTableMap::CONTENT_ID, ContentImageTableMap::FILE, ContentImageTableMap::POSITION, ContentImageTableMap::CREATED_AT, ContentImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ContentId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'contentId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ContentImageTableMap::ID => 0, ContentImageTableMap::CONTENT_ID => 1, ContentImageTableMap::FILE => 2, ContentImageTableMap::POSITION => 3, ContentImageTableMap::CREATED_AT => 4, ContentImageTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CONTENT_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'content_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('content_image'); + $this->setPhpName('ContentImage'); + $this->setClassName('\\Thelia\\Model\\ContentImage'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('ContentImageI18n', '\\Thelia\\Model\\ContentImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentImageI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to content_image * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ContentImageI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentImageTableMap::CLASS_DEFAULT : ContentImageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ContentImage object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentImageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentImageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentImageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ContentImageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ContentImageTableMap::ID); + $criteria->addSelectColumn(ContentImageTableMap::CONTENT_ID); + $criteria->addSelectColumn(ContentImageTableMap::FILE); + $criteria->addSelectColumn(ContentImageTableMap::POSITION); + $criteria->addSelectColumn(ContentImageTableMap::CREATED_AT); + $criteria->addSelectColumn(ContentImageTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CONTENT_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ContentImageTableMap::DATABASE_NAME)->getTable(ContentImageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentImageTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ContentImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ContentImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentImage) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentImageTableMap::DATABASE_NAME); + $criteria->add(ContentImageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ContentImageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentImageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentImageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentImageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentImage or Criteria object. + * + * @param mixed $criteria Criteria or ContentImage object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentImageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentImage object + } + + if ($criteria->containsKey(ContentImageTableMap::ID) && $criteria->keyContainsValue(ContentImageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentImageTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ContentImageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentImageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentImageTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index b794c7244..4a489cedb 100644 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -185,10 +185,10 @@ class ContentTableMap extends TableMap public function buildRelations() { $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); - $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Documents'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); + $this->addRelation('ContentImage', '\\Thelia\\Model\\ContentImage', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentImages'); + $this->addRelation('ContentDocument', '\\Thelia\\Model\\ContentDocument', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentDocuments'); $this->addRelation('ContentI18n', '\\Thelia\\Model\\ContentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentI18ns'); $this->addRelation('ContentVersion', '\\Thelia\\Model\\ContentVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentVersions'); $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Folders'); @@ -216,10 +216,10 @@ class ContentTableMap extends TableMap // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ContentAssocTableMap::clearInstancePool(); - ImageTableMap::clearInstancePool(); - DocumentTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); ContentFolderTableMap::clearInstancePool(); + ContentImageTableMap::clearInstancePool(); + ContentDocumentTableMap::clearInstancePool(); ContentI18nTableMap::clearInstancePool(); ContentVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php index 341a0cb45..b1251801a 100644 --- a/core/lib/Thelia/Model/Map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -57,7 +57,7 @@ class CurrencyTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 8; + const NUM_COLUMNS = 7; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CurrencyTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 8; + const NUM_HYDRATE_COLUMNS = 7; /** * the column name for the ID field @@ -94,11 +94,6 @@ class CurrencyTableMap extends TableMap */ const BY_DEFAULT = 'currency.BY_DEFAULT'; - /** - * the column name for the POSITION field - */ - const POSITION = 'currency.POSITION'; - /** * the column name for the CREATED_AT field */ @@ -130,12 +125,12 @@ class CurrencyTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Symbol', 'Rate', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'symbol', 'rate', 'byDefault', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CurrencyTableMap::ID, CurrencyTableMap::CODE, CurrencyTableMap::SYMBOL, CurrencyTableMap::RATE, CurrencyTableMap::BY_DEFAULT, CurrencyTableMap::POSITION, CurrencyTableMap::CREATED_AT, CurrencyTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'code', 'symbol', 'rate', 'by_default', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Symbol', 'Rate', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'symbol', 'rate', 'byDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CurrencyTableMap::ID, CurrencyTableMap::CODE, CurrencyTableMap::SYMBOL, CurrencyTableMap::RATE, CurrencyTableMap::BY_DEFAULT, CurrencyTableMap::CREATED_AT, CurrencyTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'symbol', 'rate', 'by_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -145,12 +140,12 @@ class CurrencyTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Symbol' => 2, 'Rate' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'symbol' => 2, 'rate' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - self::TYPE_COLNAME => array(CurrencyTableMap::ID => 0, CurrencyTableMap::CODE => 1, CurrencyTableMap::SYMBOL => 2, CurrencyTableMap::RATE => 3, CurrencyTableMap::BY_DEFAULT => 4, CurrencyTableMap::POSITION => 5, CurrencyTableMap::CREATED_AT => 6, CurrencyTableMap::UPDATED_AT => 7, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'SYMBOL' => 2, 'RATE' => 3, 'BY_DEFAULT' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'symbol' => 2, 'rate' => 3, 'by_default' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Symbol' => 2, 'Rate' => 3, 'ByDefault' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'symbol' => 2, 'rate' => 3, 'byDefault' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(CurrencyTableMap::ID => 0, CurrencyTableMap::CODE => 1, CurrencyTableMap::SYMBOL => 2, CurrencyTableMap::RATE => 3, CurrencyTableMap::BY_DEFAULT => 4, CurrencyTableMap::CREATED_AT => 5, CurrencyTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'SYMBOL' => 2, 'RATE' => 3, 'BY_DEFAULT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'symbol' => 2, 'rate' => 3, 'by_default' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -174,7 +169,6 @@ class CurrencyTableMap extends TableMap $this->addColumn('SYMBOL', 'Symbol', 'VARCHAR', false, 45, null); $this->addColumn('RATE', 'Rate', 'FLOAT', false, null, null); $this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -358,7 +352,6 @@ class CurrencyTableMap extends TableMap $criteria->addSelectColumn(CurrencyTableMap::SYMBOL); $criteria->addSelectColumn(CurrencyTableMap::RATE); $criteria->addSelectColumn(CurrencyTableMap::BY_DEFAULT); - $criteria->addSelectColumn(CurrencyTableMap::POSITION); $criteria->addSelectColumn(CurrencyTableMap::CREATED_AT); $criteria->addSelectColumn(CurrencyTableMap::UPDATED_AT); } else { @@ -367,7 +360,6 @@ class CurrencyTableMap extends TableMap $criteria->addSelectColumn($alias . '.SYMBOL'); $criteria->addSelectColumn($alias . '.RATE'); $criteria->addSelectColumn($alias . '.BY_DEFAULT'); - $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php new file mode 100644 index 000000000..28dab9d8f --- /dev/null +++ b/core/lib/Thelia/Model/Map/FolderDocumentI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(FolderDocumentI18nTableMap::ID, FolderDocumentI18nTableMap::LOCALE, FolderDocumentI18nTableMap::TITLE, FolderDocumentI18nTableMap::DESCRIPTION, FolderDocumentI18nTableMap::CHAPO, FolderDocumentI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(FolderDocumentI18nTableMap::ID => 0, FolderDocumentI18nTableMap::LOCALE => 1, FolderDocumentI18nTableMap::TITLE => 2, FolderDocumentI18nTableMap::DESCRIPTION => 3, FolderDocumentI18nTableMap::CHAPO => 4, FolderDocumentI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('folder_document_i18n'); + $this->setPhpName('FolderDocumentI18n'); + $this->setClassName('\\Thelia\\Model\\FolderDocumentI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder_document', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('FolderDocument', '\\Thelia\\Model\\FolderDocument', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\FolderDocumentI18n $obj A \Thelia\Model\FolderDocumentI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\FolderDocumentI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\FolderDocumentI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FolderDocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FolderDocumentI18nTableMap::CLASS_DEFAULT : FolderDocumentI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (FolderDocumentI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FolderDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FolderDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FolderDocumentI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FolderDocumentI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FolderDocumentI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FolderDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FolderDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + FolderDocumentI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(FolderDocumentI18nTableMap::ID); + $criteria->addSelectColumn(FolderDocumentI18nTableMap::LOCALE); + $criteria->addSelectColumn(FolderDocumentI18nTableMap::TITLE); + $criteria->addSelectColumn(FolderDocumentI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(FolderDocumentI18nTableMap::CHAPO); + $criteria->addSelectColumn(FolderDocumentI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(FolderDocumentI18nTableMap::DATABASE_NAME)->getTable(FolderDocumentI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderDocumentI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FolderDocumentI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FolderDocumentI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a FolderDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or FolderDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FolderDocumentI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FolderDocumentI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(FolderDocumentI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(FolderDocumentI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = FolderDocumentI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FolderDocumentI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FolderDocumentI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the folder_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FolderDocumentI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FolderDocumentI18n or Criteria object. + * + * @param mixed $criteria Criteria or FolderDocumentI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FolderDocumentI18n object + } + + + // Set the correct dbName + $query = FolderDocumentI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FolderDocumentI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FolderDocumentI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php b/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php new file mode 100644 index 000000000..1d0e3b74a --- /dev/null +++ b/core/lib/Thelia/Model/Map/FolderDocumentTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'FolderId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'folderId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FolderDocumentTableMap::ID, FolderDocumentTableMap::FOLDER_ID, FolderDocumentTableMap::FILE, FolderDocumentTableMap::POSITION, FolderDocumentTableMap::CREATED_AT, FolderDocumentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FOLDER_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'folder_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'FolderId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'folderId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(FolderDocumentTableMap::ID => 0, FolderDocumentTableMap::FOLDER_ID => 1, FolderDocumentTableMap::FILE => 2, FolderDocumentTableMap::POSITION => 3, FolderDocumentTableMap::CREATED_AT => 4, FolderDocumentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FOLDER_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'folder_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('folder_document'); + $this->setPhpName('FolderDocument'); + $this->setClassName('\\Thelia\\Model\\FolderDocument'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('FolderDocumentI18n', '\\Thelia\\Model\\FolderDocumentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderDocumentI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to folder_document * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FolderDocumentI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FolderDocumentTableMap::CLASS_DEFAULT : FolderDocumentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (FolderDocument object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FolderDocumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FolderDocumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FolderDocumentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FolderDocumentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FolderDocumentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FolderDocumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FolderDocumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + FolderDocumentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(FolderDocumentTableMap::ID); + $criteria->addSelectColumn(FolderDocumentTableMap::FOLDER_ID); + $criteria->addSelectColumn(FolderDocumentTableMap::FILE); + $criteria->addSelectColumn(FolderDocumentTableMap::POSITION); + $criteria->addSelectColumn(FolderDocumentTableMap::CREATED_AT); + $criteria->addSelectColumn(FolderDocumentTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.FOLDER_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(FolderDocumentTableMap::DATABASE_NAME)->getTable(FolderDocumentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderDocumentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FolderDocumentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FolderDocumentTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a FolderDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or FolderDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FolderDocument) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FolderDocumentTableMap::DATABASE_NAME); + $criteria->add(FolderDocumentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = FolderDocumentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FolderDocumentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FolderDocumentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the folder_document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FolderDocumentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FolderDocument or Criteria object. + * + * @param mixed $criteria Criteria or FolderDocument object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderDocumentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FolderDocument object + } + + if ($criteria->containsKey(FolderDocumentTableMap::ID) && $criteria->keyContainsValue(FolderDocumentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FolderDocumentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = FolderDocumentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FolderDocumentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FolderDocumentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php similarity index 76% rename from core/lib/Thelia/Model/Map/DocumentI18nTableMap.php rename to core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php index 70314ea02..f0f87fd85 100644 --- a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderImageI18nTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\DocumentI18n; -use Thelia\Model\DocumentI18nQuery; +use Thelia\Model\FolderImageI18n; +use Thelia\Model\FolderImageI18nQuery; /** - * This class defines the structure of the 'document_i18n' table. + * This class defines the structure of the 'folder_image_i18n' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\DocumentI18nQuery; * (i.e. if it's a text column type). * */ -class DocumentI18nTableMap extends TableMap +class FolderImageI18nTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.DocumentI18nTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.FolderImageI18nTableMap'; /** * The default database name for this class @@ -42,17 +42,17 @@ class DocumentI18nTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'document_i18n'; + const TABLE_NAME = 'folder_image_i18n'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\DocumentI18n'; + const OM_CLASS = '\\Thelia\\Model\\FolderImageI18n'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.DocumentI18n'; + const CLASS_DEFAULT = 'Thelia.Model.FolderImageI18n'; /** * The total number of columns @@ -72,32 +72,32 @@ class DocumentI18nTableMap extends TableMap /** * the column name for the ID field */ - const ID = 'document_i18n.ID'; + const ID = 'folder_image_i18n.ID'; /** * the column name for the LOCALE field */ - const LOCALE = 'document_i18n.LOCALE'; + const LOCALE = 'folder_image_i18n.LOCALE'; /** * the column name for the TITLE field */ - const TITLE = 'document_i18n.TITLE'; + const TITLE = 'folder_image_i18n.TITLE'; /** * the column name for the DESCRIPTION field */ - const DESCRIPTION = 'document_i18n.DESCRIPTION'; + const DESCRIPTION = 'folder_image_i18n.DESCRIPTION'; /** * the column name for the CHAPO field */ - const CHAPO = 'document_i18n.CHAPO'; + const CHAPO = 'folder_image_i18n.CHAPO'; /** * the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'document_i18n.POSTSCRIPTUM'; + const POSTSCRIPTUM = 'folder_image_i18n.POSTSCRIPTUM'; /** * The default string format for model objects of the related table @@ -113,7 +113,7 @@ class DocumentI18nTableMap extends TableMap protected static $fieldNames = array ( self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_COLNAME => array(DocumentI18nTableMap::ID, DocumentI18nTableMap::LOCALE, DocumentI18nTableMap::TITLE, DocumentI18nTableMap::DESCRIPTION, DocumentI18nTableMap::CHAPO, DocumentI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_COLNAME => array(FolderImageI18nTableMap::ID, FolderImageI18nTableMap::LOCALE, FolderImageI18nTableMap::TITLE, FolderImageI18nTableMap::DESCRIPTION, FolderImageI18nTableMap::CHAPO, FolderImageI18nTableMap::POSTSCRIPTUM, ), self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) @@ -128,7 +128,7 @@ class DocumentI18nTableMap extends TableMap protected static $fieldKeys = array ( self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_COLNAME => array(DocumentI18nTableMap::ID => 0, DocumentI18nTableMap::LOCALE => 1, DocumentI18nTableMap::TITLE => 2, DocumentI18nTableMap::DESCRIPTION => 3, DocumentI18nTableMap::CHAPO => 4, DocumentI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_COLNAME => array(FolderImageI18nTableMap::ID => 0, FolderImageI18nTableMap::LOCALE => 1, FolderImageI18nTableMap::TITLE => 2, FolderImageI18nTableMap::DESCRIPTION => 3, FolderImageI18nTableMap::CHAPO => 4, FolderImageI18nTableMap::POSTSCRIPTUM => 5, ), self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) @@ -144,13 +144,13 @@ class DocumentI18nTableMap extends TableMap public function initialize() { // attributes - $this->setName('document_i18n'); - $this->setPhpName('DocumentI18n'); - $this->setClassName('\\Thelia\\Model\\DocumentI18n'); + $this->setName('folder_image_i18n'); + $this->setPhpName('FolderImageI18n'); + $this->setClassName('\\Thelia\\Model\\FolderImageI18n'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'ID', true, null, null); + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder_image', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); @@ -163,7 +163,7 @@ class DocumentI18nTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('FolderImage', '\\Thelia\\Model\\FolderImage', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); } // buildRelations() /** @@ -174,7 +174,7 @@ class DocumentI18nTableMap extends TableMap * to the cache in order to ensure that the same objects are always returned by find*() * and findPk*() calls. * - * @param \Thelia\Model\DocumentI18n $obj A \Thelia\Model\DocumentI18n object. + * @param \Thelia\Model\FolderImageI18n $obj A \Thelia\Model\FolderImageI18n object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) @@ -195,12 +195,12 @@ class DocumentI18nTableMap extends TableMap * methods in your stub classes -- you may need to explicitly remove objects * from the cache in order to prevent returning objects that no longer exist. * - * @param mixed $value A \Thelia\Model\DocumentI18n object or a primary key value. + * @param mixed $value A \Thelia\Model\FolderImageI18n object or a primary key value. */ public static function removeInstanceFromPool($value) { if (Propel::isInstancePoolingEnabled() && null !== $value) { - if (is_object($value) && $value instanceof \Thelia\Model\DocumentI18n) { + if (is_object($value) && $value instanceof \Thelia\Model\FolderImageI18n) { $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); } elseif (is_array($value) && count($value) === 2) { @@ -211,7 +211,7 @@ class DocumentI18nTableMap extends TableMap return; } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\DocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FolderImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); throw $e; } @@ -271,7 +271,7 @@ class DocumentI18nTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? DocumentI18nTableMap::CLASS_DEFAULT : DocumentI18nTableMap::OM_CLASS; + return $withPrefix ? FolderImageI18nTableMap::CLASS_DEFAULT : FolderImageI18nTableMap::OM_CLASS; } /** @@ -285,21 +285,21 @@ class DocumentI18nTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (DocumentI18n object, last column rank) + * @return array (FolderImageI18n object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = DocumentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = DocumentI18nTableMap::getInstanceFromPool($key))) { + $key = FolderImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FolderImageI18nTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + DocumentI18nTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + FolderImageI18nTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = DocumentI18nTableMap::OM_CLASS; + $cls = FolderImageI18nTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - DocumentI18nTableMap::addInstanceToPool($obj, $key); + FolderImageI18nTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -322,8 +322,8 @@ class DocumentI18nTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = DocumentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = DocumentI18nTableMap::getInstanceFromPool($key))) { + $key = FolderImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FolderImageI18nTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -332,7 +332,7 @@ class DocumentI18nTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - DocumentI18nTableMap::addInstanceToPool($obj, $key); + FolderImageI18nTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -353,12 +353,12 @@ class DocumentI18nTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(DocumentI18nTableMap::ID); - $criteria->addSelectColumn(DocumentI18nTableMap::LOCALE); - $criteria->addSelectColumn(DocumentI18nTableMap::TITLE); - $criteria->addSelectColumn(DocumentI18nTableMap::DESCRIPTION); - $criteria->addSelectColumn(DocumentI18nTableMap::CHAPO); - $criteria->addSelectColumn(DocumentI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(FolderImageI18nTableMap::ID); + $criteria->addSelectColumn(FolderImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(FolderImageI18nTableMap::TITLE); + $criteria->addSelectColumn(FolderImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(FolderImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(FolderImageI18nTableMap::POSTSCRIPTUM); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOCALE'); @@ -378,7 +378,7 @@ class DocumentI18nTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(DocumentI18nTableMap::DATABASE_NAME)->getTable(DocumentI18nTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(FolderImageI18nTableMap::DATABASE_NAME)->getTable(FolderImageI18nTableMap::TABLE_NAME); } /** @@ -386,16 +386,16 @@ class DocumentI18nTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(DocumentI18nTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(DocumentI18nTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new DocumentI18nTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FolderImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FolderImageI18nTableMap()); } } /** - * Performs a DELETE on the database, given a DocumentI18n or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a FolderImageI18n or Criteria object OR a primary key value. * - * @param mixed $values Criteria or DocumentI18n object or primary key or array of primary keys + * @param mixed $values Criteria or FolderImageI18n object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -406,17 +406,17 @@ class DocumentI18nTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageI18nTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\DocumentI18n) { // it's a model object + } elseif ($values instanceof \Thelia\Model\FolderImageI18n) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(DocumentI18nTableMap::DATABASE_NAME); + $criteria = new Criteria(FolderImageI18nTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { @@ -424,17 +424,17 @@ class DocumentI18nTableMap extends TableMap $values = array($values); } foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(DocumentI18nTableMap::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(DocumentI18nTableMap::LOCALE, $value[1])); + $criterion = $criteria->getNewCriterion(FolderImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(FolderImageI18nTableMap::LOCALE, $value[1])); $criteria->addOr($criterion); } } - $query = DocumentI18nQuery::create()->mergeWith($criteria); + $query = FolderImageI18nQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { DocumentI18nTableMap::clearInstancePool(); + if ($values instanceof Criteria) { FolderImageI18nTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { DocumentI18nTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { FolderImageI18nTableMap::removeInstanceFromPool($singleval); } } @@ -442,20 +442,20 @@ class DocumentI18nTableMap extends TableMap } /** - * Deletes all rows from the document_i18n table. + * Deletes all rows from the folder_image_i18n table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return DocumentI18nQuery::create()->doDeleteAll($con); + return FolderImageI18nQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a DocumentI18n or Criteria object. + * Performs an INSERT on the database, given a FolderImageI18n or Criteria object. * - * @param mixed $criteria Criteria or DocumentI18n object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or FolderImageI18n object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -464,18 +464,18 @@ class DocumentI18nTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageI18nTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from DocumentI18n object + $criteria = $criteria->buildCriteria(); // build Criteria from FolderImageI18n object } // Set the correct dbName - $query = DocumentI18nQuery::create()->mergeWith($criteria); + $query = FolderImageI18nQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -491,7 +491,7 @@ class DocumentI18nTableMap extends TableMap return $pk; } -} // DocumentI18nTableMap +} // FolderImageI18nTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -DocumentI18nTableMap::buildTableMap(); +FolderImageI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FolderImageTableMap.php b/core/lib/Thelia/Model/Map/FolderImageTableMap.php new file mode 100644 index 000000000..6dc186658 --- /dev/null +++ b/core/lib/Thelia/Model/Map/FolderImageTableMap.php @@ -0,0 +1,475 @@ + array('Id', 'FolderId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'folderId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FolderImageTableMap::ID, FolderImageTableMap::FOLDER_ID, FolderImageTableMap::FILE, FolderImageTableMap::POSITION, FolderImageTableMap::CREATED_AT, FolderImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FOLDER_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'folder_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'FolderId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'folderId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(FolderImageTableMap::ID => 0, FolderImageTableMap::FOLDER_ID => 1, FolderImageTableMap::FILE => 2, FolderImageTableMap::POSITION => 3, FolderImageTableMap::CREATED_AT => 4, FolderImageTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FOLDER_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'folder_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('folder_image'); + $this->setPhpName('FolderImage'); + $this->setClassName('\\Thelia\\Model\\FolderImage'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', true, null, null); + $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('FolderImageI18n', '\\Thelia\\Model\\FolderImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderImageI18ns'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to folder_image * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FolderImageI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FolderImageTableMap::CLASS_DEFAULT : FolderImageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (FolderImage object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FolderImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FolderImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FolderImageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FolderImageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FolderImageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FolderImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FolderImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + FolderImageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(FolderImageTableMap::ID); + $criteria->addSelectColumn(FolderImageTableMap::FOLDER_ID); + $criteria->addSelectColumn(FolderImageTableMap::FILE); + $criteria->addSelectColumn(FolderImageTableMap::POSITION); + $criteria->addSelectColumn(FolderImageTableMap::CREATED_AT); + $criteria->addSelectColumn(FolderImageTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.FOLDER_ID'); + $criteria->addSelectColumn($alias . '.FILE'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(FolderImageTableMap::DATABASE_NAME)->getTable(FolderImageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FolderImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FolderImageTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a FolderImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or FolderImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FolderImage) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FolderImageTableMap::DATABASE_NAME); + $criteria->add(FolderImageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = FolderImageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FolderImageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FolderImageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the folder_image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FolderImageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FolderImage or Criteria object. + * + * @param mixed $criteria Criteria or FolderImage object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderImageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FolderImage object + } + + if ($criteria->containsKey(FolderImageTableMap::ID) && $criteria->keyContainsValue(FolderImageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FolderImageTableMap::ID.')'); + } + + + // Set the correct dbName + $query = FolderImageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FolderImageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FolderImageTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index cc791d467..1bfe2cd6e 100644 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -190,10 +190,10 @@ class FolderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Documents'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); + $this->addRelation('FolderImage', '\\Thelia\\Model\\FolderImage', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'FolderImages'); + $this->addRelation('FolderDocument', '\\Thelia\\Model\\FolderDocument', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'FolderDocuments'); $this->addRelation('FolderI18n', '\\Thelia\\Model\\FolderI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderI18ns'); $this->addRelation('FolderVersion', '\\Thelia\\Model\\FolderVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderVersions'); $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Contents'); @@ -220,10 +220,10 @@ class FolderTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImageTableMap::clearInstancePool(); - DocumentTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); ContentFolderTableMap::clearInstancePool(); + FolderImageTableMap::clearInstancePool(); + FolderDocumentTableMap::clearInstancePool(); FolderI18nTableMap::clearInstancePool(); FolderVersionTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/LangTableMap.php b/core/lib/Thelia/Model/Map/LangTableMap.php index c057cb315..86e3ebe16 100644 --- a/core/lib/Thelia/Model/Map/LangTableMap.php +++ b/core/lib/Thelia/Model/Map/LangTableMap.php @@ -57,7 +57,7 @@ class LangTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 8; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class LangTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 9; + const NUM_HYDRATE_COLUMNS = 8; /** * the column name for the ID field @@ -99,11 +99,6 @@ class LangTableMap extends TableMap */ const BY_DEFAULT = 'lang.BY_DEFAULT'; - /** - * the column name for the POSITION field - */ - const POSITION = 'lang.POSITION'; - /** * the column name for the CREATED_AT field */ @@ -126,12 +121,12 @@ class LangTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Title', 'Code', 'Locale', 'Url', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'title', 'code', 'locale', 'url', 'byDefault', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(LangTableMap::ID, LangTableMap::TITLE, LangTableMap::CODE, LangTableMap::LOCALE, LangTableMap::URL, LangTableMap::BY_DEFAULT, LangTableMap::POSITION, LangTableMap::CREATED_AT, LangTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CODE', 'LOCALE', 'URL', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'title', 'code', 'locale', 'url', 'by_default', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id', 'Title', 'Code', 'Locale', 'Url', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'title', 'code', 'locale', 'url', 'byDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(LangTableMap::ID, LangTableMap::TITLE, LangTableMap::CODE, LangTableMap::LOCALE, LangTableMap::URL, LangTableMap::BY_DEFAULT, LangTableMap::CREATED_AT, LangTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CODE', 'LOCALE', 'URL', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'title', 'code', 'locale', 'url', 'by_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -141,12 +136,12 @@ class LangTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'Code' => 2, 'Locale' => 3, 'Url' => 4, 'ByDefault' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'byDefault' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - self::TYPE_COLNAME => array(LangTableMap::ID => 0, LangTableMap::TITLE => 1, LangTableMap::CODE => 2, LangTableMap::LOCALE => 3, LangTableMap::URL => 4, LangTableMap::BY_DEFAULT => 5, LangTableMap::POSITION => 6, LangTableMap::CREATED_AT => 7, LangTableMap::UPDATED_AT => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'LOCALE' => 3, 'URL' => 4, 'BY_DEFAULT' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'by_default' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'Code' => 2, 'Locale' => 3, 'Url' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(LangTableMap::ID => 0, LangTableMap::TITLE => 1, LangTableMap::CODE => 2, LangTableMap::LOCALE => 3, LangTableMap::URL => 4, LangTableMap::BY_DEFAULT => 5, LangTableMap::CREATED_AT => 6, LangTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'LOCALE' => 3, 'URL' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -171,7 +166,6 @@ class LangTableMap extends TableMap $this->addColumn('LOCALE', 'Locale', 'VARCHAR', false, 45, null); $this->addColumn('URL', 'Url', 'VARCHAR', false, 255, null); $this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -340,7 +334,6 @@ class LangTableMap extends TableMap $criteria->addSelectColumn(LangTableMap::LOCALE); $criteria->addSelectColumn(LangTableMap::URL); $criteria->addSelectColumn(LangTableMap::BY_DEFAULT); - $criteria->addSelectColumn(LangTableMap::POSITION); $criteria->addSelectColumn(LangTableMap::CREATED_AT); $criteria->addSelectColumn(LangTableMap::UPDATED_AT); } else { @@ -350,7 +343,6 @@ class LangTableMap extends TableMap $criteria->addSelectColumn($alias . '.LOCALE'); $criteria->addSelectColumn($alias . '.URL'); $criteria->addSelectColumn($alias . '.BY_DEFAULT'); - $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php new file mode 100644 index 000000000..09e1dc0e4 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProductDocumentI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ProductDocumentI18nTableMap::ID, ProductDocumentI18nTableMap::LOCALE, ProductDocumentI18nTableMap::TITLE, ProductDocumentI18nTableMap::DESCRIPTION, ProductDocumentI18nTableMap::CHAPO, ProductDocumentI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ProductDocumentI18nTableMap::ID => 0, ProductDocumentI18nTableMap::LOCALE => 1, ProductDocumentI18nTableMap::TITLE => 2, ProductDocumentI18nTableMap::DESCRIPTION => 3, ProductDocumentI18nTableMap::CHAPO => 4, ProductDocumentI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('product_document_i18n'); + $this->setPhpName('ProductDocumentI18n'); + $this->setClassName('\\Thelia\\Model\\ProductDocumentI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product_document', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('ProductDocument', '\\Thelia\\Model\\ProductDocument', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ProductDocumentI18n $obj A \Thelia\Model\ProductDocumentI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\ProductDocumentI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\ProductDocumentI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductDocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProductDocumentI18nTableMap::CLASS_DEFAULT : ProductDocumentI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ProductDocumentI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProductDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProductDocumentI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProductDocumentI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProductDocumentI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProductDocumentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductDocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ProductDocumentI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ProductDocumentI18nTableMap::ID); + $criteria->addSelectColumn(ProductDocumentI18nTableMap::LOCALE); + $criteria->addSelectColumn(ProductDocumentI18nTableMap::TITLE); + $criteria->addSelectColumn(ProductDocumentI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ProductDocumentI18nTableMap::CHAPO); + $criteria->addSelectColumn(ProductDocumentI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ProductDocumentI18nTableMap::DATABASE_NAME)->getTable(ProductDocumentI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductDocumentI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductDocumentI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductDocumentI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ProductDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ProductDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProductDocumentI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProductDocumentI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(ProductDocumentI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProductDocumentI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ProductDocumentI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProductDocumentI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProductDocumentI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the product_document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProductDocumentI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProductDocumentI18n or Criteria object. + * + * @param mixed $criteria Criteria or ProductDocumentI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProductDocumentI18n object + } + + + // Set the correct dbName + $query = ProductDocumentI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProductDocumentI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProductDocumentI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/DocumentTableMap.php b/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php similarity index 65% rename from core/lib/Thelia/Model/Map/DocumentTableMap.php rename to core/lib/Thelia/Model/Map/ProductDocumentTableMap.php index d53263a06..ff50bad77 100644 --- a/core/lib/Thelia/Model/Map/DocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductDocumentTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\Document; -use Thelia\Model\DocumentQuery; +use Thelia\Model\ProductDocument; +use Thelia\Model\ProductDocumentQuery; /** - * This class defines the structure of the 'document' table. + * This class defines the structure of the 'product_document' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\DocumentQuery; * (i.e. if it's a text column type). * */ -class DocumentTableMap extends TableMap +class ProductDocumentTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.DocumentTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.ProductDocumentTableMap'; /** * The default database name for this class @@ -42,22 +42,22 @@ class DocumentTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'document'; + const TABLE_NAME = 'product_document'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\Document'; + const OM_CLASS = '\\Thelia\\Model\\ProductDocument'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.Document'; + const CLASS_DEFAULT = 'Thelia.Model.ProductDocument'; /** * The total number of columns */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,52 +67,37 @@ class DocumentTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 9; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field */ - const ID = 'document.ID'; + const ID = 'product_document.ID'; /** * the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'document.PRODUCT_ID'; - - /** - * the column name for the CATEGORY_ID field - */ - const CATEGORY_ID = 'document.CATEGORY_ID'; - - /** - * the column name for the FOLDER_ID field - */ - const FOLDER_ID = 'document.FOLDER_ID'; - - /** - * the column name for the CONTENT_ID field - */ - const CONTENT_ID = 'document.CONTENT_ID'; + const PRODUCT_ID = 'product_document.PRODUCT_ID'; /** * the column name for the FILE field */ - const FILE = 'document.FILE'; + const FILE = 'product_document.FILE'; /** * the column name for the POSITION field */ - const POSITION = 'document.POSITION'; + const POSITION = 'product_document.POSITION'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'document.CREATED_AT'; + const CREATED_AT = 'product_document.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'document.UPDATED_AT'; + const UPDATED_AT = 'product_document.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -135,12 +120,12 @@ class DocumentTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(DocumentTableMap::ID, DocumentTableMap::PRODUCT_ID, DocumentTableMap::CATEGORY_ID, DocumentTableMap::FOLDER_ID, DocumentTableMap::CONTENT_ID, DocumentTableMap::FILE, DocumentTableMap::POSITION, DocumentTableMap::CREATED_AT, DocumentTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id', 'ProductId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductDocumentTableMap::ID, ProductDocumentTableMap::PRODUCT_ID, ProductDocumentTableMap::FILE, ProductDocumentTableMap::POSITION, ProductDocumentTableMap::CREATED_AT, ProductDocumentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -150,12 +135,12 @@ class DocumentTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - self::TYPE_COLNAME => array(DocumentTableMap::ID => 0, DocumentTableMap::PRODUCT_ID => 1, DocumentTableMap::CATEGORY_ID => 2, DocumentTableMap::FOLDER_ID => 3, DocumentTableMap::CONTENT_ID => 4, DocumentTableMap::FILE => 5, DocumentTableMap::POSITION => 6, DocumentTableMap::CREATED_AT => 7, DocumentTableMap::UPDATED_AT => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProductDocumentTableMap::ID => 0, ProductDocumentTableMap::PRODUCT_ID => 1, ProductDocumentTableMap::FILE => 2, ProductDocumentTableMap::POSITION => 3, ProductDocumentTableMap::CREATED_AT => 4, ProductDocumentTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -168,17 +153,14 @@ class DocumentTableMap extends TableMap public function initialize() { // attributes - $this->setName('document'); - $this->setPhpName('Document'); - $this->setClassName('\\Thelia\\Model\\Document'); + $this->setName('product_document'); + $this->setPhpName('ProductDocument'); + $this->setClassName('\\Thelia\\Model\\ProductDocument'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); + $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); @@ -191,10 +173,7 @@ class DocumentTableMap extends TableMap public function buildRelations() { $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('DocumentI18n', '\\Thelia\\Model\\DocumentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'DocumentI18ns'); + $this->addRelation('ProductDocumentI18n', '\\Thelia\\Model\\ProductDocumentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductDocumentI18ns'); } // buildRelations() /** @@ -211,13 +190,13 @@ class DocumentTableMap extends TableMap ); } // getBehaviors() /** - * Method to invalidate the instance pool of all tables related to document * by a foreign key with ON DELETE CASCADE + * Method to invalidate the instance pool of all tables related to product_document * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentI18nTableMap::clearInstancePool(); + ProductDocumentI18nTableMap::clearInstancePool(); } /** @@ -276,7 +255,7 @@ class DocumentTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? DocumentTableMap::CLASS_DEFAULT : DocumentTableMap::OM_CLASS; + return $withPrefix ? ProductDocumentTableMap::CLASS_DEFAULT : ProductDocumentTableMap::OM_CLASS; } /** @@ -290,21 +269,21 @@ class DocumentTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (Document object, last column rank) + * @return array (ProductDocument object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = DocumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = DocumentTableMap::getInstanceFromPool($key))) { + $key = ProductDocumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductDocumentTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + DocumentTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + ProductDocumentTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = DocumentTableMap::OM_CLASS; + $cls = ProductDocumentTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - DocumentTableMap::addInstanceToPool($obj, $key); + ProductDocumentTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -327,8 +306,8 @@ class DocumentTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = DocumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = DocumentTableMap::getInstanceFromPool($key))) { + $key = ProductDocumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductDocumentTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -337,7 +316,7 @@ class DocumentTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - DocumentTableMap::addInstanceToPool($obj, $key); + ProductDocumentTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -358,21 +337,15 @@ class DocumentTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(DocumentTableMap::ID); - $criteria->addSelectColumn(DocumentTableMap::PRODUCT_ID); - $criteria->addSelectColumn(DocumentTableMap::CATEGORY_ID); - $criteria->addSelectColumn(DocumentTableMap::FOLDER_ID); - $criteria->addSelectColumn(DocumentTableMap::CONTENT_ID); - $criteria->addSelectColumn(DocumentTableMap::FILE); - $criteria->addSelectColumn(DocumentTableMap::POSITION); - $criteria->addSelectColumn(DocumentTableMap::CREATED_AT); - $criteria->addSelectColumn(DocumentTableMap::UPDATED_AT); + $criteria->addSelectColumn(ProductDocumentTableMap::ID); + $criteria->addSelectColumn(ProductDocumentTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ProductDocumentTableMap::FILE); + $criteria->addSelectColumn(ProductDocumentTableMap::POSITION); + $criteria->addSelectColumn(ProductDocumentTableMap::CREATED_AT); + $criteria->addSelectColumn(ProductDocumentTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.FOLDER_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); $criteria->addSelectColumn($alias . '.FILE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); @@ -389,7 +362,7 @@ class DocumentTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(DocumentTableMap::DATABASE_NAME)->getTable(DocumentTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(ProductDocumentTableMap::DATABASE_NAME)->getTable(ProductDocumentTableMap::TABLE_NAME); } /** @@ -397,16 +370,16 @@ class DocumentTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(DocumentTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(DocumentTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new DocumentTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductDocumentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductDocumentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductDocumentTableMap()); } } /** - * Performs a DELETE on the database, given a Document or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ProductDocument or Criteria object OR a primary key value. * - * @param mixed $values Criteria or Document object or primary key or array of primary keys + * @param mixed $values Criteria or ProductDocument object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -417,25 +390,25 @@ class DocumentTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Document) { // it's a model object + } elseif ($values instanceof \Thelia\Model\ProductDocument) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(DocumentTableMap::DATABASE_NAME); - $criteria->add(DocumentTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(ProductDocumentTableMap::DATABASE_NAME); + $criteria->add(ProductDocumentTableMap::ID, (array) $values, Criteria::IN); } - $query = DocumentQuery::create()->mergeWith($criteria); + $query = ProductDocumentQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { DocumentTableMap::clearInstancePool(); + if ($values instanceof Criteria) { ProductDocumentTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { DocumentTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { ProductDocumentTableMap::removeInstanceFromPool($singleval); } } @@ -443,20 +416,20 @@ class DocumentTableMap extends TableMap } /** - * Deletes all rows from the document table. + * Deletes all rows from the product_document table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return DocumentQuery::create()->doDeleteAll($con); + return ProductDocumentQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a Document or Criteria object. + * Performs an INSERT on the database, given a ProductDocument or Criteria object. * - * @param mixed $criteria Criteria or Document object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or ProductDocument object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -465,22 +438,22 @@ class DocumentTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductDocumentTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Document object + $criteria = $criteria->buildCriteria(); // build Criteria from ProductDocument object } - if ($criteria->containsKey(DocumentTableMap::ID) && $criteria->keyContainsValue(DocumentTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.DocumentTableMap::ID.')'); + if ($criteria->containsKey(ProductDocumentTableMap::ID) && $criteria->keyContainsValue(ProductDocumentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductDocumentTableMap::ID.')'); } // Set the correct dbName - $query = DocumentQuery::create()->mergeWith($criteria); + $query = ProductDocumentQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -496,7 +469,7 @@ class DocumentTableMap extends TableMap return $pk; } -} // DocumentTableMap +} // ProductDocumentTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -DocumentTableMap::buildTableMap(); +ProductDocumentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index b61dd1815..5fa712cce 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -201,8 +201,8 @@ class ProductTableMap extends TableMap $this->addRelation('FeatureProduct', '\\Thelia\\Model\\FeatureProduct', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProducts'); $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductSaleElementss'); $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); - $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Documents'); + $this->addRelation('ProdutImage', '\\Thelia\\Model\\ProdutImage', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProdutImages'); + $this->addRelation('ProductDocument', '\\Thelia\\Model\\ProductDocument', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductDocuments'); $this->addRelation('AccessoryRelatedByProductId', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByProductId'); $this->addRelation('AccessoryRelatedByAccessory', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByAccessory'); $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); @@ -239,8 +239,8 @@ class ProductTableMap extends TableMap FeatureProductTableMap::clearInstancePool(); ProductSaleElementsTableMap::clearInstancePool(); ContentAssocTableMap::clearInstancePool(); - ImageTableMap::clearInstancePool(); - DocumentTableMap::clearInstancePool(); + ProdutImageTableMap::clearInstancePool(); + ProductDocumentTableMap::clearInstancePool(); AccessoryTableMap::clearInstancePool(); RewritingTableMap::clearInstancePool(); ProductI18nTableMap::clearInstancePool(); diff --git a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ProdutImageI18nTableMap.php similarity index 76% rename from core/lib/Thelia/Model/Map/ImageI18nTableMap.php rename to core/lib/Thelia/Model/Map/ProdutImageI18nTableMap.php index a78e7667c..affc799e2 100644 --- a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProdutImageI18nTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\ImageI18n; -use Thelia\Model\ImageI18nQuery; +use Thelia\Model\ProdutImageI18n; +use Thelia\Model\ProdutImageI18nQuery; /** - * This class defines the structure of the 'image_i18n' table. + * This class defines the structure of the 'produt_image_i18n' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\ImageI18nQuery; * (i.e. if it's a text column type). * */ -class ImageI18nTableMap extends TableMap +class ProdutImageI18nTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.ImageI18nTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.ProdutImageI18nTableMap'; /** * The default database name for this class @@ -42,17 +42,17 @@ class ImageI18nTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'image_i18n'; + const TABLE_NAME = 'produt_image_i18n'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\ImageI18n'; + const OM_CLASS = '\\Thelia\\Model\\ProdutImageI18n'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.ImageI18n'; + const CLASS_DEFAULT = 'Thelia.Model.ProdutImageI18n'; /** * The total number of columns @@ -72,32 +72,32 @@ class ImageI18nTableMap extends TableMap /** * the column name for the ID field */ - const ID = 'image_i18n.ID'; + const ID = 'produt_image_i18n.ID'; /** * the column name for the LOCALE field */ - const LOCALE = 'image_i18n.LOCALE'; + const LOCALE = 'produt_image_i18n.LOCALE'; /** * the column name for the TITLE field */ - const TITLE = 'image_i18n.TITLE'; + const TITLE = 'produt_image_i18n.TITLE'; /** * the column name for the DESCRIPTION field */ - const DESCRIPTION = 'image_i18n.DESCRIPTION'; + const DESCRIPTION = 'produt_image_i18n.DESCRIPTION'; /** * the column name for the CHAPO field */ - const CHAPO = 'image_i18n.CHAPO'; + const CHAPO = 'produt_image_i18n.CHAPO'; /** * the column name for the POSTSCRIPTUM field */ - const POSTSCRIPTUM = 'image_i18n.POSTSCRIPTUM'; + const POSTSCRIPTUM = 'produt_image_i18n.POSTSCRIPTUM'; /** * The default string format for model objects of the related table @@ -113,7 +113,7 @@ class ImageI18nTableMap extends TableMap protected static $fieldNames = array ( self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_COLNAME => array(ImageI18nTableMap::ID, ImageI18nTableMap::LOCALE, ImageI18nTableMap::TITLE, ImageI18nTableMap::DESCRIPTION, ImageI18nTableMap::CHAPO, ImageI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_COLNAME => array(ProdutImageI18nTableMap::ID, ProdutImageI18nTableMap::LOCALE, ProdutImageI18nTableMap::TITLE, ProdutImageI18nTableMap::DESCRIPTION, ProdutImageI18nTableMap::CHAPO, ProdutImageI18nTableMap::POSTSCRIPTUM, ), self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) @@ -128,7 +128,7 @@ class ImageI18nTableMap extends TableMap protected static $fieldKeys = array ( self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_COLNAME => array(ImageI18nTableMap::ID => 0, ImageI18nTableMap::LOCALE => 1, ImageI18nTableMap::TITLE => 2, ImageI18nTableMap::DESCRIPTION => 3, ImageI18nTableMap::CHAPO => 4, ImageI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_COLNAME => array(ProdutImageI18nTableMap::ID => 0, ProdutImageI18nTableMap::LOCALE => 1, ProdutImageI18nTableMap::TITLE => 2, ProdutImageI18nTableMap::DESCRIPTION => 3, ProdutImageI18nTableMap::CHAPO => 4, ProdutImageI18nTableMap::POSTSCRIPTUM => 5, ), self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) @@ -144,13 +144,13 @@ class ImageI18nTableMap extends TableMap public function initialize() { // attributes - $this->setName('image_i18n'); - $this->setPhpName('ImageI18n'); - $this->setClassName('\\Thelia\\Model\\ImageI18n'); + $this->setName('produt_image_i18n'); + $this->setPhpName('ProdutImageI18n'); + $this->setClassName('\\Thelia\\Model\\ProdutImageI18n'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(false); // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'ID', true, null, null); + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'produt_image', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); @@ -163,7 +163,7 @@ class ImageI18nTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + $this->addRelation('ProdutImage', '\\Thelia\\Model\\ProdutImage', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); } // buildRelations() /** @@ -174,7 +174,7 @@ class ImageI18nTableMap extends TableMap * to the cache in order to ensure that the same objects are always returned by find*() * and findPk*() calls. * - * @param \Thelia\Model\ImageI18n $obj A \Thelia\Model\ImageI18n object. + * @param \Thelia\Model\ProdutImageI18n $obj A \Thelia\Model\ProdutImageI18n object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) @@ -195,12 +195,12 @@ class ImageI18nTableMap extends TableMap * methods in your stub classes -- you may need to explicitly remove objects * from the cache in order to prevent returning objects that no longer exist. * - * @param mixed $value A \Thelia\Model\ImageI18n object or a primary key value. + * @param mixed $value A \Thelia\Model\ProdutImageI18n object or a primary key value. */ public static function removeInstanceFromPool($value) { if (Propel::isInstancePoolingEnabled() && null !== $value) { - if (is_object($value) && $value instanceof \Thelia\Model\ImageI18n) { + if (is_object($value) && $value instanceof \Thelia\Model\ProdutImageI18n) { $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); } elseif (is_array($value) && count($value) === 2) { @@ -211,7 +211,7 @@ class ImageI18nTableMap extends TableMap return; } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProdutImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); throw $e; } @@ -271,7 +271,7 @@ class ImageI18nTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? ImageI18nTableMap::CLASS_DEFAULT : ImageI18nTableMap::OM_CLASS; + return $withPrefix ? ProdutImageI18nTableMap::CLASS_DEFAULT : ProdutImageI18nTableMap::OM_CLASS; } /** @@ -285,21 +285,21 @@ class ImageI18nTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (ImageI18n object, last column rank) + * @return array (ProdutImageI18n object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = ImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = ImageI18nTableMap::getInstanceFromPool($key))) { + $key = ProdutImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProdutImageI18nTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + ImageI18nTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + ProdutImageI18nTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = ImageI18nTableMap::OM_CLASS; + $cls = ProdutImageI18nTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - ImageI18nTableMap::addInstanceToPool($obj, $key); + ProdutImageI18nTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -322,8 +322,8 @@ class ImageI18nTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = ImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = ImageI18nTableMap::getInstanceFromPool($key))) { + $key = ProdutImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProdutImageI18nTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -332,7 +332,7 @@ class ImageI18nTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - ImageI18nTableMap::addInstanceToPool($obj, $key); + ProdutImageI18nTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -353,12 +353,12 @@ class ImageI18nTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(ImageI18nTableMap::ID); - $criteria->addSelectColumn(ImageI18nTableMap::LOCALE); - $criteria->addSelectColumn(ImageI18nTableMap::TITLE); - $criteria->addSelectColumn(ImageI18nTableMap::DESCRIPTION); - $criteria->addSelectColumn(ImageI18nTableMap::CHAPO); - $criteria->addSelectColumn(ImageI18nTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(ProdutImageI18nTableMap::ID); + $criteria->addSelectColumn(ProdutImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(ProdutImageI18nTableMap::TITLE); + $criteria->addSelectColumn(ProdutImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ProdutImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(ProdutImageI18nTableMap::POSTSCRIPTUM); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.LOCALE'); @@ -378,7 +378,7 @@ class ImageI18nTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(ImageI18nTableMap::DATABASE_NAME)->getTable(ImageI18nTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(ProdutImageI18nTableMap::DATABASE_NAME)->getTable(ProdutImageI18nTableMap::TABLE_NAME); } /** @@ -386,16 +386,16 @@ class ImageI18nTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(ImageI18nTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(ImageI18nTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new ImageI18nTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProdutImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProdutImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProdutImageI18nTableMap()); } } /** - * Performs a DELETE on the database, given a ImageI18n or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ProdutImageI18n or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ImageI18n object or primary key or array of primary keys + * @param mixed $values Criteria or ProdutImageI18n object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -406,17 +406,17 @@ class ImageI18nTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageI18nTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\ImageI18n) { // it's a model object + } elseif ($values instanceof \Thelia\Model\ProdutImageI18n) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ImageI18nTableMap::DATABASE_NAME); + $criteria = new Criteria(ProdutImageI18nTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { @@ -424,17 +424,17 @@ class ImageI18nTableMap extends TableMap $values = array($values); } foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(ImageI18nTableMap::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ImageI18nTableMap::LOCALE, $value[1])); + $criterion = $criteria->getNewCriterion(ProdutImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProdutImageI18nTableMap::LOCALE, $value[1])); $criteria->addOr($criterion); } } - $query = ImageI18nQuery::create()->mergeWith($criteria); + $query = ProdutImageI18nQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { ImageI18nTableMap::clearInstancePool(); + if ($values instanceof Criteria) { ProdutImageI18nTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { ImageI18nTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { ProdutImageI18nTableMap::removeInstanceFromPool($singleval); } } @@ -442,20 +442,20 @@ class ImageI18nTableMap extends TableMap } /** - * Deletes all rows from the image_i18n table. + * Deletes all rows from the produt_image_i18n table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return ImageI18nQuery::create()->doDeleteAll($con); + return ProdutImageI18nQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a ImageI18n or Criteria object. + * Performs an INSERT on the database, given a ProdutImageI18n or Criteria object. * - * @param mixed $criteria Criteria or ImageI18n object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or ProdutImageI18n object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -464,18 +464,18 @@ class ImageI18nTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageI18nTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from ImageI18n object + $criteria = $criteria->buildCriteria(); // build Criteria from ProdutImageI18n object } // Set the correct dbName - $query = ImageI18nQuery::create()->mergeWith($criteria); + $query = ProdutImageI18nQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -491,7 +491,7 @@ class ImageI18nTableMap extends TableMap return $pk; } -} // ImageI18nTableMap +} // ProdutImageI18nTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -ImageI18nTableMap::buildTableMap(); +ProdutImageI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ImageTableMap.php b/core/lib/Thelia/Model/Map/ProdutImageTableMap.php similarity index 66% rename from core/lib/Thelia/Model/Map/ImageTableMap.php rename to core/lib/Thelia/Model/Map/ProdutImageTableMap.php index c49f24527..a415ba991 100644 --- a/core/lib/Thelia/Model/Map/ImageTableMap.php +++ b/core/lib/Thelia/Model/Map/ProdutImageTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\Image; -use Thelia\Model\ImageQuery; +use Thelia\Model\ProdutImage; +use Thelia\Model\ProdutImageQuery; /** - * This class defines the structure of the 'image' table. + * This class defines the structure of the 'produt_image' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\ImageQuery; * (i.e. if it's a text column type). * */ -class ImageTableMap extends TableMap +class ProdutImageTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.ImageTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.ProdutImageTableMap'; /** * The default database name for this class @@ -42,22 +42,22 @@ class ImageTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'image'; + const TABLE_NAME = 'produt_image'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\Image'; + const OM_CLASS = '\\Thelia\\Model\\ProdutImage'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.Image'; + const CLASS_DEFAULT = 'Thelia.Model.ProdutImage'; /** * The total number of columns */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,52 +67,37 @@ class ImageTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 9; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field */ - const ID = 'image.ID'; + const ID = 'produt_image.ID'; /** * the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'image.PRODUCT_ID'; - - /** - * the column name for the CATEGORY_ID field - */ - const CATEGORY_ID = 'image.CATEGORY_ID'; - - /** - * the column name for the FOLDER_ID field - */ - const FOLDER_ID = 'image.FOLDER_ID'; - - /** - * the column name for the CONTENT_ID field - */ - const CONTENT_ID = 'image.CONTENT_ID'; + const PRODUCT_ID = 'produt_image.PRODUCT_ID'; /** * the column name for the FILE field */ - const FILE = 'image.FILE'; + const FILE = 'produt_image.FILE'; /** * the column name for the POSITION field */ - const POSITION = 'image.POSITION'; + const POSITION = 'produt_image.POSITION'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'image.CREATED_AT'; + const CREATED_AT = 'produt_image.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'image.UPDATED_AT'; + const UPDATED_AT = 'produt_image.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -135,12 +120,12 @@ class ImageTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ImageTableMap::ID, ImageTableMap::PRODUCT_ID, ImageTableMap::CATEGORY_ID, ImageTableMap::FOLDER_ID, ImageTableMap::CONTENT_ID, ImageTableMap::FILE, ImageTableMap::POSITION, ImageTableMap::CREATED_AT, ImageTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id', 'ProductId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProdutImageTableMap::ID, ProdutImageTableMap::PRODUCT_ID, ProdutImageTableMap::FILE, ProdutImageTableMap::POSITION, ProdutImageTableMap::CREATED_AT, ProdutImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'file', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -150,12 +135,12 @@ class ImageTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - self::TYPE_COLNAME => array(ImageTableMap::ID => 0, ImageTableMap::PRODUCT_ID => 1, ImageTableMap::CATEGORY_ID => 2, ImageTableMap::FOLDER_ID => 3, ImageTableMap::CONTENT_ID => 4, ImageTableMap::FILE => 5, ImageTableMap::POSITION => 6, ImageTableMap::CREATED_AT => 7, ImageTableMap::UPDATED_AT => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'File' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'file' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProdutImageTableMap::ID => 0, ProdutImageTableMap::PRODUCT_ID => 1, ProdutImageTableMap::FILE => 2, ProdutImageTableMap::POSITION => 3, ProdutImageTableMap::CREATED_AT => 4, ProdutImageTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FILE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'file' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -168,17 +153,14 @@ class ImageTableMap extends TableMap public function initialize() { // attributes - $this->setName('image'); - $this->setPhpName('Image'); - $this->setClassName('\\Thelia\\Model\\Image'); + $this->setName('produt_image'); + $this->setPhpName('ProdutImage'); + $this->setClassName('\\Thelia\\Model\\ProdutImage'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null); - $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null); - $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null); + $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); @@ -191,10 +173,7 @@ class ImageTableMap extends TableMap public function buildRelations() { $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('ImageI18n', '\\Thelia\\Model\\ImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ImageI18ns'); + $this->addRelation('ProdutImageI18n', '\\Thelia\\Model\\ProdutImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProdutImageI18ns'); } // buildRelations() /** @@ -211,13 +190,13 @@ class ImageTableMap extends TableMap ); } // getBehaviors() /** - * Method to invalidate the instance pool of all tables related to image * by a foreign key with ON DELETE CASCADE + * Method to invalidate the instance pool of all tables related to produt_image * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImageI18nTableMap::clearInstancePool(); + ProdutImageI18nTableMap::clearInstancePool(); } /** @@ -276,7 +255,7 @@ class ImageTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? ImageTableMap::CLASS_DEFAULT : ImageTableMap::OM_CLASS; + return $withPrefix ? ProdutImageTableMap::CLASS_DEFAULT : ProdutImageTableMap::OM_CLASS; } /** @@ -290,21 +269,21 @@ class ImageTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (Image object, last column rank) + * @return array (ProdutImage object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = ImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = ImageTableMap::getInstanceFromPool($key))) { + $key = ProdutImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProdutImageTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + ImageTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + ProdutImageTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = ImageTableMap::OM_CLASS; + $cls = ProdutImageTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - ImageTableMap::addInstanceToPool($obj, $key); + ProdutImageTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -327,8 +306,8 @@ class ImageTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = ImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = ImageTableMap::getInstanceFromPool($key))) { + $key = ProdutImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProdutImageTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -337,7 +316,7 @@ class ImageTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - ImageTableMap::addInstanceToPool($obj, $key); + ProdutImageTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -358,21 +337,15 @@ class ImageTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(ImageTableMap::ID); - $criteria->addSelectColumn(ImageTableMap::PRODUCT_ID); - $criteria->addSelectColumn(ImageTableMap::CATEGORY_ID); - $criteria->addSelectColumn(ImageTableMap::FOLDER_ID); - $criteria->addSelectColumn(ImageTableMap::CONTENT_ID); - $criteria->addSelectColumn(ImageTableMap::FILE); - $criteria->addSelectColumn(ImageTableMap::POSITION); - $criteria->addSelectColumn(ImageTableMap::CREATED_AT); - $criteria->addSelectColumn(ImageTableMap::UPDATED_AT); + $criteria->addSelectColumn(ProdutImageTableMap::ID); + $criteria->addSelectColumn(ProdutImageTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ProdutImageTableMap::FILE); + $criteria->addSelectColumn(ProdutImageTableMap::POSITION); + $criteria->addSelectColumn(ProdutImageTableMap::CREATED_AT); + $criteria->addSelectColumn(ProdutImageTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.FOLDER_ID'); - $criteria->addSelectColumn($alias . '.CONTENT_ID'); $criteria->addSelectColumn($alias . '.FILE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); @@ -389,7 +362,7 @@ class ImageTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(ImageTableMap::DATABASE_NAME)->getTable(ImageTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(ProdutImageTableMap::DATABASE_NAME)->getTable(ProdutImageTableMap::TABLE_NAME); } /** @@ -397,16 +370,16 @@ class ImageTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(ImageTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(ImageTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new ImageTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProdutImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProdutImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProdutImageTableMap()); } } /** - * Performs a DELETE on the database, given a Image or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ProdutImage or Criteria object OR a primary key value. * - * @param mixed $values Criteria or Image object or primary key or array of primary keys + * @param mixed $values Criteria or ProdutImage object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -417,25 +390,25 @@ class ImageTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Image) { // it's a model object + } elseif ($values instanceof \Thelia\Model\ProdutImage) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ImageTableMap::DATABASE_NAME); - $criteria->add(ImageTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(ProdutImageTableMap::DATABASE_NAME); + $criteria->add(ProdutImageTableMap::ID, (array) $values, Criteria::IN); } - $query = ImageQuery::create()->mergeWith($criteria); + $query = ProdutImageQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { ImageTableMap::clearInstancePool(); + if ($values instanceof Criteria) { ProdutImageTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { ImageTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { ProdutImageTableMap::removeInstanceFromPool($singleval); } } @@ -443,20 +416,20 @@ class ImageTableMap extends TableMap } /** - * Deletes all rows from the image table. + * Deletes all rows from the produt_image table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return ImageQuery::create()->doDeleteAll($con); + return ProdutImageQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a Image or Criteria object. + * Performs an INSERT on the database, given a ProdutImage or Criteria object. * - * @param mixed $criteria Criteria or Image object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or ProdutImage object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -465,22 +438,22 @@ class ImageTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProdutImageTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Image object + $criteria = $criteria->buildCriteria(); // build Criteria from ProdutImage object } - if ($criteria->containsKey(ImageTableMap::ID) && $criteria->keyContainsValue(ImageTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ImageTableMap::ID.')'); + if ($criteria->containsKey(ProdutImageTableMap::ID) && $criteria->keyContainsValue(ProdutImageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProdutImageTableMap::ID.')'); } // Set the correct dbName - $query = ImageQuery::create()->mergeWith($criteria); + $query = ProdutImageQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -496,7 +469,7 @@ class ImageTableMap extends TableMap return $pk; } -} // ImageTableMap +} // ProdutImageTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -ImageTableMap::buildTableMap(); +ProdutImageTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/ProductDocument.php b/core/lib/Thelia/Model/ProductDocument.php new file mode 100644 index 000000000..a49c4f11e --- /dev/null +++ b/core/lib/Thelia/Model/ProductDocument.php @@ -0,0 +1,10 @@ + - - + @@ -451,83 +450,41 @@
- +
- - - - + - + - - - - - - - - - - + - - - - - - - - -
- +
- - - - + - + - - - - - - - - - - + - - - - - - - - - @@ -588,8 +545,7 @@ - - + @@ -1008,4 +964,124 @@
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +