diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php
index 8fbb4d378..853aeb1a5 100644
--- a/core/lib/Thelia/Action/Coupon.php
+++ b/core/lib/Thelia/Action/Coupon.php
@@ -12,7 +12,9 @@
namespace Thelia\Action;
+use Propel\Runtime\Propel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Thelia\Condition\ConditionCollection;
use Thelia\Condition\ConditionFactory;
use Thelia\Condition\Implementation\ConditionInterface;
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
@@ -22,11 +24,17 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Coupon\CouponFactory;
use Thelia\Coupon\CouponManager;
-use Thelia\Condition\ConditionCollection;
use Thelia\Coupon\Type\CouponInterface;
+use Thelia\Model\Base\CouponCountry;
+use Thelia\Model\Base\CouponModule;
+use Thelia\Model\Base\CouponModuleQuery;
use Thelia\Model\Coupon as CouponModel;
+use Thelia\Model\CouponCountryQuery;
use Thelia\Model\CouponQuery;
+use Thelia\Model\Map\OrderCouponTableMap;
use Thelia\Model\OrderCoupon;
+use Thelia\Model\OrderCouponCountry;
+use Thelia\Model\OrderCouponModule;
/**
* Process Coupon Events
@@ -251,38 +259,80 @@ class Coupon extends BaseAction implements EventSubscriberInterface
/**
* @param \Thelia\Core\Event\Order\OrderEvent $event
+ *
+ * @throws \Exception if something goes wrong.
*/
public function afterOrder(OrderEvent $event)
{
$consumedCoupons = $this->request->getSession()->getConsumedCoupons();
if (is_array($consumedCoupons)) {
- foreach ($consumedCoupons as $couponCode) {
- $couponQuery = CouponQuery::create();
- $couponModel = $couponQuery->findOneByCode($couponCode);
- $couponModel->setLocale($this->request->getSession()->getLang()->getLocale());
- /* decrease coupon quantity */
- $this->couponManager->decrementQuantity($couponModel);
+ $con = Propel::getWriteConnection(OrderCouponTableMap::DATABASE_NAME);
+ $con->beginTransaction();
- /* memorize coupon */
- $orderCoupon = new OrderCoupon();
- $orderCoupon->setOrder($event->getOrder())
- ->setCode($couponModel->getCode())
- ->setType($couponModel->getType())
- ->setAmount($couponModel->getAmount())
+ try {
+ foreach ($consumedCoupons as $couponCode) {
+ $couponQuery = CouponQuery::create();
+ $couponModel = $couponQuery->findOneByCode($couponCode);
+ $couponModel->setLocale($this->request->getSession()->getLang()->getLocale());
- ->setTitle($couponModel->getTitle())
- ->setShortDescription($couponModel->getShortDescription())
- ->setDescription($couponModel->getDescription())
+ /* decrease coupon quantity */
+ $this->couponManager->decrementQuantity($couponModel);
- ->setExpirationDate($couponModel->getExpirationDate())
- ->setIsCumulative($couponModel->getIsCumulative())
- ->setIsRemovingPostage($couponModel->getIsRemovingPostage())
- ->setIsAvailableOnSpecialOffers($couponModel->getIsAvailableOnSpecialOffers())
- ->setSerializedConditions($couponModel->getSerializedConditions())
- ;
- $orderCoupon->save();
+ /* memorize coupon */
+ $orderCoupon = new OrderCoupon();
+ $orderCoupon->setOrder($event->getOrder())
+ ->setCode($couponModel->getCode())
+ ->setType($couponModel->getType())
+ ->setAmount($couponModel->getAmount())
+
+ ->setTitle($couponModel->getTitle())
+ ->setShortDescription($couponModel->getShortDescription())
+ ->setDescription($couponModel->getDescription())
+
+ ->setExpirationDate($couponModel->getExpirationDate())
+ ->setIsCumulative($couponModel->getIsCumulative())
+ ->setIsRemovingPostage($couponModel->getIsRemovingPostage())
+ ->setIsAvailableOnSpecialOffers($couponModel->getIsAvailableOnSpecialOffers())
+ ->setSerializedConditions($couponModel->getSerializedConditions())
+ ;
+ $orderCoupon->save();
+
+ // Copy order coupon free shipping data for countries and modules
+ $couponCountries = CouponCountryQuery::create()->filterByCouponId($couponModel->getId())->find();
+
+ /** @var CouponCountry $couponCountry */
+ foreach($couponCountries as $couponCountry) {
+ $occ = new OrderCouponCountry();
+
+ $occ
+ ->setCouponId($orderCoupon->getId())
+ ->setCountryId($couponCountry->getCountryId())
+ ->save();
+ ;
+ }
+
+ $couponModules = CouponModuleQuery::create()->filterByCouponId($couponModel->getId())->find();
+
+ /** @var CouponModule $couponModule */
+ foreach($couponModules as $couponModule) {
+ $ocm = new OrderCouponModule();
+
+ $ocm
+ ->setCouponId($orderCoupon->getId())
+ ->setModuleId($couponModule->getModuleId())
+ ->save();
+ ;
+ }
+ }
+
+ $con->commit();
+ }
+ catch (\Exception $ex) {
+ $con->rollBack();
+
+ throw($ex);
}
}
@@ -316,7 +366,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
TheliaEvents::COUPON_UPDATE => array("update", 128),
TheliaEvents::COUPON_CONSUME => array("consume", 128),
TheliaEvents::COUPON_CONDITION_UPDATE => array("updateCondition", 128),
- TheliaEvents::ORDER_SET_POSTAGE => array("testFreePostage", 256),
+ TheliaEvents::ORDER_SET_POSTAGE => array("testFreePostage", 132),
TheliaEvents::ORDER_BEFORE_PAYMENT => array("afterOrder", 128),
TheliaEvents::CART_ADDITEM => array("updateOrderDiscount", 10),
TheliaEvents::CART_UPDATEITEM => array("updateOrderDiscount", 10),
diff --git a/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php b/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php
index 2c43c75f6..f11b15168 100644
--- a/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php
+++ b/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php
@@ -69,6 +69,8 @@ class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
if (null !== $order = OrderQuery::create()->findPk($this->getOrder())) {
+ $oneDayInSeconds = 60*60*24;
+
/** @var \Thelia\Model\OrderCoupon $orderCoupon */
foreach ($loopResult->getResultDataCollection() as $orderCoupon) {
@@ -76,7 +78,7 @@ class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
$now = time();
$datediff = $orderCoupon->getExpirationDate()->getTimestamp() - $now;
- $daysLeftBeforeExpiration = floor($datediff/(60*60*24));
+ $daysLeftBeforeExpiration = floor($datediff/($oneDayInSeconds));
$freeShippingForCountriesIds = [];
/** @var OrderCouponCountry $couponCountry */
diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php
index 15d56bd17..8cfc562eb 100644
--- a/core/lib/Thelia/Model/Base/Country.php
+++ b/core/lib/Thelia/Model/Base/Country.php
@@ -29,6 +29,10 @@ 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\OrderCoupon as ChildOrderCoupon;
+use Thelia\Model\OrderCouponCountry as ChildOrderCouponCountry;
+use Thelia\Model\OrderCouponCountryQuery as ChildOrderCouponCountryQuery;
+use Thelia\Model\OrderCouponQuery as ChildOrderCouponQuery;
use Thelia\Model\TaxRuleCountry as ChildTaxRuleCountry;
use Thelia\Model\TaxRuleCountryQuery as ChildTaxRuleCountryQuery;
use Thelia\Model\Map\CountryTableMap;
@@ -146,6 +150,12 @@ abstract class Country implements ActiveRecordInterface
protected $collCouponCountries;
protected $collCouponCountriesPartial;
+ /**
+ * @var ObjectCollection|ChildOrderCouponCountry[] Collection to store aggregation of ChildOrderCouponCountry objects.
+ */
+ protected $collOrderCouponCountries;
+ protected $collOrderCouponCountriesPartial;
+
/**
* @var ObjectCollection|ChildCountryI18n[] Collection to store aggregation of ChildCountryI18n objects.
*/
@@ -157,6 +167,11 @@ abstract class Country implements ActiveRecordInterface
*/
protected $collCoupons;
+ /**
+ * @var ChildOrderCoupon[] Collection to store aggregation of ChildOrderCoupon objects.
+ */
+ protected $collOrderCoupons;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -185,6 +200,12 @@ abstract class Country implements ActiveRecordInterface
*/
protected $couponsScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $orderCouponsScheduledForDeletion = null;
+
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
@@ -203,6 +224,12 @@ abstract class Country implements ActiveRecordInterface
*/
protected $couponCountriesScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $orderCouponCountriesScheduledForDeletion = null;
+
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
@@ -955,9 +982,12 @@ abstract class Country implements ActiveRecordInterface
$this->collCouponCountries = null;
+ $this->collOrderCouponCountries = null;
+
$this->collCountryI18ns = null;
$this->collCoupons = null;
+ $this->collOrderCoupons = null;
} // if (deep)
}
@@ -1130,6 +1160,33 @@ abstract class Country implements ActiveRecordInterface
}
}
+ if ($this->orderCouponsScheduledForDeletion !== null) {
+ if (!$this->orderCouponsScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->orderCouponsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ OrderCouponCountryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->orderCouponsScheduledForDeletion = null;
+ }
+
+ foreach ($this->getOrderCoupons() as $orderCoupon) {
+ if ($orderCoupon->isModified()) {
+ $orderCoupon->save($con);
+ }
+ }
+ } elseif ($this->collOrderCoupons) {
+ foreach ($this->collOrderCoupons as $orderCoupon) {
+ if ($orderCoupon->isModified()) {
+ $orderCoupon->save($con);
+ }
+ }
+ }
+
if ($this->taxRuleCountriesScheduledForDeletion !== null) {
if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) {
\Thelia\Model\TaxRuleCountryQuery::create()
@@ -1181,6 +1238,23 @@ abstract class Country implements ActiveRecordInterface
}
}
+ if ($this->orderCouponCountriesScheduledForDeletion !== null) {
+ if (!$this->orderCouponCountriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderCouponCountryQuery::create()
+ ->filterByPrimaryKeys($this->orderCouponCountriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderCouponCountriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderCouponCountries !== null) {
+ foreach ($this->collOrderCouponCountries 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()
@@ -1435,6 +1509,9 @@ abstract class Country implements ActiveRecordInterface
if (null !== $this->collCouponCountries) {
$result['CouponCountries'] = $this->collCouponCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collOrderCouponCountries) {
+ $result['OrderCouponCountries'] = $this->collOrderCouponCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
if (null !== $this->collCountryI18ns) {
$result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
@@ -1647,6 +1724,12 @@ abstract class Country implements ActiveRecordInterface
}
}
+ foreach ($this->getOrderCouponCountries() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderCouponCountry($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));
@@ -1754,6 +1837,9 @@ abstract class Country implements ActiveRecordInterface
if ('CouponCountry' == $relationName) {
return $this->initCouponCountries();
}
+ if ('OrderCouponCountry' == $relationName) {
+ return $this->initOrderCouponCountries();
+ }
if ('CountryI18n' == $relationName) {
return $this->initCountryI18ns();
}
@@ -2544,6 +2630,252 @@ abstract class Country implements ActiveRecordInterface
return $this->getCouponCountries($query, $con);
}
+ /**
+ * Clears out the collOrderCouponCountries 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 addOrderCouponCountries()
+ */
+ public function clearOrderCouponCountries()
+ {
+ $this->collOrderCouponCountries = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderCouponCountries collection loaded partially.
+ */
+ public function resetPartialOrderCouponCountries($v = true)
+ {
+ $this->collOrderCouponCountriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderCouponCountries collection.
+ *
+ * By default this just sets the collOrderCouponCountries collection to an empty array (like clearcollOrderCouponCountries());
+ * 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 initOrderCouponCountries($overrideExisting = true)
+ {
+ if (null !== $this->collOrderCouponCountries && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderCouponCountries = new ObjectCollection();
+ $this->collOrderCouponCountries->setModel('\Thelia\Model\OrderCouponCountry');
+ }
+
+ /**
+ * Gets an array of ChildOrderCouponCountry 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|ChildOrderCouponCountry[] List of ChildOrderCouponCountry objects
+ * @throws PropelException
+ */
+ public function getOrderCouponCountries($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponCountriesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponCountries) {
+ // return empty collection
+ $this->initOrderCouponCountries();
+ } else {
+ $collOrderCouponCountries = ChildOrderCouponCountryQuery::create(null, $criteria)
+ ->filterByCountry($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderCouponCountriesPartial && count($collOrderCouponCountries)) {
+ $this->initOrderCouponCountries(false);
+
+ foreach ($collOrderCouponCountries as $obj) {
+ if (false == $this->collOrderCouponCountries->contains($obj)) {
+ $this->collOrderCouponCountries->append($obj);
+ }
+ }
+
+ $this->collOrderCouponCountriesPartial = true;
+ }
+
+ reset($collOrderCouponCountries);
+
+ return $collOrderCouponCountries;
+ }
+
+ if ($partial && $this->collOrderCouponCountries) {
+ foreach ($this->collOrderCouponCountries as $obj) {
+ if ($obj->isNew()) {
+ $collOrderCouponCountries[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderCouponCountries = $collOrderCouponCountries;
+ $this->collOrderCouponCountriesPartial = false;
+ }
+ }
+
+ return $this->collOrderCouponCountries;
+ }
+
+ /**
+ * Sets a collection of OrderCouponCountry 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 $orderCouponCountries A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function setOrderCouponCountries(Collection $orderCouponCountries, ConnectionInterface $con = null)
+ {
+ $orderCouponCountriesToDelete = $this->getOrderCouponCountries(new Criteria(), $con)->diff($orderCouponCountries);
+
+
+ //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->orderCouponCountriesScheduledForDeletion = clone $orderCouponCountriesToDelete;
+
+ foreach ($orderCouponCountriesToDelete as $orderCouponCountryRemoved) {
+ $orderCouponCountryRemoved->setCountry(null);
+ }
+
+ $this->collOrderCouponCountries = null;
+ foreach ($orderCouponCountries as $orderCouponCountry) {
+ $this->addOrderCouponCountry($orderCouponCountry);
+ }
+
+ $this->collOrderCouponCountries = $orderCouponCountries;
+ $this->collOrderCouponCountriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderCouponCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderCouponCountry objects.
+ * @throws PropelException
+ */
+ public function countOrderCouponCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponCountriesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponCountries) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderCouponCountries());
+ }
+
+ $query = ChildOrderCouponCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCountry($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderCouponCountries);
+ }
+
+ /**
+ * Method called to associate a ChildOrderCouponCountry object to this object
+ * through the ChildOrderCouponCountry foreign key attribute.
+ *
+ * @param ChildOrderCouponCountry $l ChildOrderCouponCountry
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function addOrderCouponCountry(ChildOrderCouponCountry $l)
+ {
+ if ($this->collOrderCouponCountries === null) {
+ $this->initOrderCouponCountries();
+ $this->collOrderCouponCountriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderCouponCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderCouponCountry($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderCouponCountry $orderCouponCountry The orderCouponCountry object to add.
+ */
+ protected function doAddOrderCouponCountry($orderCouponCountry)
+ {
+ $this->collOrderCouponCountries[]= $orderCouponCountry;
+ $orderCouponCountry->setCountry($this);
+ }
+
+ /**
+ * @param OrderCouponCountry $orderCouponCountry The orderCouponCountry object to remove.
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function removeOrderCouponCountry($orderCouponCountry)
+ {
+ if ($this->getOrderCouponCountries()->contains($orderCouponCountry)) {
+ $this->collOrderCouponCountries->remove($this->collOrderCouponCountries->search($orderCouponCountry));
+ if (null === $this->orderCouponCountriesScheduledForDeletion) {
+ $this->orderCouponCountriesScheduledForDeletion = clone $this->collOrderCouponCountries;
+ $this->orderCouponCountriesScheduledForDeletion->clear();
+ }
+ $this->orderCouponCountriesScheduledForDeletion[]= clone $orderCouponCountry;
+ $orderCouponCountry->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 OrderCouponCountries 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|ChildOrderCouponCountry[] List of ChildOrderCouponCountry objects
+ */
+ public function getOrderCouponCountriesJoinOrderCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderCouponCountryQuery::create(null, $criteria);
+ $query->joinWith('OrderCoupon', $joinBehavior);
+
+ return $this->getOrderCouponCountries($query, $con);
+ }
+
/**
* Clears out the collCountryI18ns collection
*
@@ -2952,6 +3284,189 @@ abstract class Country implements ActiveRecordInterface
return $this;
}
+ /**
+ * Clears out the collOrderCoupons 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 addOrderCoupons()
+ */
+ public function clearOrderCoupons()
+ {
+ $this->collOrderCoupons = null; // important to set this to NULL since that means it is uninitialized
+ $this->collOrderCouponsPartial = null;
+ }
+
+ /**
+ * Initializes the collOrderCoupons collection.
+ *
+ * By default this just sets the collOrderCoupons collection to an empty collection (like clearOrderCoupons());
+ * 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 initOrderCoupons()
+ {
+ $this->collOrderCoupons = new ObjectCollection();
+ $this->collOrderCoupons->setModel('\Thelia\Model\OrderCoupon');
+ }
+
+ /**
+ * Gets a collection of ChildOrderCoupon objects related by a many-to-many relationship
+ * to the current object by way of the order_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|ChildOrderCoupon[] List of ChildOrderCoupon objects
+ */
+ public function getOrderCoupons($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collOrderCoupons || null !== $criteria) {
+ if ($this->isNew() && null === $this->collOrderCoupons) {
+ // return empty collection
+ $this->initOrderCoupons();
+ } else {
+ $collOrderCoupons = ChildOrderCouponQuery::create(null, $criteria)
+ ->filterByCountry($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collOrderCoupons;
+ }
+ $this->collOrderCoupons = $collOrderCoupons;
+ }
+ }
+
+ return $this->collOrderCoupons;
+ }
+
+ /**
+ * Sets a collection of OrderCoupon objects related by a many-to-many relationship
+ * to the current object by way of the order_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 $orderCoupons A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function setOrderCoupons(Collection $orderCoupons, ConnectionInterface $con = null)
+ {
+ $this->clearOrderCoupons();
+ $currentOrderCoupons = $this->getOrderCoupons();
+
+ $this->orderCouponsScheduledForDeletion = $currentOrderCoupons->diff($orderCoupons);
+
+ foreach ($orderCoupons as $orderCoupon) {
+ if (!$currentOrderCoupons->contains($orderCoupon)) {
+ $this->doAddOrderCoupon($orderCoupon);
+ }
+ }
+
+ $this->collOrderCoupons = $orderCoupons;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildOrderCoupon objects related by a many-to-many relationship
+ * to the current object by way of the order_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 ChildOrderCoupon objects
+ */
+ public function countOrderCoupons($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collOrderCoupons || null !== $criteria) {
+ if ($this->isNew() && null === $this->collOrderCoupons) {
+ return 0;
+ } else {
+ $query = ChildOrderCouponQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCountry($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collOrderCoupons);
+ }
+ }
+
+ /**
+ * Associate a ChildOrderCoupon object to this object
+ * through the order_coupon_country cross reference table.
+ *
+ * @param ChildOrderCoupon $orderCoupon The ChildOrderCouponCountry object to relate
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function addOrderCoupon(ChildOrderCoupon $orderCoupon)
+ {
+ if ($this->collOrderCoupons === null) {
+ $this->initOrderCoupons();
+ }
+
+ if (!$this->collOrderCoupons->contains($orderCoupon)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderCoupon($orderCoupon);
+ $this->collOrderCoupons[] = $orderCoupon;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderCoupon $orderCoupon The orderCoupon object to add.
+ */
+ protected function doAddOrderCoupon($orderCoupon)
+ {
+ $orderCouponCountry = new ChildOrderCouponCountry();
+ $orderCouponCountry->setOrderCoupon($orderCoupon);
+ $this->addOrderCouponCountry($orderCouponCountry);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$orderCoupon->getCountries()->contains($this)) {
+ $foreignCollection = $orderCoupon->getCountries();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildOrderCoupon object to this object
+ * through the order_coupon_country cross reference table.
+ *
+ * @param ChildOrderCoupon $orderCoupon The ChildOrderCouponCountry object to relate
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function removeOrderCoupon(ChildOrderCoupon $orderCoupon)
+ {
+ if ($this->getOrderCoupons()->contains($orderCoupon)) {
+ $this->collOrderCoupons->remove($this->collOrderCoupons->search($orderCoupon));
+
+ if (null === $this->orderCouponsScheduledForDeletion) {
+ $this->orderCouponsScheduledForDeletion = clone $this->collOrderCoupons;
+ $this->orderCouponsScheduledForDeletion->clear();
+ }
+
+ $this->orderCouponsScheduledForDeletion[] = $orderCoupon;
+ }
+
+ return $this;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -3001,6 +3516,11 @@ abstract class Country implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
+ if ($this->collOrderCouponCountries) {
+ foreach ($this->collOrderCouponCountries as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
if ($this->collCountryI18ns) {
foreach ($this->collCountryI18ns as $o) {
$o->clearAllReferences($deep);
@@ -3011,6 +3531,11 @@ abstract class Country implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
+ if ($this->collOrderCoupons) {
+ foreach ($this->collOrderCoupons as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
// i18n behavior
@@ -3020,8 +3545,10 @@ abstract class Country implements ActiveRecordInterface
$this->collTaxRuleCountries = null;
$this->collAddresses = null;
$this->collCouponCountries = null;
+ $this->collOrderCouponCountries = null;
$this->collCountryI18ns = null;
$this->collCoupons = null;
+ $this->collOrderCoupons = null;
$this->aArea = null;
}
diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php
index 6373c4912..c5c409bf8 100644
--- a/core/lib/Thelia/Model/Base/CountryQuery.php
+++ b/core/lib/Thelia/Model/Base/CountryQuery.php
@@ -62,6 +62,10 @@ use Thelia\Model\Map\CountryTableMap;
* @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 leftJoinOrderCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponCountry relation
+ * @method ChildCountryQuery rightJoinOrderCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponCountry relation
+ * @method ChildCountryQuery innerJoinOrderCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponCountry 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
@@ -884,6 +888,79 @@ abstract class CountryQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CouponCountry', '\Thelia\Model\CouponCountryQuery');
}
+ /**
+ * Filter the query by a related \Thelia\Model\OrderCouponCountry object
+ *
+ * @param \Thelia\Model\OrderCouponCountry|ObjectCollection $orderCouponCountry 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 filterByOrderCouponCountry($orderCouponCountry, $comparison = null)
+ {
+ if ($orderCouponCountry instanceof \Thelia\Model\OrderCouponCountry) {
+ return $this
+ ->addUsingAlias(CountryTableMap::ID, $orderCouponCountry->getCountryId(), $comparison);
+ } elseif ($orderCouponCountry instanceof ObjectCollection) {
+ return $this
+ ->useOrderCouponCountryQuery()
+ ->filterByPrimaryKeys($orderCouponCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderCouponCountry() only accepts arguments of type \Thelia\Model\OrderCouponCountry or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderCouponCountry 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 joinOrderCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderCouponCountry');
+
+ // 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, 'OrderCouponCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderCouponCountry relation OrderCouponCountry 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\OrderCouponCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderCouponCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderCouponCountry', '\Thelia\Model\OrderCouponCountryQuery');
+ }
+
/**
* Filter the query by a related \Thelia\Model\CountryI18n object
*
@@ -974,6 +1051,23 @@ abstract class CountryQuery extends ModelCriteria
->endUse();
}
+ /**
+ * Filter the query by a related OrderCoupon object
+ * using the order_coupon_country table as cross reference
+ *
+ * @param OrderCoupon $orderCoupon 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 filterByOrderCoupon($orderCoupon, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useOrderCouponCountryQuery()
+ ->filterByOrderCoupon($orderCoupon, $comparison)
+ ->endUse();
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php
index 159f1ecf0..e45b80096 100644
--- a/core/lib/Thelia/Model/Base/Module.php
+++ b/core/lib/Thelia/Model/Base/Module.php
@@ -30,6 +30,10 @@ use Thelia\Model\ModuleImage as ChildModuleImage;
use Thelia\Model\ModuleImageQuery as ChildModuleImageQuery;
use Thelia\Model\ModuleQuery as ChildModuleQuery;
use Thelia\Model\Order as ChildOrder;
+use Thelia\Model\OrderCoupon as ChildOrderCoupon;
+use Thelia\Model\OrderCouponModule as ChildOrderCouponModule;
+use Thelia\Model\OrderCouponModuleQuery as ChildOrderCouponModuleQuery;
+use Thelia\Model\OrderCouponQuery as ChildOrderCouponQuery;
use Thelia\Model\OrderQuery as ChildOrderQuery;
use Thelia\Model\ProfileModule as ChildProfileModule;
use Thelia\Model\ProfileModuleQuery as ChildProfileModuleQuery;
@@ -153,6 +157,12 @@ abstract class Module implements ActiveRecordInterface
protected $collCouponModules;
protected $collCouponModulesPartial;
+ /**
+ * @var ObjectCollection|ChildOrderCouponModule[] Collection to store aggregation of ChildOrderCouponModule objects.
+ */
+ protected $collOrderCouponModules;
+ protected $collOrderCouponModulesPartial;
+
/**
* @var ObjectCollection|ChildModuleI18n[] Collection to store aggregation of ChildModuleI18n objects.
*/
@@ -164,6 +174,11 @@ abstract class Module implements ActiveRecordInterface
*/
protected $collCoupons;
+ /**
+ * @var ChildOrderCoupon[] Collection to store aggregation of ChildOrderCoupon objects.
+ */
+ protected $collOrderCoupons;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -192,6 +207,12 @@ abstract class Module implements ActiveRecordInterface
*/
protected $couponsScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $orderCouponsScheduledForDeletion = null;
+
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
@@ -228,6 +249,12 @@ abstract class Module implements ActiveRecordInterface
*/
protected $couponModulesScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $orderCouponModulesScheduledForDeletion = null;
+
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
@@ -913,9 +940,12 @@ abstract class Module implements ActiveRecordInterface
$this->collCouponModules = null;
+ $this->collOrderCouponModules = null;
+
$this->collModuleI18ns = null;
$this->collCoupons = null;
+ $this->collOrderCoupons = null;
} // if (deep)
}
@@ -1076,6 +1106,33 @@ abstract class Module implements ActiveRecordInterface
}
}
+ if ($this->orderCouponsScheduledForDeletion !== null) {
+ if (!$this->orderCouponsScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->orderCouponsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ OrderCouponModuleQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->orderCouponsScheduledForDeletion = null;
+ }
+
+ foreach ($this->getOrderCoupons() as $orderCoupon) {
+ if ($orderCoupon->isModified()) {
+ $orderCoupon->save($con);
+ }
+ }
+ } elseif ($this->collOrderCoupons) {
+ foreach ($this->collOrderCoupons as $orderCoupon) {
+ if ($orderCoupon->isModified()) {
+ $orderCoupon->save($con);
+ }
+ }
+ }
+
if ($this->ordersRelatedByPaymentModuleIdScheduledForDeletion !== null) {
if (!$this->ordersRelatedByPaymentModuleIdScheduledForDeletion->isEmpty()) {
\Thelia\Model\OrderQuery::create()
@@ -1178,6 +1235,23 @@ abstract class Module implements ActiveRecordInterface
}
}
+ if ($this->orderCouponModulesScheduledForDeletion !== null) {
+ if (!$this->orderCouponModulesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderCouponModuleQuery::create()
+ ->filterByPrimaryKeys($this->orderCouponModulesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderCouponModulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderCouponModules !== null) {
+ foreach ($this->collOrderCouponModules 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()
@@ -1428,6 +1502,9 @@ abstract class Module implements ActiveRecordInterface
if (null !== $this->collCouponModules) {
$result['CouponModules'] = $this->collCouponModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collOrderCouponModules) {
+ $result['OrderCouponModules'] = $this->collOrderCouponModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
if (null !== $this->collModuleI18ns) {
$result['ModuleI18ns'] = $this->collModuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
@@ -1652,6 +1729,12 @@ abstract class Module implements ActiveRecordInterface
}
}
+ foreach ($this->getOrderCouponModules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderCouponModule($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));
@@ -1717,6 +1800,9 @@ abstract class Module implements ActiveRecordInterface
if ('CouponModule' == $relationName) {
return $this->initCouponModules();
}
+ if ('OrderCouponModule' == $relationName) {
+ return $this->initOrderCouponModules();
+ }
if ('ModuleI18n' == $relationName) {
return $this->initModuleI18ns();
}
@@ -3411,6 +3497,252 @@ abstract class Module implements ActiveRecordInterface
return $this->getCouponModules($query, $con);
}
+ /**
+ * Clears out the collOrderCouponModules 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 addOrderCouponModules()
+ */
+ public function clearOrderCouponModules()
+ {
+ $this->collOrderCouponModules = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderCouponModules collection loaded partially.
+ */
+ public function resetPartialOrderCouponModules($v = true)
+ {
+ $this->collOrderCouponModulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderCouponModules collection.
+ *
+ * By default this just sets the collOrderCouponModules collection to an empty array (like clearcollOrderCouponModules());
+ * 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 initOrderCouponModules($overrideExisting = true)
+ {
+ if (null !== $this->collOrderCouponModules && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderCouponModules = new ObjectCollection();
+ $this->collOrderCouponModules->setModel('\Thelia\Model\OrderCouponModule');
+ }
+
+ /**
+ * Gets an array of ChildOrderCouponModule 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|ChildOrderCouponModule[] List of ChildOrderCouponModule objects
+ * @throws PropelException
+ */
+ public function getOrderCouponModules($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponModulesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponModules) {
+ // return empty collection
+ $this->initOrderCouponModules();
+ } else {
+ $collOrderCouponModules = ChildOrderCouponModuleQuery::create(null, $criteria)
+ ->filterByModule($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderCouponModulesPartial && count($collOrderCouponModules)) {
+ $this->initOrderCouponModules(false);
+
+ foreach ($collOrderCouponModules as $obj) {
+ if (false == $this->collOrderCouponModules->contains($obj)) {
+ $this->collOrderCouponModules->append($obj);
+ }
+ }
+
+ $this->collOrderCouponModulesPartial = true;
+ }
+
+ reset($collOrderCouponModules);
+
+ return $collOrderCouponModules;
+ }
+
+ if ($partial && $this->collOrderCouponModules) {
+ foreach ($this->collOrderCouponModules as $obj) {
+ if ($obj->isNew()) {
+ $collOrderCouponModules[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderCouponModules = $collOrderCouponModules;
+ $this->collOrderCouponModulesPartial = false;
+ }
+ }
+
+ return $this->collOrderCouponModules;
+ }
+
+ /**
+ * Sets a collection of OrderCouponModule 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 $orderCouponModules A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function setOrderCouponModules(Collection $orderCouponModules, ConnectionInterface $con = null)
+ {
+ $orderCouponModulesToDelete = $this->getOrderCouponModules(new Criteria(), $con)->diff($orderCouponModules);
+
+
+ //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->orderCouponModulesScheduledForDeletion = clone $orderCouponModulesToDelete;
+
+ foreach ($orderCouponModulesToDelete as $orderCouponModuleRemoved) {
+ $orderCouponModuleRemoved->setModule(null);
+ }
+
+ $this->collOrderCouponModules = null;
+ foreach ($orderCouponModules as $orderCouponModule) {
+ $this->addOrderCouponModule($orderCouponModule);
+ }
+
+ $this->collOrderCouponModules = $orderCouponModules;
+ $this->collOrderCouponModulesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderCouponModule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderCouponModule objects.
+ * @throws PropelException
+ */
+ public function countOrderCouponModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponModulesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponModules) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderCouponModules());
+ }
+
+ $query = ChildOrderCouponModuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByModule($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderCouponModules);
+ }
+
+ /**
+ * Method called to associate a ChildOrderCouponModule object to this object
+ * through the ChildOrderCouponModule foreign key attribute.
+ *
+ * @param ChildOrderCouponModule $l ChildOrderCouponModule
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function addOrderCouponModule(ChildOrderCouponModule $l)
+ {
+ if ($this->collOrderCouponModules === null) {
+ $this->initOrderCouponModules();
+ $this->collOrderCouponModulesPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderCouponModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderCouponModule($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderCouponModule $orderCouponModule The orderCouponModule object to add.
+ */
+ protected function doAddOrderCouponModule($orderCouponModule)
+ {
+ $this->collOrderCouponModules[]= $orderCouponModule;
+ $orderCouponModule->setModule($this);
+ }
+
+ /**
+ * @param OrderCouponModule $orderCouponModule The orderCouponModule object to remove.
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function removeOrderCouponModule($orderCouponModule)
+ {
+ if ($this->getOrderCouponModules()->contains($orderCouponModule)) {
+ $this->collOrderCouponModules->remove($this->collOrderCouponModules->search($orderCouponModule));
+ if (null === $this->orderCouponModulesScheduledForDeletion) {
+ $this->orderCouponModulesScheduledForDeletion = clone $this->collOrderCouponModules;
+ $this->orderCouponModulesScheduledForDeletion->clear();
+ }
+ $this->orderCouponModulesScheduledForDeletion[]= clone $orderCouponModule;
+ $orderCouponModule->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 OrderCouponModules 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|ChildOrderCouponModule[] List of ChildOrderCouponModule objects
+ */
+ public function getOrderCouponModulesJoinOrderCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderCouponModuleQuery::create(null, $criteria);
+ $query->joinWith('OrderCoupon', $joinBehavior);
+
+ return $this->getOrderCouponModules($query, $con);
+ }
+
/**
* Clears out the collModuleI18ns collection
*
@@ -3819,6 +4151,189 @@ abstract class Module implements ActiveRecordInterface
return $this;
}
+ /**
+ * Clears out the collOrderCoupons 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 addOrderCoupons()
+ */
+ public function clearOrderCoupons()
+ {
+ $this->collOrderCoupons = null; // important to set this to NULL since that means it is uninitialized
+ $this->collOrderCouponsPartial = null;
+ }
+
+ /**
+ * Initializes the collOrderCoupons collection.
+ *
+ * By default this just sets the collOrderCoupons collection to an empty collection (like clearOrderCoupons());
+ * 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 initOrderCoupons()
+ {
+ $this->collOrderCoupons = new ObjectCollection();
+ $this->collOrderCoupons->setModel('\Thelia\Model\OrderCoupon');
+ }
+
+ /**
+ * Gets a collection of ChildOrderCoupon objects related by a many-to-many relationship
+ * to the current object by way of the order_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|ChildOrderCoupon[] List of ChildOrderCoupon objects
+ */
+ public function getOrderCoupons($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collOrderCoupons || null !== $criteria) {
+ if ($this->isNew() && null === $this->collOrderCoupons) {
+ // return empty collection
+ $this->initOrderCoupons();
+ } else {
+ $collOrderCoupons = ChildOrderCouponQuery::create(null, $criteria)
+ ->filterByModule($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collOrderCoupons;
+ }
+ $this->collOrderCoupons = $collOrderCoupons;
+ }
+ }
+
+ return $this->collOrderCoupons;
+ }
+
+ /**
+ * Sets a collection of OrderCoupon objects related by a many-to-many relationship
+ * to the current object by way of the order_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 $orderCoupons A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function setOrderCoupons(Collection $orderCoupons, ConnectionInterface $con = null)
+ {
+ $this->clearOrderCoupons();
+ $currentOrderCoupons = $this->getOrderCoupons();
+
+ $this->orderCouponsScheduledForDeletion = $currentOrderCoupons->diff($orderCoupons);
+
+ foreach ($orderCoupons as $orderCoupon) {
+ if (!$currentOrderCoupons->contains($orderCoupon)) {
+ $this->doAddOrderCoupon($orderCoupon);
+ }
+ }
+
+ $this->collOrderCoupons = $orderCoupons;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildOrderCoupon objects related by a many-to-many relationship
+ * to the current object by way of the order_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 ChildOrderCoupon objects
+ */
+ public function countOrderCoupons($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collOrderCoupons || null !== $criteria) {
+ if ($this->isNew() && null === $this->collOrderCoupons) {
+ return 0;
+ } else {
+ $query = ChildOrderCouponQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByModule($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collOrderCoupons);
+ }
+ }
+
+ /**
+ * Associate a ChildOrderCoupon object to this object
+ * through the order_coupon_module cross reference table.
+ *
+ * @param ChildOrderCoupon $orderCoupon The ChildOrderCouponModule object to relate
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function addOrderCoupon(ChildOrderCoupon $orderCoupon)
+ {
+ if ($this->collOrderCoupons === null) {
+ $this->initOrderCoupons();
+ }
+
+ if (!$this->collOrderCoupons->contains($orderCoupon)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderCoupon($orderCoupon);
+ $this->collOrderCoupons[] = $orderCoupon;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderCoupon $orderCoupon The orderCoupon object to add.
+ */
+ protected function doAddOrderCoupon($orderCoupon)
+ {
+ $orderCouponModule = new ChildOrderCouponModule();
+ $orderCouponModule->setOrderCoupon($orderCoupon);
+ $this->addOrderCouponModule($orderCouponModule);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$orderCoupon->getModules()->contains($this)) {
+ $foreignCollection = $orderCoupon->getModules();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildOrderCoupon object to this object
+ * through the order_coupon_module cross reference table.
+ *
+ * @param ChildOrderCoupon $orderCoupon The ChildOrderCouponModule object to relate
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function removeOrderCoupon(ChildOrderCoupon $orderCoupon)
+ {
+ if ($this->getOrderCoupons()->contains($orderCoupon)) {
+ $this->collOrderCoupons->remove($this->collOrderCoupons->search($orderCoupon));
+
+ if (null === $this->orderCouponsScheduledForDeletion) {
+ $this->orderCouponsScheduledForDeletion = clone $this->collOrderCoupons;
+ $this->orderCouponsScheduledForDeletion->clear();
+ }
+
+ $this->orderCouponsScheduledForDeletion[] = $orderCoupon;
+ }
+
+ return $this;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -3881,6 +4396,11 @@ abstract class Module implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
+ if ($this->collOrderCouponModules) {
+ foreach ($this->collOrderCouponModules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
if ($this->collModuleI18ns) {
foreach ($this->collModuleI18ns as $o) {
$o->clearAllReferences($deep);
@@ -3891,6 +4411,11 @@ abstract class Module implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
+ if ($this->collOrderCoupons) {
+ foreach ($this->collOrderCoupons as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
// i18n behavior
@@ -3903,8 +4428,10 @@ abstract class Module implements ActiveRecordInterface
$this->collProfileModules = null;
$this->collModuleImages = null;
$this->collCouponModules = null;
+ $this->collOrderCouponModules = null;
$this->collModuleI18ns = null;
$this->collCoupons = null;
+ $this->collOrderCoupons = null;
}
/**
diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php
index 0c7d4a726..c56c70be5 100644
--- a/core/lib/Thelia/Model/Base/ModuleQuery.php
+++ b/core/lib/Thelia/Model/Base/ModuleQuery.php
@@ -68,6 +68,10 @@ use Thelia\Model\Map\ModuleTableMap;
* @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 leftJoinOrderCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponModule relation
+ * @method ChildModuleQuery rightJoinOrderCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponModule relation
+ * @method ChildModuleQuery innerJoinOrderCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponModule 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
@@ -1015,6 +1019,79 @@ abstract class ModuleQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CouponModule', '\Thelia\Model\CouponModuleQuery');
}
+ /**
+ * Filter the query by a related \Thelia\Model\OrderCouponModule object
+ *
+ * @param \Thelia\Model\OrderCouponModule|ObjectCollection $orderCouponModule 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 filterByOrderCouponModule($orderCouponModule, $comparison = null)
+ {
+ if ($orderCouponModule instanceof \Thelia\Model\OrderCouponModule) {
+ return $this
+ ->addUsingAlias(ModuleTableMap::ID, $orderCouponModule->getModuleId(), $comparison);
+ } elseif ($orderCouponModule instanceof ObjectCollection) {
+ return $this
+ ->useOrderCouponModuleQuery()
+ ->filterByPrimaryKeys($orderCouponModule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderCouponModule() only accepts arguments of type \Thelia\Model\OrderCouponModule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderCouponModule 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 joinOrderCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderCouponModule');
+
+ // 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, 'OrderCouponModule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderCouponModule relation OrderCouponModule 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\OrderCouponModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderCouponModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderCouponModule', '\Thelia\Model\OrderCouponModuleQuery');
+ }
+
/**
* Filter the query by a related \Thelia\Model\ModuleI18n object
*
@@ -1105,6 +1182,23 @@ abstract class ModuleQuery extends ModelCriteria
->endUse();
}
+ /**
+ * Filter the query by a related OrderCoupon object
+ * using the order_coupon_module table as cross reference
+ *
+ * @param OrderCoupon $orderCoupon 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 filterByOrderCoupon($orderCoupon, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useOrderCouponModuleQuery()
+ ->filterByOrderCoupon($orderCoupon, $comparison)
+ ->endUse();
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/Base/OrderCoupon.php b/core/lib/Thelia/Model/Base/OrderCoupon.php
index 25179228e..4702db6ba 100644
--- a/core/lib/Thelia/Model/Base/OrderCoupon.php
+++ b/core/lib/Thelia/Model/Base/OrderCoupon.php
@@ -10,14 +10,23 @@ use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Propel\Runtime\Collection\Collection;
+use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\BadMethodCallException;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Parser\AbstractParser;
use Propel\Runtime\Util\PropelDateTime;
+use Thelia\Model\Country as ChildCountry;
+use Thelia\Model\CountryQuery as ChildCountryQuery;
+use Thelia\Model\Module as ChildModule;
+use Thelia\Model\ModuleQuery as ChildModuleQuery;
use Thelia\Model\Order as ChildOrder;
use Thelia\Model\OrderCoupon as ChildOrderCoupon;
+use Thelia\Model\OrderCouponCountry as ChildOrderCouponCountry;
+use Thelia\Model\OrderCouponCountryQuery as ChildOrderCouponCountryQuery;
+use Thelia\Model\OrderCouponModule as ChildOrderCouponModule;
+use Thelia\Model\OrderCouponModuleQuery as ChildOrderCouponModuleQuery;
use Thelia\Model\OrderCouponQuery as ChildOrderCouponQuery;
use Thelia\Model\OrderQuery as ChildOrderQuery;
use Thelia\Model\Map\OrderCouponTableMap;
@@ -151,6 +160,28 @@ abstract class OrderCoupon implements ActiveRecordInterface
*/
protected $aOrder;
+ /**
+ * @var ObjectCollection|ChildOrderCouponCountry[] Collection to store aggregation of ChildOrderCouponCountry objects.
+ */
+ protected $collOrderCouponCountries;
+ protected $collOrderCouponCountriesPartial;
+
+ /**
+ * @var ObjectCollection|ChildOrderCouponModule[] Collection to store aggregation of ChildOrderCouponModule objects.
+ */
+ protected $collOrderCouponModules;
+ protected $collOrderCouponModulesPartial;
+
+ /**
+ * @var ChildCountry[] Collection to store aggregation of ChildCountry objects.
+ */
+ protected $collCountries;
+
+ /**
+ * @var ChildModule[] Collection to store aggregation of ChildModule objects.
+ */
+ protected $collModules;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -159,6 +190,30 @@ abstract class OrderCoupon implements ActiveRecordInterface
*/
protected $alreadyInSave = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $countriesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $modulesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $orderCouponCountriesScheduledForDeletion = null;
+
+ /**
+ * An array of objects scheduled for deletion.
+ * @var ObjectCollection
+ */
+ protected $orderCouponModulesScheduledForDeletion = null;
+
/**
* Initializes internal state of Thelia\Model\Base\OrderCoupon object.
*/
@@ -1115,6 +1170,12 @@ abstract class OrderCoupon implements ActiveRecordInterface
if ($deep) { // also de-associate any related objects?
$this->aOrder = null;
+ $this->collOrderCouponCountries = null;
+
+ $this->collOrderCouponModules = null;
+
+ $this->collCountries = null;
+ $this->collModules = null;
} // if (deep)
}
@@ -1260,6 +1321,94 @@ abstract class OrderCoupon implements ActiveRecordInterface
$this->resetModified();
}
+ if ($this->countriesScheduledForDeletion !== null) {
+ if (!$this->countriesScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->countriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ OrderCouponCountryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->countriesScheduledForDeletion = null;
+ }
+
+ foreach ($this->getCountries() as $country) {
+ if ($country->isModified()) {
+ $country->save($con);
+ }
+ }
+ } elseif ($this->collCountries) {
+ foreach ($this->collCountries as $country) {
+ if ($country->isModified()) {
+ $country->save($con);
+ }
+ }
+ }
+
+ if ($this->modulesScheduledForDeletion !== null) {
+ if (!$this->modulesScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->modulesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ OrderCouponModuleQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->modulesScheduledForDeletion = null;
+ }
+
+ foreach ($this->getModules() as $module) {
+ if ($module->isModified()) {
+ $module->save($con);
+ }
+ }
+ } elseif ($this->collModules) {
+ foreach ($this->collModules as $module) {
+ if ($module->isModified()) {
+ $module->save($con);
+ }
+ }
+ }
+
+ if ($this->orderCouponCountriesScheduledForDeletion !== null) {
+ if (!$this->orderCouponCountriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderCouponCountryQuery::create()
+ ->filterByPrimaryKeys($this->orderCouponCountriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderCouponCountriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderCouponCountries !== null) {
+ foreach ($this->collOrderCouponCountries as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->orderCouponModulesScheduledForDeletion !== null) {
+ if (!$this->orderCouponModulesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderCouponModuleQuery::create()
+ ->filterByPrimaryKeys($this->orderCouponModulesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderCouponModulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderCouponModules !== null) {
+ foreach ($this->collOrderCouponModules as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -1548,6 +1697,12 @@ abstract class OrderCoupon implements ActiveRecordInterface
if (null !== $this->aOrder) {
$result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
+ if (null !== $this->collOrderCouponCountries) {
+ $result['OrderCouponCountries'] = $this->collOrderCouponCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrderCouponModules) {
+ $result['OrderCouponModules'] = $this->collOrderCouponModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
}
return $result;
@@ -1769,6 +1924,26 @@ abstract class OrderCoupon implements ActiveRecordInterface
$copyObj->setSerializedConditions($this->getSerializedConditions());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ if ($deepCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+
+ foreach ($this->getOrderCouponCountries() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderCouponCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getOrderCouponModules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderCouponModule($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
@@ -1848,6 +2023,883 @@ abstract class OrderCoupon implements ActiveRecordInterface
return $this->aOrder;
}
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('OrderCouponCountry' == $relationName) {
+ return $this->initOrderCouponCountries();
+ }
+ if ('OrderCouponModule' == $relationName) {
+ return $this->initOrderCouponModules();
+ }
+ }
+
+ /**
+ * Clears out the collOrderCouponCountries 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 addOrderCouponCountries()
+ */
+ public function clearOrderCouponCountries()
+ {
+ $this->collOrderCouponCountries = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderCouponCountries collection loaded partially.
+ */
+ public function resetPartialOrderCouponCountries($v = true)
+ {
+ $this->collOrderCouponCountriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderCouponCountries collection.
+ *
+ * By default this just sets the collOrderCouponCountries collection to an empty array (like clearcollOrderCouponCountries());
+ * 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 initOrderCouponCountries($overrideExisting = true)
+ {
+ if (null !== $this->collOrderCouponCountries && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderCouponCountries = new ObjectCollection();
+ $this->collOrderCouponCountries->setModel('\Thelia\Model\OrderCouponCountry');
+ }
+
+ /**
+ * Gets an array of ChildOrderCouponCountry 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 ChildOrderCoupon 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|ChildOrderCouponCountry[] List of ChildOrderCouponCountry objects
+ * @throws PropelException
+ */
+ public function getOrderCouponCountries($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponCountriesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponCountries) {
+ // return empty collection
+ $this->initOrderCouponCountries();
+ } else {
+ $collOrderCouponCountries = ChildOrderCouponCountryQuery::create(null, $criteria)
+ ->filterByOrderCoupon($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderCouponCountriesPartial && count($collOrderCouponCountries)) {
+ $this->initOrderCouponCountries(false);
+
+ foreach ($collOrderCouponCountries as $obj) {
+ if (false == $this->collOrderCouponCountries->contains($obj)) {
+ $this->collOrderCouponCountries->append($obj);
+ }
+ }
+
+ $this->collOrderCouponCountriesPartial = true;
+ }
+
+ reset($collOrderCouponCountries);
+
+ return $collOrderCouponCountries;
+ }
+
+ if ($partial && $this->collOrderCouponCountries) {
+ foreach ($this->collOrderCouponCountries as $obj) {
+ if ($obj->isNew()) {
+ $collOrderCouponCountries[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderCouponCountries = $collOrderCouponCountries;
+ $this->collOrderCouponCountriesPartial = false;
+ }
+ }
+
+ return $this->collOrderCouponCountries;
+ }
+
+ /**
+ * Sets a collection of OrderCouponCountry 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 $orderCouponCountries A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function setOrderCouponCountries(Collection $orderCouponCountries, ConnectionInterface $con = null)
+ {
+ $orderCouponCountriesToDelete = $this->getOrderCouponCountries(new Criteria(), $con)->diff($orderCouponCountries);
+
+
+ //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->orderCouponCountriesScheduledForDeletion = clone $orderCouponCountriesToDelete;
+
+ foreach ($orderCouponCountriesToDelete as $orderCouponCountryRemoved) {
+ $orderCouponCountryRemoved->setOrderCoupon(null);
+ }
+
+ $this->collOrderCouponCountries = null;
+ foreach ($orderCouponCountries as $orderCouponCountry) {
+ $this->addOrderCouponCountry($orderCouponCountry);
+ }
+
+ $this->collOrderCouponCountries = $orderCouponCountries;
+ $this->collOrderCouponCountriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderCouponCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderCouponCountry objects.
+ * @throws PropelException
+ */
+ public function countOrderCouponCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponCountriesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponCountries) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderCouponCountries());
+ }
+
+ $query = ChildOrderCouponCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderCoupon($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderCouponCountries);
+ }
+
+ /**
+ * Method called to associate a ChildOrderCouponCountry object to this object
+ * through the ChildOrderCouponCountry foreign key attribute.
+ *
+ * @param ChildOrderCouponCountry $l ChildOrderCouponCountry
+ * @return \Thelia\Model\OrderCoupon The current object (for fluent API support)
+ */
+ public function addOrderCouponCountry(ChildOrderCouponCountry $l)
+ {
+ if ($this->collOrderCouponCountries === null) {
+ $this->initOrderCouponCountries();
+ $this->collOrderCouponCountriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderCouponCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderCouponCountry($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderCouponCountry $orderCouponCountry The orderCouponCountry object to add.
+ */
+ protected function doAddOrderCouponCountry($orderCouponCountry)
+ {
+ $this->collOrderCouponCountries[]= $orderCouponCountry;
+ $orderCouponCountry->setOrderCoupon($this);
+ }
+
+ /**
+ * @param OrderCouponCountry $orderCouponCountry The orderCouponCountry object to remove.
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function removeOrderCouponCountry($orderCouponCountry)
+ {
+ if ($this->getOrderCouponCountries()->contains($orderCouponCountry)) {
+ $this->collOrderCouponCountries->remove($this->collOrderCouponCountries->search($orderCouponCountry));
+ if (null === $this->orderCouponCountriesScheduledForDeletion) {
+ $this->orderCouponCountriesScheduledForDeletion = clone $this->collOrderCouponCountries;
+ $this->orderCouponCountriesScheduledForDeletion->clear();
+ }
+ $this->orderCouponCountriesScheduledForDeletion[]= clone $orderCouponCountry;
+ $orderCouponCountry->setOrderCoupon(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderCoupon is new, it will return
+ * an empty collection; or if this OrderCoupon has previously
+ * been saved, it will retrieve related OrderCouponCountries 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 OrderCoupon.
+ *
+ * @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|ChildOrderCouponCountry[] List of ChildOrderCouponCountry objects
+ */
+ public function getOrderCouponCountriesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderCouponCountryQuery::create(null, $criteria);
+ $query->joinWith('Country', $joinBehavior);
+
+ return $this->getOrderCouponCountries($query, $con);
+ }
+
+ /**
+ * Clears out the collOrderCouponModules 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 addOrderCouponModules()
+ */
+ public function clearOrderCouponModules()
+ {
+ $this->collOrderCouponModules = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderCouponModules collection loaded partially.
+ */
+ public function resetPartialOrderCouponModules($v = true)
+ {
+ $this->collOrderCouponModulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderCouponModules collection.
+ *
+ * By default this just sets the collOrderCouponModules collection to an empty array (like clearcollOrderCouponModules());
+ * 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 initOrderCouponModules($overrideExisting = true)
+ {
+ if (null !== $this->collOrderCouponModules && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderCouponModules = new ObjectCollection();
+ $this->collOrderCouponModules->setModel('\Thelia\Model\OrderCouponModule');
+ }
+
+ /**
+ * Gets an array of ChildOrderCouponModule 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 ChildOrderCoupon 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|ChildOrderCouponModule[] List of ChildOrderCouponModule objects
+ * @throws PropelException
+ */
+ public function getOrderCouponModules($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponModulesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponModules) {
+ // return empty collection
+ $this->initOrderCouponModules();
+ } else {
+ $collOrderCouponModules = ChildOrderCouponModuleQuery::create(null, $criteria)
+ ->filterByOrderCoupon($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderCouponModulesPartial && count($collOrderCouponModules)) {
+ $this->initOrderCouponModules(false);
+
+ foreach ($collOrderCouponModules as $obj) {
+ if (false == $this->collOrderCouponModules->contains($obj)) {
+ $this->collOrderCouponModules->append($obj);
+ }
+ }
+
+ $this->collOrderCouponModulesPartial = true;
+ }
+
+ reset($collOrderCouponModules);
+
+ return $collOrderCouponModules;
+ }
+
+ if ($partial && $this->collOrderCouponModules) {
+ foreach ($this->collOrderCouponModules as $obj) {
+ if ($obj->isNew()) {
+ $collOrderCouponModules[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderCouponModules = $collOrderCouponModules;
+ $this->collOrderCouponModulesPartial = false;
+ }
+ }
+
+ return $this->collOrderCouponModules;
+ }
+
+ /**
+ * Sets a collection of OrderCouponModule 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 $orderCouponModules A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function setOrderCouponModules(Collection $orderCouponModules, ConnectionInterface $con = null)
+ {
+ $orderCouponModulesToDelete = $this->getOrderCouponModules(new Criteria(), $con)->diff($orderCouponModules);
+
+
+ //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->orderCouponModulesScheduledForDeletion = clone $orderCouponModulesToDelete;
+
+ foreach ($orderCouponModulesToDelete as $orderCouponModuleRemoved) {
+ $orderCouponModuleRemoved->setOrderCoupon(null);
+ }
+
+ $this->collOrderCouponModules = null;
+ foreach ($orderCouponModules as $orderCouponModule) {
+ $this->addOrderCouponModule($orderCouponModule);
+ }
+
+ $this->collOrderCouponModules = $orderCouponModules;
+ $this->collOrderCouponModulesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderCouponModule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderCouponModule objects.
+ * @throws PropelException
+ */
+ public function countOrderCouponModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderCouponModulesPartial && !$this->isNew();
+ if (null === $this->collOrderCouponModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderCouponModules) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderCouponModules());
+ }
+
+ $query = ChildOrderCouponModuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderCoupon($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderCouponModules);
+ }
+
+ /**
+ * Method called to associate a ChildOrderCouponModule object to this object
+ * through the ChildOrderCouponModule foreign key attribute.
+ *
+ * @param ChildOrderCouponModule $l ChildOrderCouponModule
+ * @return \Thelia\Model\OrderCoupon The current object (for fluent API support)
+ */
+ public function addOrderCouponModule(ChildOrderCouponModule $l)
+ {
+ if ($this->collOrderCouponModules === null) {
+ $this->initOrderCouponModules();
+ $this->collOrderCouponModulesPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderCouponModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderCouponModule($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderCouponModule $orderCouponModule The orderCouponModule object to add.
+ */
+ protected function doAddOrderCouponModule($orderCouponModule)
+ {
+ $this->collOrderCouponModules[]= $orderCouponModule;
+ $orderCouponModule->setOrderCoupon($this);
+ }
+
+ /**
+ * @param OrderCouponModule $orderCouponModule The orderCouponModule object to remove.
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function removeOrderCouponModule($orderCouponModule)
+ {
+ if ($this->getOrderCouponModules()->contains($orderCouponModule)) {
+ $this->collOrderCouponModules->remove($this->collOrderCouponModules->search($orderCouponModule));
+ if (null === $this->orderCouponModulesScheduledForDeletion) {
+ $this->orderCouponModulesScheduledForDeletion = clone $this->collOrderCouponModules;
+ $this->orderCouponModulesScheduledForDeletion->clear();
+ }
+ $this->orderCouponModulesScheduledForDeletion[]= clone $orderCouponModule;
+ $orderCouponModule->setOrderCoupon(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderCoupon is new, it will return
+ * an empty collection; or if this OrderCoupon has previously
+ * been saved, it will retrieve related OrderCouponModules 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 OrderCoupon.
+ *
+ * @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|ChildOrderCouponModule[] List of ChildOrderCouponModule objects
+ */
+ public function getOrderCouponModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderCouponModuleQuery::create(null, $criteria);
+ $query->joinWith('Module', $joinBehavior);
+
+ return $this->getOrderCouponModules($query, $con);
+ }
+
+ /**
+ * Clears out the collCountries 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 addCountries()
+ */
+ public function clearCountries()
+ {
+ $this->collCountries = null; // important to set this to NULL since that means it is uninitialized
+ $this->collCountriesPartial = null;
+ }
+
+ /**
+ * Initializes the collCountries collection.
+ *
+ * By default this just sets the collCountries collection to an empty collection (like clearCountries());
+ * 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 initCountries()
+ {
+ $this->collCountries = new ObjectCollection();
+ $this->collCountries->setModel('\Thelia\Model\Country');
+ }
+
+ /**
+ * Gets a collection of ChildCountry objects related by a many-to-many relationship
+ * to the current object by way of the order_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 ChildOrderCoupon 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|ChildCountry[] List of ChildCountry objects
+ */
+ public function getCountries($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCountries || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCountries) {
+ // return empty collection
+ $this->initCountries();
+ } else {
+ $collCountries = ChildCountryQuery::create(null, $criteria)
+ ->filterByOrderCoupon($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collCountries;
+ }
+ $this->collCountries = $collCountries;
+ }
+ }
+
+ return $this->collCountries;
+ }
+
+ /**
+ * Sets a collection of Country objects related by a many-to-many relationship
+ * to the current object by way of the order_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 $countries A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function setCountries(Collection $countries, ConnectionInterface $con = null)
+ {
+ $this->clearCountries();
+ $currentCountries = $this->getCountries();
+
+ $this->countriesScheduledForDeletion = $currentCountries->diff($countries);
+
+ foreach ($countries as $country) {
+ if (!$currentCountries->contains($country)) {
+ $this->doAddCountry($country);
+ }
+ }
+
+ $this->collCountries = $countries;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildCountry objects related by a many-to-many relationship
+ * to the current object by way of the order_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 ChildCountry objects
+ */
+ public function countCountries($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCountries || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCountries) {
+ return 0;
+ } else {
+ $query = ChildCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderCoupon($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCountries);
+ }
+ }
+
+ /**
+ * Associate a ChildCountry object to this object
+ * through the order_coupon_country cross reference table.
+ *
+ * @param ChildCountry $country The ChildOrderCouponCountry object to relate
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function addCountry(ChildCountry $country)
+ {
+ if ($this->collCountries === null) {
+ $this->initCountries();
+ }
+
+ if (!$this->collCountries->contains($country)) { // only add it if the **same** object is not already associated
+ $this->doAddCountry($country);
+ $this->collCountries[] = $country;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Country $country The country object to add.
+ */
+ protected function doAddCountry($country)
+ {
+ $orderCouponCountry = new ChildOrderCouponCountry();
+ $orderCouponCountry->setCountry($country);
+ $this->addOrderCouponCountry($orderCouponCountry);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$country->getOrderCoupons()->contains($this)) {
+ $foreignCollection = $country->getOrderCoupons();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildCountry object to this object
+ * through the order_coupon_country cross reference table.
+ *
+ * @param ChildCountry $country The ChildOrderCouponCountry object to relate
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function removeCountry(ChildCountry $country)
+ {
+ if ($this->getCountries()->contains($country)) {
+ $this->collCountries->remove($this->collCountries->search($country));
+
+ if (null === $this->countriesScheduledForDeletion) {
+ $this->countriesScheduledForDeletion = clone $this->collCountries;
+ $this->countriesScheduledForDeletion->clear();
+ }
+
+ $this->countriesScheduledForDeletion[] = $country;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collModules 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 addModules()
+ */
+ public function clearModules()
+ {
+ $this->collModules = null; // important to set this to NULL since that means it is uninitialized
+ $this->collModulesPartial = null;
+ }
+
+ /**
+ * Initializes the collModules collection.
+ *
+ * By default this just sets the collModules collection to an empty collection (like clearModules());
+ * 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 initModules()
+ {
+ $this->collModules = new ObjectCollection();
+ $this->collModules->setModel('\Thelia\Model\Module');
+ }
+
+ /**
+ * Gets a collection of ChildModule objects related by a many-to-many relationship
+ * to the current object by way of the order_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 ChildOrderCoupon 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|ChildModule[] List of ChildModule objects
+ */
+ public function getModules($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collModules || null !== $criteria) {
+ if ($this->isNew() && null === $this->collModules) {
+ // return empty collection
+ $this->initModules();
+ } else {
+ $collModules = ChildModuleQuery::create(null, $criteria)
+ ->filterByOrderCoupon($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collModules;
+ }
+ $this->collModules = $collModules;
+ }
+ }
+
+ return $this->collModules;
+ }
+
+ /**
+ * Sets a collection of Module objects related by a many-to-many relationship
+ * to the current object by way of the order_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 $modules A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function setModules(Collection $modules, ConnectionInterface $con = null)
+ {
+ $this->clearModules();
+ $currentModules = $this->getModules();
+
+ $this->modulesScheduledForDeletion = $currentModules->diff($modules);
+
+ foreach ($modules as $module) {
+ if (!$currentModules->contains($module)) {
+ $this->doAddModule($module);
+ }
+ }
+
+ $this->collModules = $modules;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildModule objects related by a many-to-many relationship
+ * to the current object by way of the order_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 ChildModule objects
+ */
+ public function countModules($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collModules || null !== $criteria) {
+ if ($this->isNew() && null === $this->collModules) {
+ return 0;
+ } else {
+ $query = ChildModuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderCoupon($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collModules);
+ }
+ }
+
+ /**
+ * Associate a ChildModule object to this object
+ * through the order_coupon_module cross reference table.
+ *
+ * @param ChildModule $module The ChildOrderCouponModule object to relate
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function addModule(ChildModule $module)
+ {
+ if ($this->collModules === null) {
+ $this->initModules();
+ }
+
+ if (!$this->collModules->contains($module)) { // only add it if the **same** object is not already associated
+ $this->doAddModule($module);
+ $this->collModules[] = $module;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Module $module The module object to add.
+ */
+ protected function doAddModule($module)
+ {
+ $orderCouponModule = new ChildOrderCouponModule();
+ $orderCouponModule->setModule($module);
+ $this->addOrderCouponModule($orderCouponModule);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$module->getOrderCoupons()->contains($this)) {
+ $foreignCollection = $module->getOrderCoupons();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildModule object to this object
+ * through the order_coupon_module cross reference table.
+ *
+ * @param ChildModule $module The ChildOrderCouponModule object to relate
+ * @return ChildOrderCoupon The current object (for fluent API support)
+ */
+ public function removeModule(ChildModule $module)
+ {
+ if ($this->getModules()->contains($module)) {
+ $this->collModules->remove($this->collModules->search($module));
+
+ if (null === $this->modulesScheduledForDeletion) {
+ $this->modulesScheduledForDeletion = clone $this->collModules;
+ $this->modulesScheduledForDeletion->clear();
+ }
+
+ $this->modulesScheduledForDeletion[] = $module;
+ }
+
+ return $this;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1887,8 +2939,32 @@ abstract class OrderCoupon implements ActiveRecordInterface
public function clearAllReferences($deep = false)
{
if ($deep) {
+ if ($this->collOrderCouponCountries) {
+ foreach ($this->collOrderCouponCountries as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrderCouponModules) {
+ foreach ($this->collOrderCouponModules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCountries) {
+ foreach ($this->collCountries as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collModules) {
+ foreach ($this->collModules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
+ $this->collOrderCouponCountries = null;
+ $this->collOrderCouponModules = null;
+ $this->collCountries = null;
+ $this->collModules = null;
$this->aOrder = null;
}
diff --git a/core/lib/Thelia/Model/Base/OrderCouponCountry.php b/core/lib/Thelia/Model/Base/OrderCouponCountry.php
new file mode 100644
index 000000000..21325b962
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderCouponCountry.php
@@ -0,0 +1,1268 @@
+modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderCouponCountry instance. If
+ * obj is an instance of OrderCouponCountry, delegates to
+ * equals(OrderCouponCountry). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderCouponCountry The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderCouponCountry The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [coupon_id] column value.
+ *
+ * @return int
+ */
+ public function getCouponId()
+ {
+
+ return $this->coupon_id;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+
+ return $this->country_id;
+ }
+
+ /**
+ * Set the value of [coupon_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderCouponCountry The current object (for fluent API support)
+ */
+ public function setCouponId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->coupon_id !== $v) {
+ $this->coupon_id = $v;
+ $this->modifiedColumns[OrderCouponCountryTableMap::COUPON_ID] = true;
+ }
+
+ if ($this->aOrderCoupon !== null && $this->aOrderCoupon->getId() !== $v) {
+ $this->aOrderCoupon = null;
+ }
+
+
+ return $this;
+ } // setCouponId()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderCouponCountry The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[OrderCouponCountryTableMap::COUNTRY_ID] = true;
+ }
+
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderCouponCountryTableMap::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->coupon_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderCouponCountryTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->country_id = (null !== $col) ? (int) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 2; // 2 = OrderCouponCountryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\OrderCouponCountry object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aOrderCoupon !== null && $this->coupon_id !== $this->aOrderCoupon->getId()) {
+ $this->aOrderCoupon = null;
+ }
+ if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
+ $this->aCountry = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderCouponCountryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderCouponCountryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCountry = null;
+ $this->aOrderCoupon = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderCouponCountry::setDeleted()
+ * @see OrderCouponCountry::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponCountryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderCouponCountryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponCountryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderCouponCountryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCountry !== null) {
+ if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
+ $affectedRows += $this->aCountry->save($con);
+ }
+ $this->setCountry($this->aCountry);
+ }
+
+ if ($this->aOrderCoupon !== null) {
+ if ($this->aOrderCoupon->isModified() || $this->aOrderCoupon->isNew()) {
+ $affectedRows += $this->aOrderCoupon->save($con);
+ }
+ $this->setOrderCoupon($this->aOrderCoupon);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderCouponCountryTableMap::COUPON_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUPON_ID`';
+ }
+ if ($this->isColumnModified(OrderCouponCountryTableMap::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUNTRY_ID`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order_coupon_country` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`COUPON_ID`':
+ $stmt->bindValue($identifier, $this->coupon_id, PDO::PARAM_INT);
+ break;
+ case '`COUNTRY_ID`':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderCouponCountryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getCouponId();
+ break;
+ case 1:
+ return $this->getCountryId();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderCouponCountry'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderCouponCountry'][serialize($this->getPrimaryKey())] = true;
+ $keys = OrderCouponCountryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getCouponId(),
+ $keys[1] => $this->getCountryId(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderCoupon) {
+ $result['OrderCoupon'] = $this->aOrderCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderCouponCountryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setCouponId($value);
+ break;
+ case 1:
+ $this->setCountryId($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderCouponCountryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setCouponId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCountryId($arr[$keys[1]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderCouponCountryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderCouponCountryTableMap::COUPON_ID)) $criteria->add(OrderCouponCountryTableMap::COUPON_ID, $this->coupon_id);
+ if ($this->isColumnModified(OrderCouponCountryTableMap::COUNTRY_ID)) $criteria->add(OrderCouponCountryTableMap::COUNTRY_ID, $this->country_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderCouponCountryTableMap::DATABASE_NAME);
+ $criteria->add(OrderCouponCountryTableMap::COUPON_ID, $this->coupon_id);
+ $criteria->add(OrderCouponCountryTableMap::COUNTRY_ID, $this->country_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getCouponId();
+ $pks[1] = $this->getCountryId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setCouponId($keys[0]);
+ $this->setCountryId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getCouponId()) && (null === $this->getCountryId());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \Thelia\Model\OrderCouponCountry (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCouponId($this->getCouponId());
+ $copyObj->setCountryId($this->getCountryId());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \Thelia\Model\OrderCouponCountry Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCountry object.
+ *
+ * @param ChildCountry $v
+ * @return \Thelia\Model\OrderCouponCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCountry(ChildCountry $v = null)
+ {
+ if ($v === null) {
+ $this->setCountryId(NULL);
+ } else {
+ $this->setCountryId($v->getId());
+ }
+
+ $this->aCountry = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCountry object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderCouponCountry($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCountry object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCountry The associated ChildCountry object.
+ * @throws PropelException
+ */
+ public function getCountry(ConnectionInterface $con = null)
+ {
+ if ($this->aCountry === null && ($this->country_id !== null)) {
+ $this->aCountry = ChildCountryQuery::create()->findPk($this->country_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCountry->addOrderCouponCountries($this);
+ */
+ }
+
+ return $this->aCountry;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderCoupon object.
+ *
+ * @param ChildOrderCoupon $v
+ * @return \Thelia\Model\OrderCouponCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderCoupon(ChildOrderCoupon $v = null)
+ {
+ if ($v === null) {
+ $this->setCouponId(NULL);
+ } else {
+ $this->setCouponId($v->getId());
+ }
+
+ $this->aOrderCoupon = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderCoupon object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderCouponCountry($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderCoupon object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderCoupon The associated ChildOrderCoupon object.
+ * @throws PropelException
+ */
+ public function getOrderCoupon(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderCoupon === null && ($this->coupon_id !== null)) {
+ $this->aOrderCoupon = ChildOrderCouponQuery::create()->findPk($this->coupon_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderCoupon->addOrderCouponCountries($this);
+ */
+ }
+
+ return $this->aOrderCoupon;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->coupon_id = null;
+ $this->country_id = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCountry = null;
+ $this->aOrderCoupon = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderCouponCountryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderCouponCountryQuery.php b/core/lib/Thelia/Model/Base/OrderCouponCountryQuery.php
new file mode 100644
index 000000000..10bdd7d04
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderCouponCountryQuery.php
@@ -0,0 +1,568 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$coupon_id, $country_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderCouponCountry|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderCouponCountryTableMap::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(OrderCouponCountryTableMap::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 ChildOrderCouponCountry A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `COUPON_ID`, `COUNTRY_ID` FROM `order_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 ChildOrderCouponCountry();
+ $obj->hydrate($row);
+ OrderCouponCountryTableMap::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 ChildOrderCouponCountry|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderCouponCountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(OrderCouponCountryTableMap::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 ChildOrderCouponCountryQuery 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(OrderCouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(OrderCouponCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the coupon_id column
+ *
+ * Example usage:
+ *
+ * $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
+ *
+ *
+ * @see filterByOrderCoupon()
+ *
+ * @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 ChildOrderCouponCountryQuery 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(OrderCouponCountryTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($couponId['max'])) {
+ $this->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $couponId, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $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
+ *
+ *
+ * @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 ChildOrderCouponCountryQuery 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(OrderCouponCountryTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCouponCountryTableMap::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 ChildOrderCouponCountryQuery The current query, for fluid interface
+ */
+ public function filterByCountry($country, $comparison = null)
+ {
+ if ($country instanceof \Thelia\Model\Country) {
+ return $this
+ ->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $country->getId(), $comparison);
+ } elseif ($country instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderCouponCountryTableMap::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 ChildOrderCouponCountryQuery 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\OrderCoupon object
+ *
+ * @param \Thelia\Model\OrderCoupon|ObjectCollection $orderCoupon The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderCouponCountryQuery The current query, for fluid interface
+ */
+ public function filterByOrderCoupon($orderCoupon, $comparison = null)
+ {
+ if ($orderCoupon instanceof \Thelia\Model\OrderCoupon) {
+ return $this
+ ->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $orderCoupon->getId(), $comparison);
+ } elseif ($orderCoupon instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $orderCoupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderCoupon() only accepts arguments of type \Thelia\Model\OrderCoupon or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderCoupon relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderCouponCountryQuery The current query, for fluid interface
+ */
+ public function joinOrderCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderCoupon');
+
+ // 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, 'OrderCoupon');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderCoupon relation OrderCoupon 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\OrderCouponQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderCoupon($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderCoupon', '\Thelia\Model\OrderCouponQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrderCouponCountry $orderCouponCountry Object to remove from the list of results
+ *
+ * @return ChildOrderCouponCountryQuery The current query, for fluid interface
+ */
+ public function prune($orderCouponCountry = null)
+ {
+ if ($orderCouponCountry) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(OrderCouponCountryTableMap::COUPON_ID), $orderCouponCountry->getCouponId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(OrderCouponCountryTableMap::COUNTRY_ID), $orderCouponCountry->getCountryId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_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(OrderCouponCountryTableMap::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).
+ OrderCouponCountryTableMap::clearInstancePool();
+ OrderCouponCountryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderCouponCountry or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderCouponCountry 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(OrderCouponCountryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderCouponCountryTableMap::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();
+
+
+ OrderCouponCountryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderCouponCountryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // OrderCouponCountryQuery
diff --git a/core/lib/Thelia/Model/Base/OrderCouponModule.php b/core/lib/Thelia/Model/Base/OrderCouponModule.php
new file mode 100644
index 000000000..01b18da8a
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderCouponModule.php
@@ -0,0 +1,1268 @@
+modifiedColumns;
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return boolean true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ if (isset($this->modifiedColumns[$col])) {
+ unset($this->modifiedColumns[$col]);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderCouponModule instance. If
+ * obj is an instance of OrderCouponModule, delegates to
+ * equals(OrderCouponModule). Otherwise, returns false.
+ *
+ * @param mixed $obj The object to compare to.
+ * @return boolean Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return array_key_exists($name, $this->virtualColumns);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @return mixed
+ *
+ * @throws PropelException
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderCouponModule The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderCouponModule The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+
+ return $this;
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [coupon_id] column value.
+ *
+ * @return int
+ */
+ public function getCouponId()
+ {
+
+ return $this->coupon_id;
+ }
+
+ /**
+ * Get the [module_id] column value.
+ *
+ * @return int
+ */
+ public function getModuleId()
+ {
+
+ return $this->module_id;
+ }
+
+ /**
+ * Set the value of [coupon_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderCouponModule The current object (for fluent API support)
+ */
+ public function setCouponId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->coupon_id !== $v) {
+ $this->coupon_id = $v;
+ $this->modifiedColumns[OrderCouponModuleTableMap::COUPON_ID] = true;
+ }
+
+ if ($this->aOrderCoupon !== null && $this->aOrderCoupon->getId() !== $v) {
+ $this->aOrderCoupon = null;
+ }
+
+
+ return $this;
+ } // setCouponId()
+
+ /**
+ * Set the value of [module_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderCouponModule The current object (for fluent API support)
+ */
+ public function setModuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->module_id !== $v) {
+ $this->module_id = $v;
+ $this->modifiedColumns[OrderCouponModuleTableMap::MODULE_ID] = true;
+ }
+
+ if ($this->aModule !== null && $this->aModule->getId() !== $v) {
+ $this->aModule = null;
+ }
+
+
+ return $this;
+ } // setModuleId()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderCouponModuleTableMap::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->coupon_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderCouponModuleTableMap::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->module_id = (null !== $col) ? (int) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 2; // 2 = OrderCouponModuleTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\OrderCouponModule object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aOrderCoupon !== null && $this->coupon_id !== $this->aOrderCoupon->getId()) {
+ $this->aOrderCoupon = null;
+ }
+ if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) {
+ $this->aModule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderCouponModuleTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderCouponModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrderCoupon = null;
+ $this->aModule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderCouponModule::setDeleted()
+ * @see OrderCouponModule::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponModuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderCouponModuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see doSave()
+ */
+ public function save(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponModuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderCouponModuleTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param ConnectionInterface $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrderCoupon !== null) {
+ if ($this->aOrderCoupon->isModified() || $this->aOrderCoupon->isNew()) {
+ $affectedRows += $this->aOrderCoupon->save($con);
+ }
+ $this->setOrderCoupon($this->aOrderCoupon);
+ }
+
+ if ($this->aModule !== null) {
+ if ($this->aModule->isModified() || $this->aModule->isNew()) {
+ $affectedRows += $this->aModule->save($con);
+ }
+ $this->setModule($this->aModule);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderCouponModuleTableMap::COUPON_ID)) {
+ $modifiedColumns[':p' . $index++] = '`COUPON_ID`';
+ }
+ if ($this->isColumnModified(OrderCouponModuleTableMap::MODULE_ID)) {
+ $modifiedColumns[':p' . $index++] = '`MODULE_ID`';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO `order_coupon_module` (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '`COUPON_ID`':
+ $stmt->bindValue($identifier, $this->coupon_id, PDO::PARAM_INT);
+ break;
+ case '`MODULE_ID`':
+ $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderCouponModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getCouponId();
+ break;
+ case 1:
+ return $this->getModuleId();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderCouponModule'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderCouponModule'][serialize($this->getPrimaryKey())] = true;
+ $keys = OrderCouponModuleTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getCouponId(),
+ $keys[1] => $this->getModuleId(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrderCoupon) {
+ $result['OrderCoupon'] = $this->aOrderCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aModule) {
+ $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderCouponModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+
+ return $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setCouponId($value);
+ break;
+ case 1:
+ $this->setModuleId($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderCouponModuleTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setCouponId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setModuleId($arr[$keys[1]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(OrderCouponModuleTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderCouponModuleTableMap::COUPON_ID)) $criteria->add(OrderCouponModuleTableMap::COUPON_ID, $this->coupon_id);
+ if ($this->isColumnModified(OrderCouponModuleTableMap::MODULE_ID)) $criteria->add(OrderCouponModuleTableMap::MODULE_ID, $this->module_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(OrderCouponModuleTableMap::DATABASE_NAME);
+ $criteria->add(OrderCouponModuleTableMap::COUPON_ID, $this->coupon_id);
+ $criteria->add(OrderCouponModuleTableMap::MODULE_ID, $this->module_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getCouponId();
+ $pks[1] = $this->getModuleId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setCouponId($keys[0]);
+ $this->setModuleId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getCouponId()) && (null === $this->getModuleId());
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of \Thelia\Model\OrderCouponModule (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCouponId($this->getCouponId());
+ $copyObj->setModuleId($this->getModuleId());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return \Thelia\Model\OrderCouponModule Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderCoupon object.
+ *
+ * @param ChildOrderCoupon $v
+ * @return \Thelia\Model\OrderCouponModule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderCoupon(ChildOrderCoupon $v = null)
+ {
+ if ($v === null) {
+ $this->setCouponId(NULL);
+ } else {
+ $this->setCouponId($v->getId());
+ }
+
+ $this->aOrderCoupon = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderCoupon object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderCouponModule($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderCoupon object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderCoupon The associated ChildOrderCoupon object.
+ * @throws PropelException
+ */
+ public function getOrderCoupon(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderCoupon === null && ($this->coupon_id !== null)) {
+ $this->aOrderCoupon = ChildOrderCouponQuery::create()->findPk($this->coupon_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderCoupon->addOrderCouponModules($this);
+ */
+ }
+
+ return $this->aOrderCoupon;
+ }
+
+ /**
+ * Declares an association between this object and a ChildModule object.
+ *
+ * @param ChildModule $v
+ * @return \Thelia\Model\OrderCouponModule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setModule(ChildModule $v = null)
+ {
+ if ($v === null) {
+ $this->setModuleId(NULL);
+ } else {
+ $this->setModuleId($v->getId());
+ }
+
+ $this->aModule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildModule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderCouponModule($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildModule object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildModule The associated ChildModule object.
+ * @throws PropelException
+ */
+ public function getModule(ConnectionInterface $con = null)
+ {
+ if ($this->aModule === null && ($this->module_id !== null)) {
+ $this->aModule = ChildModuleQuery::create()->findPk($this->module_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aModule->addOrderCouponModules($this);
+ */
+ }
+
+ return $this->aModule;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->coupon_id = null;
+ $this->module_id = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrderCoupon = null;
+ $this->aModule = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderCouponModuleTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderCouponModuleQuery.php b/core/lib/Thelia/Model/Base/OrderCouponModuleQuery.php
new file mode 100644
index 000000000..67a064849
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderCouponModuleQuery.php
@@ -0,0 +1,568 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$coupon_id, $module_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderCouponModule|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderCouponModuleTableMap::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(OrderCouponModuleTableMap::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 ChildOrderCouponModule A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT `COUPON_ID`, `MODULE_ID` FROM `order_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 ChildOrderCouponModule();
+ $obj->hydrate($row);
+ OrderCouponModuleTableMap::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 ChildOrderCouponModule|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderCouponModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(OrderCouponModuleTableMap::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 ChildOrderCouponModuleQuery 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(OrderCouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(OrderCouponModuleTableMap::MODULE_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the coupon_id column
+ *
+ * Example usage:
+ *
+ * $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
+ *
+ *
+ * @see filterByOrderCoupon()
+ *
+ * @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 ChildOrderCouponModuleQuery 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(OrderCouponModuleTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($couponId['max'])) {
+ $this->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $couponId, $comparison);
+ }
+
+ /**
+ * Filter the query on the module_id column
+ *
+ * Example usage:
+ *
+ * $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
+ *
+ *
+ * @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 ChildOrderCouponModuleQuery 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(OrderCouponModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($moduleId['max'])) {
+ $this->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $moduleId, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderCoupon object
+ *
+ * @param \Thelia\Model\OrderCoupon|ObjectCollection $orderCoupon The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderCouponModuleQuery The current query, for fluid interface
+ */
+ public function filterByOrderCoupon($orderCoupon, $comparison = null)
+ {
+ if ($orderCoupon instanceof \Thelia\Model\OrderCoupon) {
+ return $this
+ ->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $orderCoupon->getId(), $comparison);
+ } elseif ($orderCoupon instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $orderCoupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderCoupon() only accepts arguments of type \Thelia\Model\OrderCoupon or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderCoupon relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderCouponModuleQuery The current query, for fluid interface
+ */
+ public function joinOrderCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderCoupon');
+
+ // 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, 'OrderCoupon');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderCoupon relation OrderCoupon 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\OrderCouponQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderCoupon($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderCoupon', '\Thelia\Model\OrderCouponQuery');
+ }
+
+ /**
+ * 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 ChildOrderCouponModuleQuery The current query, for fluid interface
+ */
+ public function filterByModule($module, $comparison = null)
+ {
+ if ($module instanceof \Thelia\Model\Module) {
+ return $this
+ ->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $module->getId(), $comparison);
+ } elseif ($module instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderCouponModuleTableMap::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 ChildOrderCouponModuleQuery 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 ChildOrderCouponModule $orderCouponModule Object to remove from the list of results
+ *
+ * @return ChildOrderCouponModuleQuery The current query, for fluid interface
+ */
+ public function prune($orderCouponModule = null)
+ {
+ if ($orderCouponModule) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(OrderCouponModuleTableMap::COUPON_ID), $orderCouponModule->getCouponId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(OrderCouponModuleTableMap::MODULE_ID), $orderCouponModule->getModuleId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_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(OrderCouponModuleTableMap::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).
+ OrderCouponModuleTableMap::clearInstancePool();
+ OrderCouponModuleTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderCouponModule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderCouponModule 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(OrderCouponModuleTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderCouponModuleTableMap::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();
+
+
+ OrderCouponModuleTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderCouponModuleTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // OrderCouponModuleQuery
diff --git a/core/lib/Thelia/Model/Base/OrderCouponQuery.php b/core/lib/Thelia/Model/Base/OrderCouponQuery.php
index 037a8f695..466c52899 100644
--- a/core/lib/Thelia/Model/Base/OrderCouponQuery.php
+++ b/core/lib/Thelia/Model/Base/OrderCouponQuery.php
@@ -61,6 +61,14 @@ use Thelia\Model\Map\OrderCouponTableMap;
* @method ChildOrderCouponQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
* @method ChildOrderCouponQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
*
+ * @method ChildOrderCouponQuery leftJoinOrderCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponCountry relation
+ * @method ChildOrderCouponQuery rightJoinOrderCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponCountry relation
+ * @method ChildOrderCouponQuery innerJoinOrderCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponCountry relation
+ *
+ * @method ChildOrderCouponQuery leftJoinOrderCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponModule relation
+ * @method ChildOrderCouponQuery rightJoinOrderCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponModule relation
+ * @method ChildOrderCouponQuery innerJoinOrderCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponModule relation
+ *
* @method ChildOrderCoupon findOne(ConnectionInterface $con = null) Return the first ChildOrderCoupon matching the query
* @method ChildOrderCoupon findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderCoupon matching the query, or a new ChildOrderCoupon object populated from the query conditions when no match is found
*
@@ -856,6 +864,186 @@ abstract class OrderCouponQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
}
+ /**
+ * Filter the query by a related \Thelia\Model\OrderCouponCountry object
+ *
+ * @param \Thelia\Model\OrderCouponCountry|ObjectCollection $orderCouponCountry the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderCouponQuery The current query, for fluid interface
+ */
+ public function filterByOrderCouponCountry($orderCouponCountry, $comparison = null)
+ {
+ if ($orderCouponCountry instanceof \Thelia\Model\OrderCouponCountry) {
+ return $this
+ ->addUsingAlias(OrderCouponTableMap::ID, $orderCouponCountry->getCouponId(), $comparison);
+ } elseif ($orderCouponCountry instanceof ObjectCollection) {
+ return $this
+ ->useOrderCouponCountryQuery()
+ ->filterByPrimaryKeys($orderCouponCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderCouponCountry() only accepts arguments of type \Thelia\Model\OrderCouponCountry or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderCouponCountry relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderCouponQuery The current query, for fluid interface
+ */
+ public function joinOrderCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderCouponCountry');
+
+ // 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, 'OrderCouponCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderCouponCountry relation OrderCouponCountry 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\OrderCouponCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderCouponCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderCouponCountry', '\Thelia\Model\OrderCouponCountryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderCouponModule object
+ *
+ * @param \Thelia\Model\OrderCouponModule|ObjectCollection $orderCouponModule the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderCouponQuery The current query, for fluid interface
+ */
+ public function filterByOrderCouponModule($orderCouponModule, $comparison = null)
+ {
+ if ($orderCouponModule instanceof \Thelia\Model\OrderCouponModule) {
+ return $this
+ ->addUsingAlias(OrderCouponTableMap::ID, $orderCouponModule->getCouponId(), $comparison);
+ } elseif ($orderCouponModule instanceof ObjectCollection) {
+ return $this
+ ->useOrderCouponModuleQuery()
+ ->filterByPrimaryKeys($orderCouponModule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderCouponModule() only accepts arguments of type \Thelia\Model\OrderCouponModule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderCouponModule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderCouponQuery The current query, for fluid interface
+ */
+ public function joinOrderCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderCouponModule');
+
+ // 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, 'OrderCouponModule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderCouponModule relation OrderCouponModule 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\OrderCouponModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderCouponModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderCouponModule', '\Thelia\Model\OrderCouponModuleQuery');
+ }
+
+ /**
+ * Filter the query by a related Country object
+ * using the order_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 ChildOrderCouponQuery The current query, for fluid interface
+ */
+ public function filterByCountry($country, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useOrderCouponCountryQuery()
+ ->filterByCountry($country, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Filter the query by a related Module object
+ * using the order_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 ChildOrderCouponQuery The current query, for fluid interface
+ */
+ public function filterByModule($module, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useOrderCouponModuleQuery()
+ ->filterByModule($module, $comparison)
+ ->endUse();
+ }
+
/**
* Exclude object from result
*
diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php
index 803db114e..866a6683a 100644
--- a/core/lib/Thelia/Model/Map/CountryTableMap.php
+++ b/core/lib/Thelia/Model/Map/CountryTableMap.php
@@ -195,8 +195,10 @@ class CountryTableMap extends TableMap
$this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountries');
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'RESTRICT', 'RESTRICT', 'Addresses');
$this->addRelation('CouponCountry', '\\Thelia\\Model\\CouponCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'CouponCountries');
+ $this->addRelation('OrderCouponCountry', '\\Thelia\\Model\\OrderCouponCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', null, 'OrderCouponCountries');
$this->addRelation('CountryI18n', '\\Thelia\\Model\\CountryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CountryI18ns');
$this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_MANY, array(), 'CASCADE', null, 'Coupons');
+ $this->addRelation('OrderCoupon', '\\Thelia\\Model\\OrderCoupon', RelationMap::MANY_TO_MANY, array(), null, null, 'OrderCoupons');
} // buildRelations()
/**
@@ -221,6 +223,7 @@ class CountryTableMap extends TableMap
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
TaxRuleCountryTableMap::clearInstancePool();
CouponCountryTableMap::clearInstancePool();
+ OrderCouponCountryTableMap::clearInstancePool();
CountryI18nTableMap::clearInstancePool();
}
diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php
index 5e162556e..32511e06e 100644
--- a/core/lib/Thelia/Model/Map/ModuleTableMap.php
+++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php
@@ -191,8 +191,10 @@ class ModuleTableMap extends TableMap
$this->addRelation('ProfileModule', '\\Thelia\\Model\\ProfileModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'ProfileModules');
$this->addRelation('ModuleImage', '\\Thelia\\Model\\ModuleImage', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'ModuleImages');
$this->addRelation('CouponModule', '\\Thelia\\Model\\CouponModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', null, 'CouponModules');
+ $this->addRelation('OrderCouponModule', '\\Thelia\\Model\\OrderCouponModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', null, 'OrderCouponModules');
$this->addRelation('ModuleI18n', '\\Thelia\\Model\\ModuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleI18ns');
$this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_MANY, array(), 'CASCADE', null, 'Coupons');
+ $this->addRelation('OrderCoupon', '\\Thelia\\Model\\OrderCoupon', RelationMap::MANY_TO_MANY, array(), 'CASCADE', null, 'OrderCoupons');
} // buildRelations()
/**
@@ -219,6 +221,7 @@ class ModuleTableMap extends TableMap
ProfileModuleTableMap::clearInstancePool();
ModuleImageTableMap::clearInstancePool();
CouponModuleTableMap::clearInstancePool();
+ OrderCouponModuleTableMap::clearInstancePool();
ModuleI18nTableMap::clearInstancePool();
}
diff --git a/core/lib/Thelia/Model/Map/OrderCouponCountryTableMap.php b/core/lib/Thelia/Model/Map/OrderCouponCountryTableMap.php
new file mode 100644
index 000000000..9df81cdde
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderCouponCountryTableMap.php
@@ -0,0 +1,468 @@
+ array('CouponId', 'CountryId', ),
+ self::TYPE_STUDLYPHPNAME => array('couponId', 'countryId', ),
+ self::TYPE_COLNAME => array(OrderCouponCountryTableMap::COUPON_ID, OrderCouponCountryTableMap::COUNTRY_ID, ),
+ self::TYPE_RAW_COLNAME => array('COUPON_ID', 'COUNTRY_ID', ),
+ self::TYPE_FIELDNAME => array('coupon_id', 'country_id', ),
+ self::TYPE_NUM => array(0, 1, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('CouponId' => 0, 'CountryId' => 1, ),
+ self::TYPE_STUDLYPHPNAME => array('couponId' => 0, 'countryId' => 1, ),
+ self::TYPE_COLNAME => array(OrderCouponCountryTableMap::COUPON_ID => 0, OrderCouponCountryTableMap::COUNTRY_ID => 1, ),
+ self::TYPE_RAW_COLNAME => array('COUPON_ID' => 0, 'COUNTRY_ID' => 1, ),
+ self::TYPE_FIELDNAME => array('coupon_id' => 0, 'country_id' => 1, ),
+ self::TYPE_NUM => array(0, 1, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_coupon_country');
+ $this->setPhpName('OrderCouponCountry');
+ $this->setClassName('\\Thelia\\Model\\OrderCouponCountry');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addForeignPrimaryKey('COUPON_ID', 'CouponId', 'INTEGER' , 'order_coupon', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('COUNTRY_ID', 'CountryId', 'INTEGER' , 'country', 'ID', true, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('OrderCoupon', '\\Thelia\\Model\\OrderCoupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), null, null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\OrderCouponCountry $obj A \Thelia\Model\OrderCouponCountry object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getCouponId(), (string) $obj->getCountryId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\OrderCouponCountry object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\OrderCouponCountry) {
+ $key = serialize(array((string) $value->getCouponId(), (string) $value->getCountryId()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\OrderCouponCountry object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderCouponCountryTableMap::CLASS_DEFAULT : OrderCouponCountryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderCouponCountry object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderCouponCountryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderCouponCountryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderCouponCountryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderCouponCountryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderCouponCountryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderCouponCountryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderCouponCountryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderCouponCountryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderCouponCountryTableMap::COUPON_ID);
+ $criteria->addSelectColumn(OrderCouponCountryTableMap::COUNTRY_ID);
+ } else {
+ $criteria->addSelectColumn($alias . '.COUPON_ID');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(OrderCouponCountryTableMap::DATABASE_NAME)->getTable(OrderCouponCountryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderCouponCountryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderCouponCountryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderCouponCountryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderCouponCountry or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderCouponCountry object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponCountryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\OrderCouponCountry) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderCouponCountryTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(OrderCouponCountryTableMap::COUPON_ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(OrderCouponCountryTableMap::COUNTRY_ID, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = OrderCouponCountryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderCouponCountryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderCouponCountryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_coupon_country table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderCouponCountryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderCouponCountry or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderCouponCountry object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponCountryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderCouponCountry object
+ }
+
+
+ // Set the correct dbName
+ $query = OrderCouponCountryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderCouponCountryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderCouponCountryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderCouponModuleTableMap.php b/core/lib/Thelia/Model/Map/OrderCouponModuleTableMap.php
new file mode 100644
index 000000000..86a6343db
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderCouponModuleTableMap.php
@@ -0,0 +1,468 @@
+ array('CouponId', 'ModuleId', ),
+ self::TYPE_STUDLYPHPNAME => array('couponId', 'moduleId', ),
+ self::TYPE_COLNAME => array(OrderCouponModuleTableMap::COUPON_ID, OrderCouponModuleTableMap::MODULE_ID, ),
+ self::TYPE_RAW_COLNAME => array('COUPON_ID', 'MODULE_ID', ),
+ self::TYPE_FIELDNAME => array('coupon_id', 'module_id', ),
+ self::TYPE_NUM => array(0, 1, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('CouponId' => 0, 'ModuleId' => 1, ),
+ self::TYPE_STUDLYPHPNAME => array('couponId' => 0, 'moduleId' => 1, ),
+ self::TYPE_COLNAME => array(OrderCouponModuleTableMap::COUPON_ID => 0, OrderCouponModuleTableMap::MODULE_ID => 1, ),
+ self::TYPE_RAW_COLNAME => array('COUPON_ID' => 0, 'MODULE_ID' => 1, ),
+ self::TYPE_FIELDNAME => array('coupon_id' => 0, 'module_id' => 1, ),
+ self::TYPE_NUM => array(0, 1, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_coupon_module');
+ $this->setPhpName('OrderCouponModule');
+ $this->setClassName('\\Thelia\\Model\\OrderCouponModule');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addForeignPrimaryKey('COUPON_ID', 'CouponId', 'INTEGER' , 'order_coupon', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('MODULE_ID', 'ModuleId', 'INTEGER' , 'module', 'ID', true, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('OrderCoupon', '\\Thelia\\Model\\OrderCoupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\OrderCouponModule $obj A \Thelia\Model\OrderCouponModule object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getCouponId(), (string) $obj->getModuleId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\OrderCouponModule object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\OrderCouponModule) {
+ $key = serialize(array((string) $value->getCouponId(), (string) $value->getModuleId()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\OrderCouponModule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderCouponModuleTableMap::CLASS_DEFAULT : OrderCouponModuleTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderCouponModule object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderCouponModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderCouponModuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderCouponModuleTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderCouponModuleTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderCouponModuleTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderCouponModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderCouponModuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderCouponModuleTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderCouponModuleTableMap::COUPON_ID);
+ $criteria->addSelectColumn(OrderCouponModuleTableMap::MODULE_ID);
+ } else {
+ $criteria->addSelectColumn($alias . '.COUPON_ID');
+ $criteria->addSelectColumn($alias . '.MODULE_ID');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getServiceContainer()->getDatabaseMap(OrderCouponModuleTableMap::DATABASE_NAME)->getTable(OrderCouponModuleTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderCouponModuleTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderCouponModuleTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderCouponModuleTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderCouponModule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderCouponModule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponModuleTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\OrderCouponModule) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderCouponModuleTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(OrderCouponModuleTableMap::COUPON_ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(OrderCouponModuleTableMap::MODULE_ID, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = OrderCouponModuleQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderCouponModuleTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderCouponModuleTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_coupon_module table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderCouponModuleQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderCouponModule or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderCouponModule object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponModuleTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderCouponModule object
+ }
+
+
+ // Set the correct dbName
+ $query = OrderCouponModuleQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderCouponModuleTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderCouponModuleTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderCouponTableMap.php b/core/lib/Thelia/Model/Map/OrderCouponTableMap.php
index 7f795ea57..3957534b3 100644
--- a/core/lib/Thelia/Model/Map/OrderCouponTableMap.php
+++ b/core/lib/Thelia/Model/Map/OrderCouponTableMap.php
@@ -219,6 +219,10 @@ class OrderCouponTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('OrderCouponCountry', '\\Thelia\\Model\\OrderCouponCountry', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), null, null, 'OrderCouponCountries');
+ $this->addRelation('OrderCouponModule', '\\Thelia\\Model\\OrderCouponModule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', null, 'OrderCouponModules');
+ $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_MANY, array(), 'CASCADE', null, 'Countries');
+ $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_MANY, array(), 'CASCADE', null, 'Modules');
} // buildRelations()
/**
@@ -233,6 +237,15 @@ class OrderCouponTableMap extends TableMap
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to order_coupon * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderCouponModuleTableMap::clearInstancePool();
+ }
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
diff --git a/core/lib/Thelia/Model/OrderCoupon.php b/core/lib/Thelia/Model/OrderCoupon.php
index 558496813..ebee15c94 100644
--- a/core/lib/Thelia/Model/OrderCoupon.php
+++ b/core/lib/Thelia/Model/OrderCoupon.php
@@ -3,8 +3,25 @@
namespace Thelia\Model;
use Thelia\Model\Base\OrderCoupon as BaseOrderCoupon;
+use Thelia\Model\Base\OrderCouponCountryQuery;
class OrderCoupon extends BaseOrderCoupon
{
+ /**
+ * Return the countries for which free shipping is valid
+ * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
+ */
+ public function getFreeShippingForCountries() {
+ return OrderCouponCountryQuery::create()->filterByOrderCoupon($this)->find();
+ }
+
+ /**
+ * Return the modules for which free shipping is valid
+ *
+ * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
+ */
+ public function getFreeShippingForModules() {
+ return OrderCouponModuleQuery::create()->filterByOrderCoupon($this)->find();
+ }
}
diff --git a/core/lib/Thelia/Model/OrderCouponCountry.php b/core/lib/Thelia/Model/OrderCouponCountry.php
new file mode 100644
index 000000000..8a3f26417
--- /dev/null
+++ b/core/lib/Thelia/Model/OrderCouponCountry.php
@@ -0,0 +1,10 @@
+
+