Free shipping restricitions based on Countries and Shipping module

This commit is contained in:
Franck Allimant
2014-05-16 10:30:15 +02:00
parent ffd842cbf6
commit 90947bcda9
24 changed files with 7358 additions and 25 deletions

View File

@@ -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),

View File

@@ -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 */

View File

@@ -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;
}

View File

@@ -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
*

View File

@@ -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;
}
/**

View File

@@ -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
*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,568 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\OrderCouponCountry as ChildOrderCouponCountry;
use Thelia\Model\OrderCouponCountryQuery as ChildOrderCouponCountryQuery;
use Thelia\Model\Map\OrderCouponCountryTableMap;
/**
* Base class that represents a query for the 'order_coupon_country' table.
*
*
*
* @method ChildOrderCouponCountryQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
* @method ChildOrderCouponCountryQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column
*
* @method ChildOrderCouponCountryQuery groupByCouponId() Group by the coupon_id column
* @method ChildOrderCouponCountryQuery groupByCountryId() Group by the country_id column
*
* @method ChildOrderCouponCountryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildOrderCouponCountryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildOrderCouponCountryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildOrderCouponCountryQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
* @method ChildOrderCouponCountryQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
* @method ChildOrderCouponCountryQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
*
* @method ChildOrderCouponCountryQuery leftJoinOrderCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCoupon relation
* @method ChildOrderCouponCountryQuery rightJoinOrderCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCoupon relation
* @method ChildOrderCouponCountryQuery innerJoinOrderCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCoupon relation
*
* @method ChildOrderCouponCountry findOne(ConnectionInterface $con = null) Return the first ChildOrderCouponCountry matching the query
* @method ChildOrderCouponCountry findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderCouponCountry matching the query, or a new ChildOrderCouponCountry object populated from the query conditions when no match is found
*
* @method ChildOrderCouponCountry findOneByCouponId(int $coupon_id) Return the first ChildOrderCouponCountry filtered by the coupon_id column
* @method ChildOrderCouponCountry findOneByCountryId(int $country_id) Return the first ChildOrderCouponCountry filtered by the country_id column
*
* @method array findByCouponId(int $coupon_id) Return ChildOrderCouponCountry objects filtered by the coupon_id column
* @method array findByCountryId(int $country_id) Return ChildOrderCouponCountry objects filtered by the country_id column
*
*/
abstract class OrderCouponCountryQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\OrderCouponCountryQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\OrderCouponCountry', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildOrderCouponCountryQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildOrderCouponCountryQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\OrderCouponCountryQuery) {
return $criteria;
}
$query = new \Thelia\Model\OrderCouponCountryQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$coupon_id, $country_id] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return 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
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return 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:
* <code>
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
* </code>
*
* @see 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:
* <code>
* $query->filterByCountryId(1234); // WHERE country_id = 1234
* $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
* </code>
*
* @see filterByCountry()
*
* @param mixed $countryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return 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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,568 @@
<?php
namespace Thelia\Model\Base;
use \Exception;
use \PDO;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\OrderCouponModule as ChildOrderCouponModule;
use Thelia\Model\OrderCouponModuleQuery as ChildOrderCouponModuleQuery;
use Thelia\Model\Map\OrderCouponModuleTableMap;
/**
* Base class that represents a query for the 'order_coupon_module' table.
*
*
*
* @method ChildOrderCouponModuleQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
* @method ChildOrderCouponModuleQuery orderByModuleId($order = Criteria::ASC) Order by the module_id column
*
* @method ChildOrderCouponModuleQuery groupByCouponId() Group by the coupon_id column
* @method ChildOrderCouponModuleQuery groupByModuleId() Group by the module_id column
*
* @method ChildOrderCouponModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildOrderCouponModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildOrderCouponModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildOrderCouponModuleQuery leftJoinOrderCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCoupon relation
* @method ChildOrderCouponModuleQuery rightJoinOrderCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCoupon relation
* @method ChildOrderCouponModuleQuery innerJoinOrderCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCoupon relation
*
* @method ChildOrderCouponModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation
* @method ChildOrderCouponModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation
* @method ChildOrderCouponModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation
*
* @method ChildOrderCouponModule findOne(ConnectionInterface $con = null) Return the first ChildOrderCouponModule matching the query
* @method ChildOrderCouponModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderCouponModule matching the query, or a new ChildOrderCouponModule object populated from the query conditions when no match is found
*
* @method ChildOrderCouponModule findOneByCouponId(int $coupon_id) Return the first ChildOrderCouponModule filtered by the coupon_id column
* @method ChildOrderCouponModule findOneByModuleId(int $module_id) Return the first ChildOrderCouponModule filtered by the module_id column
*
* @method array findByCouponId(int $coupon_id) Return ChildOrderCouponModule objects filtered by the coupon_id column
* @method array findByModuleId(int $module_id) Return ChildOrderCouponModule objects filtered by the module_id column
*
*/
abstract class OrderCouponModuleQuery extends ModelCriteria
{
/**
* Initializes internal state of \Thelia\Model\Base\OrderCouponModuleQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\OrderCouponModule', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildOrderCouponModuleQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildOrderCouponModuleQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \Thelia\Model\OrderCouponModuleQuery) {
return $criteria;
}
$query = new \Thelia\Model\OrderCouponModuleQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$coupon_id, $module_id] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return 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
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return 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:
* <code>
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
* </code>
*
* @see 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:
* <code>
* $query->filterByModuleId(1234); // WHERE module_id = 1234
* $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34)
* $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
* </code>
*
* @see filterByModule()
*
* @param mixed $moduleId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return 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

View File

@@ -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
*

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -0,0 +1,468 @@
<?php
namespace Thelia\Model\Map;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
use Thelia\Model\OrderCouponCountry;
use Thelia\Model\OrderCouponCountryQuery;
/**
* This class defines the structure of the 'order_coupon_country' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class OrderCouponCountryTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'Thelia.Model.Map.OrderCouponCountryTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'order_coupon_country';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\Thelia\\Model\\OrderCouponCountry';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'Thelia.Model.OrderCouponCountry';
/**
* The total number of columns
*/
const NUM_COLUMNS = 2;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 2;
/**
* the column name for the COUPON_ID field
*/
const COUPON_ID = 'order_coupon_country.COUPON_ID';
/**
* the column name for the COUNTRY_ID field
*/
const COUNTRY_ID = 'order_coupon_country.COUNTRY_ID';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => 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();

View File

@@ -0,0 +1,468 @@
<?php
namespace Thelia\Model\Map;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
use Thelia\Model\OrderCouponModule;
use Thelia\Model\OrderCouponModuleQuery;
/**
* This class defines the structure of the 'order_coupon_module' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class OrderCouponModuleTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'Thelia.Model.Map.OrderCouponModuleTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'order_coupon_module';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\Thelia\\Model\\OrderCouponModule';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'Thelia.Model.OrderCouponModule';
/**
* The total number of columns
*/
const NUM_COLUMNS = 2;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 2;
/**
* the column name for the COUPON_ID field
*/
const COUPON_ID = 'order_coupon_module.COUPON_ID';
/**
* the column name for the MODULE_ID field
*/
const MODULE_ID = 'order_coupon_module.MODULE_ID';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => 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();

View File

@@ -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.

View File

@@ -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();
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\OrderCouponCountry as BaseOrderCouponCountry;
class OrderCouponCountry extends BaseOrderCouponCountry
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\OrderCouponCountryQuery as BaseOrderCouponCountryQuery;
/**
* Skeleton subclass for performing query and update operations on the 'order_coupon_country' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class OrderCouponCountryQuery extends BaseOrderCouponCountryQuery
{
} // OrderCouponCountryQuery

View File

@@ -0,0 +1,10 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\OrderCouponModule as BaseOrderCouponModule;
class OrderCouponModule extends BaseOrderCouponModule
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\OrderCouponModuleQuery as BaseOrderCouponModuleQuery;
/**
* Skeleton subclass for performing query and update operations on the 'order_coupon_module' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class OrderCouponModuleQuery extends BaseOrderCouponModuleQuery
{
} // OrderCouponModuleQuery

View File

@@ -1369,4 +1369,30 @@
<index name="fk_module_id_idx">
<index-column name="module_id" />
</index>
</table>
<table isCrossRef="true" name="order_coupon_country" namespace="Thelia\Model">
<column name="coupon_id" primaryKey="true" required="true" type="INTEGER" />
<column name="country_id" primaryKey="true" required="true" type="INTEGER" />
<foreign-key foreignTable="country" name="fk_order_coupon_country_country_id" onDelete="CASCADE">
<reference foreign="id" local="country_id" />
</foreign-key>
<foreign-key foreignTable="order_coupon" name="fk_order_coupon_country_coupon_id">
<reference foreign="id" local="coupon_id" />
</foreign-key>
<index name="fk_country_id_idx">
<index-column name="country_id" />
</index>
</table>
<table isCrossRef="true" name="order_coupon_module" namespace="Thelia\Model">
<column name="coupon_id" primaryKey="true" required="true" type="INTEGER" />
<column name="module_id" primaryKey="true" required="true" type="INTEGER" />
<foreign-key foreignTable="order_coupon" name="fk_coupon_module_coupon_id0" onDelete="CASCADE">
<reference foreign="id" local="coupon_id" />
</foreign-key>
<foreign-key foreignTable="module" name="fk_coupon_module_module_id0" onDelete="CASCADE">
<reference foreign="id" local="module_id" />
</foreign-key>
<index name="fk_module_id_idx">
<index-column name="module_id" />
</index>
</table>

View File

@@ -1690,6 +1690,49 @@ CREATE TABLE `coupon_module`
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- order_coupon_country
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `order_coupon_country`;
CREATE TABLE `order_coupon_country`
(
`coupon_id` INTEGER NOT NULL,
`country_id` INTEGER NOT NULL,
PRIMARY KEY (`coupon_id`,`country_id`),
INDEX `fk_country_id_idx` (`country_id`),
CONSTRAINT `fk_order_coupon_country_country_id`
FOREIGN KEY (`country_id`)
REFERENCES `country` (`id`)
ON DELETE CASCADE,
CONSTRAINT `fk_order_coupon_country_coupon_id`
FOREIGN KEY (`coupon_id`)
REFERENCES `order_coupon` (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- order_coupon_module
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `order_coupon_module`;
CREATE TABLE `order_coupon_module`
(
`coupon_id` INTEGER NOT NULL,
`module_id` INTEGER NOT NULL,
PRIMARY KEY (`coupon_id`,`module_id`),
INDEX `fk_module_id_idx` (`module_id`),
CONSTRAINT `fk_coupon_module_coupon_id0`
FOREIGN KEY (`coupon_id`)
REFERENCES `order_coupon` (`id`)
ON DELETE CASCADE,
CONSTRAINT `fk_coupon_module_module_id0`
FOREIGN KEY (`module_id`)
REFERENCES `module` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- category_i18n
-- ---------------------------------------------------------------------