From 9a1b39f52ad648b4feb7c016eb2670009b68aaf4 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 14 May 2020 22:04:44 +0200 Subject: [PATCH] Fixed model generation --- Config/module.xml | 2 +- Model/Base/CustomerFamily.php | 763 ++++++++++++++++++++++++++- Model/Base/CustomerFamilyQuery.php | 246 ++++++++- Model/Map/CustomerFamilyTableMap.php | 48 +- 4 files changed, 1029 insertions(+), 30 deletions(-) diff --git a/Config/module.xml b/Config/module.xml index ba65e1b..110c617 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -7,7 +7,7 @@ Famille de clients et prix d'achat - 1.5.3 + 1.5.4 Guillaume Barral / Etienne Perriere gbarral@openstudio.fr / eperriere@openstudio.fr diff --git a/Model/Base/CustomerFamily.php b/Model/Base/CustomerFamily.php index 090e1b6..dc34dee 100644 --- a/Model/Base/CustomerFamily.php +++ b/Model/Base/CustomerFamily.php @@ -8,6 +8,10 @@ use CustomerFamily\Model\CustomerCustomerFamily as ChildCustomerCustomerFamily; use CustomerFamily\Model\CustomerCustomerFamilyQuery as ChildCustomerCustomerFamilyQuery; use CustomerFamily\Model\CustomerFamily as ChildCustomerFamily; +use CustomerFamily\Model\CustomerFamilyAvailableBrand as ChildCustomerFamilyAvailableBrand; +use CustomerFamily\Model\CustomerFamilyAvailableBrandQuery as ChildCustomerFamilyAvailableBrandQuery; +use CustomerFamily\Model\CustomerFamilyAvailableCategory as ChildCustomerFamilyAvailableCategory; +use CustomerFamily\Model\CustomerFamilyAvailableCategoryQuery as ChildCustomerFamilyAvailableCategoryQuery; use CustomerFamily\Model\CustomerFamilyI18n as ChildCustomerFamilyI18n; use CustomerFamily\Model\CustomerFamilyI18nQuery as ChildCustomerFamilyI18nQuery; use CustomerFamily\Model\CustomerFamilyOrder as ChildCustomerFamilyOrder; @@ -75,6 +79,20 @@ abstract class CustomerFamily implements ActiveRecordInterface */ protected $code; + /** + * The value for the category_restriction_enabled field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $category_restriction_enabled; + + /** + * The value for the brand_restriction_enabled field. + * Note: this column has a database default value of: 0 + * @var int + */ + protected $brand_restriction_enabled; + /** * The value for the is_default field. * @var int @@ -111,6 +129,18 @@ abstract class CustomerFamily implements ActiveRecordInterface protected $collCustomerFamilyOrders; protected $collCustomerFamilyOrdersPartial; + /** + * @var ObjectCollection|ChildCustomerFamilyAvailableCategory[] Collection to store aggregation of ChildCustomerFamilyAvailableCategory objects. + */ + protected $collCustomerFamilyAvailableCategories; + protected $collCustomerFamilyAvailableCategoriesPartial; + + /** + * @var ObjectCollection|ChildCustomerFamilyAvailableBrand[] Collection to store aggregation of ChildCustomerFamilyAvailableBrand objects. + */ + protected $collCustomerFamilyAvailableBrands; + protected $collCustomerFamilyAvailableBrandsPartial; + /** * @var ObjectCollection|ChildCustomerFamilyI18n[] Collection to store aggregation of ChildCustomerFamilyI18n objects. */ @@ -157,17 +187,43 @@ abstract class CustomerFamily implements ActiveRecordInterface */ protected $customerFamilyOrdersScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $customerFamilyAvailableCategoriesScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $customerFamilyAvailableBrandsScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection */ protected $customerFamilyI18nsScheduledForDeletion = null; + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->category_restriction_enabled = 0; + $this->brand_restriction_enabled = 0; + } + /** * Initializes internal state of CustomerFamily\Model\Base\CustomerFamily object. + * @see applyDefaults() */ public function __construct() { + $this->applyDefaultValues(); } /** @@ -443,6 +499,28 @@ public function getCode() return $this->code; } + /** + * Get the [category_restriction_enabled] column value. + * + * @return int + */ + public function getCategoryRestrictionEnabled() + { + + return $this->category_restriction_enabled; + } + + /** + * Get the [brand_restriction_enabled] column value. + * + * @return int + */ + public function getBrandRestrictionEnabled() + { + + return $this->brand_restriction_enabled; + } + /** * Get the [is_default] column value. * @@ -536,6 +614,48 @@ public function setCode($v) return $this; } // setCode() + /** + * Set the value of [category_restriction_enabled] column. + * + * @param int $v new value + * @return \CustomerFamily\Model\CustomerFamily The current object (for fluent API support) + */ + public function setCategoryRestrictionEnabled($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_restriction_enabled !== $v) { + $this->category_restriction_enabled = $v; + $this->modifiedColumns[CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED] = true; + } + + + return $this; + } // setCategoryRestrictionEnabled() + + /** + * Set the value of [brand_restriction_enabled] column. + * + * @param int $v new value + * @return \CustomerFamily\Model\CustomerFamily The current object (for fluent API support) + */ + public function setBrandRestrictionEnabled($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->brand_restriction_enabled !== $v) { + $this->brand_restriction_enabled = $v; + $this->modifiedColumns[CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED] = true; + } + + + return $this; + } // setBrandRestrictionEnabled() + /** * Set the value of [is_default] column. * @@ -609,6 +729,14 @@ public function setUpdatedAt($v) */ public function hasOnlyDefaultValues() { + if ($this->category_restriction_enabled !== 0) { + return false; + } + + if ($this->brand_restriction_enabled !== 0) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -642,16 +770,22 @@ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = Ta $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerFamilyTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; $this->code = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerFamilyTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerFamilyTableMap::translateFieldName('CategoryRestrictionEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_restriction_enabled = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerFamilyTableMap::translateFieldName('BrandRestrictionEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->brand_restriction_enabled = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerFamilyTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_default = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerFamilyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerFamilyTableMap::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 ? 4 + $startcol : CustomerFamilyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerFamilyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -664,7 +798,7 @@ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = Ta $this->ensureConsistency(); } - return $startcol + 5; // 5 = CustomerFamilyTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 7; // 7 = CustomerFamilyTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \CustomerFamily\Model\CustomerFamily object", 0, $e); @@ -731,6 +865,10 @@ public function reload($deep = false, ConnectionInterface $con = null) $this->collCustomerFamilyOrders = null; + $this->collCustomerFamilyAvailableCategories = null; + + $this->collCustomerFamilyAvailableBrands = null; + $this->collCustomerFamilyI18ns = null; } // if (deep) @@ -917,6 +1055,40 @@ protected function doSave(ConnectionInterface $con) } } + if ($this->customerFamilyAvailableCategoriesScheduledForDeletion !== null) { + if (!$this->customerFamilyAvailableCategoriesScheduledForDeletion->isEmpty()) { + \CustomerFamily\Model\CustomerFamilyAvailableCategoryQuery::create() + ->filterByPrimaryKeys($this->customerFamilyAvailableCategoriesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->customerFamilyAvailableCategoriesScheduledForDeletion = null; + } + } + + if ($this->collCustomerFamilyAvailableCategories !== null) { + foreach ($this->collCustomerFamilyAvailableCategories as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->customerFamilyAvailableBrandsScheduledForDeletion !== null) { + if (!$this->customerFamilyAvailableBrandsScheduledForDeletion->isEmpty()) { + \CustomerFamily\Model\CustomerFamilyAvailableBrandQuery::create() + ->filterByPrimaryKeys($this->customerFamilyAvailableBrandsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->customerFamilyAvailableBrandsScheduledForDeletion = null; + } + } + + if ($this->collCustomerFamilyAvailableBrands !== null) { + foreach ($this->collCustomerFamilyAvailableBrands as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->customerFamilyI18nsScheduledForDeletion !== null) { if (!$this->customerFamilyI18nsScheduledForDeletion->isEmpty()) { \CustomerFamily\Model\CustomerFamilyI18nQuery::create() @@ -966,6 +1138,12 @@ protected function doInsert(ConnectionInterface $con) if ($this->isColumnModified(CustomerFamilyTableMap::CODE)) { $modifiedColumns[':p' . $index++] = 'CODE'; } + if ($this->isColumnModified(CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_RESTRICTION_ENABLED'; + } + if ($this->isColumnModified(CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED)) { + $modifiedColumns[':p' . $index++] = 'BRAND_RESTRICTION_ENABLED'; + } if ($this->isColumnModified(CustomerFamilyTableMap::IS_DEFAULT)) { $modifiedColumns[':p' . $index++] = 'IS_DEFAULT'; } @@ -992,6 +1170,12 @@ protected function doInsert(ConnectionInterface $con) case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; + case 'CATEGORY_RESTRICTION_ENABLED': + $stmt->bindValue($identifier, $this->category_restriction_enabled, PDO::PARAM_INT); + break; + case 'BRAND_RESTRICTION_ENABLED': + $stmt->bindValue($identifier, $this->brand_restriction_enabled, PDO::PARAM_INT); + break; case 'IS_DEFAULT': $stmt->bindValue($identifier, $this->is_default, PDO::PARAM_INT); break; @@ -1070,12 +1254,18 @@ public function getByPosition($pos) return $this->getCode(); break; case 2: - return $this->getIsDefault(); + return $this->getCategoryRestrictionEnabled(); break; case 3: - return $this->getCreatedAt(); + return $this->getBrandRestrictionEnabled(); break; case 4: + return $this->getIsDefault(); + break; + case 5: + return $this->getCreatedAt(); + break; + case 6: return $this->getUpdatedAt(); break; default: @@ -1109,9 +1299,11 @@ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColum $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), - $keys[2] => $this->getIsDefault(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[2] => $this->getCategoryRestrictionEnabled(), + $keys[3] => $this->getBrandRestrictionEnabled(), + $keys[4] => $this->getIsDefault(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1128,6 +1320,12 @@ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColum if (null !== $this->collCustomerFamilyOrders) { $result['CustomerFamilyOrders'] = $this->collCustomerFamilyOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collCustomerFamilyAvailableCategories) { + $result['CustomerFamilyAvailableCategories'] = $this->collCustomerFamilyAvailableCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collCustomerFamilyAvailableBrands) { + $result['CustomerFamilyAvailableBrands'] = $this->collCustomerFamilyAvailableBrands->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collCustomerFamilyI18ns) { $result['CustomerFamilyI18ns'] = $this->collCustomerFamilyI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1172,12 +1370,18 @@ public function setByPosition($pos, $value) $this->setCode($value); break; case 2: - $this->setIsDefault($value); + $this->setCategoryRestrictionEnabled($value); break; case 3: - $this->setCreatedAt($value); + $this->setBrandRestrictionEnabled($value); break; case 4: + $this->setIsDefault($value); + break; + case 5: + $this->setCreatedAt($value); + break; + case 6: $this->setUpdatedAt($value); break; } // switch() @@ -1206,9 +1410,11 @@ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setIsDefault($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[2], $arr)) $this->setCategoryRestrictionEnabled($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setBrandRestrictionEnabled($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setIsDefault($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); } /** @@ -1222,6 +1428,8 @@ public function buildCriteria() if ($this->isColumnModified(CustomerFamilyTableMap::ID)) $criteria->add(CustomerFamilyTableMap::ID, $this->id); if ($this->isColumnModified(CustomerFamilyTableMap::CODE)) $criteria->add(CustomerFamilyTableMap::CODE, $this->code); + if ($this->isColumnModified(CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED)) $criteria->add(CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED, $this->category_restriction_enabled); + if ($this->isColumnModified(CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED)) $criteria->add(CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED, $this->brand_restriction_enabled); if ($this->isColumnModified(CustomerFamilyTableMap::IS_DEFAULT)) $criteria->add(CustomerFamilyTableMap::IS_DEFAULT, $this->is_default); if ($this->isColumnModified(CustomerFamilyTableMap::CREATED_AT)) $criteria->add(CustomerFamilyTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CustomerFamilyTableMap::UPDATED_AT)) $criteria->add(CustomerFamilyTableMap::UPDATED_AT, $this->updated_at); @@ -1289,6 +1497,8 @@ public function isPrimaryKeyNull() public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setCode($this->getCode()); + $copyObj->setCategoryRestrictionEnabled($this->getCategoryRestrictionEnabled()); + $copyObj->setBrandRestrictionEnabled($this->getBrandRestrictionEnabled()); $copyObj->setIsDefault($this->getIsDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1316,6 +1526,18 @@ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) } } + foreach ($this->getCustomerFamilyAvailableCategories() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCustomerFamilyAvailableCategory($relObj->copy($deepCopy)); + } + } + + foreach ($this->getCustomerFamilyAvailableBrands() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCustomerFamilyAvailableBrand($relObj->copy($deepCopy)); + } + } + foreach ($this->getCustomerFamilyI18ns() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addCustomerFamilyI18n($relObj->copy($deepCopy)); @@ -1372,6 +1594,12 @@ public function initRelation($relationName) if ('CustomerFamilyOrder' == $relationName) { return $this->initCustomerFamilyOrders(); } + if ('CustomerFamilyAvailableCategory' == $relationName) { + return $this->initCustomerFamilyAvailableCategories(); + } + if ('CustomerFamilyAvailableBrand' == $relationName) { + return $this->initCustomerFamilyAvailableBrands(); + } if ('CustomerFamilyI18n' == $relationName) { return $this->initCustomerFamilyI18ns(); } @@ -2084,6 +2312,498 @@ public function getCustomerFamilyOrdersJoinOrder($criteria = null, $con = null, return $this->getCustomerFamilyOrders($query, $con); } + /** + * Clears out the collCustomerFamilyAvailableCategories 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 addCustomerFamilyAvailableCategories() + */ + public function clearCustomerFamilyAvailableCategories() + { + $this->collCustomerFamilyAvailableCategories = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCustomerFamilyAvailableCategories collection loaded partially. + */ + public function resetPartialCustomerFamilyAvailableCategories($v = true) + { + $this->collCustomerFamilyAvailableCategoriesPartial = $v; + } + + /** + * Initializes the collCustomerFamilyAvailableCategories collection. + * + * By default this just sets the collCustomerFamilyAvailableCategories collection to an empty array (like clearcollCustomerFamilyAvailableCategories()); + * 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 initCustomerFamilyAvailableCategories($overrideExisting = true) + { + if (null !== $this->collCustomerFamilyAvailableCategories && !$overrideExisting) { + return; + } + $this->collCustomerFamilyAvailableCategories = new ObjectCollection(); + $this->collCustomerFamilyAvailableCategories->setModel('\CustomerFamily\Model\CustomerFamilyAvailableCategory'); + } + + /** + * Gets an array of ChildCustomerFamilyAvailableCategory 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 ChildCustomerFamily 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|ChildCustomerFamilyAvailableCategory[] List of ChildCustomerFamilyAvailableCategory objects + * @throws PropelException + */ + public function getCustomerFamilyAvailableCategories($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCustomerFamilyAvailableCategoriesPartial && !$this->isNew(); + if (null === $this->collCustomerFamilyAvailableCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCustomerFamilyAvailableCategories) { + // return empty collection + $this->initCustomerFamilyAvailableCategories(); + } else { + $collCustomerFamilyAvailableCategories = ChildCustomerFamilyAvailableCategoryQuery::create(null, $criteria) + ->filterByCustomerFamily($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCustomerFamilyAvailableCategoriesPartial && count($collCustomerFamilyAvailableCategories)) { + $this->initCustomerFamilyAvailableCategories(false); + + foreach ($collCustomerFamilyAvailableCategories as $obj) { + if (false == $this->collCustomerFamilyAvailableCategories->contains($obj)) { + $this->collCustomerFamilyAvailableCategories->append($obj); + } + } + + $this->collCustomerFamilyAvailableCategoriesPartial = true; + } + + reset($collCustomerFamilyAvailableCategories); + + return $collCustomerFamilyAvailableCategories; + } + + if ($partial && $this->collCustomerFamilyAvailableCategories) { + foreach ($this->collCustomerFamilyAvailableCategories as $obj) { + if ($obj->isNew()) { + $collCustomerFamilyAvailableCategories[] = $obj; + } + } + } + + $this->collCustomerFamilyAvailableCategories = $collCustomerFamilyAvailableCategories; + $this->collCustomerFamilyAvailableCategoriesPartial = false; + } + } + + return $this->collCustomerFamilyAvailableCategories; + } + + /** + * Sets a collection of CustomerFamilyAvailableCategory 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 $customerFamilyAvailableCategories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomerFamily The current object (for fluent API support) + */ + public function setCustomerFamilyAvailableCategories(Collection $customerFamilyAvailableCategories, ConnectionInterface $con = null) + { + $customerFamilyAvailableCategoriesToDelete = $this->getCustomerFamilyAvailableCategories(new Criteria(), $con)->diff($customerFamilyAvailableCategories); + + + //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->customerFamilyAvailableCategoriesScheduledForDeletion = clone $customerFamilyAvailableCategoriesToDelete; + + foreach ($customerFamilyAvailableCategoriesToDelete as $customerFamilyAvailableCategoryRemoved) { + $customerFamilyAvailableCategoryRemoved->setCustomerFamily(null); + } + + $this->collCustomerFamilyAvailableCategories = null; + foreach ($customerFamilyAvailableCategories as $customerFamilyAvailableCategory) { + $this->addCustomerFamilyAvailableCategory($customerFamilyAvailableCategory); + } + + $this->collCustomerFamilyAvailableCategories = $customerFamilyAvailableCategories; + $this->collCustomerFamilyAvailableCategoriesPartial = false; + + return $this; + } + + /** + * Returns the number of related CustomerFamilyAvailableCategory objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CustomerFamilyAvailableCategory objects. + * @throws PropelException + */ + public function countCustomerFamilyAvailableCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCustomerFamilyAvailableCategoriesPartial && !$this->isNew(); + if (null === $this->collCustomerFamilyAvailableCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCustomerFamilyAvailableCategories) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCustomerFamilyAvailableCategories()); + } + + $query = ChildCustomerFamilyAvailableCategoryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomerFamily($this) + ->count($con); + } + + return count($this->collCustomerFamilyAvailableCategories); + } + + /** + * Method called to associate a ChildCustomerFamilyAvailableCategory object to this object + * through the ChildCustomerFamilyAvailableCategory foreign key attribute. + * + * @param ChildCustomerFamilyAvailableCategory $l ChildCustomerFamilyAvailableCategory + * @return \CustomerFamily\Model\CustomerFamily The current object (for fluent API support) + */ + public function addCustomerFamilyAvailableCategory(ChildCustomerFamilyAvailableCategory $l) + { + if ($this->collCustomerFamilyAvailableCategories === null) { + $this->initCustomerFamilyAvailableCategories(); + $this->collCustomerFamilyAvailableCategoriesPartial = true; + } + + if (!in_array($l, $this->collCustomerFamilyAvailableCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCustomerFamilyAvailableCategory($l); + } + + return $this; + } + + /** + * @param CustomerFamilyAvailableCategory $customerFamilyAvailableCategory The customerFamilyAvailableCategory object to add. + */ + protected function doAddCustomerFamilyAvailableCategory($customerFamilyAvailableCategory) + { + $this->collCustomerFamilyAvailableCategories[]= $customerFamilyAvailableCategory; + $customerFamilyAvailableCategory->setCustomerFamily($this); + } + + /** + * @param CustomerFamilyAvailableCategory $customerFamilyAvailableCategory The customerFamilyAvailableCategory object to remove. + * @return ChildCustomerFamily The current object (for fluent API support) + */ + public function removeCustomerFamilyAvailableCategory($customerFamilyAvailableCategory) + { + if ($this->getCustomerFamilyAvailableCategories()->contains($customerFamilyAvailableCategory)) { + $this->collCustomerFamilyAvailableCategories->remove($this->collCustomerFamilyAvailableCategories->search($customerFamilyAvailableCategory)); + if (null === $this->customerFamilyAvailableCategoriesScheduledForDeletion) { + $this->customerFamilyAvailableCategoriesScheduledForDeletion = clone $this->collCustomerFamilyAvailableCategories; + $this->customerFamilyAvailableCategoriesScheduledForDeletion->clear(); + } + $this->customerFamilyAvailableCategoriesScheduledForDeletion[]= clone $customerFamilyAvailableCategory; + $customerFamilyAvailableCategory->setCustomerFamily(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CustomerFamily is new, it will return + * an empty collection; or if this CustomerFamily has previously + * been saved, it will retrieve related CustomerFamilyAvailableCategories 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 CustomerFamily. + * + * @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|ChildCustomerFamilyAvailableCategory[] List of ChildCustomerFamilyAvailableCategory objects + */ + public function getCustomerFamilyAvailableCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCustomerFamilyAvailableCategoryQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); + + return $this->getCustomerFamilyAvailableCategories($query, $con); + } + + /** + * Clears out the collCustomerFamilyAvailableBrands 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 addCustomerFamilyAvailableBrands() + */ + public function clearCustomerFamilyAvailableBrands() + { + $this->collCustomerFamilyAvailableBrands = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCustomerFamilyAvailableBrands collection loaded partially. + */ + public function resetPartialCustomerFamilyAvailableBrands($v = true) + { + $this->collCustomerFamilyAvailableBrandsPartial = $v; + } + + /** + * Initializes the collCustomerFamilyAvailableBrands collection. + * + * By default this just sets the collCustomerFamilyAvailableBrands collection to an empty array (like clearcollCustomerFamilyAvailableBrands()); + * 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 initCustomerFamilyAvailableBrands($overrideExisting = true) + { + if (null !== $this->collCustomerFamilyAvailableBrands && !$overrideExisting) { + return; + } + $this->collCustomerFamilyAvailableBrands = new ObjectCollection(); + $this->collCustomerFamilyAvailableBrands->setModel('\CustomerFamily\Model\CustomerFamilyAvailableBrand'); + } + + /** + * Gets an array of ChildCustomerFamilyAvailableBrand 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 ChildCustomerFamily 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|ChildCustomerFamilyAvailableBrand[] List of ChildCustomerFamilyAvailableBrand objects + * @throws PropelException + */ + public function getCustomerFamilyAvailableBrands($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCustomerFamilyAvailableBrandsPartial && !$this->isNew(); + if (null === $this->collCustomerFamilyAvailableBrands || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCustomerFamilyAvailableBrands) { + // return empty collection + $this->initCustomerFamilyAvailableBrands(); + } else { + $collCustomerFamilyAvailableBrands = ChildCustomerFamilyAvailableBrandQuery::create(null, $criteria) + ->filterByCustomerFamily($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCustomerFamilyAvailableBrandsPartial && count($collCustomerFamilyAvailableBrands)) { + $this->initCustomerFamilyAvailableBrands(false); + + foreach ($collCustomerFamilyAvailableBrands as $obj) { + if (false == $this->collCustomerFamilyAvailableBrands->contains($obj)) { + $this->collCustomerFamilyAvailableBrands->append($obj); + } + } + + $this->collCustomerFamilyAvailableBrandsPartial = true; + } + + reset($collCustomerFamilyAvailableBrands); + + return $collCustomerFamilyAvailableBrands; + } + + if ($partial && $this->collCustomerFamilyAvailableBrands) { + foreach ($this->collCustomerFamilyAvailableBrands as $obj) { + if ($obj->isNew()) { + $collCustomerFamilyAvailableBrands[] = $obj; + } + } + } + + $this->collCustomerFamilyAvailableBrands = $collCustomerFamilyAvailableBrands; + $this->collCustomerFamilyAvailableBrandsPartial = false; + } + } + + return $this->collCustomerFamilyAvailableBrands; + } + + /** + * Sets a collection of CustomerFamilyAvailableBrand 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 $customerFamilyAvailableBrands A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomerFamily The current object (for fluent API support) + */ + public function setCustomerFamilyAvailableBrands(Collection $customerFamilyAvailableBrands, ConnectionInterface $con = null) + { + $customerFamilyAvailableBrandsToDelete = $this->getCustomerFamilyAvailableBrands(new Criteria(), $con)->diff($customerFamilyAvailableBrands); + + + //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->customerFamilyAvailableBrandsScheduledForDeletion = clone $customerFamilyAvailableBrandsToDelete; + + foreach ($customerFamilyAvailableBrandsToDelete as $customerFamilyAvailableBrandRemoved) { + $customerFamilyAvailableBrandRemoved->setCustomerFamily(null); + } + + $this->collCustomerFamilyAvailableBrands = null; + foreach ($customerFamilyAvailableBrands as $customerFamilyAvailableBrand) { + $this->addCustomerFamilyAvailableBrand($customerFamilyAvailableBrand); + } + + $this->collCustomerFamilyAvailableBrands = $customerFamilyAvailableBrands; + $this->collCustomerFamilyAvailableBrandsPartial = false; + + return $this; + } + + /** + * Returns the number of related CustomerFamilyAvailableBrand objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CustomerFamilyAvailableBrand objects. + * @throws PropelException + */ + public function countCustomerFamilyAvailableBrands(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCustomerFamilyAvailableBrandsPartial && !$this->isNew(); + if (null === $this->collCustomerFamilyAvailableBrands || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCustomerFamilyAvailableBrands) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCustomerFamilyAvailableBrands()); + } + + $query = ChildCustomerFamilyAvailableBrandQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCustomerFamily($this) + ->count($con); + } + + return count($this->collCustomerFamilyAvailableBrands); + } + + /** + * Method called to associate a ChildCustomerFamilyAvailableBrand object to this object + * through the ChildCustomerFamilyAvailableBrand foreign key attribute. + * + * @param ChildCustomerFamilyAvailableBrand $l ChildCustomerFamilyAvailableBrand + * @return \CustomerFamily\Model\CustomerFamily The current object (for fluent API support) + */ + public function addCustomerFamilyAvailableBrand(ChildCustomerFamilyAvailableBrand $l) + { + if ($this->collCustomerFamilyAvailableBrands === null) { + $this->initCustomerFamilyAvailableBrands(); + $this->collCustomerFamilyAvailableBrandsPartial = true; + } + + if (!in_array($l, $this->collCustomerFamilyAvailableBrands->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCustomerFamilyAvailableBrand($l); + } + + return $this; + } + + /** + * @param CustomerFamilyAvailableBrand $customerFamilyAvailableBrand The customerFamilyAvailableBrand object to add. + */ + protected function doAddCustomerFamilyAvailableBrand($customerFamilyAvailableBrand) + { + $this->collCustomerFamilyAvailableBrands[]= $customerFamilyAvailableBrand; + $customerFamilyAvailableBrand->setCustomerFamily($this); + } + + /** + * @param CustomerFamilyAvailableBrand $customerFamilyAvailableBrand The customerFamilyAvailableBrand object to remove. + * @return ChildCustomerFamily The current object (for fluent API support) + */ + public function removeCustomerFamilyAvailableBrand($customerFamilyAvailableBrand) + { + if ($this->getCustomerFamilyAvailableBrands()->contains($customerFamilyAvailableBrand)) { + $this->collCustomerFamilyAvailableBrands->remove($this->collCustomerFamilyAvailableBrands->search($customerFamilyAvailableBrand)); + if (null === $this->customerFamilyAvailableBrandsScheduledForDeletion) { + $this->customerFamilyAvailableBrandsScheduledForDeletion = clone $this->collCustomerFamilyAvailableBrands; + $this->customerFamilyAvailableBrandsScheduledForDeletion->clear(); + } + $this->customerFamilyAvailableBrandsScheduledForDeletion[]= clone $customerFamilyAvailableBrand; + $customerFamilyAvailableBrand->setCustomerFamily(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CustomerFamily is new, it will return + * an empty collection; or if this CustomerFamily has previously + * been saved, it will retrieve related CustomerFamilyAvailableBrands 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 CustomerFamily. + * + * @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|ChildCustomerFamilyAvailableBrand[] List of ChildCustomerFamilyAvailableBrand objects + */ + public function getCustomerFamilyAvailableBrandsJoinBrand($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildCustomerFamilyAvailableBrandQuery::create(null, $criteria); + $query->joinWith('Brand', $joinBehavior); + + return $this->getCustomerFamilyAvailableBrands($query, $con); + } + /** * Clears out the collCustomerFamilyI18ns collection * @@ -2316,11 +3036,14 @@ public function clear() { $this->id = null; $this->code = null; + $this->category_restriction_enabled = null; + $this->brand_restriction_enabled = null; $this->is_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); + $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); @@ -2353,6 +3076,16 @@ public function clearAllReferences($deep = false) $o->clearAllReferences($deep); } } + if ($this->collCustomerFamilyAvailableCategories) { + foreach ($this->collCustomerFamilyAvailableCategories as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collCustomerFamilyAvailableBrands) { + foreach ($this->collCustomerFamilyAvailableBrands as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collCustomerFamilyI18ns) { foreach ($this->collCustomerFamilyI18ns as $o) { $o->clearAllReferences($deep); @@ -2367,6 +3100,8 @@ public function clearAllReferences($deep = false) $this->collCustomerCustomerFamilies = null; $this->collCustomerFamilyPrices = null; $this->collCustomerFamilyOrders = null; + $this->collCustomerFamilyAvailableCategories = null; + $this->collCustomerFamilyAvailableBrands = null; $this->collCustomerFamilyI18ns = null; } diff --git a/Model/Base/CustomerFamilyQuery.php b/Model/Base/CustomerFamilyQuery.php index c15da4f..35d19ea 100644 --- a/Model/Base/CustomerFamilyQuery.php +++ b/Model/Base/CustomerFamilyQuery.php @@ -24,12 +24,16 @@ * * @method ChildCustomerFamilyQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildCustomerFamilyQuery orderByCode($order = Criteria::ASC) Order by the code column + * @method ChildCustomerFamilyQuery orderByCategoryRestrictionEnabled($order = Criteria::ASC) Order by the category_restriction_enabled column + * @method ChildCustomerFamilyQuery orderByBrandRestrictionEnabled($order = Criteria::ASC) Order by the brand_restriction_enabled column * @method ChildCustomerFamilyQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column * @method ChildCustomerFamilyQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCustomerFamilyQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildCustomerFamilyQuery groupById() Group by the id column * @method ChildCustomerFamilyQuery groupByCode() Group by the code column + * @method ChildCustomerFamilyQuery groupByCategoryRestrictionEnabled() Group by the category_restriction_enabled column + * @method ChildCustomerFamilyQuery groupByBrandRestrictionEnabled() Group by the brand_restriction_enabled column * @method ChildCustomerFamilyQuery groupByIsDefault() Group by the is_default column * @method ChildCustomerFamilyQuery groupByCreatedAt() Group by the created_at column * @method ChildCustomerFamilyQuery groupByUpdatedAt() Group by the updated_at column @@ -50,6 +54,14 @@ * @method ChildCustomerFamilyQuery rightJoinCustomerFamilyOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerFamilyOrder relation * @method ChildCustomerFamilyQuery innerJoinCustomerFamilyOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerFamilyOrder relation * + * @method ChildCustomerFamilyQuery leftJoinCustomerFamilyAvailableCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerFamilyAvailableCategory relation + * @method ChildCustomerFamilyQuery rightJoinCustomerFamilyAvailableCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerFamilyAvailableCategory relation + * @method ChildCustomerFamilyQuery innerJoinCustomerFamilyAvailableCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerFamilyAvailableCategory relation + * + * @method ChildCustomerFamilyQuery leftJoinCustomerFamilyAvailableBrand($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerFamilyAvailableBrand relation + * @method ChildCustomerFamilyQuery rightJoinCustomerFamilyAvailableBrand($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerFamilyAvailableBrand relation + * @method ChildCustomerFamilyQuery innerJoinCustomerFamilyAvailableBrand($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerFamilyAvailableBrand relation + * * @method ChildCustomerFamilyQuery leftJoinCustomerFamilyI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerFamilyI18n relation * @method ChildCustomerFamilyQuery rightJoinCustomerFamilyI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerFamilyI18n relation * @method ChildCustomerFamilyQuery innerJoinCustomerFamilyI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerFamilyI18n relation @@ -59,12 +71,16 @@ * * @method ChildCustomerFamily findOneById(int $id) Return the first ChildCustomerFamily filtered by the id column * @method ChildCustomerFamily findOneByCode(string $code) Return the first ChildCustomerFamily filtered by the code column + * @method ChildCustomerFamily findOneByCategoryRestrictionEnabled(int $category_restriction_enabled) Return the first ChildCustomerFamily filtered by the category_restriction_enabled column + * @method ChildCustomerFamily findOneByBrandRestrictionEnabled(int $brand_restriction_enabled) Return the first ChildCustomerFamily filtered by the brand_restriction_enabled column * @method ChildCustomerFamily findOneByIsDefault(int $is_default) Return the first ChildCustomerFamily filtered by the is_default column * @method ChildCustomerFamily findOneByCreatedAt(string $created_at) Return the first ChildCustomerFamily filtered by the created_at column * @method ChildCustomerFamily findOneByUpdatedAt(string $updated_at) Return the first ChildCustomerFamily filtered by the updated_at column * * @method array findById(int $id) Return ChildCustomerFamily objects filtered by the id column * @method array findByCode(string $code) Return ChildCustomerFamily objects filtered by the code column + * @method array findByCategoryRestrictionEnabled(int $category_restriction_enabled) Return ChildCustomerFamily objects filtered by the category_restriction_enabled column + * @method array findByBrandRestrictionEnabled(int $brand_restriction_enabled) Return ChildCustomerFamily objects filtered by the brand_restriction_enabled column * @method array findByIsDefault(int $is_default) Return ChildCustomerFamily objects filtered by the is_default column * @method array findByCreatedAt(string $created_at) Return ChildCustomerFamily objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCustomerFamily objects filtered by the updated_at column @@ -156,7 +172,7 @@ public function findPk($key, $con = null) */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM customer_family WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, CATEGORY_RESTRICTION_ENABLED, BRAND_RESTRICTION_ENABLED, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM customer_family WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -315,6 +331,88 @@ public function filterByCode($code = null, $comparison = null) return $this->addUsingAlias(CustomerFamilyTableMap::CODE, $code, $comparison); } + /** + * Filter the query on the category_restriction_enabled column + * + * Example usage: + * + * $query->filterByCategoryRestrictionEnabled(1234); // WHERE category_restriction_enabled = 1234 + * $query->filterByCategoryRestrictionEnabled(array(12, 34)); // WHERE category_restriction_enabled IN (12, 34) + * $query->filterByCategoryRestrictionEnabled(array('min' => 12)); // WHERE category_restriction_enabled > 12 + * + * + * @param mixed $categoryRestrictionEnabled 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 ChildCustomerFamilyQuery The current query, for fluid interface + */ + public function filterByCategoryRestrictionEnabled($categoryRestrictionEnabled = null, $comparison = null) + { + if (is_array($categoryRestrictionEnabled)) { + $useMinMax = false; + if (isset($categoryRestrictionEnabled['min'])) { + $this->addUsingAlias(CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED, $categoryRestrictionEnabled['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($categoryRestrictionEnabled['max'])) { + $this->addUsingAlias(CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED, $categoryRestrictionEnabled['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED, $categoryRestrictionEnabled, $comparison); + } + + /** + * Filter the query on the brand_restriction_enabled column + * + * Example usage: + * + * $query->filterByBrandRestrictionEnabled(1234); // WHERE brand_restriction_enabled = 1234 + * $query->filterByBrandRestrictionEnabled(array(12, 34)); // WHERE brand_restriction_enabled IN (12, 34) + * $query->filterByBrandRestrictionEnabled(array('min' => 12)); // WHERE brand_restriction_enabled > 12 + * + * + * @param mixed $brandRestrictionEnabled 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 ChildCustomerFamilyQuery The current query, for fluid interface + */ + public function filterByBrandRestrictionEnabled($brandRestrictionEnabled = null, $comparison = null) + { + if (is_array($brandRestrictionEnabled)) { + $useMinMax = false; + if (isset($brandRestrictionEnabled['min'])) { + $this->addUsingAlias(CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED, $brandRestrictionEnabled['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($brandRestrictionEnabled['max'])) { + $this->addUsingAlias(CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED, $brandRestrictionEnabled['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED, $brandRestrictionEnabled, $comparison); + } + /** * Filter the query on the is_default column * @@ -661,6 +759,152 @@ public function useCustomerFamilyOrderQuery($relationAlias = null, $joinType = C ->useQuery($relationAlias ? $relationAlias : 'CustomerFamilyOrder', '\CustomerFamily\Model\CustomerFamilyOrderQuery'); } + /** + * Filter the query by a related \CustomerFamily\Model\CustomerFamilyAvailableCategory object + * + * @param \CustomerFamily\Model\CustomerFamilyAvailableCategory|ObjectCollection $customerFamilyAvailableCategory the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCustomerFamilyQuery The current query, for fluid interface + */ + public function filterByCustomerFamilyAvailableCategory($customerFamilyAvailableCategory, $comparison = null) + { + if ($customerFamilyAvailableCategory instanceof \CustomerFamily\Model\CustomerFamilyAvailableCategory) { + return $this + ->addUsingAlias(CustomerFamilyTableMap::ID, $customerFamilyAvailableCategory->getCustomerFamilyId(), $comparison); + } elseif ($customerFamilyAvailableCategory instanceof ObjectCollection) { + return $this + ->useCustomerFamilyAvailableCategoryQuery() + ->filterByPrimaryKeys($customerFamilyAvailableCategory->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCustomerFamilyAvailableCategory() only accepts arguments of type \CustomerFamily\Model\CustomerFamilyAvailableCategory or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CustomerFamilyAvailableCategory relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCustomerFamilyQuery The current query, for fluid interface + */ + public function joinCustomerFamilyAvailableCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CustomerFamilyAvailableCategory'); + + // 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, 'CustomerFamilyAvailableCategory'); + } + + return $this; + } + + /** + * Use the CustomerFamilyAvailableCategory relation CustomerFamilyAvailableCategory 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 \CustomerFamily\Model\CustomerFamilyAvailableCategoryQuery A secondary query class using the current class as primary query + */ + public function useCustomerFamilyAvailableCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCustomerFamilyAvailableCategory($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CustomerFamilyAvailableCategory', '\CustomerFamily\Model\CustomerFamilyAvailableCategoryQuery'); + } + + /** + * Filter the query by a related \CustomerFamily\Model\CustomerFamilyAvailableBrand object + * + * @param \CustomerFamily\Model\CustomerFamilyAvailableBrand|ObjectCollection $customerFamilyAvailableBrand the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCustomerFamilyQuery The current query, for fluid interface + */ + public function filterByCustomerFamilyAvailableBrand($customerFamilyAvailableBrand, $comparison = null) + { + if ($customerFamilyAvailableBrand instanceof \CustomerFamily\Model\CustomerFamilyAvailableBrand) { + return $this + ->addUsingAlias(CustomerFamilyTableMap::ID, $customerFamilyAvailableBrand->getCustomerFamilyId(), $comparison); + } elseif ($customerFamilyAvailableBrand instanceof ObjectCollection) { + return $this + ->useCustomerFamilyAvailableBrandQuery() + ->filterByPrimaryKeys($customerFamilyAvailableBrand->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCustomerFamilyAvailableBrand() only accepts arguments of type \CustomerFamily\Model\CustomerFamilyAvailableBrand or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CustomerFamilyAvailableBrand relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCustomerFamilyQuery The current query, for fluid interface + */ + public function joinCustomerFamilyAvailableBrand($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CustomerFamilyAvailableBrand'); + + // 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, 'CustomerFamilyAvailableBrand'); + } + + return $this; + } + + /** + * Use the CustomerFamilyAvailableBrand relation CustomerFamilyAvailableBrand 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 \CustomerFamily\Model\CustomerFamilyAvailableBrandQuery A secondary query class using the current class as primary query + */ + public function useCustomerFamilyAvailableBrandQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinCustomerFamilyAvailableBrand($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CustomerFamilyAvailableBrand', '\CustomerFamily\Model\CustomerFamilyAvailableBrandQuery'); + } + /** * Filter the query by a related \CustomerFamily\Model\CustomerFamilyI18n object * diff --git a/Model/Map/CustomerFamilyTableMap.php b/Model/Map/CustomerFamilyTableMap.php index ced760f..7a5308d 100644 --- a/Model/Map/CustomerFamilyTableMap.php +++ b/Model/Map/CustomerFamilyTableMap.php @@ -58,7 +58,7 @@ class CustomerFamilyTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 7; /** * The number of lazy-loaded columns @@ -68,7 +68,7 @@ class CustomerFamilyTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 7; /** * the column name for the ID field @@ -80,6 +80,16 @@ class CustomerFamilyTableMap extends TableMap */ const CODE = 'customer_family.CODE'; + /** + * the column name for the CATEGORY_RESTRICTION_ENABLED field + */ + const CATEGORY_RESTRICTION_ENABLED = 'customer_family.CATEGORY_RESTRICTION_ENABLED'; + + /** + * the column name for the BRAND_RESTRICTION_ENABLED field + */ + const BRAND_RESTRICTION_ENABLED = 'customer_family.BRAND_RESTRICTION_ENABLED'; + /** * the column name for the IS_DEFAULT field */ @@ -116,12 +126,12 @@ class CustomerFamilyTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'isDefault', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CustomerFamilyTableMap::ID, CustomerFamilyTableMap::CODE, CustomerFamilyTableMap::IS_DEFAULT, CustomerFamilyTableMap::CREATED_AT, CustomerFamilyTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'code', 'is_default', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'CategoryRestrictionEnabled', 'BrandRestrictionEnabled', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'categoryRestrictionEnabled', 'brandRestrictionEnabled', 'isDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CustomerFamilyTableMap::ID, CustomerFamilyTableMap::CODE, CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED, CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED, CustomerFamilyTableMap::IS_DEFAULT, CustomerFamilyTableMap::CREATED_AT, CustomerFamilyTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CATEGORY_RESTRICTION_ENABLED', 'BRAND_RESTRICTION_ENABLED', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'category_restriction_enabled', 'brand_restriction_enabled', 'is_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -131,12 +141,12 @@ class CustomerFamilyTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'IsDefault' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'isDefault' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(CustomerFamilyTableMap::ID => 0, CustomerFamilyTableMap::CODE => 1, CustomerFamilyTableMap::IS_DEFAULT => 2, CustomerFamilyTableMap::CREATED_AT => 3, CustomerFamilyTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'IS_DEFAULT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'is_default' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CategoryRestrictionEnabled' => 2, 'BrandRestrictionEnabled' => 3, 'IsDefault' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'categoryRestrictionEnabled' => 2, 'brandRestrictionEnabled' => 3, 'isDefault' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(CustomerFamilyTableMap::ID => 0, CustomerFamilyTableMap::CODE => 1, CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED => 2, CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED => 3, CustomerFamilyTableMap::IS_DEFAULT => 4, CustomerFamilyTableMap::CREATED_AT => 5, CustomerFamilyTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CATEGORY_RESTRICTION_ENABLED' => 2, 'BRAND_RESTRICTION_ENABLED' => 3, 'IS_DEFAULT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'category_restriction_enabled' => 2, 'brand_restriction_enabled' => 3, 'is_default' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -157,6 +167,8 @@ public function initialize() // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); + $this->addColumn('CATEGORY_RESTRICTION_ENABLED', 'CategoryRestrictionEnabled', 'TINYINT', false, null, 0); + $this->addColumn('BRAND_RESTRICTION_ENABLED', 'BrandRestrictionEnabled', 'TINYINT', false, null, 0); $this->addColumn('IS_DEFAULT', 'IsDefault', 'TINYINT', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -170,6 +182,8 @@ public function buildRelations() $this->addRelation('CustomerCustomerFamily', '\\CustomerFamily\\Model\\CustomerCustomerFamily', RelationMap::ONE_TO_MANY, array('id' => 'customer_family_id', ), 'CASCADE', null, 'CustomerCustomerFamilies'); $this->addRelation('CustomerFamilyPrice', '\\CustomerFamily\\Model\\CustomerFamilyPrice', RelationMap::ONE_TO_MANY, array('id' => 'customer_family_id', ), 'CASCADE', 'RESTRICT', 'CustomerFamilyPrices'); $this->addRelation('CustomerFamilyOrder', '\\CustomerFamily\\Model\\CustomerFamilyOrder', RelationMap::ONE_TO_MANY, array('id' => 'customer_family_id', ), null, 'CASCADE', 'CustomerFamilyOrders'); + $this->addRelation('CustomerFamilyAvailableCategory', '\\CustomerFamily\\Model\\CustomerFamilyAvailableCategory', RelationMap::ONE_TO_MANY, array('id' => 'customer_family_id', ), 'CASCADE', 'CASCADE', 'CustomerFamilyAvailableCategories'); + $this->addRelation('CustomerFamilyAvailableBrand', '\\CustomerFamily\\Model\\CustomerFamilyAvailableBrand', RelationMap::ONE_TO_MANY, array('id' => 'customer_family_id', ), 'CASCADE', 'CASCADE', 'CustomerFamilyAvailableBrands'); $this->addRelation('CustomerFamilyI18n', '\\CustomerFamily\\Model\\CustomerFamilyI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerFamilyI18ns'); } // buildRelations() @@ -195,6 +209,8 @@ public static function clearRelatedInstancePool() // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CustomerCustomerFamilyTableMap::clearInstancePool(); CustomerFamilyPriceTableMap::clearInstancePool(); + CustomerFamilyAvailableCategoryTableMap::clearInstancePool(); + CustomerFamilyAvailableBrandTableMap::clearInstancePool(); CustomerFamilyI18nTableMap::clearInstancePool(); } @@ -338,12 +354,16 @@ public static function addSelectColumns(Criteria $criteria, $alias = null) if (null === $alias) { $criteria->addSelectColumn(CustomerFamilyTableMap::ID); $criteria->addSelectColumn(CustomerFamilyTableMap::CODE); + $criteria->addSelectColumn(CustomerFamilyTableMap::CATEGORY_RESTRICTION_ENABLED); + $criteria->addSelectColumn(CustomerFamilyTableMap::BRAND_RESTRICTION_ENABLED); $criteria->addSelectColumn(CustomerFamilyTableMap::IS_DEFAULT); $criteria->addSelectColumn(CustomerFamilyTableMap::CREATED_AT); $criteria->addSelectColumn(CustomerFamilyTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.CODE'); + $criteria->addSelectColumn($alias . '.CATEGORY_RESTRICTION_ENABLED'); + $criteria->addSelectColumn($alias . '.BRAND_RESTRICTION_ENABLED'); $criteria->addSelectColumn($alias . '.IS_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT');