Added coupon_country and coupon_module tables
This commit is contained in:
@@ -25,6 +25,10 @@ use Thelia\Model\Country as ChildCountry;
|
||||
use Thelia\Model\CountryI18n as ChildCountryI18n;
|
||||
use Thelia\Model\CountryI18nQuery as ChildCountryI18nQuery;
|
||||
use Thelia\Model\CountryQuery as ChildCountryQuery;
|
||||
use Thelia\Model\Coupon as ChildCoupon;
|
||||
use Thelia\Model\CouponCountry as ChildCouponCountry;
|
||||
use Thelia\Model\CouponCountryQuery as ChildCouponCountryQuery;
|
||||
use Thelia\Model\CouponQuery as ChildCouponQuery;
|
||||
use Thelia\Model\TaxRuleCountry as ChildTaxRuleCountry;
|
||||
use Thelia\Model\TaxRuleCountryQuery as ChildTaxRuleCountryQuery;
|
||||
use Thelia\Model\Map\CountryTableMap;
|
||||
@@ -136,12 +140,23 @@ abstract class Country implements ActiveRecordInterface
|
||||
protected $collAddresses;
|
||||
protected $collAddressesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCouponCountry[] Collection to store aggregation of ChildCouponCountry objects.
|
||||
*/
|
||||
protected $collCouponCountries;
|
||||
protected $collCouponCountriesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCountryI18n[] Collection to store aggregation of ChildCountryI18n objects.
|
||||
*/
|
||||
protected $collCountryI18ns;
|
||||
protected $collCountryI18nsPartial;
|
||||
|
||||
/**
|
||||
* @var ChildCoupon[] Collection to store aggregation of ChildCoupon objects.
|
||||
*/
|
||||
protected $collCoupons;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -164,6 +179,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $currentTranslations;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $couponsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -176,6 +197,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $addressesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $couponCountriesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -926,8 +953,11 @@ abstract class Country implements ActiveRecordInterface
|
||||
|
||||
$this->collAddresses = null;
|
||||
|
||||
$this->collCouponCountries = null;
|
||||
|
||||
$this->collCountryI18ns = null;
|
||||
|
||||
$this->collCoupons = null;
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -1073,6 +1103,33 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->resetModified();
|
||||
}
|
||||
|
||||
if ($this->couponsScheduledForDeletion !== null) {
|
||||
if (!$this->couponsScheduledForDeletion->isEmpty()) {
|
||||
$pks = array();
|
||||
$pk = $this->getPrimaryKey();
|
||||
foreach ($this->couponsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
|
||||
$pks[] = array($pk, $remotePk);
|
||||
}
|
||||
|
||||
CouponCountryQuery::create()
|
||||
->filterByPrimaryKeys($pks)
|
||||
->delete($con);
|
||||
$this->couponsScheduledForDeletion = null;
|
||||
}
|
||||
|
||||
foreach ($this->getCoupons() as $coupon) {
|
||||
if ($coupon->isModified()) {
|
||||
$coupon->save($con);
|
||||
}
|
||||
}
|
||||
} elseif ($this->collCoupons) {
|
||||
foreach ($this->collCoupons as $coupon) {
|
||||
if ($coupon->isModified()) {
|
||||
$coupon->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taxRuleCountriesScheduledForDeletion !== null) {
|
||||
if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\TaxRuleCountryQuery::create()
|
||||
@@ -1107,6 +1164,23 @@ abstract class Country implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->couponCountriesScheduledForDeletion !== null) {
|
||||
if (!$this->couponCountriesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CouponCountryQuery::create()
|
||||
->filterByPrimaryKeys($this->couponCountriesScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->couponCountriesScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCouponCountries !== null) {
|
||||
foreach ($this->collCouponCountries as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->countryI18nsScheduledForDeletion !== null) {
|
||||
if (!$this->countryI18nsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CountryI18nQuery::create()
|
||||
@@ -1358,6 +1432,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if (null !== $this->collAddresses) {
|
||||
$result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCouponCountries) {
|
||||
$result['CouponCountries'] = $this->collCouponCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCountryI18ns) {
|
||||
$result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -1564,6 +1641,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCouponCountries() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCouponCountry($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCountryI18ns() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCountryI18n($relObj->copy($deepCopy));
|
||||
@@ -1668,6 +1751,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ('Address' == $relationName) {
|
||||
return $this->initAddresses();
|
||||
}
|
||||
if ('CouponCountry' == $relationName) {
|
||||
return $this->initCouponCountries();
|
||||
}
|
||||
if ('CountryI18n' == $relationName) {
|
||||
return $this->initCountryI18ns();
|
||||
}
|
||||
@@ -2212,6 +2298,252 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->getAddresses($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCouponCountries 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 addCouponCountries()
|
||||
*/
|
||||
public function clearCouponCountries()
|
||||
{
|
||||
$this->collCouponCountries = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCouponCountries collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCouponCountries($v = true)
|
||||
{
|
||||
$this->collCouponCountriesPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCouponCountries collection.
|
||||
*
|
||||
* By default this just sets the collCouponCountries collection to an empty array (like clearcollCouponCountries());
|
||||
* 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 initCouponCountries($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCouponCountries && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCouponCountries = new ObjectCollection();
|
||||
$this->collCouponCountries->setModel('\Thelia\Model\CouponCountry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCouponCountry 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 ChildCountry 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|ChildCouponCountry[] List of ChildCouponCountry objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCouponCountries($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCouponCountriesPartial && !$this->isNew();
|
||||
if (null === $this->collCouponCountries || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCouponCountries) {
|
||||
// return empty collection
|
||||
$this->initCouponCountries();
|
||||
} else {
|
||||
$collCouponCountries = ChildCouponCountryQuery::create(null, $criteria)
|
||||
->filterByCountry($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCouponCountriesPartial && count($collCouponCountries)) {
|
||||
$this->initCouponCountries(false);
|
||||
|
||||
foreach ($collCouponCountries as $obj) {
|
||||
if (false == $this->collCouponCountries->contains($obj)) {
|
||||
$this->collCouponCountries->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCouponCountriesPartial = true;
|
||||
}
|
||||
|
||||
reset($collCouponCountries);
|
||||
|
||||
return $collCouponCountries;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCouponCountries) {
|
||||
foreach ($this->collCouponCountries as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCouponCountries[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCouponCountries = $collCouponCountries;
|
||||
$this->collCouponCountriesPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCouponCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of CouponCountry 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 $couponCountries A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function setCouponCountries(Collection $couponCountries, ConnectionInterface $con = null)
|
||||
{
|
||||
$couponCountriesToDelete = $this->getCouponCountries(new Criteria(), $con)->diff($couponCountries);
|
||||
|
||||
|
||||
//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->couponCountriesScheduledForDeletion = clone $couponCountriesToDelete;
|
||||
|
||||
foreach ($couponCountriesToDelete as $couponCountryRemoved) {
|
||||
$couponCountryRemoved->setCountry(null);
|
||||
}
|
||||
|
||||
$this->collCouponCountries = null;
|
||||
foreach ($couponCountries as $couponCountry) {
|
||||
$this->addCouponCountry($couponCountry);
|
||||
}
|
||||
|
||||
$this->collCouponCountries = $couponCountries;
|
||||
$this->collCouponCountriesPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related CouponCountry objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related CouponCountry objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCouponCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCouponCountriesPartial && !$this->isNew();
|
||||
if (null === $this->collCouponCountries || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCouponCountries) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCouponCountries());
|
||||
}
|
||||
|
||||
$query = ChildCouponCountryQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCountry($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCouponCountries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCouponCountry object to this object
|
||||
* through the ChildCouponCountry foreign key attribute.
|
||||
*
|
||||
* @param ChildCouponCountry $l ChildCouponCountry
|
||||
* @return \Thelia\Model\Country The current object (for fluent API support)
|
||||
*/
|
||||
public function addCouponCountry(ChildCouponCountry $l)
|
||||
{
|
||||
if ($this->collCouponCountries === null) {
|
||||
$this->initCouponCountries();
|
||||
$this->collCouponCountriesPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCouponCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCouponCountry($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CouponCountry $couponCountry The couponCountry object to add.
|
||||
*/
|
||||
protected function doAddCouponCountry($couponCountry)
|
||||
{
|
||||
$this->collCouponCountries[]= $couponCountry;
|
||||
$couponCountry->setCountry($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CouponCountry $couponCountry The couponCountry object to remove.
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCouponCountry($couponCountry)
|
||||
{
|
||||
if ($this->getCouponCountries()->contains($couponCountry)) {
|
||||
$this->collCouponCountries->remove($this->collCouponCountries->search($couponCountry));
|
||||
if (null === $this->couponCountriesScheduledForDeletion) {
|
||||
$this->couponCountriesScheduledForDeletion = clone $this->collCouponCountries;
|
||||
$this->couponCountriesScheduledForDeletion->clear();
|
||||
}
|
||||
$this->couponCountriesScheduledForDeletion[]= clone $couponCountry;
|
||||
$couponCountry->setCountry(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Country is new, it will return
|
||||
* an empty collection; or if this Country has previously
|
||||
* been saved, it will retrieve related CouponCountries 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 Country.
|
||||
*
|
||||
* @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|ChildCouponCountry[] List of ChildCouponCountry objects
|
||||
*/
|
||||
public function getCouponCountriesJoinCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCouponCountryQuery::create(null, $criteria);
|
||||
$query->joinWith('Coupon', $joinBehavior);
|
||||
|
||||
return $this->getCouponCountries($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCountryI18ns collection
|
||||
*
|
||||
@@ -2437,6 +2769,189 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCoupons 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 addCoupons()
|
||||
*/
|
||||
public function clearCoupons()
|
||||
{
|
||||
$this->collCoupons = null; // important to set this to NULL since that means it is uninitialized
|
||||
$this->collCouponsPartial = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCoupons collection.
|
||||
*
|
||||
* By default this just sets the collCoupons collection to an empty collection (like clearCoupons());
|
||||
* 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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initCoupons()
|
||||
{
|
||||
$this->collCoupons = new ObjectCollection();
|
||||
$this->collCoupons->setModel('\Thelia\Model\Coupon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of ChildCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_country cross-reference table.
|
||||
*
|
||||
* 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 ChildCountry is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return ObjectCollection|ChildCoupon[] List of ChildCoupon objects
|
||||
*/
|
||||
public function getCoupons($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCoupons) {
|
||||
// return empty collection
|
||||
$this->initCoupons();
|
||||
} else {
|
||||
$collCoupons = ChildCouponQuery::create(null, $criteria)
|
||||
->filterByCountry($this)
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collCoupons;
|
||||
}
|
||||
$this->collCoupons = $collCoupons;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCoupons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of Coupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_country cross-reference table.
|
||||
* 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 $coupons A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function setCoupons(Collection $coupons, ConnectionInterface $con = null)
|
||||
{
|
||||
$this->clearCoupons();
|
||||
$currentCoupons = $this->getCoupons();
|
||||
|
||||
$this->couponsScheduledForDeletion = $currentCoupons->diff($coupons);
|
||||
|
||||
foreach ($coupons as $coupon) {
|
||||
if (!$currentCoupons->contains($coupon)) {
|
||||
$this->doAddCoupon($coupon);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCoupons = $coupons;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of ChildCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_country cross-reference table.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param boolean $distinct Set to true to force count distinct
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return int the number of related ChildCoupon objects
|
||||
*/
|
||||
public function countCoupons($criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCoupons) {
|
||||
return 0;
|
||||
} else {
|
||||
$query = ChildCouponQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCountry($this)
|
||||
->count($con);
|
||||
}
|
||||
} else {
|
||||
return count($this->collCoupons);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate a ChildCoupon object to this object
|
||||
* through the coupon_country cross reference table.
|
||||
*
|
||||
* @param ChildCoupon $coupon The ChildCouponCountry object to relate
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function addCoupon(ChildCoupon $coupon)
|
||||
{
|
||||
if ($this->collCoupons === null) {
|
||||
$this->initCoupons();
|
||||
}
|
||||
|
||||
if (!$this->collCoupons->contains($coupon)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCoupon($coupon);
|
||||
$this->collCoupons[] = $coupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Coupon $coupon The coupon object to add.
|
||||
*/
|
||||
protected function doAddCoupon($coupon)
|
||||
{
|
||||
$couponCountry = new ChildCouponCountry();
|
||||
$couponCountry->setCoupon($coupon);
|
||||
$this->addCouponCountry($couponCountry);
|
||||
// set the back reference to this object directly as using provided method either results
|
||||
// in endless loop or in multiple relations
|
||||
if (!$coupon->getCountries()->contains($this)) {
|
||||
$foreignCollection = $coupon->getCountries();
|
||||
$foreignCollection[] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a ChildCoupon object to this object
|
||||
* through the coupon_country cross reference table.
|
||||
*
|
||||
* @param ChildCoupon $coupon The ChildCouponCountry object to relate
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCoupon(ChildCoupon $coupon)
|
||||
{
|
||||
if ($this->getCoupons()->contains($coupon)) {
|
||||
$this->collCoupons->remove($this->collCoupons->search($coupon));
|
||||
|
||||
if (null === $this->couponsScheduledForDeletion) {
|
||||
$this->couponsScheduledForDeletion = clone $this->collCoupons;
|
||||
$this->couponsScheduledForDeletion->clear();
|
||||
}
|
||||
|
||||
$this->couponsScheduledForDeletion[] = $coupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -2481,11 +2996,21 @@ abstract class Country implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCouponCountries) {
|
||||
foreach ($this->collCouponCountries as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCountryI18ns) {
|
||||
foreach ($this->collCountryI18ns as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCoupons) {
|
||||
foreach ($this->collCoupons as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
// i18n behavior
|
||||
@@ -2494,7 +3019,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
|
||||
$this->collTaxRuleCountries = null;
|
||||
$this->collAddresses = null;
|
||||
$this->collCouponCountries = null;
|
||||
$this->collCountryI18ns = null;
|
||||
$this->collCoupons = null;
|
||||
$this->aArea = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation
|
||||
* @method ChildCountryQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation
|
||||
*
|
||||
* @method ChildCountryQuery leftJoinCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCountryQuery rightJoinCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCountryQuery innerJoinCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @method ChildCountryQuery leftJoinCountryI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CountryI18n relation
|
||||
* @method ChildCountryQuery rightJoinCountryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CountryI18n relation
|
||||
* @method ChildCountryQuery innerJoinCountryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CountryI18n relation
|
||||
@@ -807,6 +811,79 @@ abstract class CountryQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponCountry object
|
||||
*
|
||||
* @param \Thelia\Model\CouponCountry|ObjectCollection $couponCountry the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponCountry($couponCountry, $comparison = null)
|
||||
{
|
||||
if ($couponCountry instanceof \Thelia\Model\CouponCountry) {
|
||||
return $this
|
||||
->addUsingAlias(CountryTableMap::ID, $couponCountry->getCountryId(), $comparison);
|
||||
} elseif ($couponCountry instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByPrimaryKeys($couponCountry->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponCountry() only accepts arguments of type \Thelia\Model\CouponCountry or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponCountry');
|
||||
|
||||
// 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, 'CouponCountry');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponCountry relation CouponCountry 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\CouponCountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponCountry', '\Thelia\Model\CouponCountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CountryI18n object
|
||||
*
|
||||
@@ -880,6 +957,23 @@ abstract class CountryQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'CountryI18n', '\Thelia\Model\CountryI18nQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Coupon object
|
||||
* using the coupon_country table as cross reference
|
||||
*
|
||||
* @param Coupon $coupon the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByCoupon($coupon, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1268
core/lib/Thelia/Model/Base/CouponCountry.php
Normal file
1268
core/lib/Thelia/Model/Base/CouponCountry.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/CouponCountryQuery.php
Normal file
568
core/lib/Thelia/Model/Base/CouponCountryQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\CouponCountry as ChildCouponCountry;
|
||||
use Thelia\Model\CouponCountryQuery as ChildCouponCountryQuery;
|
||||
use Thelia\Model\Map\CouponCountryTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'coupon_country' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildCouponCountryQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
|
||||
* @method ChildCouponCountryQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column
|
||||
*
|
||||
* @method ChildCouponCountryQuery groupByCouponId() Group by the coupon_id column
|
||||
* @method ChildCouponCountryQuery groupByCountryId() Group by the country_id column
|
||||
*
|
||||
* @method ChildCouponCountryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildCouponCountryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCouponCountryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCouponCountryQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
|
||||
* @method ChildCouponCountryQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
|
||||
* @method ChildCouponCountryQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @method ChildCouponCountryQuery leftJoinCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponCountryQuery rightJoinCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponCountryQuery innerJoinCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @method ChildCouponCountry findOne(ConnectionInterface $con = null) Return the first ChildCouponCountry matching the query
|
||||
* @method ChildCouponCountry findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCouponCountry matching the query, or a new ChildCouponCountry object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildCouponCountry findOneByCouponId(int $coupon_id) Return the first ChildCouponCountry filtered by the coupon_id column
|
||||
* @method ChildCouponCountry findOneByCountryId(int $country_id) Return the first ChildCouponCountry filtered by the country_id column
|
||||
*
|
||||
* @method array findByCouponId(int $coupon_id) Return ChildCouponCountry objects filtered by the coupon_id column
|
||||
* @method array findByCountryId(int $country_id) Return ChildCouponCountry objects filtered by the country_id column
|
||||
*
|
||||
*/
|
||||
abstract class CouponCountryQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\CouponCountryQuery 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\\CouponCountry', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildCouponCountryQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildCouponCountryQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\CouponCountryQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\CouponCountryQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->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.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param array[$coupon_id, $country_id] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildCouponCountry|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = CouponCountryTableMap::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(CouponCountryTableMap::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 ChildCouponCountry A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `COUPON_ID`, `COUNTRY_ID` FROM `coupon_country` WHERE `COUPON_ID` = :p0 AND `COUNTRY_ID` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], 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 ChildCouponCountry();
|
||||
$obj->hydrate($row);
|
||||
CouponCountryTableMap::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 ChildCouponCountry|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
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @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 ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $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 ChildCouponCountryQuery 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(CouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(CouponCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the coupon_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
|
||||
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
|
||||
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCoupon()
|
||||
*
|
||||
* @param mixed $couponId 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 ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponId($couponId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($couponId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($couponId['min'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($couponId['max'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $couponId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the country_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCountryId(1234); // WHERE country_id = 1234
|
||||
* $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
|
||||
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCountry()
|
||||
*
|
||||
* @param mixed $countryId 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 ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountryId($countryId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($countryId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($countryId['min'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($countryId['max'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $countryId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Country object
|
||||
*
|
||||
* @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountry($country, $comparison = null)
|
||||
{
|
||||
if ($country instanceof \Thelia\Model\Country) {
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $country->getId(), $comparison);
|
||||
} elseif ($country instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Country');
|
||||
|
||||
// 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, 'Country');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Country relation Country 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\CountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Coupon object
|
||||
*
|
||||
* @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = null)
|
||||
{
|
||||
if ($coupon instanceof \Thelia\Model\Coupon) {
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUPON_ID, $coupon->getId(), $comparison);
|
||||
} elseif ($coupon instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Coupon');
|
||||
|
||||
// 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, 'Coupon');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Coupon relation Coupon 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\CouponQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCoupon($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildCouponCountry $couponCountry Object to remove from the list of results
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($couponCountry = null)
|
||||
{
|
||||
if ($couponCountry) {
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(CouponCountryTableMap::COUPON_ID), $couponCountry->getCouponId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(CouponCountryTableMap::COUNTRY_ID), $couponCountry->getCountryId(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_country 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(CouponCountryTableMap::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).
|
||||
CouponCountryTableMap::clearInstancePool();
|
||||
CouponCountryTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildCouponCountry or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildCouponCountry 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(CouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(CouponCountryTableMap::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();
|
||||
|
||||
|
||||
CouponCountryTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
CouponCountryTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // CouponCountryQuery
|
||||
1268
core/lib/Thelia/Model/Base/CouponModule.php
Normal file
1268
core/lib/Thelia/Model/Base/CouponModule.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/CouponModuleQuery.php
Normal file
568
core/lib/Thelia/Model/Base/CouponModuleQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\CouponModule as ChildCouponModule;
|
||||
use Thelia\Model\CouponModuleQuery as ChildCouponModuleQuery;
|
||||
use Thelia\Model\Map\CouponModuleTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'coupon_module' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildCouponModuleQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
|
||||
* @method ChildCouponModuleQuery orderByModuleId($order = Criteria::ASC) Order by the module_id column
|
||||
*
|
||||
* @method ChildCouponModuleQuery groupByCouponId() Group by the coupon_id column
|
||||
* @method ChildCouponModuleQuery groupByModuleId() Group by the module_id column
|
||||
*
|
||||
* @method ChildCouponModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildCouponModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCouponModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCouponModuleQuery leftJoinCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponModuleQuery rightJoinCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponModuleQuery innerJoinCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @method ChildCouponModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation
|
||||
* @method ChildCouponModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation
|
||||
* @method ChildCouponModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @method ChildCouponModule findOne(ConnectionInterface $con = null) Return the first ChildCouponModule matching the query
|
||||
* @method ChildCouponModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCouponModule matching the query, or a new ChildCouponModule object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildCouponModule findOneByCouponId(int $coupon_id) Return the first ChildCouponModule filtered by the coupon_id column
|
||||
* @method ChildCouponModule findOneByModuleId(int $module_id) Return the first ChildCouponModule filtered by the module_id column
|
||||
*
|
||||
* @method array findByCouponId(int $coupon_id) Return ChildCouponModule objects filtered by the coupon_id column
|
||||
* @method array findByModuleId(int $module_id) Return ChildCouponModule objects filtered by the module_id column
|
||||
*
|
||||
*/
|
||||
abstract class CouponModuleQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\CouponModuleQuery 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\\CouponModule', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildCouponModuleQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildCouponModuleQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\CouponModuleQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\CouponModuleQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->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.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param array[$coupon_id, $module_id] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildCouponModule|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = CouponModuleTableMap::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(CouponModuleTableMap::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 ChildCouponModule A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `COUPON_ID`, `MODULE_ID` FROM `coupon_module` WHERE `COUPON_ID` = :p0 AND `MODULE_ID` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], 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 ChildCouponModule();
|
||||
$obj->hydrate($row);
|
||||
CouponModuleTableMap::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 ChildCouponModule|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
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @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 ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $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 ChildCouponModuleQuery 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(CouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(CouponModuleTableMap::MODULE_ID, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the coupon_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
|
||||
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
|
||||
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCoupon()
|
||||
*
|
||||
* @param mixed $couponId 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 ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponId($couponId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($couponId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($couponId['min'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($couponId['max'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $couponId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the module_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByModuleId(1234); // WHERE module_id = 1234
|
||||
* $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34)
|
||||
* $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByModule()
|
||||
*
|
||||
* @param mixed $moduleId 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 ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModuleId($moduleId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($moduleId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($moduleId['min'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($moduleId['max'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $moduleId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Coupon object
|
||||
*
|
||||
* @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = null)
|
||||
{
|
||||
if ($coupon instanceof \Thelia\Model\Coupon) {
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::COUPON_ID, $coupon->getId(), $comparison);
|
||||
} elseif ($coupon instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Coupon');
|
||||
|
||||
// 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, 'Coupon');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Coupon relation Coupon 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\CouponQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCoupon($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Module object
|
||||
*
|
||||
* @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModule($module, $comparison = null)
|
||||
{
|
||||
if ($module instanceof \Thelia\Model\Module) {
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::MODULE_ID, $module->getId(), $comparison);
|
||||
} elseif ($module instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Module');
|
||||
|
||||
// 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, 'Module');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Module relation Module 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\ModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildCouponModule $couponModule Object to remove from the list of results
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($couponModule = null)
|
||||
{
|
||||
if ($couponModule) {
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(CouponModuleTableMap::COUPON_ID), $couponModule->getCouponId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(CouponModuleTableMap::MODULE_ID), $couponModule->getModuleId(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_module 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(CouponModuleTableMap::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).
|
||||
CouponModuleTableMap::clearInstancePool();
|
||||
CouponModuleTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildCouponModule or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildCouponModule 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(CouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(CouponModuleTableMap::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();
|
||||
|
||||
|
||||
CouponModuleTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
CouponModuleTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // CouponModuleQuery
|
||||
@@ -58,6 +58,14 @@ use Thelia\Model\Map\CouponTableMap;
|
||||
* @method ChildCouponQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCouponQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCouponQuery leftJoinCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCouponQuery rightJoinCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCouponQuery innerJoinCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @method ChildCouponQuery leftJoinCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildCouponQuery rightJoinCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildCouponQuery innerJoinCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @method ChildCouponQuery leftJoinCouponI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponI18n relation
|
||||
* @method ChildCouponQuery rightJoinCouponI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponI18n relation
|
||||
* @method ChildCouponQuery innerJoinCouponI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponI18n relation
|
||||
@@ -787,6 +795,152 @@ abstract class CouponQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CouponTableMap::VERSION, $version, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponCountry object
|
||||
*
|
||||
* @param \Thelia\Model\CouponCountry|ObjectCollection $couponCountry the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponCountry($couponCountry, $comparison = null)
|
||||
{
|
||||
if ($couponCountry instanceof \Thelia\Model\CouponCountry) {
|
||||
return $this
|
||||
->addUsingAlias(CouponTableMap::ID, $couponCountry->getCouponId(), $comparison);
|
||||
} elseif ($couponCountry instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByPrimaryKeys($couponCountry->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponCountry() only accepts arguments of type \Thelia\Model\CouponCountry or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponCountry');
|
||||
|
||||
// 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, 'CouponCountry');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponCountry relation CouponCountry 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\CouponCountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponCountry', '\Thelia\Model\CouponCountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponModule object
|
||||
*
|
||||
* @param \Thelia\Model\CouponModule|ObjectCollection $couponModule the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponModule($couponModule, $comparison = null)
|
||||
{
|
||||
if ($couponModule instanceof \Thelia\Model\CouponModule) {
|
||||
return $this
|
||||
->addUsingAlias(CouponTableMap::ID, $couponModule->getCouponId(), $comparison);
|
||||
} elseif ($couponModule instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByPrimaryKeys($couponModule->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponModule() only accepts arguments of type \Thelia\Model\CouponModule or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponModule');
|
||||
|
||||
// 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, 'CouponModule');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponModule relation CouponModule 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\CouponModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponModule', '\Thelia\Model\CouponModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponI18n object
|
||||
*
|
||||
@@ -933,6 +1087,40 @@ abstract class CouponQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponVersion', '\Thelia\Model\CouponVersionQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Country object
|
||||
* using the coupon_country table as cross reference
|
||||
*
|
||||
* @param Country $country the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountry($country, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByCountry($country, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Module object
|
||||
* using the coupon_module table as cross reference
|
||||
*
|
||||
* @param Module $module the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModule($module, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByModule($module, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
@@ -19,6 +19,10 @@ use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery;
|
||||
use Thelia\Model\Coupon as ChildCoupon;
|
||||
use Thelia\Model\CouponModule as ChildCouponModule;
|
||||
use Thelia\Model\CouponModuleQuery as ChildCouponModuleQuery;
|
||||
use Thelia\Model\CouponQuery as ChildCouponQuery;
|
||||
use Thelia\Model\Module as ChildModule;
|
||||
use Thelia\Model\ModuleI18n as ChildModuleI18n;
|
||||
use Thelia\Model\ModuleI18nQuery as ChildModuleI18nQuery;
|
||||
@@ -143,12 +147,23 @@ abstract class Module implements ActiveRecordInterface
|
||||
protected $collModuleImages;
|
||||
protected $collModuleImagesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCouponModule[] Collection to store aggregation of ChildCouponModule objects.
|
||||
*/
|
||||
protected $collCouponModules;
|
||||
protected $collCouponModulesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildModuleI18n[] Collection to store aggregation of ChildModuleI18n objects.
|
||||
*/
|
||||
protected $collModuleI18ns;
|
||||
protected $collModuleI18nsPartial;
|
||||
|
||||
/**
|
||||
* @var ChildCoupon[] Collection to store aggregation of ChildCoupon objects.
|
||||
*/
|
||||
protected $collCoupons;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -171,6 +186,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
*/
|
||||
protected $currentTranslations;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $couponsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -201,6 +222,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
*/
|
||||
protected $moduleImagesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $couponModulesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -884,8 +911,11 @@ abstract class Module implements ActiveRecordInterface
|
||||
|
||||
$this->collModuleImages = null;
|
||||
|
||||
$this->collCouponModules = null;
|
||||
|
||||
$this->collModuleI18ns = null;
|
||||
|
||||
$this->collCoupons = null;
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -1019,6 +1049,33 @@ abstract class Module implements ActiveRecordInterface
|
||||
$this->resetModified();
|
||||
}
|
||||
|
||||
if ($this->couponsScheduledForDeletion !== null) {
|
||||
if (!$this->couponsScheduledForDeletion->isEmpty()) {
|
||||
$pks = array();
|
||||
$pk = $this->getPrimaryKey();
|
||||
foreach ($this->couponsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
|
||||
$pks[] = array($remotePk, $pk);
|
||||
}
|
||||
|
||||
CouponModuleQuery::create()
|
||||
->filterByPrimaryKeys($pks)
|
||||
->delete($con);
|
||||
$this->couponsScheduledForDeletion = null;
|
||||
}
|
||||
|
||||
foreach ($this->getCoupons() as $coupon) {
|
||||
if ($coupon->isModified()) {
|
||||
$coupon->save($con);
|
||||
}
|
||||
}
|
||||
} elseif ($this->collCoupons) {
|
||||
foreach ($this->collCoupons as $coupon) {
|
||||
if ($coupon->isModified()) {
|
||||
$coupon->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->ordersRelatedByPaymentModuleIdScheduledForDeletion !== null) {
|
||||
if (!$this->ordersRelatedByPaymentModuleIdScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\OrderQuery::create()
|
||||
@@ -1104,6 +1161,23 @@ abstract class Module implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->couponModulesScheduledForDeletion !== null) {
|
||||
if (!$this->couponModulesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CouponModuleQuery::create()
|
||||
->filterByPrimaryKeys($this->couponModulesScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->couponModulesScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCouponModules !== null) {
|
||||
foreach ($this->collCouponModules as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->moduleI18nsScheduledForDeletion !== null) {
|
||||
if (!$this->moduleI18nsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\ModuleI18nQuery::create()
|
||||
@@ -1351,6 +1425,9 @@ abstract class Module implements ActiveRecordInterface
|
||||
if (null !== $this->collModuleImages) {
|
||||
$result['ModuleImages'] = $this->collModuleImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCouponModules) {
|
||||
$result['CouponModules'] = $this->collCouponModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collModuleI18ns) {
|
||||
$result['ModuleI18ns'] = $this->collModuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -1569,6 +1646,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCouponModules() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCouponModule($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getModuleI18ns() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addModuleI18n($relObj->copy($deepCopy));
|
||||
@@ -1631,6 +1714,9 @@ abstract class Module implements ActiveRecordInterface
|
||||
if ('ModuleImage' == $relationName) {
|
||||
return $this->initModuleImages();
|
||||
}
|
||||
if ('CouponModule' == $relationName) {
|
||||
return $this->initCouponModules();
|
||||
}
|
||||
if ('ModuleI18n' == $relationName) {
|
||||
return $this->initModuleI18ns();
|
||||
}
|
||||
@@ -3079,6 +3165,252 @@ abstract class Module implements ActiveRecordInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCouponModules 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 addCouponModules()
|
||||
*/
|
||||
public function clearCouponModules()
|
||||
{
|
||||
$this->collCouponModules = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCouponModules collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCouponModules($v = true)
|
||||
{
|
||||
$this->collCouponModulesPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCouponModules collection.
|
||||
*
|
||||
* By default this just sets the collCouponModules collection to an empty array (like clearcollCouponModules());
|
||||
* 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 initCouponModules($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCouponModules && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCouponModules = new ObjectCollection();
|
||||
$this->collCouponModules->setModel('\Thelia\Model\CouponModule');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCouponModule 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 ChildModule 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|ChildCouponModule[] List of ChildCouponModule objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCouponModules($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCouponModulesPartial && !$this->isNew();
|
||||
if (null === $this->collCouponModules || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCouponModules) {
|
||||
// return empty collection
|
||||
$this->initCouponModules();
|
||||
} else {
|
||||
$collCouponModules = ChildCouponModuleQuery::create(null, $criteria)
|
||||
->filterByModule($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCouponModulesPartial && count($collCouponModules)) {
|
||||
$this->initCouponModules(false);
|
||||
|
||||
foreach ($collCouponModules as $obj) {
|
||||
if (false == $this->collCouponModules->contains($obj)) {
|
||||
$this->collCouponModules->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCouponModulesPartial = true;
|
||||
}
|
||||
|
||||
reset($collCouponModules);
|
||||
|
||||
return $collCouponModules;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCouponModules) {
|
||||
foreach ($this->collCouponModules as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCouponModules[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCouponModules = $collCouponModules;
|
||||
$this->collCouponModulesPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCouponModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of CouponModule 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 $couponModules A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function setCouponModules(Collection $couponModules, ConnectionInterface $con = null)
|
||||
{
|
||||
$couponModulesToDelete = $this->getCouponModules(new Criteria(), $con)->diff($couponModules);
|
||||
|
||||
|
||||
//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->couponModulesScheduledForDeletion = clone $couponModulesToDelete;
|
||||
|
||||
foreach ($couponModulesToDelete as $couponModuleRemoved) {
|
||||
$couponModuleRemoved->setModule(null);
|
||||
}
|
||||
|
||||
$this->collCouponModules = null;
|
||||
foreach ($couponModules as $couponModule) {
|
||||
$this->addCouponModule($couponModule);
|
||||
}
|
||||
|
||||
$this->collCouponModules = $couponModules;
|
||||
$this->collCouponModulesPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related CouponModule objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related CouponModule objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCouponModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCouponModulesPartial && !$this->isNew();
|
||||
if (null === $this->collCouponModules || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCouponModules) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCouponModules());
|
||||
}
|
||||
|
||||
$query = ChildCouponModuleQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByModule($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCouponModules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCouponModule object to this object
|
||||
* through the ChildCouponModule foreign key attribute.
|
||||
*
|
||||
* @param ChildCouponModule $l ChildCouponModule
|
||||
* @return \Thelia\Model\Module The current object (for fluent API support)
|
||||
*/
|
||||
public function addCouponModule(ChildCouponModule $l)
|
||||
{
|
||||
if ($this->collCouponModules === null) {
|
||||
$this->initCouponModules();
|
||||
$this->collCouponModulesPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCouponModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCouponModule($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CouponModule $couponModule The couponModule object to add.
|
||||
*/
|
||||
protected function doAddCouponModule($couponModule)
|
||||
{
|
||||
$this->collCouponModules[]= $couponModule;
|
||||
$couponModule->setModule($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CouponModule $couponModule The couponModule object to remove.
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCouponModule($couponModule)
|
||||
{
|
||||
if ($this->getCouponModules()->contains($couponModule)) {
|
||||
$this->collCouponModules->remove($this->collCouponModules->search($couponModule));
|
||||
if (null === $this->couponModulesScheduledForDeletion) {
|
||||
$this->couponModulesScheduledForDeletion = clone $this->collCouponModules;
|
||||
$this->couponModulesScheduledForDeletion->clear();
|
||||
}
|
||||
$this->couponModulesScheduledForDeletion[]= clone $couponModule;
|
||||
$couponModule->setModule(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Module is new, it will return
|
||||
* an empty collection; or if this Module has previously
|
||||
* been saved, it will retrieve related CouponModules 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 Module.
|
||||
*
|
||||
* @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|ChildCouponModule[] List of ChildCouponModule objects
|
||||
*/
|
||||
public function getCouponModulesJoinCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCouponModuleQuery::create(null, $criteria);
|
||||
$query->joinWith('Coupon', $joinBehavior);
|
||||
|
||||
return $this->getCouponModules($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collModuleI18ns collection
|
||||
*
|
||||
@@ -3304,6 +3636,189 @@ abstract class Module implements ActiveRecordInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCoupons 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 addCoupons()
|
||||
*/
|
||||
public function clearCoupons()
|
||||
{
|
||||
$this->collCoupons = null; // important to set this to NULL since that means it is uninitialized
|
||||
$this->collCouponsPartial = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCoupons collection.
|
||||
*
|
||||
* By default this just sets the collCoupons collection to an empty collection (like clearCoupons());
|
||||
* 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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initCoupons()
|
||||
{
|
||||
$this->collCoupons = new ObjectCollection();
|
||||
$this->collCoupons->setModel('\Thelia\Model\Coupon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of ChildCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_module cross-reference table.
|
||||
*
|
||||
* 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 ChildModule is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return ObjectCollection|ChildCoupon[] List of ChildCoupon objects
|
||||
*/
|
||||
public function getCoupons($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCoupons) {
|
||||
// return empty collection
|
||||
$this->initCoupons();
|
||||
} else {
|
||||
$collCoupons = ChildCouponQuery::create(null, $criteria)
|
||||
->filterByModule($this)
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collCoupons;
|
||||
}
|
||||
$this->collCoupons = $collCoupons;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCoupons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of Coupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_module cross-reference table.
|
||||
* 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 $coupons A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function setCoupons(Collection $coupons, ConnectionInterface $con = null)
|
||||
{
|
||||
$this->clearCoupons();
|
||||
$currentCoupons = $this->getCoupons();
|
||||
|
||||
$this->couponsScheduledForDeletion = $currentCoupons->diff($coupons);
|
||||
|
||||
foreach ($coupons as $coupon) {
|
||||
if (!$currentCoupons->contains($coupon)) {
|
||||
$this->doAddCoupon($coupon);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCoupons = $coupons;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of ChildCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_module cross-reference table.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param boolean $distinct Set to true to force count distinct
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return int the number of related ChildCoupon objects
|
||||
*/
|
||||
public function countCoupons($criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCoupons) {
|
||||
return 0;
|
||||
} else {
|
||||
$query = ChildCouponQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByModule($this)
|
||||
->count($con);
|
||||
}
|
||||
} else {
|
||||
return count($this->collCoupons);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate a ChildCoupon object to this object
|
||||
* through the coupon_module cross reference table.
|
||||
*
|
||||
* @param ChildCoupon $coupon The ChildCouponModule object to relate
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function addCoupon(ChildCoupon $coupon)
|
||||
{
|
||||
if ($this->collCoupons === null) {
|
||||
$this->initCoupons();
|
||||
}
|
||||
|
||||
if (!$this->collCoupons->contains($coupon)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCoupon($coupon);
|
||||
$this->collCoupons[] = $coupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Coupon $coupon The coupon object to add.
|
||||
*/
|
||||
protected function doAddCoupon($coupon)
|
||||
{
|
||||
$couponModule = new ChildCouponModule();
|
||||
$couponModule->setCoupon($coupon);
|
||||
$this->addCouponModule($couponModule);
|
||||
// set the back reference to this object directly as using provided method either results
|
||||
// in endless loop or in multiple relations
|
||||
if (!$coupon->getModules()->contains($this)) {
|
||||
$foreignCollection = $coupon->getModules();
|
||||
$foreignCollection[] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a ChildCoupon object to this object
|
||||
* through the coupon_module cross reference table.
|
||||
*
|
||||
* @param ChildCoupon $coupon The ChildCouponModule object to relate
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCoupon(ChildCoupon $coupon)
|
||||
{
|
||||
if ($this->getCoupons()->contains($coupon)) {
|
||||
$this->collCoupons->remove($this->collCoupons->search($coupon));
|
||||
|
||||
if (null === $this->couponsScheduledForDeletion) {
|
||||
$this->couponsScheduledForDeletion = clone $this->collCoupons;
|
||||
$this->couponsScheduledForDeletion->clear();
|
||||
}
|
||||
|
||||
$this->couponsScheduledForDeletion[] = $coupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -3361,11 +3876,21 @@ abstract class Module implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCouponModules) {
|
||||
foreach ($this->collCouponModules as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collModuleI18ns) {
|
||||
foreach ($this->collModuleI18ns as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCoupons) {
|
||||
foreach ($this->collCoupons as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
// i18n behavior
|
||||
@@ -3377,7 +3902,9 @@ abstract class Module implements ActiveRecordInterface
|
||||
$this->collAreaDeliveryModules = null;
|
||||
$this->collProfileModules = null;
|
||||
$this->collModuleImages = null;
|
||||
$this->collCouponModules = null;
|
||||
$this->collModuleI18ns = null;
|
||||
$this->collCoupons = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,10 @@ use Thelia\Model\Map\ModuleTableMap;
|
||||
* @method ChildModuleQuery rightJoinModuleImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleImage relation
|
||||
* @method ChildModuleQuery innerJoinModuleImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleImage relation
|
||||
*
|
||||
* @method ChildModuleQuery leftJoinCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildModuleQuery rightJoinCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildModuleQuery innerJoinCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @method ChildModuleQuery leftJoinModuleI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleI18n relation
|
||||
* @method ChildModuleQuery rightJoinModuleI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleI18n relation
|
||||
* @method ChildModuleQuery innerJoinModuleI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleI18n relation
|
||||
@@ -938,6 +942,79 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'ModuleImage', '\Thelia\Model\ModuleImageQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponModule object
|
||||
*
|
||||
* @param \Thelia\Model\CouponModule|ObjectCollection $couponModule the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponModule($couponModule, $comparison = null)
|
||||
{
|
||||
if ($couponModule instanceof \Thelia\Model\CouponModule) {
|
||||
return $this
|
||||
->addUsingAlias(ModuleTableMap::ID, $couponModule->getModuleId(), $comparison);
|
||||
} elseif ($couponModule instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByPrimaryKeys($couponModule->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponModule() only accepts arguments of type \Thelia\Model\CouponModule or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponModule');
|
||||
|
||||
// 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, 'CouponModule');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponModule relation CouponModule 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\CouponModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponModule', '\Thelia\Model\CouponModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\ModuleI18n object
|
||||
*
|
||||
@@ -1011,6 +1088,23 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', '\Thelia\Model\ModuleI18nQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Coupon object
|
||||
* using the coupon_module table as cross reference
|
||||
*
|
||||
* @param Coupon $coupon the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByCoupon($coupon, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user