15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,11 +1,12 @@
|
||||
#2.0.2
|
||||
- New coupon conditions :
|
||||
- Start date
|
||||
- Billing country
|
||||
- Shipping country
|
||||
- Cart contains product
|
||||
- Cart contains product from category
|
||||
- For specific customers
|
||||
- New coupon conditions :
|
||||
- Start date
|
||||
- Billing country
|
||||
- Shipping country
|
||||
- Cart contains product
|
||||
- Cart contains product from category
|
||||
- For specific customers
|
||||
- Free shipping can now be restricted to some countries and/or shipping methods
|
||||
|
||||
|
||||
#2.0.1
|
||||
|
||||
@@ -17,11 +17,11 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Cart\CartEvent;
|
||||
use Thelia\Core\Event\Currency\CurrencyChangeEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Model\CartItem;
|
||||
use Thelia\Model\CartItemQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Model\Tools\ProductPriceTools;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,17 +24,23 @@ 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\Coupon as CouponModel;
|
||||
use Thelia\Model\CouponCountry;
|
||||
use Thelia\Model\CouponCountryQuery;
|
||||
use Thelia\Model\CouponModule;
|
||||
use Thelia\Model\CouponModuleQuery;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Model\Map\OrderCouponTableMap;
|
||||
use Thelia\Model\OrderCoupon;
|
||||
use Thelia\Model\OrderCouponCountry;
|
||||
use Thelia\Model\OrderCouponModule;
|
||||
|
||||
/**
|
||||
* Process Coupon Events
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>, Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
@@ -115,7 +123,9 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$coupon = $this->couponFactory->buildCouponFromCode($event->getCode());
|
||||
|
||||
if ($coupon) {
|
||||
|
||||
$isValid = $coupon->isMatching();
|
||||
|
||||
if ($isValid) {
|
||||
$consumedCoupons = $this->request->getSession()->getConsumedCoupons();
|
||||
|
||||
@@ -124,6 +134,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
if (!isset($consumedCoupons[$event->getCode()])) {
|
||||
|
||||
// Prevent accumulation of the same Coupon on a Checkout
|
||||
$consumedCoupons[$event->getCode()] = $event->getCode();
|
||||
|
||||
@@ -140,7 +151,6 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
->getSession()
|
||||
->getOrder()
|
||||
->setDiscount($totalDiscount)
|
||||
// ->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -150,9 +160,8 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->setDiscount($totalDiscount);
|
||||
}
|
||||
|
||||
public function updateOrderDiscount($event)
|
||||
public function updateOrderDiscount(/** @noinspection PhpUnusedParameterInspection */ $event)
|
||||
{
|
||||
|
||||
$discount = $this->couponManager->getDiscount();
|
||||
|
||||
$this->request
|
||||
@@ -160,6 +169,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
->getCart()
|
||||
->setDiscount($discount)
|
||||
->save();
|
||||
|
||||
$this->request
|
||||
->getSession()
|
||||
->getOrder()
|
||||
@@ -202,7 +212,10 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->isCumulative(),
|
||||
$event->getMaxUsage(),
|
||||
$defaultSerializedRule,
|
||||
$event->getLocale()
|
||||
$event->getLocale(),
|
||||
$event->getFreeShippingForCountries(),
|
||||
$event->getFreeShippingForMethods(),
|
||||
$event->getPerCustomerUsageCount()
|
||||
);
|
||||
|
||||
$event->setCouponModel($coupon);
|
||||
@@ -235,8 +248,9 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function testFreePostage(OrderEvent $event)
|
||||
{
|
||||
if ($this->couponManager->isCouponRemovingPostage()) {
|
||||
$order = $event->getOrder();
|
||||
$order = $event->getOrder();
|
||||
|
||||
if ($this->couponManager->isCouponRemovingPostage($order)) {
|
||||
|
||||
$order->setPostage(0);
|
||||
|
||||
@@ -248,38 +262,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, $event->getOrder()->getCustomerId());
|
||||
|
||||
->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())
|
||||
->setPerCustomerUsageCount($couponModel->getPerCustomerUsageCount())
|
||||
;
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +369,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),
|
||||
|
||||
@@ -161,7 +161,7 @@ class Module extends BaseAction implements EventSubscriberInterface
|
||||
);
|
||||
}
|
||||
|
||||
$paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
||||
$paymentModuleInstance = $paymentModule->getModuleInstance($this->container);
|
||||
|
||||
$response = $paymentModuleInstance->pay($order);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->chosenDeliveryAddress = $event->getDeliveryAddress();
|
||||
$order->setChoosenDeliveryAddress($event->getDeliveryAddress());
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->chosenInvoiceAddress = $event->getInvoiceAddress();
|
||||
$order->setChoosenInvoiceAddress($event->getInvoiceAddress());
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
@@ -153,9 +153,9 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
$placedOrder = $sessionOrder->copy();
|
||||
$placedOrder->setDispatcher($dispatcher);
|
||||
|
||||
$deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress);
|
||||
$deliveryAddress = AddressQuery::create()->findPk($sessionOrder->getChoosenDeliveryAddress());
|
||||
$taxCountry = $deliveryAddress->getCountry();
|
||||
$invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress);
|
||||
$invoiceAddress = AddressQuery::create()->findPk($sessionOrder->getChoosenInvoiceAddress());
|
||||
$cartItems = $cart->getCartItems();
|
||||
|
||||
/* fulfill order */
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace Thelia\Condition\Implementation;
|
||||
use Thelia\Condition\Operators;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Exception\InvalidConditionValueException;
|
||||
use Thelia\Model\Base\CountryQuery;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\CountryQuery;
|
||||
|
||||
/**
|
||||
* Check a Checkout against its Product number
|
||||
@@ -44,9 +45,9 @@ abstract class AbstractMatchCountries extends ConditionAbstract
|
||||
parent::__construct($facade);
|
||||
}
|
||||
|
||||
protected abstract function getSummaryLabel($cntryStrList, $i18nOperator);
|
||||
abstract protected function getSummaryLabel($cntryStrList, $i18nOperator);
|
||||
|
||||
protected abstract function getFormLabel();
|
||||
abstract protected function getFormLabel();
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@@ -87,6 +88,7 @@ abstract class AbstractMatchCountries extends ConditionAbstract
|
||||
// The delivery address should match one of the selected countries.
|
||||
|
||||
/* TODO !!!! */
|
||||
|
||||
return $this->conditionValidator->variableOpComparison(
|
||||
$this->facade->getNbArticlesInCart(),
|
||||
$this->operators[self::COUNTRIES_LIST],
|
||||
@@ -109,8 +111,8 @@ abstract class AbstractMatchCountries extends ConditionAbstract
|
||||
|
||||
if (null !== $cntryList = CountryQuery::create()->findPks($cntryIds)) {
|
||||
|
||||
/** @var Category $cntry */
|
||||
foreach($cntryList as $cntry) {
|
||||
/** @var Country $cntry */
|
||||
foreach ($cntryList as $cntry) {
|
||||
$cntryStrList .= $cntry->getTitle() . ', ';
|
||||
}
|
||||
|
||||
@@ -147,4 +149,4 @@ abstract class AbstractMatchCountries extends ConditionAbstract
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ class CartContainsCategories extends ConditionAbstract
|
||||
$cartItems = $this->facade->getCart()->getCartItems();
|
||||
|
||||
/** @var CartItem $cartItem */
|
||||
foreach($cartItems as $cartItem) {
|
||||
foreach ($cartItems as $cartItem) {
|
||||
|
||||
$categories = $cartItem->getProduct()->getCategories();
|
||||
|
||||
/** @var Category $category */
|
||||
foreach($categories as $category) {
|
||||
foreach ($categories as $category) {
|
||||
$catecoryInCart = $this->conditionValidator->variableOpComparison(
|
||||
$category->getId(),
|
||||
$this->operators[self::CATEGORIES_LIST],
|
||||
@@ -156,7 +156,7 @@ class CartContainsCategories extends ConditionAbstract
|
||||
if (null !== $catList = CategoryQuery::create()->findPks($catIds)) {
|
||||
|
||||
/** @var Category $cat */
|
||||
foreach($catList as $cat) {
|
||||
foreach ($catList as $cat) {
|
||||
$catStrList .= $cat->getTitle() . ', ';
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Thelia\Condition\Implementation;
|
||||
use Thelia\Condition\Operators;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Exception\InvalidConditionValueException;
|
||||
use Thelia\Model\Base\ProductQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\CartItem;
|
||||
use Thelia\Model\Product;
|
||||
|
||||
@@ -93,13 +93,12 @@ class CartContainsProducts extends ConditionAbstract
|
||||
$cartItems = $this->facade->getCart()->getCartItems();
|
||||
|
||||
/** @var CartItem $cartItem */
|
||||
foreach($cartItems as $cartItem) {
|
||||
foreach ($cartItems as $cartItem) {
|
||||
|
||||
if ($this->conditionValidator->variableOpComparison(
|
||||
$cartItem->getProduct()->getId(),
|
||||
$this->operators[self::PRODUCTS_LIST],
|
||||
$this->values[self::PRODUCTS_LIST])) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +148,7 @@ class CartContainsProducts extends ConditionAbstract
|
||||
if (null !== $prodList = ProductQuery::create()->findPks($prodIds)) {
|
||||
|
||||
/** @var Product $prod */
|
||||
foreach($prodList as $prod) {
|
||||
foreach ($prodList as $prod) {
|
||||
$prodStrList .= $prod->getTitle() . ', ';
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Exception\InvalidConditionOperatorException;
|
||||
use Thelia\Exception\InvalidConditionValueException;
|
||||
use Thelia\Model\Base\CurrencyQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\Currency;
|
||||
use Thelia\Type\FloatType;
|
||||
|
||||
@@ -66,15 +66,15 @@ abstract class ConditionAbstract implements ConditionInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $operatorList the list of comparison operator values, as entered in the condition parameter form
|
||||
* @param array $operatorList the list of comparison operator values, as entered in the condition parameter form
|
||||
* @param string $parameterName the name of the parameter to check
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Thelia\Exception\InvalidConditionOperatorException if the operator value is not in the allowed value
|
||||
*/
|
||||
protected function checkComparisonOperatorValue($operatorList, $parameterName) {
|
||||
|
||||
protected function checkComparisonOperatorValue($operatorList, $parameterName)
|
||||
{
|
||||
$isOperator1Legit = $this->isOperatorLegit(
|
||||
$operatorList[$parameterName],
|
||||
$this->availableOperators[$parameterName]
|
||||
|
||||
@@ -139,7 +139,7 @@ class ForSomeCustomers extends ConditionAbstract
|
||||
if (null !== $custList = CustomerQuery::create()->findPks($custIds)) {
|
||||
|
||||
/** @var Customer $cust */
|
||||
foreach($custList as $cust) {
|
||||
foreach ($custList as $cust) {
|
||||
$custStrList .= $cust->getLastname() . ' ' . $cust->getFirstname() . ' ('.$cust->getRef().'), ';
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@ class MatchBillingCountries extends AbstractMatchCountries
|
||||
return $toolTip;
|
||||
}
|
||||
|
||||
protected function getSummaryLabel($cntryStrList, $i18nOperator) {
|
||||
|
||||
protected function getSummaryLabel($cntryStrList, $i18nOperator)
|
||||
{
|
||||
return $this->translator->trans(
|
||||
'Only if order billing country is %op% <strong>%countries_list%</strong>', [
|
||||
'%countries_list%' => $cntryStrList,
|
||||
@@ -79,7 +79,8 @@ class MatchBillingCountries extends AbstractMatchCountries
|
||||
);
|
||||
}
|
||||
|
||||
protected function getFormLabel() {
|
||||
protected function getFormLabel()
|
||||
{
|
||||
return $this->translator->trans(
|
||||
'Billing coutry is', [], 'condition'
|
||||
);
|
||||
|
||||
@@ -69,8 +69,8 @@ class MatchDeliveryCountries extends AbstractMatchCountries
|
||||
return $toolTip;
|
||||
}
|
||||
|
||||
protected function getSummaryLabel($cntryStrList, $i18nOperator) {
|
||||
|
||||
protected function getSummaryLabel($cntryStrList, $i18nOperator)
|
||||
{
|
||||
return $this->translator->trans(
|
||||
'Only if order shipping country is %op% <strong>%countries_list%</strong>', [
|
||||
'%countries_list%' => $cntryStrList,
|
||||
@@ -79,7 +79,8 @@ class MatchDeliveryCountries extends AbstractMatchCountries
|
||||
);
|
||||
}
|
||||
|
||||
protected function getFormLabel() {
|
||||
protected function getFormLabel()
|
||||
{
|
||||
return $this->translator->trans(
|
||||
'Delivery coutry is', [], 'condition'
|
||||
);
|
||||
|
||||
@@ -26,8 +26,8 @@ class MatchForEveryone extends ConditionAbstract
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function __construct(FacadeInterface $facade) {
|
||||
|
||||
public function __construct(FacadeInterface $facade)
|
||||
{
|
||||
// Define the allowed comparison operators
|
||||
$this->availableOperators = [];
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace Thelia\Condition\Implementation;
|
||||
|
||||
use Thelia\Condition\Operators;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Exception\InvalidConditionOperatorException;
|
||||
use Thelia\Exception\InvalidConditionValueException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,11 +14,7 @@ namespace Thelia\Condition\Implementation;
|
||||
|
||||
use Thelia\Condition\Operators;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Exception\InvalidConditionOperatorException;
|
||||
use Thelia\Exception\InvalidConditionValueException;
|
||||
use Thelia\Model\Category;
|
||||
use Thelia\Model\CategoryImageQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Tools\DateTimeFormat;
|
||||
|
||||
/**
|
||||
@@ -76,8 +72,7 @@ class StartDate extends ConditionAbstract
|
||||
}
|
||||
|
||||
$timestamp = $date->getTimestamp();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$timestamp = $values[self::START_DATE];
|
||||
}
|
||||
|
||||
@@ -147,7 +142,8 @@ class StartDate extends ConditionAbstract
|
||||
return $toolTip;
|
||||
}
|
||||
|
||||
private function getDateFormat() {
|
||||
private function getDateFormat()
|
||||
{
|
||||
return DateTimeFormat::getInstance($this->facade->getRequest())->getFormat("date");
|
||||
}
|
||||
|
||||
@@ -177,8 +173,7 @@ class StartDate extends ConditionAbstract
|
||||
$date->setTimestamp($this->values[self::START_DATE]);
|
||||
|
||||
$strDate = $date->format($this->getDateFormat());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$strDate = '';
|
||||
}
|
||||
|
||||
@@ -189,4 +184,4 @@ class StartDate extends ConditionAbstract
|
||||
'currentValue' => $strDate
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,24 +25,30 @@ return array(
|
||||
'Administrator ID not found' => 'Administrator ID not found',
|
||||
'Advertise this product as new' => 'Advertise this product as new',
|
||||
'Alerts' => 'Alerts',
|
||||
'All countries' => 'All countries',
|
||||
'All shipping methods' => 'All shipping methods',
|
||||
'Alpha code 2 *' => 'Alpha code 2 *',
|
||||
'Alpha code 3 *' => 'Alpha code 3 *',
|
||||
'Apply exchange rates on price in %sym' => 'Apply exchange rates on price in %sym',
|
||||
'At least one of cart products categories is %op% <strong>%categories_list%</strong>' => 'At least one of cart products categories is %op% <strong>%categories_list%</strong>',
|
||||
'Attribute ID:Attribute AV ID' => 'Attribute ID:Attribute AV ID',
|
||||
'Auth mode' => 'Auth mode',
|
||||
'Available quantity' => 'Available quantity',
|
||||
'Available quantity *' => 'Available quantity *',
|
||||
'Available shipping zones' => 'Available shipping zones',
|
||||
'Bad tax list JSON' => 'Bad tax list JSON',
|
||||
'Billing country condition' => 'Pays de facturation',
|
||||
'Billing country' => 'Billing country',
|
||||
'Billing coutry is' => 'Le pays de facturation est',
|
||||
'Business ID' => 'Business ID',
|
||||
'By cart total amount' => 'By cart total amount',
|
||||
'Cannot find a default country. Please define one.' => 'Cannot find a default country. Please define one.',
|
||||
'Cannot find the shop country. Please select a shop country.' => 'Cannot find the shop country. Please select a shop country.',
|
||||
'Cannot instanciante module "%name%": the namespace is null. Maybe the model is not loaded ?' => 'Cannot instanciante module "%name%": the namespace is null. Maybe the model is not loaded ?',
|
||||
'Cart item count condition' => 'Cart item count condition',
|
||||
'Cart contains at least a product %op% <strong>%products_list%</strong>' => 'Cart contains at least a product %op% <strong>%products_list%</strong>',
|
||||
'Cart contains categories condition' => 'Cart contains categories condition',
|
||||
'Cart contains specific products' => 'Cart contains specific products',
|
||||
'Cart item count' => 'Cart item count',
|
||||
'Cart item count is' => 'Cart item count is',
|
||||
'Cart total amount' => 'Cart total amount',
|
||||
'Cart total amount is' => 'Cart total amount is',
|
||||
'Category title *' => 'Category title *',
|
||||
'Cellphone' => 'Cellphone',
|
||||
@@ -61,16 +67,19 @@ return array(
|
||||
'Country ID not found' => 'Country ID not found',
|
||||
'Country area' => 'Country area',
|
||||
'Country title *' => 'Country title *',
|
||||
'Coupon %code is expired.' => 'Coupon %code is expired.',
|
||||
'Critical' => 'Critical',
|
||||
'Current Password' => 'Current Password',
|
||||
'Customer is %op% <strong>%customer_list%</strong>' => 'Customer is %op% <strong>%customer_list%</strong>',
|
||||
'Date \'%date\' is invalid, please enter a valid date using %fmt format' => 'Date \'%date\' is invalid, please enter a valid date using %fmt format',
|
||||
'Debug' => 'Debug',
|
||||
'Decimal places' => 'Decimal places',
|
||||
'Default folder *' => 'Default folder *',
|
||||
'Default product category *' => 'Default product category *',
|
||||
'Default product sale element' => 'Default product sale element',
|
||||
'Deleting document for %id% with parent id %parentId%' => 'Deleting document for %id% with parent id %parentId%',
|
||||
'Deleting image for %id% with parent id %parentId%' => 'Deleting image for %id% with parent id %parentId%',
|
||||
'Delivery country condition' => 'Pays de livraison',
|
||||
'Delivery country' => 'Delivery country',
|
||||
'Delivery coutry is' => 'Le pays de livraison est',
|
||||
'Delivery module ID not found' => 'Delivery module ID not found',
|
||||
'Description' => 'Description',
|
||||
@@ -103,7 +112,9 @@ return array(
|
||||
'First Name' => 'First Name',
|
||||
'Firstname' => 'Firstname',
|
||||
'Fixed Amount Discount' => 'Fixed Amount Discount',
|
||||
'Fixed amount discount on selected categories' => 'Fixed amount discount on selected categories',
|
||||
'Folder title *' => 'Folder title *',
|
||||
'For one ore more customers' => 'For one ore more customers',
|
||||
'Full Name' => 'Full Name',
|
||||
'Greater than' => 'Greater than',
|
||||
'Greater than or equals' => 'Greater than or equals',
|
||||
@@ -140,6 +151,7 @@ return array(
|
||||
'Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`' => 'Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`',
|
||||
'Loop type \'%type\' is not defined.' => 'Loop type \'%type\' is not defined.',
|
||||
'Make this address as my primary address' => 'Make this address as my primary address',
|
||||
'Maximum usage count reached for coupon %code' => 'Maximum usage count reached for coupon %code',
|
||||
'Message subject' => 'Message subject',
|
||||
'Meta Description' => 'Meta Description',
|
||||
'Meta Keywords' => 'Meta Keywords',
|
||||
@@ -170,12 +182,14 @@ return array(
|
||||
'Order address ID not found' => 'Order address ID not found',
|
||||
'Order ref. %ref is now unpaid.' => 'Order ref. %ref is now unpaid.',
|
||||
'Order ref. %ref, ID %id has been successfully paid.' => 'Order ref. %ref, ID %id has been successfully paid.',
|
||||
'Overall' => 'Overall',
|
||||
'Page Title' => 'Page Title',
|
||||
'Parent category *' => 'Parent category *',
|
||||
'Parent folder *' => 'Parent folder *',
|
||||
'Password' => 'Password',
|
||||
'Password *' => 'Password *',
|
||||
'Password confirmation' => 'Password confirmation',
|
||||
'Per customer' => 'Per customer',
|
||||
'Percent Discount' => 'Percent Discount',
|
||||
'Percentage of the product price' => 'Percentage of the product price',
|
||||
'Phone' => 'Phone',
|
||||
@@ -260,6 +274,9 @@ return array(
|
||||
'Text Message' => 'Text Message',
|
||||
'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.',
|
||||
'The cart item count should match the condition' => 'The cart item count should match the condition',
|
||||
'The coupon applies if the cart contains at least one product of the selected categories' => 'The coupon applies if the cart contains at least one product of the selected categories',
|
||||
'The coupon applies if the cart contains at least one product of the specified product list' => 'The coupon applies if the cart contains at least one product of the specified product list',
|
||||
'The coupon applies to some customers only' => 'The coupon applies to some customers only',
|
||||
'The coupon applies to the selected delivery countries' => 'Ce code promo s\'applique seulement aux pays de facturation sélectionnés',
|
||||
'The coupon is valid after a given date' => 'Le code promo est valide seulement à partir d\'une certaine date',
|
||||
'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.' => 'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.',
|
||||
@@ -268,6 +285,7 @@ return array(
|
||||
'This condition is always true' => 'This condition is always true',
|
||||
'This content is online.' => 'This content is online.',
|
||||
'This coupon does not exists' => 'This coupon does not exists',
|
||||
'This coupon subtracts the specified amount from the order total for each product of the selected categories. If the discount is greater than the total order, the customer will only pay the shipping, or nothing if the coupon also provides free shipping.' => 'This coupon subtracts the specified amount from the order total for each product of the selected categories. If the discount is greater than the total order, the customer will only pay the shipping, or nothing if the coupon also provides free shipping.',
|
||||
'This coupon will offert a flat percentage off a shopper\'s entire order (not applied to shipping costs or tax rates). If the discount is greater than the total order corst, the customer will only pay the shipping, or nothing if the coupon also provides free shipping.' => 'This coupon will offert a flat percentage off a shopper\'s entire order (not applied to shipping costs or tax rates). If the discount is greater than the total order corst, the customer will only pay the shipping, or nothing if the coupon also provides free shipping.',
|
||||
'This coupon will subtracts a set amount from the total cost of an order. If the discount is greater than the total order corst, the customer will only pay the shipping, or nothing if the coupon also provides free shipping.' => 'This coupon will subtracts a set amount from the total cost of an order. If the discount is greater than the total order corst, the customer will only pay the shipping, or nothing if the coupon also provides free shipping.',
|
||||
'This email already exists.' => 'This email already exists.',
|
||||
|
||||
@@ -25,22 +25,30 @@ return array(
|
||||
'Administrator ID not found' => 'ID de l\'administrateur not trouvé',
|
||||
'Advertise this product as new' => 'Afficher ce produit comme nouveau',
|
||||
'Alerts' => 'Alertes',
|
||||
'All countries' => 'Tous les pays',
|
||||
'All shipping methods' => 'Tous les modes de livraison',
|
||||
'Alpha code 2 *' => 'Code Alpha 2 *',
|
||||
'Alpha code 3 *' => 'Code Alpha 3 *',
|
||||
'Apply exchange rates on price in %sym' => 'Appliquer le taux de change sur le prix en %sym',
|
||||
'At least one of cart products categories is %op% <strong>%categories_list%</strong>' => 'Au moins une des catégories des produits présents dans le panier %op% <strong>%categories_list%</strong> ',
|
||||
'Attribute ID:Attribute AV ID' => 'Déclinaison ID : Valeur de déclinaison ID',
|
||||
'Auth mode' => 'Mode d\'authentification',
|
||||
'Available quantity' => 'Quantité disponible',
|
||||
'Available quantity *' => 'Quantité disponible *',
|
||||
'Available shipping zones' => 'Zones de livraison disponibles',
|
||||
'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes',
|
||||
'Billing country' => 'Pays de livraison',
|
||||
'Billing coutry is' => 'Pays de facturation',
|
||||
'Business ID' => 'ID du business',
|
||||
'By cart total amount' => 'Montant total du panier',
|
||||
'Cannot find a default country. Please define one.' => 'Impossible de trouver un pays par défaut. Veuillez en définir un.',
|
||||
'Cannot find the shop country. Please select a shop country.' => 'Impossible de trouver le pays du magasin. Veuillez en sélectionner un.',
|
||||
'Cannot instanciante module "%name%": the namespace is null. Maybe the model is not loaded ?' => 'Ne peut instancier le module "%name%": le namespace est null. Peut-être que le modèle n\'est pas chargé ?',
|
||||
'Cart item count condition' => 'Nombre d\'articles dans le panier',
|
||||
'Cart contains at least a product %op% <strong>%products_list%</strong>' => 'Le panier contient au moins un produit %op% <strong>%products_list%</strong> ',
|
||||
'Cart contains categories condition' => 'Valable si le panier contient/ne contient pas des produits appartenant à certaines catégories',
|
||||
'Cart contains specific products' => 'Valable si le panier contient certains produits',
|
||||
'Cart item count' => 'Nombre d\'artciles dans le panier',
|
||||
'Cart item count is' => 'Le nombre d\'articles dans le panier est',
|
||||
'Cart total amount' => 'Montant total du panier',
|
||||
'Cart total amount is' => 'Le total du panier est',
|
||||
'Category title *' => 'Titre de la catégorie *',
|
||||
'Cellphone' => 'Numéro de portable',
|
||||
@@ -59,15 +67,20 @@ return array(
|
||||
'Country ID not found' => 'ID du pays non trouvé',
|
||||
'Country area' => 'Zone du pays',
|
||||
'Country title *' => 'Pays *',
|
||||
'Coupon %code is expired.' => 'La date limite d\'utilisation du coupon %code est dépassée.',
|
||||
'Critical' => 'Critique',
|
||||
'Current Password' => 'Mot de passe actuel.',
|
||||
'Customer is %op% <strong>%customer_list%</strong>' => 'Le client est %op% <strong>%customer_list%</strong> ',
|
||||
'Date \'%date\' is invalid, please enter a valid date using %fmt format' => 'La date \'%date\' est incorrecte, merci d\'indiquer une date au format %fmt',
|
||||
'Debug' => 'Debug',
|
||||
'Decimal places' => 'Nombre de chiffres après la virgule',
|
||||
'Default folder *' => 'Dossier par défaut *',
|
||||
'Default product category *' => 'Catégorie du produit par défaut *',
|
||||
'Default product sale element' => 'Product Sale Element par défaut',
|
||||
'Deleting document for %id% with parent id %parentId%' => 'Suppression du document %id% avec l\'ID parent %parentId%',
|
||||
'Deleting image for %id% with parent id %parentId%' => 'Suppression de l\'image %id% avec l\'ID parent %parentId%',
|
||||
'Delivery country' => 'Pays de livraison',
|
||||
'Delivery coutry is' => 'Le pays de livraison est',
|
||||
'Delivery module ID not found' => 'Id du module de livraison non trouvé',
|
||||
'Description' => 'Description',
|
||||
'Detailed description' => 'Description détaillée',
|
||||
@@ -81,7 +94,7 @@ return array(
|
||||
'Emergency' => 'Urgence',
|
||||
'Enable remote SMTP use' => 'Activer l\'utilisation d\'un serveur SMTP distant.',
|
||||
'Encryption' => 'Chiffrement',
|
||||
'Equals' => 'Egal à',
|
||||
'Equal to' => 'Egal à',
|
||||
'Error during %action process : %error. Exception was %exc' => 'Erreur lors de %action: %error. Exception: %exc ',
|
||||
'Error occured while processing order ref. %ref, ID %id: %err' => 'Un erreur est survenue paedant le traitement de la commande ref. %ref, ID %id; %err',
|
||||
'Errors' => 'Erreurs',
|
||||
@@ -100,6 +113,7 @@ return array(
|
||||
'Firstname' => 'Prénom',
|
||||
'Fixed Amount Discount' => 'Remise d\'un montant fixe',
|
||||
'Folder title *' => 'Titre du dossier *',
|
||||
'For one ore more customers' => 'Valable pour un ou plusieurs clients',
|
||||
'Full Name' => 'Nom complet',
|
||||
'Greater than' => 'Supérieur à',
|
||||
'Greater than or equals' => 'Supérieur ou égal à',
|
||||
@@ -136,6 +150,7 @@ return array(
|
||||
'Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`' => 'Une boucle doit implémenter au moins une de ces interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`',
|
||||
'Loop type \'%type\' is not defined.' => 'La boucle de type \'%type\' n\'existe pas.',
|
||||
'Make this address as my primary address' => 'Choisir cette adresse comme adresse par défaut',
|
||||
'Maximum usage count reached for coupon %code' => 'Le nombre maximum d\'utilisation pour le coupon %code est dépassé.',
|
||||
'Message subject' => 'Sujet',
|
||||
'Meta Description' => 'Meta description',
|
||||
'Meta Keywords' => 'Meta keywords',
|
||||
@@ -157,19 +172,23 @@ return array(
|
||||
'No module found for code \'%item\'' => 'Aucun module trouvé pour \'%item\' ',
|
||||
'No pagination currently defined for loop name \'%name\'' => 'La pagination n\'est pas définie pour la boucle \'%name\'',
|
||||
'No, I am a new customer.' => 'Non, je suis un nouveau client.',
|
||||
'Not equals' => 'Différent de',
|
||||
'Not equal to' => 'Différent de',
|
||||
'Not found' => 'Non trouvé.',
|
||||
'Not in' => 'Non compris dans',
|
||||
'Notices' => 'Notices',
|
||||
'Only if order billing country is %op% <strong>%countries_list%</strong>' => 'Si le pays de facturation %op% <strong>%countries_list%</strong> ',
|
||||
'Only if order shipping country is %op% <strong>%countries_list%</strong>' => 'Si le pays de livraison %op% <strong>%countries_list%</strong> ',
|
||||
'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé',
|
||||
'Order ref. %ref is now unpaid.' => 'La commande %ref, ID %id est désormais non payée',
|
||||
'Order ref. %ref, ID %id has been successfully paid.' => 'La commande ref. %ref, ID %id a été correctement payée',
|
||||
'Overall' => 'Pour tous les clients',
|
||||
'Page Title' => 'Titre de la page',
|
||||
'Parent category *' => 'Catégorie parente *',
|
||||
'Parent folder *' => 'Dossier parent *',
|
||||
'Password' => 'Mot de passe',
|
||||
'Password *' => 'Mot de passe *',
|
||||
'Password confirmation' => 'Confirmation du mot de passe.',
|
||||
'Per customer' => 'Par client',
|
||||
'Percent Discount' => 'Remise en pourcentage de la commande',
|
||||
'Percentage of the product price' => 'Pourcentage du prix du produit',
|
||||
'Phone' => 'Téléphone',
|
||||
@@ -230,6 +249,7 @@ return array(
|
||||
'Sorry, you are not allowed to perform this action.' => 'Désolé, vous n\'êtes pas autorisé à réaliser cette action.',
|
||||
'Sorry, you\'re not allowed to perform this action' => 'Désolé, vous n\'êtes pas autorisé à réaliser cette action.',
|
||||
'Source IP' => 'IP source',
|
||||
'Start date' => 'Date de début de validité',
|
||||
'Stats on %month/%year' => 'Statistiques pour %month/%year ',
|
||||
'Store configuration failed.' => 'Erreur de configuration du magasin.',
|
||||
'Store email address' => 'Adresse mail du magasin',
|
||||
@@ -253,6 +273,11 @@ return array(
|
||||
'Text Message' => 'Message au format texte',
|
||||
'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.',
|
||||
'The cart item count should match the condition' => 'Le nombre d\'articles dans le panier doit vérifier la condition',
|
||||
'The coupon applies if the cart contains at least one product of the selected categories' => 'Le code promo est valable si le panier contient/ne contient pas des produits appartenant aux catégories sélectionnées',
|
||||
'The coupon applies if the cart contains at least one product of the specified product list' => 'Le code promo est valable si le panier contient/ne contient pas au moins un des produits selectionnés',
|
||||
'The coupon applies to some customers only' => 'Ce code promo est valable pour les clients sélectionnés',
|
||||
'The coupon applies to the selected delivery countries' => 'Ce code promo s\'applique pour les pays de livraison sélectionnés',
|
||||
'The coupon is valid after a given date' => 'Le code promo est valide à partir de cette date',
|
||||
'The image which replaces an undefined country flag (%file) was not found. Please check unknown-flag-path configuration variable, and check that the image exists.' => 'L\'image qui remplace un drapeau de pays manquant (%file) n\'a pas été trouvée. Merci de vérifier la variable de configuration unknown-flag-path.',
|
||||
'The loop name \'%name\' is already defined in %className class' => 'La boucle \'%name\' est déjà définir dans la classe %className',
|
||||
'This category is online.' => 'Cette catégorie est en ligne.',
|
||||
@@ -287,6 +312,7 @@ return array(
|
||||
'Unsupported magic method %name. only getArgname() is supported.' => 'La méthode magique %name n\'est pas supportée. Seule get<argname>() est supporté..',
|
||||
'Username' => 'Nom d\'utilisateur',
|
||||
'Username *' => 'Nom d\'utilisateur *',
|
||||
'Valid only from %date% to the coupon expiration date' => 'Valide à partir de %date% jusqu\'à la date d\'expoiration',
|
||||
'Value' => 'Valeur',
|
||||
'Value *' => 'Valeur *',
|
||||
'Warnings' => 'Avertissements',
|
||||
@@ -299,6 +325,7 @@ return array(
|
||||
'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas',
|
||||
'Zip code' => 'Code postal',
|
||||
'date format' => 'Format de date',
|
||||
'decimal separator' => 'Séparateur décimal',
|
||||
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'le module de livraison %s n\'est pas un Thelia\Module\DeliveryModuleInterface',
|
||||
'language locale' => 'Langue locale',
|
||||
'mailing system modification' => 'Modification du système d\'envoi de mail.',
|
||||
@@ -308,5 +335,6 @@ return array(
|
||||
'permanent discount (in percent)' => 'Remise permanente (en pourcentage)',
|
||||
'quantity value is not valid' => 'la valeur de la quantité n\'est pas valide',
|
||||
'this product id does not exists : %d' => 'l\'id du produit %d n\'existe pas',
|
||||
'thousands separator' => 'Séparateur des milliers',
|
||||
'time format' => 'Format d\'heure',
|
||||
);
|
||||
|
||||
@@ -4,32 +4,40 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
|
||||
<services>
|
||||
|
||||
|
||||
<!-- Coupon module -->
|
||||
|
||||
<service id="thelia.facade" class="Thelia\Coupon\BaseFacade">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
|
||||
<service id="thelia.coupon.manager" class="Thelia\Coupon\CouponManager">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
|
||||
<service id="thelia.coupon.factory" class="Thelia\Coupon\CouponFactory">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
|
||||
<!-- Coupon types -->
|
||||
|
||||
<service id="thelia.coupon.type.remove_x_amount" class="Thelia\Coupon\Type\RemoveXAmount">
|
||||
<argument type="service" id="thelia.facade" />
|
||||
<tag name="thelia.coupon.addCoupon"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.coupon.type.remove_x_percent" class="Thelia\Coupon\Type\RemoveXPercent">
|
||||
<argument type="service" id="thelia.facade" />
|
||||
<tag name="thelia.coupon.addCoupon"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.coupon.type.remove_amount_on_categories" class="Thelia\Coupon\Type\RemoveAmountOnCategories">
|
||||
<argument type="service" id="thelia.facade" />
|
||||
<tag name="thelia.coupon.addCoupon"/>
|
||||
</service>
|
||||
|
||||
<!-- Condition module -->
|
||||
|
||||
<service id="thelia.condition.factory" class="Thelia\Condition\ConditionFactory">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
@@ -83,5 +91,4 @@
|
||||
</service>
|
||||
|
||||
</services>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -32,6 +32,8 @@ use Thelia\Form\CouponCreationForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Coupon;
|
||||
use Thelia\Model\CouponCountry;
|
||||
use Thelia\Model\CouponModule;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Tools\Rest\ResponseRest;
|
||||
@@ -152,6 +154,21 @@ class CouponController extends BaseAdminController
|
||||
$coupon->getSerializedConditions()
|
||||
);
|
||||
|
||||
$freeShippingForCountries = $freeShippingForModules = [];
|
||||
|
||||
/** @var CouponCountry $item */
|
||||
foreach ($coupon->getFreeShippingForCountries() as $item) {
|
||||
$freeShippingForCountries[] = $item->getCountryId();
|
||||
}
|
||||
|
||||
/** @var CouponModule $item */
|
||||
foreach ($coupon->getFreeShippingForModules() as $item) {
|
||||
$freeShippingForModules[] = $item->getModuleId();
|
||||
}
|
||||
|
||||
if (empty($freeShippingForCountries)) $freeShippingForCountries[] = 0;
|
||||
if (empty($freeShippingForModules)) $freeShippingForModules[] = 0;
|
||||
|
||||
$data = [
|
||||
'code' => $coupon->getCode(),
|
||||
'title' => $coupon->getTitle(),
|
||||
@@ -167,6 +184,9 @@ class CouponController extends BaseAdminController
|
||||
'maxUsage' => $coupon->getMaxUsage(),
|
||||
'conditions' => $conditions,
|
||||
'locale' => $this->getCurrentEditionLocale(),
|
||||
'freeShippingForCountries' => $freeShippingForCountries,
|
||||
'freeShippingForModules' => $freeShippingForModules,
|
||||
'perCustomerUsageCount' => $coupon->getPerCustomerUsageCount(),
|
||||
];
|
||||
|
||||
$args['conditions'] = $this->cleanConditionForTemplate($conditions);
|
||||
@@ -557,7 +577,7 @@ class CouponController extends BaseAdminController
|
||||
$condition['serviceId'] = $availableCoupon->getServiceId();
|
||||
$condition['name'] = $availableCoupon->getName();
|
||||
$condition['toolTip'] = $availableCoupon->getToolTip();
|
||||
$condition['inputName'] = $availableCoupon->getInputName();
|
||||
// $condition['inputName'] = $availableCoupon->getInputName();
|
||||
$cleanedCoupons[] = $condition;
|
||||
}
|
||||
|
||||
@@ -716,7 +736,10 @@ class CouponController extends BaseAdminController
|
||||
$data['isCumulative'],
|
||||
$data['isRemovingPostage'],
|
||||
$data['maxUsage'],
|
||||
$data['locale']
|
||||
$data['locale'],
|
||||
$data['freeShippingForCountries'],
|
||||
$data['freeShippingForModules'],
|
||||
$data['perCustomerUsageCount']
|
||||
);
|
||||
|
||||
// If Update mode
|
||||
@@ -774,7 +797,10 @@ class CouponController extends BaseAdminController
|
||||
$coupon->getIsCumulative(),
|
||||
$coupon->getIsRemovingPostage(),
|
||||
$coupon->getMaxUsage(),
|
||||
$coupon->getLocale()
|
||||
$coupon->getLocale(),
|
||||
$coupon->getFreeShippingForCountries(),
|
||||
$coupon->getFreeShippingForModules(),
|
||||
$coupon->getPerCustomerUsageCount()
|
||||
);
|
||||
$couponEvent->setCouponModel($coupon);
|
||||
$couponEvent->setConditions($conditions);
|
||||
|
||||
@@ -19,7 +19,7 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Form\OrderUpdateAddress;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Base\OrderAddressQuery;
|
||||
use Thelia\Model\OrderAddressQuery;
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace Thelia\Controller\Front;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Controller\BaseController;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class BaseFrontController extends BaseController
|
||||
@@ -65,7 +65,15 @@ class BaseFrontController extends BaseController
|
||||
protected function checkValidDelivery()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if (null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) {
|
||||
if (null === $order
|
||||
||
|
||||
null === $order->getChoosenDeliveryAddress()
|
||||
||
|
||||
null === $order->getDeliveryModuleId()
|
||||
||
|
||||
null === AddressQuery::create()->findPk($order->getChoosenDeliveryAddress())
|
||||
||
|
||||
null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) {
|
||||
$this->redirectToRoute("order.delivery");
|
||||
}
|
||||
}
|
||||
@@ -73,13 +81,21 @@ class BaseFrontController extends BaseController
|
||||
protected function checkValidInvoice()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if (null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
|
||||
if (null === $order
|
||||
||
|
||||
null === $order->getChoosenInvoiceAddress()
|
||||
||
|
||||
null === $order->getPaymentModuleId()
|
||||
||
|
||||
null === AddressQuery::create()->findPk($order->getChoosenInvoiceAddress())
|
||||
||
|
||||
null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
|
||||
$this->redirectToRoute("order.invoice");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParserInterface instance parser
|
||||
* @return TemplateDefinition the template
|
||||
*/
|
||||
protected function getParser($template = null)
|
||||
{
|
||||
|
||||
@@ -31,19 +31,42 @@ class CouponConsumeEvent extends ActionEvent
|
||||
/** @var bool If Coupon is valid or if Customer meets coupon conditions */
|
||||
protected $isValid = null;
|
||||
|
||||
/** @var bool true if coupon offers free shipping */
|
||||
protected $freeShipping = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $code Coupon code
|
||||
* @param float $discount Total discount given by this coupon
|
||||
* @param bool $isValid If Coupon is valid or
|
||||
* if Customer meets coupon conditions
|
||||
* @param string $code Coupon code
|
||||
* @param float $discount Total discount given by this coupon
|
||||
* @param bool $isValid If Coupon is valid or f Customer meets coupon conditions
|
||||
* @param bool $freeShipping true if coupon offers free shipping
|
||||
*/
|
||||
public function __construct($code, $discount = null, $isValid = null)
|
||||
public function __construct($code, $discount = null, $isValid = null, $freeShipping = false)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->discount = $discount;
|
||||
$this->isValid = $isValid;
|
||||
$this->discount = $discount;
|
||||
|
||||
$this->freeShipping = $freeShipping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $freeShipping
|
||||
*/
|
||||
public function setFreeShipping($freeShipping)
|
||||
{
|
||||
$this->freeShipping = $freeShipping;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getFreeShipping()
|
||||
{
|
||||
return $this->freeShipping;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,6 +73,15 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
/** @var string Language code ISO (ex: fr_FR) */
|
||||
protected $locale = null;
|
||||
|
||||
/** @var array ID of Countries to which shipping is free */
|
||||
protected $freeShippingForCountries;
|
||||
|
||||
/** @var array ID of Shipping modules for which shipping is free */
|
||||
protected $freeShippingForMethods;
|
||||
|
||||
/** @var true if usage count is per customer only */
|
||||
protected $perCustomerUsageCount;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -91,8 +100,15 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param boolean $isRemovingPostage Is removing Postage
|
||||
* @param int $maxUsage Coupon quantity
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
* @param array $freeShippingForCountries ID of Countries to which shipping is free
|
||||
* @param array $freeShippingForMethods ID of Shipping modules for which shipping is free
|
||||
* @param boolean $perCustomerUsageCount Usage count is per customer
|
||||
*/
|
||||
public function __construct($code, $serviceId, $title, array $effects, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale)
|
||||
public function __construct(
|
||||
$code, $serviceId, $title, array $effects, $shortDescription, $description,
|
||||
$isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative,
|
||||
$isRemovingPostage, $maxUsage, $locale, $freeShippingForCountries, $freeShippingForMethods,
|
||||
$perCustomerUsageCount)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->description = $description;
|
||||
@@ -107,6 +123,65 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$this->serviceId = $serviceId;
|
||||
$this->locale = $locale;
|
||||
$this->setEffects($effects);
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
$this->freeShippingForMethods = $freeShippingForMethods;
|
||||
$this->perCustomerUsageCount = $perCustomerUsageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param true $perCustomerUsageCount
|
||||
*/
|
||||
public function setPerCustomerUsageCount($perCustomerUsageCount)
|
||||
{
|
||||
$this->perCustomerUsageCount = $perCustomerUsageCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true
|
||||
*/
|
||||
public function getPerCustomerUsageCount()
|
||||
{
|
||||
return $this->perCustomerUsageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $freeShippingForCountries
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreeShippingForCountries($freeShippingForCountries)
|
||||
{
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeShippingForCountries()
|
||||
{
|
||||
return $this->freeShippingForCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $freeShippingForMethods
|
||||
* @return $this
|
||||
*/
|
||||
public function setFreeShippingForMethods($freeShippingForMethods)
|
||||
{
|
||||
$this->freeShippingForMethods = $freeShippingForMethods;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFreeShippingForMethods()
|
||||
{
|
||||
return $this->freeShippingForMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\AttributeQuery;
|
||||
use Thelia\Model\AttributeQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\ProductQuery;
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\AttributeAvQuery;
|
||||
use Thelia\Model\AttributeAvQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\AttributeCombinationQuery;
|
||||
use Thelia\Model\AttributeCombinationQuery;
|
||||
use Thelia\Model\Map\AttributeAvTableMap;
|
||||
use Thelia\Model\Map\AttributeTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
|
||||
@@ -23,7 +23,9 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\CouponModule;
|
||||
use Thelia\Model\Coupon as MCoupon;
|
||||
use Thelia\Model\CouponCountry;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Model\Map\CouponTableMap;
|
||||
use Thelia\Type\EnumListType;
|
||||
@@ -178,7 +180,10 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
$coupon->getIsAvailableOnSpecialOffers(),
|
||||
$coupon->getIsEnabled(),
|
||||
$coupon->getMaxUsage(),
|
||||
$coupon->getExpirationDate()
|
||||
$coupon->getExpirationDate(),
|
||||
$coupon->getFreeShippingForCountries(),
|
||||
$coupon->getFreeShippingForModules(),
|
||||
$coupon->getPerCustomerUsageCount()
|
||||
);
|
||||
|
||||
$cleanedConditions = array();
|
||||
@@ -191,6 +196,18 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
$cleanedConditions[] = $temp;
|
||||
}
|
||||
|
||||
$freeShippingForCountriesIds = [];
|
||||
/** @var CouponCountry $couponCountry */
|
||||
foreach ($coupon->getFreeShippingForCountries() as $couponCountry) {
|
||||
$freeShippingForCountriesIds[] = $couponCountry->getCountryId();
|
||||
}
|
||||
|
||||
$freeShippingForModulesIds = [];
|
||||
/** @var CouponModule $couponModule */
|
||||
foreach ($coupon->getFreeShippingForModules() as $couponModule) {
|
||||
$freeShippingForModulesIds[] = $couponModule->getModuleId();
|
||||
}
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $coupon->getId())
|
||||
->set("IS_TRANSLATED", $coupon->getVirtualColumn('IS_TRANSLATED'))
|
||||
@@ -201,6 +218,7 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
->set("DESCRIPTION", $coupon->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("EXPIRATION_DATE", $coupon->getExpirationDate())
|
||||
->set("USAGE_LEFT", $coupon->getMaxUsage())
|
||||
->set("PER_CUSTOMER_USAGE_COUNT", $coupon->getPerCustomerUsageCount())
|
||||
->set("IS_CUMULATIVE", $coupon->getIsCumulative())
|
||||
->set("IS_REMOVING_POSTAGE", $coupon->getIsRemovingPostage())
|
||||
->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $coupon->getIsAvailableOnSpecialOffers())
|
||||
@@ -209,7 +227,11 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
->set("APPLICATION_CONDITIONS", $cleanedConditions)
|
||||
->set("TOOLTIP", $couponManager->getToolTip())
|
||||
->set("DAY_LEFT_BEFORE_EXPIRATION", max(0, $coupon->getVirtualColumn('days_left')))
|
||||
->set("SERVICE_ID", $couponManager->getServiceId());
|
||||
->set("SERVICE_ID", $couponManager->getServiceId())
|
||||
->set("FREE_SHIPPING_FOR_COUNTRIES_LIST", implode(',', $freeShippingForCountriesIds))
|
||||
->set("FREE_SHIPPING_FOR_MODULES_LIST", implode(',', $freeShippingForModulesIds))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class Delivery extends BaseSpecificModule
|
||||
$loopResultRow = new LoopResultRow($deliveryModule);
|
||||
|
||||
/** @var DeliveryModuleInterface $moduleInstance */
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||
$moduleInstance = $deliveryModule->getModuleInstance($this->container);
|
||||
|
||||
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
|
||||
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\FeatureAvQuery;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\FeatureProductQuery;
|
||||
use Thelia\Model\FeatureProductQuery;
|
||||
use Thelia\Model\Map\FeatureAvTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -20,6 +20,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\OrderCouponCountry;
|
||||
use Thelia\Model\OrderCouponModule;
|
||||
use Thelia\Model\OrderCouponQuery;
|
||||
use Thelia\Model\OrderQuery;
|
||||
|
||||
@@ -52,9 +54,10 @@ class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
|
||||
|
||||
$order = $this->getOrder();
|
||||
|
||||
$search->filterByOrderId($order, Criteria::EQUAL);
|
||||
|
||||
$search->orderById(Criteria::ASC);
|
||||
$search
|
||||
->filterByOrderId($order, Criteria::EQUAL)
|
||||
->orderById(Criteria::ASC)
|
||||
;
|
||||
|
||||
return $search;
|
||||
|
||||
@@ -64,26 +67,48 @@ class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
$this->container->get('thelia.condition.factory');
|
||||
|
||||
/** @var OrderCoupon $orderCoupon */
|
||||
foreach ($loopResult->getResultDataCollection() as $orderCoupon) {
|
||||
$loopResultRow = new LoopResultRow($orderCoupon);
|
||||
if (null !== $order = OrderQuery::create()->findPk($this->getOrder())) {
|
||||
|
||||
$now = time();
|
||||
$datediff = $orderCoupon->getExpirationDate()->getTimestamp() - $now;
|
||||
$daysLeftBeforeExpiration = floor($datediff/(60*60*24));
|
||||
$oneDayInSeconds = 86400;
|
||||
|
||||
$loopResultRow->set("ID", $orderCoupon->getId())
|
||||
->set("CODE", $orderCoupon->getCode())
|
||||
->set("TITLE", $orderCoupon->getTitle())
|
||||
->set("SHORT_DESCRIPTION", $orderCoupon->getShortDescription())
|
||||
->set("DESCRIPTION", $orderCoupon->getDescription())
|
||||
->set("EXPIRATION_DATE", $orderCoupon->getExpirationDate( OrderQuery::create()->findPk($this->getOrder())->getLangId() ))
|
||||
->set("IS_CUMULATIVE", $orderCoupon->getIsCumulative())
|
||||
->set("IS_REMOVING_POSTAGE", $orderCoupon->getIsRemovingPostage())
|
||||
->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $orderCoupon->getIsAvailableOnSpecialOffers())
|
||||
->set("DAY_LEFT_BEFORE_EXPIRATION", $daysLeftBeforeExpiration)
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
/** @var \Thelia\Model\OrderCoupon $orderCoupon */
|
||||
foreach ($loopResult->getResultDataCollection() as $orderCoupon) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($orderCoupon);
|
||||
|
||||
$now = time();
|
||||
$datediff = $orderCoupon->getExpirationDate()->getTimestamp() - $now;
|
||||
$daysLeftBeforeExpiration = floor($datediff/($oneDayInSeconds));
|
||||
|
||||
$freeShippingForCountriesIds = [];
|
||||
/** @var OrderCouponCountry $couponCountry */
|
||||
foreach ($orderCoupon->getFreeShippingForCountries() as $couponCountry) {
|
||||
$freeShippingForCountriesIds[] = $couponCountry->getCountryId();
|
||||
}
|
||||
|
||||
$freeShippingForModulesIds = [];
|
||||
/** @var OrderCouponModule $couponModule */
|
||||
foreach ($orderCoupon->getFreeShippingForModules() as $couponModule) {
|
||||
$freeShippingForModulesIds[] = $couponModule->getModuleId();
|
||||
}
|
||||
|
||||
$loopResultRow->set("ID", $orderCoupon->getId())
|
||||
->set("CODE", $orderCoupon->getCode())
|
||||
->set("TITLE", $orderCoupon->getTitle())
|
||||
->set("SHORT_DESCRIPTION", $orderCoupon->getShortDescription())
|
||||
->set("DESCRIPTION", $orderCoupon->getDescription())
|
||||
->set("EXPIRATION_DATE", $orderCoupon->getExpirationDate( $order->getLangId() ))
|
||||
->set("IS_CUMULATIVE", $orderCoupon->getIsCumulative())
|
||||
->set("IS_REMOVING_POSTAGE", $orderCoupon->getIsRemovingPostage())
|
||||
->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $orderCoupon->getIsAvailableOnSpecialOffers())
|
||||
->set("DAY_LEFT_BEFORE_EXPIRATION", $daysLeftBeforeExpiration)
|
||||
->set("FREE_SHIPPING_FOR_COUNTRIES_LIST", implode(',', $freeShippingForCountriesIds))
|
||||
->set("FREE_SHIPPING_FOR_MODULES_LIST", implode(',', $freeShippingForModulesIds))
|
||||
->set("PER_CUSTOMER_USAGE_COUNT", $orderCoupon->getPerCustomerUsageCount())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\OrderProductQuery;
|
||||
use Thelia\Model\OrderProductQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\OrderProductAttributeCombinationQuery;
|
||||
use Thelia\Model\OrderProductAttributeCombinationQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class Payment extends BaseSpecificModule implements PropelSearchLoopInterface
|
||||
foreach ($loopResult->getResultDataCollection() as $paymentModule) {
|
||||
$loopResultRow = new LoopResultRow($paymentModule);
|
||||
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
|
||||
$moduleInstance = $paymentModule->getModuleInstance($this->container);
|
||||
|
||||
if (false === $moduleInstance instanceof PaymentModuleInterface) {
|
||||
throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode()));
|
||||
|
||||
@@ -22,7 +22,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\TemplateQuery;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\TaxRuleCountryQuery;
|
||||
use Thelia\Model\TaxRuleCountryQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\TaxQuery;
|
||||
|
||||
@@ -150,7 +150,7 @@ class SmartyAssetsManager
|
||||
$files = $finder->files()->in($assetSource)->name($file);
|
||||
|
||||
if (! empty($files)) {
|
||||
|
||||
|
||||
$url = $this->assetsManager->processAsset(
|
||||
$assetSource . DS . $file,
|
||||
$assetSource . DS . self::$assetsDirectory,
|
||||
@@ -162,8 +162,7 @@ class SmartyAssetsManager
|
||||
$filters,
|
||||
$debug
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Tlog::getInstance()->addError("Asset $assetSource".DS."$file was not found.");
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ class CartPostage extends AbstractSmartyPlugin
|
||||
foreach ($deliveryModules as $deliveryModule) {
|
||||
|
||||
/** @var DeliveryModuleInterface $moduleInstance */
|
||||
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
|
||||
$moduleInstance = $deliveryModule->getModuleInstance($this->container);
|
||||
|
||||
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
|
||||
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
|
||||
|
||||
@@ -204,9 +204,9 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
case 'discount':
|
||||
return $order->getDiscount();
|
||||
case 'delivery_address':
|
||||
return $order->chosenDeliveryAddress;
|
||||
return $order->getChoosenDeliveryAddress();
|
||||
case 'invoice_address':
|
||||
return $order->chosenInvoiceAddress;
|
||||
return $order->getChoosenInvoiceAddress();
|
||||
case 'delivery_module':
|
||||
return $order->getDeliveryModuleId();
|
||||
case 'payment_module':
|
||||
|
||||
@@ -82,7 +82,7 @@ class Security extends AbstractSmartyPlugin
|
||||
$order = $this->request->getSession()->getOrder();
|
||||
/* Does address and module still exists ? We assume address owner can't change neither module type */
|
||||
if ($order !== null) {
|
||||
$checkAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress);
|
||||
$checkAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress());
|
||||
$checkModule = ModuleQuery::create()->findPk($order->getDeliveryModuleId());
|
||||
}
|
||||
if (null === $order || null == $checkAddress || null === $checkModule) {
|
||||
|
||||
@@ -77,9 +77,8 @@ class BaseFacade implements FacadeInterface
|
||||
public function getDeliveryAddress()
|
||||
{
|
||||
try {
|
||||
return AddressQuery::create()->findPk($this->getRequest()->getSession()->getOrder()->chosenDeliveryAddress);
|
||||
}
|
||||
catch(\Exception $ex) {
|
||||
return AddressQuery::create()->findPk($this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress());
|
||||
} catch (\Exception $ex) {
|
||||
throw new \LogicException("Failed to get delivery address (" . $ex->getMessage() . ")");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Condition\ConditionFactory;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Exception\CouponExpiredException;
|
||||
use Thelia\Exception\CouponNoUsageLeftException;
|
||||
use Thelia\Exception\InvalidConditionException;
|
||||
use Thelia\Model\Coupon;
|
||||
|
||||
@@ -62,12 +63,19 @@ class CouponFactory
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check coupon expiration date
|
||||
if ($couponModel->getExpirationDate() < new \DateTime()) {
|
||||
throw new CouponExpiredException($couponCode);
|
||||
}
|
||||
|
||||
// Check coupon usage count
|
||||
if ($couponModel->getUsagesLeft($this->facade->getCustomer()->getId()) <= 0) {
|
||||
throw new CouponNoUsageLeftException($couponCode);
|
||||
}
|
||||
|
||||
/** @var CouponInterface $couponInterface */
|
||||
$couponInterface = $this->buildCouponFromModel($couponModel);
|
||||
|
||||
if ($couponInterface && $couponInterface->getConditions()->count() == 0) {
|
||||
throw new InvalidConditionException(
|
||||
get_class($couponInterface)
|
||||
@@ -107,7 +115,10 @@ class CouponFactory
|
||||
$model->getIsAvailableOnSpecialOffers(),
|
||||
$model->getIsEnabled(),
|
||||
$model->getMaxUsage(),
|
||||
$model->getExpirationDate()
|
||||
$model->getExpirationDate(),
|
||||
$model->getFreeShippingForCountries(),
|
||||
$model->getFreeShippingForModules(),
|
||||
$model->getPerCustomerUsageCount()
|
||||
);
|
||||
|
||||
/** @var ConditionFactory $conditionFactory */
|
||||
|
||||
@@ -15,7 +15,14 @@ namespace Thelia\Coupon;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Condition\Implementation\ConditionInterface;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\CouponModule;
|
||||
use Thelia\Model\Coupon;
|
||||
use Thelia\Model\CouponCountry;
|
||||
use Thelia\Model\CouponCustomerCount;
|
||||
use Thelia\Model\CouponCustomerCountQuery;
|
||||
use Thelia\Model\Order;
|
||||
|
||||
/**
|
||||
* Manage how Coupons could interact with a Checkout
|
||||
@@ -78,9 +85,10 @@ class CouponManager
|
||||
* Check if there is a Coupon removing Postage
|
||||
* @return bool
|
||||
*/
|
||||
public function isCouponRemovingPostage()
|
||||
public function isCouponRemovingPostage(Order $order)
|
||||
{
|
||||
$coupons = $this->facade->getCurrentCoupons();
|
||||
|
||||
if (count($coupons) == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +97,60 @@ class CouponManager
|
||||
|
||||
/** @var CouponInterface $coupon */
|
||||
foreach ($couponsKept as $coupon) {
|
||||
|
||||
if ($coupon->isRemovingPostage()) {
|
||||
|
||||
// Check if delivery country is on the list of countries for which delivery is free
|
||||
// If the list is empty, the shipping is free for all countries.
|
||||
$couponCountries = $coupon->getFreeShippingForCountries();
|
||||
|
||||
if (! $couponCountries->isEmpty()) {
|
||||
|
||||
if (null === $deliveryAddress = AddressQuery::create()->findPk($order->getChoosenDeliveryAddress())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$countryValid = false;
|
||||
|
||||
$deliveryCountryId = $deliveryAddress->getCountryId();
|
||||
|
||||
/** @var CouponCountry $couponCountry */
|
||||
foreach ($couponCountries as $couponCountry) {
|
||||
if ($deliveryCountryId == $couponCountry->getCountryId()) {
|
||||
$countryValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $countryValid) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if shipping method is on the list of methods for which delivery is free
|
||||
// If the list is empty, the shipping is free for all methods.
|
||||
$couponModules = $coupon->getFreeShippingForModules();
|
||||
|
||||
if (! $couponModules->isEmpty()) {
|
||||
|
||||
$moduleValid = false;
|
||||
|
||||
$shippingModuleId = $order->getDeliveryModuleId();
|
||||
|
||||
/** @var CouponModule $couponModule */
|
||||
foreach ($couponModules as $couponModule) {
|
||||
if ($shippingModuleId == $couponModule->getModuleId()) {
|
||||
$moduleValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $moduleValid) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// All conditions are met, the shipping is free !
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -210,27 +271,64 @@ class CouponManager
|
||||
*
|
||||
* To call when a coupon is consumed
|
||||
*
|
||||
* @param \Thelia\Model\Coupon $coupon Coupon consumed
|
||||
* @param \Thelia\Model\Coupon $coupon Coupon consumed
|
||||
* @param int|null $customerId the ID of the ordering customer
|
||||
*
|
||||
* @return int Usage left after decremental
|
||||
*/
|
||||
public function decrementQuantity(Coupon $coupon)
|
||||
public function decrementQuantity(Coupon $coupon, $customerId = null)
|
||||
{
|
||||
$ret = -1;
|
||||
$ret = false;
|
||||
|
||||
try {
|
||||
|
||||
$usageLeft = $coupon->getMaxUsage();
|
||||
$usageLeft = $coupon->getUsagesLeft($customerId);
|
||||
|
||||
if ($usageLeft > 0) {
|
||||
$usageLeft--;
|
||||
$coupon->setMaxUsage($usageLeft);
|
||||
if ($usageLeft > 0) {
|
||||
|
||||
$coupon->save();
|
||||
$ret = $usageLeft;
|
||||
}
|
||||
// If the coupon usage is per user, add an entry to coupon customer usage count table
|
||||
if ($coupon->getPerCustomerUsageCount()) {
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$ret = false;
|
||||
if (null == $customerId) {
|
||||
throw new \LogicException("Customer should not be null at this time.");
|
||||
}
|
||||
|
||||
$ccc = CouponCustomerCountQuery::create()
|
||||
->filterByCouponId($coupon->getId())
|
||||
->filterByCustomerId($customerId)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
if ($ccc === null) {
|
||||
$ccc = new CouponCustomerCount();
|
||||
|
||||
$ccc
|
||||
->setCustomerId($customerId)
|
||||
->setCouponId($coupon->getId())
|
||||
->setCount(0);
|
||||
}
|
||||
|
||||
$newCount = 1 + $ccc->getCount();
|
||||
|
||||
$ccc
|
||||
->setCount($newCount)
|
||||
->save()
|
||||
;
|
||||
|
||||
$ret = $usageLeft - $newCount;
|
||||
} else {
|
||||
$usageLeft--;
|
||||
|
||||
$coupon->setMaxUsage($usageLeft);
|
||||
|
||||
$coupon->save();
|
||||
|
||||
$ret = $usageLeft;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
// Just log the problem.
|
||||
Tlog::getInstance()->addError(sprintf("Failed to decrement coupon %s: %s", $coupon->getCode(), $ex->getMessage()));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
||||
@@ -12,11 +12,13 @@
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
use Thelia\Condition\ConditionCollection;
|
||||
use Thelia\Condition\ConditionEvaluator;
|
||||
use Thelia\Condition\ConditionOrganizerInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Condition\ConditionCollection;
|
||||
use Thelia\Condition\ConditionOrganizerInterface;
|
||||
use Thelia\Model\CouponCountry;
|
||||
use Thelia\Model\CouponModule;
|
||||
|
||||
/**
|
||||
* Assist in writing a CouponInterface
|
||||
@@ -88,6 +90,15 @@ abstract class CouponAbstract implements CouponInterface
|
||||
/** @var bool if Coupon is available for Products already on special offers */
|
||||
protected $isAvailableOnSpecialOffers = false;
|
||||
|
||||
/** @var CouponCountry[] list of country IDs for which shipping is free. All if empty*/
|
||||
protected $freeShippingForCountries = [];
|
||||
|
||||
/** @var CouponModule[] list of shipping module IDs for which shippiog is free. All if empty*/
|
||||
protected $freeShippingForModules = [];
|
||||
|
||||
/** @var true if usage count is per customer only */
|
||||
protected $perCustomerUsageCount;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -115,23 +126,7 @@ abstract class CouponAbstract implements CouponInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon
|
||||
*
|
||||
* @param FacadeInterface $facade Provides necessary value from Thelia
|
||||
* @param string $code Coupon code (ex: XMAS)
|
||||
* @param string $title Coupon title (ex: Coupon for XMAS)
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param array $effects Coupon effects params
|
||||
* @param bool $isCumulative If Coupon is cumulative
|
||||
* @param bool $isRemovingPostage If Coupon is removing postage
|
||||
* @param bool $isAvailableOnSpecialOffers If available on Product already
|
||||
* on special offer price
|
||||
* @param bool $isEnabled False if Coupon is disabled by admin
|
||||
* @param int $maxUsage How many usage left
|
||||
* @param \Datetime $expirationDate When the Code is expiring
|
||||
*
|
||||
* @return $this
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function set(
|
||||
FacadeInterface $facade,
|
||||
@@ -145,7 +140,10 @@ abstract class CouponAbstract implements CouponInterface
|
||||
$isAvailableOnSpecialOffers,
|
||||
$isEnabled,
|
||||
$maxUsage,
|
||||
\DateTime $expirationDate
|
||||
\DateTime $expirationDate,
|
||||
$freeShippingForCountries,
|
||||
$freeShippingForModules,
|
||||
$perCustomerUsageCount
|
||||
)
|
||||
{
|
||||
$this->code = $code;
|
||||
@@ -165,9 +163,31 @@ abstract class CouponAbstract implements CouponInterface
|
||||
$this->effects = $effects;
|
||||
$this->amount = $effects[self::INPUT_AMOUNT_NAME];
|
||||
|
||||
$this->freeShippingForCountries = $freeShippingForCountries;
|
||||
$this->freeShippingForModules = $freeShippingForModules;
|
||||
$this->perCustomerUsageCount = $perCustomerUsageCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param true $perCustomerUsageCount
|
||||
*/
|
||||
public function setPerCustomerUsageCount($perCustomerUsageCount)
|
||||
{
|
||||
$this->perCustomerUsageCount = $perCustomerUsageCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true
|
||||
*/
|
||||
public function getPerCustomerUsageCount()
|
||||
{
|
||||
return $this->perCustomerUsageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Coupon code (ex: XMAS)
|
||||
*
|
||||
@@ -230,6 +250,22 @@ abstract class CouponAbstract implements CouponInterface
|
||||
return $this->isRemovingPostage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array list of country IDs for which shipping is free. All if empty
|
||||
*/
|
||||
public function getFreeShippingForCountries()
|
||||
{
|
||||
return $this->freeShippingForCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array list of module IDs for which shipping is free. All if empty
|
||||
*/
|
||||
public function getFreeShippingForModules()
|
||||
{
|
||||
return $this->freeShippingForModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return effects generated by the coupon
|
||||
* A negative value
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Thelia\Condition\ConditionCollection;
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
|
||||
@@ -31,13 +32,6 @@ interface CouponInterface
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Get I18n amount input name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputName();
|
||||
|
||||
/**
|
||||
* Get I18n tooltip
|
||||
*
|
||||
@@ -55,19 +49,22 @@ interface CouponInterface
|
||||
/**
|
||||
* Set Coupon
|
||||
*
|
||||
* @param FacadeInterface $facade Provides necessary value from Thelia
|
||||
* @param string $code Coupon code (ex: XMAS)
|
||||
* @param string $title Coupon title (ex: Coupon for XMAS)
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param array $effects Coupon effects params
|
||||
* @param bool $isCumulative If Coupon is cumulative
|
||||
* @param bool $isRemovingPostage If Coupon is removing postage
|
||||
* @param bool $isAvailableOnSpecialOffers If available on Product already
|
||||
* on special offer price
|
||||
* @param bool $isEnabled False if Coupon is disabled by admin
|
||||
* @param int $maxUsage How many usage left
|
||||
* @param \Datetime $expirationDate When the Code is expiring
|
||||
* @param FacadeInterface $facade Provides necessary value from Thelia
|
||||
* @param string $code Coupon code (ex: XMAS)
|
||||
* @param string $title Coupon title (ex: Coupon for XMAS)
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param array $effects Coupon effects params
|
||||
* @param bool $isCumulative If Coupon is cumulative
|
||||
* @param bool $isRemovingPostage If Coupon is removing postage
|
||||
* @param bool $isAvailableOnSpecialOffers If available on Product already
|
||||
* on special offer price
|
||||
* @param bool $isEnabled False if Coupon is disabled by admin
|
||||
* @param int $maxUsage How many usage left
|
||||
* @param \Datetime $expirationDate When the Code is expiring
|
||||
* @param ObjectCollection $freeShippingForCountries list of countries which shipping is free. All if empty
|
||||
* @param ObjectCollection $freeShippingForModules list of modules for which shipping is free. All if empty
|
||||
* @param bool $perCustomerUsageCount true if usage count is per customer only
|
||||
*/
|
||||
public function set(
|
||||
FacadeInterface $facade,
|
||||
@@ -81,7 +78,11 @@ interface CouponInterface
|
||||
$isAvailableOnSpecialOffers,
|
||||
$isEnabled,
|
||||
$maxUsage,
|
||||
\DateTime $expirationDate);
|
||||
\DateTime $expirationDate,
|
||||
$freeShippingForCountries,
|
||||
$freeShippingForModules,
|
||||
$perCustomerUsageCount
|
||||
);
|
||||
|
||||
/**
|
||||
* Return Coupon code (ex: XMAS)
|
||||
@@ -160,6 +161,14 @@ interface CouponInterface
|
||||
*/
|
||||
public function isAvailableOnSpecialOffers();
|
||||
|
||||
/**
|
||||
* Check if the Coupon can be used against a
|
||||
* product already with a special offer price
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPerCustomerUsageCount();
|
||||
|
||||
/**
|
||||
* Check if Coupon has been disabled by admin
|
||||
*
|
||||
@@ -218,4 +227,13 @@ interface CouponInterface
|
||||
*/
|
||||
public function getExtendedInputs();
|
||||
|
||||
/**
|
||||
* @return ObjectCollection list of country IDs for which shipping is free. All if empty
|
||||
*/
|
||||
public function getFreeShippingForCountries();
|
||||
|
||||
/**
|
||||
* @return ObjectCollection list of module IDs for which shipping is free. All if empty
|
||||
*/
|
||||
public function getFreeShippingForModules();
|
||||
}
|
||||
|
||||
@@ -35,23 +35,7 @@ class RemoveXPercent extends CouponAbstract
|
||||
);
|
||||
|
||||
/**
|
||||
* Set Coupon
|
||||
*
|
||||
* @param FacadeInterface $facade Provides necessary value from Thelia
|
||||
* @param string $code Coupon code (ex: XMAS)
|
||||
* @param string $title Coupon title (ex: Coupon for XMAS)
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param array $effects Coupon effects params
|
||||
* @param bool $isCumulative If Coupon is cumulative
|
||||
* @param bool $isRemovingPostage If Coupon is removing postage
|
||||
* @param bool $isAvailableOnSpecialOffers If available on Product already
|
||||
* on special offer price
|
||||
* @param bool $isEnabled False if Coupon is disabled by admin
|
||||
* @param int $maxUsage How many usage left
|
||||
* @param \Datetime $expirationDate When the Code is expiring
|
||||
*
|
||||
* @return $this
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function set(
|
||||
FacadeInterface $facade,
|
||||
@@ -65,12 +49,20 @@ class RemoveXPercent extends CouponAbstract
|
||||
$isAvailableOnSpecialOffers,
|
||||
$isEnabled,
|
||||
$maxUsage,
|
||||
\DateTime $expirationDate
|
||||
\DateTime $expirationDate,
|
||||
$freeShippingForCountries,
|
||||
$freeShippingForModules,
|
||||
$perCustomerUsageCount
|
||||
)
|
||||
{
|
||||
parent::set(
|
||||
$facade, $code, $title, $shortDescription, $description, $effects, $isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate
|
||||
$facade, $code, $title, $shortDescription, $description, $effects,
|
||||
$isCumulative, $isRemovingPostage, $isAvailableOnSpecialOffers, $isEnabled, $maxUsage, $expirationDate,
|
||||
$freeShippingForCountries,
|
||||
$freeShippingForModules,
|
||||
$perCustomerUsageCount
|
||||
);
|
||||
|
||||
$this->percentage = $effects[self::INPUT_PERCENTAGE_NAME];
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace Thelia\Exception;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,8 @@ class CouponExpiredException extends \Exception
|
||||
*/
|
||||
public function __construct($couponCode)
|
||||
{
|
||||
$message = 'Expired Coupon ' . $couponCode . 'attempt';
|
||||
$message = Translator::getInstance()->trans('Coupon %code is expired.', ['%code' => $couponCode ]);
|
||||
|
||||
Tlog::getInstance()->addWarning($message);
|
||||
|
||||
parent::__construct($message);
|
||||
|
||||
39
core/lib/Thelia/Exception/CouponNoUsageLeftException.php
Normal file
39
core/lib/Thelia/Exception/CouponNoUsageLeftException.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Exception;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
* Thrown when a Coupon with no usage lect (etiher overall or per customer usage) is tried
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class CouponNoUsageLeftException extends \Exception
|
||||
{
|
||||
/**
|
||||
* CouponExpiredException thrown when a Coupon is expired
|
||||
*
|
||||
* @param string $couponCode Coupon code
|
||||
*/
|
||||
public function __construct($couponCode)
|
||||
{
|
||||
$message = Translator::getInstance()->trans('Maximum usage count reached for coupon %code', ['%code' => $couponCode ]);
|
||||
|
||||
Tlog::getInstance()->addWarning($message);
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,11 @@ use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\Base\LangQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Module;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
/**
|
||||
* Allow to build a form Coupon
|
||||
@@ -36,6 +40,33 @@ class CouponCreationForm extends BaseForm
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
// Create countries and shipping modules list
|
||||
$countries = [0 => ' '];
|
||||
|
||||
$list = CountryQuery::create()->find();
|
||||
|
||||
/** @var Country $item */
|
||||
foreach ($list as $item) {
|
||||
$countries[$item->getId()] = $item->getTitle();
|
||||
}
|
||||
|
||||
asort($countries);
|
||||
|
||||
$countries[0] = Translator::getInstance()->trans("All countries");
|
||||
|
||||
$modules = [0 => ' '];
|
||||
|
||||
$list = ModuleQuery::create()->filterByActivate(BaseModule::IS_ACTIVATED)->filterByType(BaseModule::DELIVERY_MODULE_TYPE)->find();
|
||||
|
||||
/** @var Module $item */
|
||||
foreach ($list as $item) {
|
||||
$modules[$item->getId()] = $item->getTitle();
|
||||
}
|
||||
|
||||
asort($modules);
|
||||
|
||||
$modules[0] = Translator::getInstance()->trans("All shipping methods");
|
||||
|
||||
$this->formBuilder
|
||||
->add(
|
||||
'code',
|
||||
@@ -116,6 +147,22 @@ class CouponCreationForm extends BaseForm
|
||||
'text',
|
||||
array()
|
||||
)
|
||||
->add(
|
||||
'freeShippingForCountries',
|
||||
'choice',
|
||||
array(
|
||||
'multiple' => true,
|
||||
'choices' => $countries
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'freeShippingForModules',
|
||||
'choice',
|
||||
array(
|
||||
'multiple' => true,
|
||||
'choices' => $modules
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'isAvailableOnSpecialOffers',
|
||||
'text',
|
||||
@@ -131,6 +178,18 @@ class CouponCreationForm extends BaseForm
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'perCustomerUsageCount',
|
||||
'choice',
|
||||
array(
|
||||
'multiple' => false,
|
||||
'required' => true,
|
||||
'choices' => [
|
||||
1 => Translator::getInstance()->trans('Per customer'),
|
||||
0 => Translator::getInstance()->trans('Overall')
|
||||
]
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'locale',
|
||||
'hidden',
|
||||
|
||||
@@ -17,7 +17,7 @@ use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\Base\CustomerQuery;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
|
||||
/**
|
||||
* Class CustomerLogin
|
||||
|
||||
@@ -110,7 +110,7 @@ class LangCreateForm extends BaseForm
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Sets the number of decimal points'),
|
||||
'label' => Translator::getInstance()->trans('Decimal places'),
|
||||
'label_attr' => array(
|
||||
'for' => 'decimals'
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,14 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation
|
||||
* @method ChildCountryQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation
|
||||
*
|
||||
* @method ChildCountryQuery leftJoinCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCountryQuery rightJoinCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCountryQuery innerJoinCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @method ChildCountryQuery 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
|
||||
@@ -807,6 +815,152 @@ abstract class CountryQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponCountry object
|
||||
*
|
||||
* @param \Thelia\Model\CouponCountry|ObjectCollection $couponCountry the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponCountry($couponCountry, $comparison = null)
|
||||
{
|
||||
if ($couponCountry instanceof \Thelia\Model\CouponCountry) {
|
||||
return $this
|
||||
->addUsingAlias(CountryTableMap::ID, $couponCountry->getCountryId(), $comparison);
|
||||
} elseif ($couponCountry instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByPrimaryKeys($couponCountry->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponCountry() only accepts arguments of type \Thelia\Model\CouponCountry or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponCountry');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'CouponCountry');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponCountry relation CouponCountry object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CouponCountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponCountry', '\Thelia\Model\CouponCountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\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
|
||||
*
|
||||
@@ -880,6 +1034,40 @@ abstract class CountryQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'CountryI18n', '\Thelia\Model\CountryI18nQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Coupon object
|
||||
* using the coupon_country table as cross reference
|
||||
*
|
||||
* @param Coupon $coupon the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByCoupon($coupon, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1268
core/lib/Thelia/Model/Base/CouponCountry.php
Normal file
1268
core/lib/Thelia/Model/Base/CouponCountry.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/CouponCountryQuery.php
Normal file
568
core/lib/Thelia/Model/Base/CouponCountryQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\CouponCountry as ChildCouponCountry;
|
||||
use Thelia\Model\CouponCountryQuery as ChildCouponCountryQuery;
|
||||
use Thelia\Model\Map\CouponCountryTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'coupon_country' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildCouponCountryQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
|
||||
* @method ChildCouponCountryQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column
|
||||
*
|
||||
* @method ChildCouponCountryQuery groupByCouponId() Group by the coupon_id column
|
||||
* @method ChildCouponCountryQuery groupByCountryId() Group by the country_id column
|
||||
*
|
||||
* @method ChildCouponCountryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildCouponCountryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCouponCountryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCouponCountryQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
|
||||
* @method ChildCouponCountryQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
|
||||
* @method ChildCouponCountryQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @method ChildCouponCountryQuery leftJoinCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponCountryQuery rightJoinCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponCountryQuery innerJoinCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @method ChildCouponCountry findOne(ConnectionInterface $con = null) Return the first ChildCouponCountry matching the query
|
||||
* @method ChildCouponCountry findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCouponCountry matching the query, or a new ChildCouponCountry object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildCouponCountry findOneByCouponId(int $coupon_id) Return the first ChildCouponCountry filtered by the coupon_id column
|
||||
* @method ChildCouponCountry findOneByCountryId(int $country_id) Return the first ChildCouponCountry filtered by the country_id column
|
||||
*
|
||||
* @method array findByCouponId(int $coupon_id) Return ChildCouponCountry objects filtered by the coupon_id column
|
||||
* @method array findByCountryId(int $country_id) Return ChildCouponCountry objects filtered by the country_id column
|
||||
*
|
||||
*/
|
||||
abstract class CouponCountryQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\CouponCountryQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\CouponCountry', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildCouponCountryQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildCouponCountryQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\CouponCountryQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\CouponCountryQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param array[$coupon_id, $country_id] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildCouponCountry|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = CouponCountryTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(CouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildCouponCountry A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `COUPON_ID`, `COUNTRY_ID` FROM `coupon_country` WHERE `COUPON_ID` = :p0 AND `COUNTRY_ID` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildCouponCountry();
|
||||
$obj->hydrate($row);
|
||||
CouponCountryTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildCouponCountry|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return $this->add(null, '1<>1', Criteria::CUSTOM);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$cton0 = $this->getNewCriterion(CouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(CouponCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the coupon_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
|
||||
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
|
||||
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCoupon()
|
||||
*
|
||||
* @param mixed $couponId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponId($couponId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($couponId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($couponId['min'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($couponId['max'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponCountryTableMap::COUPON_ID, $couponId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the country_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCountryId(1234); // WHERE country_id = 1234
|
||||
* $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
|
||||
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCountry()
|
||||
*
|
||||
* @param mixed $countryId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountryId($countryId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($countryId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($countryId['min'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($countryId['max'])) {
|
||||
$this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $countryId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Country object
|
||||
*
|
||||
* @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountry($country, $comparison = null)
|
||||
{
|
||||
if ($country instanceof \Thelia\Model\Country) {
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $country->getId(), $comparison);
|
||||
} elseif ($country instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Country');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Country');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Country relation Country object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Coupon object
|
||||
*
|
||||
* @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = null)
|
||||
{
|
||||
if ($coupon instanceof \Thelia\Model\Coupon) {
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUPON_ID, $coupon->getId(), $comparison);
|
||||
} elseif ($coupon instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponCountryTableMap::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Coupon');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Coupon');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Coupon relation Coupon object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCoupon($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildCouponCountry $couponCountry Object to remove from the list of results
|
||||
*
|
||||
* @return ChildCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($couponCountry = null)
|
||||
{
|
||||
if ($couponCountry) {
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(CouponCountryTableMap::COUPON_ID), $couponCountry->getCouponId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(CouponCountryTableMap::COUNTRY_ID), $couponCountry->getCountryId(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_country table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(CouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
CouponCountryTableMap::clearInstancePool();
|
||||
CouponCountryTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildCouponCountry or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildCouponCountry object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(CouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(CouponCountryTableMap::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
CouponCountryTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
CouponCountryTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // CouponCountryQuery
|
||||
1341
core/lib/Thelia/Model/Base/CouponCustomerCount.php
Normal file
1341
core/lib/Thelia/Model/Base/CouponCustomerCount.php
Normal file
File diff suppressed because it is too large
Load Diff
521
core/lib/Thelia/Model/Base/CouponCustomerCountQuery.php
Normal file
521
core/lib/Thelia/Model/Base/CouponCustomerCountQuery.php
Normal file
@@ -0,0 +1,521 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
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\CouponCustomerCount as ChildCouponCustomerCount;
|
||||
use Thelia\Model\CouponCustomerCountQuery as ChildCouponCustomerCountQuery;
|
||||
use Thelia\Model\Map\CouponCustomerCountTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'coupon_customer_count' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildCouponCustomerCountQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
|
||||
* @method ChildCouponCustomerCountQuery orderByCustomerId($order = Criteria::ASC) Order by the customer_id column
|
||||
* @method ChildCouponCustomerCountQuery orderByCount($order = Criteria::ASC) Order by the count column
|
||||
*
|
||||
* @method ChildCouponCustomerCountQuery groupByCouponId() Group by the coupon_id column
|
||||
* @method ChildCouponCustomerCountQuery groupByCustomerId() Group by the customer_id column
|
||||
* @method ChildCouponCustomerCountQuery groupByCount() Group by the count column
|
||||
*
|
||||
* @method ChildCouponCustomerCountQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildCouponCustomerCountQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCouponCustomerCountQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCouponCustomerCountQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation
|
||||
* @method ChildCouponCustomerCountQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation
|
||||
* @method ChildCouponCustomerCountQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation
|
||||
*
|
||||
* @method ChildCouponCustomerCountQuery leftJoinCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponCustomerCountQuery rightJoinCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponCustomerCountQuery innerJoinCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @method ChildCouponCustomerCount findOne(ConnectionInterface $con = null) Return the first ChildCouponCustomerCount matching the query
|
||||
* @method ChildCouponCustomerCount findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCouponCustomerCount matching the query, or a new ChildCouponCustomerCount object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildCouponCustomerCount findOneByCouponId(int $coupon_id) Return the first ChildCouponCustomerCount filtered by the coupon_id column
|
||||
* @method ChildCouponCustomerCount findOneByCustomerId(int $customer_id) Return the first ChildCouponCustomerCount filtered by the customer_id column
|
||||
* @method ChildCouponCustomerCount findOneByCount(int $count) Return the first ChildCouponCustomerCount filtered by the count column
|
||||
*
|
||||
* @method array findByCouponId(int $coupon_id) Return ChildCouponCustomerCount objects filtered by the coupon_id column
|
||||
* @method array findByCustomerId(int $customer_id) Return ChildCouponCustomerCount objects filtered by the customer_id column
|
||||
* @method array findByCount(int $count) Return ChildCouponCustomerCount objects filtered by the count column
|
||||
*
|
||||
*/
|
||||
abstract class CouponCustomerCountQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\CouponCustomerCountQuery 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\\CouponCustomerCount', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildCouponCustomerCountQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\CouponCustomerCountQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\CouponCustomerCountQuery();
|
||||
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(12, $con);
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildCouponCustomerCount|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
throw new \LogicException('The ChildCouponCustomerCount class has no primary key');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
throw new \LogicException('The ChildCouponCustomerCount class has no primary key');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
throw new \LogicException('The ChildCouponCustomerCount class has no primary key');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
throw new \LogicException('The ChildCouponCustomerCount class has no primary key');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the coupon_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
|
||||
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
|
||||
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCoupon()
|
||||
*
|
||||
* @param mixed $couponId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery 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(CouponCustomerCountTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($couponId['max'])) {
|
||||
$this->addUsingAlias(CouponCustomerCountTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponCustomerCountTableMap::COUPON_ID, $couponId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the customer_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCustomerId(1234); // WHERE customer_id = 1234
|
||||
* $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
|
||||
* $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCustomer()
|
||||
*
|
||||
* @param mixed $customerId 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 ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCustomerId($customerId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($customerId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($customerId['min'])) {
|
||||
$this->addUsingAlias(CouponCustomerCountTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($customerId['max'])) {
|
||||
$this->addUsingAlias(CouponCustomerCountTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponCustomerCountTableMap::CUSTOMER_ID, $customerId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the count column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCount(1234); // WHERE count = 1234
|
||||
* $query->filterByCount(array(12, 34)); // WHERE count IN (12, 34)
|
||||
* $query->filterByCount(array('min' => 12)); // WHERE count > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $count 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 ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCount($count = null, $comparison = null)
|
||||
{
|
||||
if (is_array($count)) {
|
||||
$useMinMax = false;
|
||||
if (isset($count['min'])) {
|
||||
$this->addUsingAlias(CouponCustomerCountTableMap::COUNT, $count['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($count['max'])) {
|
||||
$this->addUsingAlias(CouponCustomerCountTableMap::COUNT, $count['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponCustomerCountTableMap::COUNT, $count, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Customer object
|
||||
*
|
||||
* @param \Thelia\Model\Customer|ObjectCollection $customer The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCustomer($customer, $comparison = null)
|
||||
{
|
||||
if ($customer instanceof \Thelia\Model\Customer) {
|
||||
return $this
|
||||
->addUsingAlias(CouponCustomerCountTableMap::CUSTOMER_ID, $customer->getId(), $comparison);
|
||||
} elseif ($customer instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponCustomerCountTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Customer relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Customer');
|
||||
|
||||
// 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, 'Customer');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Customer relation Customer 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\CustomerQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCustomer($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Coupon object
|
||||
*
|
||||
* @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = null)
|
||||
{
|
||||
if ($coupon instanceof \Thelia\Model\Coupon) {
|
||||
return $this
|
||||
->addUsingAlias(CouponCustomerCountTableMap::COUPON_ID, $coupon->getId(), $comparison);
|
||||
} elseif ($coupon instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponCustomerCountTableMap::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Coupon');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Coupon');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Coupon relation Coupon object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCoupon($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildCouponCustomerCount $couponCustomerCount Object to remove from the list of results
|
||||
*
|
||||
* @return ChildCouponCustomerCountQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($couponCustomerCount = null)
|
||||
{
|
||||
if ($couponCustomerCount) {
|
||||
throw new \LogicException('ChildCouponCustomerCount class has no primary key');
|
||||
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_customer_count 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(CouponCustomerCountTableMap::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).
|
||||
CouponCustomerCountTableMap::clearInstancePool();
|
||||
CouponCustomerCountTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildCouponCustomerCount or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildCouponCustomerCount 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(CouponCustomerCountTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(CouponCustomerCountTableMap::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();
|
||||
|
||||
|
||||
CouponCustomerCountTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
CouponCustomerCountTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // CouponCustomerCountQuery
|
||||
1268
core/lib/Thelia/Model/Base/CouponModule.php
Normal file
1268
core/lib/Thelia/Model/Base/CouponModule.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/CouponModuleQuery.php
Normal file
568
core/lib/Thelia/Model/Base/CouponModuleQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\CouponModule as ChildCouponModule;
|
||||
use Thelia\Model\CouponModuleQuery as ChildCouponModuleQuery;
|
||||
use Thelia\Model\Map\CouponModuleTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'coupon_module' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildCouponModuleQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
|
||||
* @method ChildCouponModuleQuery orderByModuleId($order = Criteria::ASC) Order by the module_id column
|
||||
*
|
||||
* @method ChildCouponModuleQuery groupByCouponId() Group by the coupon_id column
|
||||
* @method ChildCouponModuleQuery groupByModuleId() Group by the module_id column
|
||||
*
|
||||
* @method ChildCouponModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildCouponModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCouponModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCouponModuleQuery leftJoinCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponModuleQuery rightJoinCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Coupon relation
|
||||
* @method ChildCouponModuleQuery innerJoinCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @method ChildCouponModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation
|
||||
* @method ChildCouponModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation
|
||||
* @method ChildCouponModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @method ChildCouponModule findOne(ConnectionInterface $con = null) Return the first ChildCouponModule matching the query
|
||||
* @method ChildCouponModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCouponModule matching the query, or a new ChildCouponModule object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildCouponModule findOneByCouponId(int $coupon_id) Return the first ChildCouponModule filtered by the coupon_id column
|
||||
* @method ChildCouponModule findOneByModuleId(int $module_id) Return the first ChildCouponModule filtered by the module_id column
|
||||
*
|
||||
* @method array findByCouponId(int $coupon_id) Return ChildCouponModule objects filtered by the coupon_id column
|
||||
* @method array findByModuleId(int $module_id) Return ChildCouponModule objects filtered by the module_id column
|
||||
*
|
||||
*/
|
||||
abstract class CouponModuleQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\CouponModuleQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\CouponModule', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildCouponModuleQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildCouponModuleQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\CouponModuleQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\CouponModuleQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param array[$coupon_id, $module_id] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildCouponModule|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = CouponModuleTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(CouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildCouponModule A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `COUPON_ID`, `MODULE_ID` FROM `coupon_module` WHERE `COUPON_ID` = :p0 AND `MODULE_ID` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildCouponModule();
|
||||
$obj->hydrate($row);
|
||||
CouponModuleTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildCouponModule|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $key[1], Criteria::EQUAL);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return $this->add(null, '1<>1', Criteria::CUSTOM);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$cton0 = $this->getNewCriterion(CouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(CouponModuleTableMap::MODULE_ID, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the coupon_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
|
||||
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
|
||||
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCoupon()
|
||||
*
|
||||
* @param mixed $couponId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponId($couponId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($couponId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($couponId['min'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($couponId['max'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponModuleTableMap::COUPON_ID, $couponId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the module_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByModuleId(1234); // WHERE module_id = 1234
|
||||
* $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34)
|
||||
* $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByModule()
|
||||
*
|
||||
* @param mixed $moduleId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModuleId($moduleId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($moduleId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($moduleId['min'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($moduleId['max'])) {
|
||||
$this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponModuleTableMap::MODULE_ID, $moduleId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Coupon object
|
||||
*
|
||||
* @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = null)
|
||||
{
|
||||
if ($coupon instanceof \Thelia\Model\Coupon) {
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::COUPON_ID, $coupon->getId(), $comparison);
|
||||
} elseif ($coupon instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Coupon relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Coupon');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Coupon');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Coupon relation Coupon object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCoupon($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Module object
|
||||
*
|
||||
* @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModule($module, $comparison = null)
|
||||
{
|
||||
if ($module instanceof \Thelia\Model\Module) {
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::MODULE_ID, $module->getId(), $comparison);
|
||||
} elseif ($module instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CouponModuleTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Module');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Module');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Module relation Module object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildCouponModule $couponModule Object to remove from the list of results
|
||||
*
|
||||
* @return ChildCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($couponModule = null)
|
||||
{
|
||||
if ($couponModule) {
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(CouponModuleTableMap::COUPON_ID), $couponModule->getCouponId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(CouponModuleTableMap::MODULE_ID), $couponModule->getModuleId(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_module table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(CouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
CouponModuleTableMap::clearInstancePool();
|
||||
CouponModuleTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildCouponModule or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildCouponModule object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(CouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(CouponModuleTableMap::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
CouponModuleTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
CouponModuleTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // CouponModuleQuery
|
||||
@@ -34,6 +34,7 @@ use Thelia\Model\Map\CouponTableMap;
|
||||
* @method ChildCouponQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column
|
||||
* @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column
|
||||
* @method ChildCouponQuery orderBySerializedConditions($order = Criteria::ASC) Order by the serialized_conditions column
|
||||
* @method ChildCouponQuery orderByPerCustomerUsageCount($order = Criteria::ASC) Order by the per_customer_usage_count column
|
||||
* @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
* @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column
|
||||
@@ -50,6 +51,7 @@ use Thelia\Model\Map\CouponTableMap;
|
||||
* @method ChildCouponQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column
|
||||
* @method ChildCouponQuery groupByIsUsed() Group by the is_used column
|
||||
* @method ChildCouponQuery groupBySerializedConditions() Group by the serialized_conditions column
|
||||
* @method ChildCouponQuery groupByPerCustomerUsageCount() Group by the per_customer_usage_count column
|
||||
* @method ChildCouponQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column
|
||||
* @method ChildCouponQuery groupByVersion() Group by the version column
|
||||
@@ -58,6 +60,18 @@ use Thelia\Model\Map\CouponTableMap;
|
||||
* @method ChildCouponQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCouponQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCouponQuery leftJoinCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCouponQuery rightJoinCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCouponQuery innerJoinCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @method ChildCouponQuery leftJoinCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildCouponQuery rightJoinCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildCouponQuery innerJoinCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @method ChildCouponQuery leftJoinCouponCustomerCount($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponCustomerCount relation
|
||||
* @method ChildCouponQuery rightJoinCouponCustomerCount($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCustomerCount relation
|
||||
* @method ChildCouponQuery innerJoinCouponCustomerCount($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCustomerCount relation
|
||||
*
|
||||
* @method ChildCouponQuery leftJoinCouponI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponI18n relation
|
||||
* @method ChildCouponQuery rightJoinCouponI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponI18n relation
|
||||
* @method ChildCouponQuery innerJoinCouponI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponI18n relation
|
||||
@@ -81,6 +95,7 @@ use Thelia\Model\Map\CouponTableMap;
|
||||
* @method ChildCoupon findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCoupon filtered by the is_available_on_special_offers column
|
||||
* @method ChildCoupon findOneByIsUsed(boolean $is_used) Return the first ChildCoupon filtered by the is_used column
|
||||
* @method ChildCoupon findOneBySerializedConditions(string $serialized_conditions) Return the first ChildCoupon filtered by the serialized_conditions column
|
||||
* @method ChildCoupon findOneByPerCustomerUsageCount(boolean $per_customer_usage_count) Return the first ChildCoupon filtered by the per_customer_usage_count column
|
||||
* @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column
|
||||
* @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column
|
||||
* @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column
|
||||
@@ -97,6 +112,7 @@ use Thelia\Model\Map\CouponTableMap;
|
||||
* @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCoupon objects filtered by the is_available_on_special_offers column
|
||||
* @method array findByIsUsed(boolean $is_used) Return ChildCoupon objects filtered by the is_used column
|
||||
* @method array findBySerializedConditions(string $serialized_conditions) Return ChildCoupon objects filtered by the serialized_conditions column
|
||||
* @method array findByPerCustomerUsageCount(boolean $per_customer_usage_count) Return ChildCoupon objects filtered by the per_customer_usage_count column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column
|
||||
* @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column
|
||||
@@ -195,7 +211,7 @@ abstract class CouponQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon` WHERE `ID` = :p0';
|
||||
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `PER_CUSTOMER_USAGE_COUNT`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon` WHERE `ID` = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -660,6 +676,33 @@ abstract class CouponQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CouponTableMap::SERIALIZED_CONDITIONS, $serializedConditions, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the per_customer_usage_count column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByPerCustomerUsageCount(true); // WHERE per_customer_usage_count = true
|
||||
* $query->filterByPerCustomerUsageCount('yes'); // WHERE per_customer_usage_count = true
|
||||
* </code>
|
||||
*
|
||||
* @param boolean|string $perCustomerUsageCount The value to use as filter.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPerCustomerUsageCount($perCustomerUsageCount = null, $comparison = null)
|
||||
{
|
||||
if (is_string($perCustomerUsageCount)) {
|
||||
$per_customer_usage_count = in_array(strtolower($perCustomerUsageCount), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponTableMap::PER_CUSTOMER_USAGE_COUNT, $perCustomerUsageCount, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
@@ -787,6 +830,225 @@ abstract class CouponQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CouponTableMap::VERSION, $version, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponCountry object
|
||||
*
|
||||
* @param \Thelia\Model\CouponCountry|ObjectCollection $couponCountry the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponCountry($couponCountry, $comparison = null)
|
||||
{
|
||||
if ($couponCountry instanceof \Thelia\Model\CouponCountry) {
|
||||
return $this
|
||||
->addUsingAlias(CouponTableMap::ID, $couponCountry->getCouponId(), $comparison);
|
||||
} elseif ($couponCountry instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByPrimaryKeys($couponCountry->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponCountry() only accepts arguments of type \Thelia\Model\CouponCountry or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponCountry');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'CouponCountry');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponCountry relation CouponCountry object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CouponCountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponCountry', '\Thelia\Model\CouponCountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponModule object
|
||||
*
|
||||
* @param \Thelia\Model\CouponModule|ObjectCollection $couponModule the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponModule($couponModule, $comparison = null)
|
||||
{
|
||||
if ($couponModule instanceof \Thelia\Model\CouponModule) {
|
||||
return $this
|
||||
->addUsingAlias(CouponTableMap::ID, $couponModule->getCouponId(), $comparison);
|
||||
} elseif ($couponModule instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByPrimaryKeys($couponModule->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponModule() only accepts arguments of type \Thelia\Model\CouponModule or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponModule');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'CouponModule');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponModule relation CouponModule object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CouponModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponModule', '\Thelia\Model\CouponModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponCustomerCount object
|
||||
*
|
||||
* @param \Thelia\Model\CouponCustomerCount|ObjectCollection $couponCustomerCount the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponCustomerCount($couponCustomerCount, $comparison = null)
|
||||
{
|
||||
if ($couponCustomerCount instanceof \Thelia\Model\CouponCustomerCount) {
|
||||
return $this
|
||||
->addUsingAlias(CouponTableMap::ID, $couponCustomerCount->getCouponId(), $comparison);
|
||||
} elseif ($couponCustomerCount instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponCustomerCountQuery()
|
||||
->filterByPrimaryKeys($couponCustomerCount->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponCustomerCount() only accepts arguments of type \Thelia\Model\CouponCustomerCount or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponCustomerCount relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponCustomerCount($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponCustomerCount');
|
||||
|
||||
// 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, 'CouponCustomerCount');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponCustomerCount relation CouponCustomerCount 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\CouponCustomerCountQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponCustomerCountQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponCustomerCount($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponCustomerCount', '\Thelia\Model\CouponCustomerCountQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponI18n object
|
||||
*
|
||||
@@ -933,6 +1195,57 @@ abstract class CouponQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponVersion', '\Thelia\Model\CouponVersionQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Country object
|
||||
* using the coupon_country table as cross reference
|
||||
*
|
||||
* @param Country $country the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountry($country, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponCountryQuery()
|
||||
->filterByCountry($country, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Module object
|
||||
* using the coupon_module table as cross reference
|
||||
*
|
||||
* @param Module $module the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModule($module, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByModule($module, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Customer object
|
||||
* using the coupon_customer_count table as cross reference
|
||||
*
|
||||
* @param Customer $customer the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCustomer($customer, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponCustomerCountQuery()
|
||||
->filterByCustomer($customer, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
@@ -127,6 +127,12 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
*/
|
||||
protected $serialized_conditions;
|
||||
|
||||
/**
|
||||
* The value for the per_customer_usage_count field.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $per_customer_usage_count;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
@@ -571,6 +577,17 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
return $this->serialized_conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [per_customer_usage_count] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPerCustomerUsageCount()
|
||||
{
|
||||
|
||||
return $this->per_customer_usage_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
@@ -918,6 +935,35 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setSerializedConditions()
|
||||
|
||||
/**
|
||||
* Sets the value of the [per_customer_usage_count] column.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
*
|
||||
* @param boolean|integer|string $v The new value
|
||||
* @return \Thelia\Model\CouponVersion The current object (for fluent API support)
|
||||
*/
|
||||
public function setPerCustomerUsageCount($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
if (is_string($v)) {
|
||||
$v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
} else {
|
||||
$v = (boolean) $v;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->per_customer_usage_count !== $v) {
|
||||
$this->per_customer_usage_count = $v;
|
||||
$this->modifiedColumns[CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT] = true;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setPerCustomerUsageCount()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
@@ -1061,19 +1107,22 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('SerializedConditions', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->serialized_conditions = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('PerCustomerUsageCount', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->per_customer_usage_count = (null !== $col) ? (boolean) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CouponVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->version = (null !== $col) ? (int) $col : null;
|
||||
$this->resetModified();
|
||||
|
||||
@@ -1083,7 +1132,7 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 15; // 15 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 16; // 16 = CouponVersionTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\CouponVersion object", 0, $e);
|
||||
@@ -1340,6 +1389,9 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) {
|
||||
$modifiedColumns[':p' . $index++] = '`SERIALIZED_CONDITIONS`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT)) {
|
||||
$modifiedColumns[':p' . $index++] = '`PER_CUSTOMER_USAGE_COUNT`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = '`CREATED_AT`';
|
||||
}
|
||||
@@ -1396,6 +1448,9 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
case '`SERIALIZED_CONDITIONS`':
|
||||
$stmt->bindValue($identifier, $this->serialized_conditions, PDO::PARAM_STR);
|
||||
break;
|
||||
case '`PER_CUSTOMER_USAGE_COUNT`':
|
||||
$stmt->bindValue($identifier, (int) $this->per_customer_usage_count, PDO::PARAM_INT);
|
||||
break;
|
||||
case '`CREATED_AT`':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
@@ -1497,12 +1552,15 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
return $this->getSerializedConditions();
|
||||
break;
|
||||
case 12:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getPerCustomerUsageCount();
|
||||
break;
|
||||
case 13:
|
||||
return $this->getUpdatedAt();
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 14:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
case 15:
|
||||
return $this->getVersion();
|
||||
break;
|
||||
default:
|
||||
@@ -1546,9 +1604,10 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
$keys[9] => $this->getIsAvailableOnSpecialOffers(),
|
||||
$keys[10] => $this->getIsUsed(),
|
||||
$keys[11] => $this->getSerializedConditions(),
|
||||
$keys[12] => $this->getCreatedAt(),
|
||||
$keys[13] => $this->getUpdatedAt(),
|
||||
$keys[14] => $this->getVersion(),
|
||||
$keys[12] => $this->getPerCustomerUsageCount(),
|
||||
$keys[13] => $this->getCreatedAt(),
|
||||
$keys[14] => $this->getUpdatedAt(),
|
||||
$keys[15] => $this->getVersion(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach ($virtualColumns as $key => $virtualColumn) {
|
||||
@@ -1630,12 +1689,15 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
$this->setSerializedConditions($value);
|
||||
break;
|
||||
case 12:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setPerCustomerUsageCount($value);
|
||||
break;
|
||||
case 13:
|
||||
$this->setUpdatedAt($value);
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 14:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
case 15:
|
||||
$this->setVersion($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1674,9 +1736,10 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[9], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[10], $arr)) $this->setIsUsed($arr[$keys[10]]);
|
||||
if (array_key_exists($keys[11], $arr)) $this->setSerializedConditions($arr[$keys[11]]);
|
||||
if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
|
||||
if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
|
||||
if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
|
||||
if (array_key_exists($keys[12], $arr)) $this->setPerCustomerUsageCount($arr[$keys[12]]);
|
||||
if (array_key_exists($keys[13], $arr)) $this->setCreatedAt($arr[$keys[13]]);
|
||||
if (array_key_exists($keys[14], $arr)) $this->setUpdatedAt($arr[$keys[14]]);
|
||||
if (array_key_exists($keys[15], $arr)) $this->setVersion($arr[$keys[15]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1700,6 +1763,7 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers);
|
||||
if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used);
|
||||
if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) $criteria->add(CouponVersionTableMap::SERIALIZED_CONDITIONS, $this->serialized_conditions);
|
||||
if ($this->isColumnModified(CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT)) $criteria->add(CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT, $this->per_customer_usage_count);
|
||||
if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) $criteria->add(CouponVersionTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) $criteria->add(CouponVersionTableMap::UPDATED_AT, $this->updated_at);
|
||||
if ($this->isColumnModified(CouponVersionTableMap::VERSION)) $criteria->add(CouponVersionTableMap::VERSION, $this->version);
|
||||
@@ -1785,6 +1849,7 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
$copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers());
|
||||
$copyObj->setIsUsed($this->getIsUsed());
|
||||
$copyObj->setSerializedConditions($this->getSerializedConditions());
|
||||
$copyObj->setPerCustomerUsageCount($this->getPerCustomerUsageCount());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
$copyObj->setVersion($this->getVersion());
|
||||
@@ -1883,6 +1948,7 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
$this->is_available_on_special_offers = null;
|
||||
$this->is_used = null;
|
||||
$this->serialized_conditions = null;
|
||||
$this->per_customer_usage_count = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->version = null;
|
||||
|
||||
@@ -33,6 +33,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
|
||||
* @method ChildCouponVersionQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column
|
||||
* @method ChildCouponVersionQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column
|
||||
* @method ChildCouponVersionQuery orderBySerializedConditions($order = Criteria::ASC) Order by the serialized_conditions column
|
||||
* @method ChildCouponVersionQuery orderByPerCustomerUsageCount($order = Criteria::ASC) Order by the per_customer_usage_count column
|
||||
* @method ChildCouponVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildCouponVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
* @method ChildCouponVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column
|
||||
@@ -49,6 +50,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
|
||||
* @method ChildCouponVersionQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column
|
||||
* @method ChildCouponVersionQuery groupByIsUsed() Group by the is_used column
|
||||
* @method ChildCouponVersionQuery groupBySerializedConditions() Group by the serialized_conditions column
|
||||
* @method ChildCouponVersionQuery groupByPerCustomerUsageCount() Group by the per_customer_usage_count column
|
||||
* @method ChildCouponVersionQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildCouponVersionQuery groupByUpdatedAt() Group by the updated_at column
|
||||
* @method ChildCouponVersionQuery groupByVersion() Group by the version column
|
||||
@@ -76,6 +78,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
|
||||
* @method ChildCouponVersion findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCouponVersion filtered by the is_available_on_special_offers column
|
||||
* @method ChildCouponVersion findOneByIsUsed(boolean $is_used) Return the first ChildCouponVersion filtered by the is_used column
|
||||
* @method ChildCouponVersion findOneBySerializedConditions(string $serialized_conditions) Return the first ChildCouponVersion filtered by the serialized_conditions column
|
||||
* @method ChildCouponVersion findOneByPerCustomerUsageCount(boolean $per_customer_usage_count) Return the first ChildCouponVersion filtered by the per_customer_usage_count column
|
||||
* @method ChildCouponVersion findOneByCreatedAt(string $created_at) Return the first ChildCouponVersion filtered by the created_at column
|
||||
* @method ChildCouponVersion findOneByUpdatedAt(string $updated_at) Return the first ChildCouponVersion filtered by the updated_at column
|
||||
* @method ChildCouponVersion findOneByVersion(int $version) Return the first ChildCouponVersion filtered by the version column
|
||||
@@ -92,6 +95,7 @@ use Thelia\Model\Map\CouponVersionTableMap;
|
||||
* @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCouponVersion objects filtered by the is_available_on_special_offers column
|
||||
* @method array findByIsUsed(boolean $is_used) Return ChildCouponVersion objects filtered by the is_used column
|
||||
* @method array findBySerializedConditions(string $serialized_conditions) Return ChildCouponVersion objects filtered by the serialized_conditions column
|
||||
* @method array findByPerCustomerUsageCount(boolean $per_customer_usage_count) Return ChildCouponVersion objects filtered by the per_customer_usage_count column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCouponVersion objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildCouponVersion objects filtered by the updated_at column
|
||||
* @method array findByVersion(int $version) Return ChildCouponVersion objects filtered by the version column
|
||||
@@ -183,7 +187,7 @@ abstract class CouponVersionQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
|
||||
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `PER_CUSTOMER_USAGE_COUNT`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
@@ -662,6 +666,33 @@ abstract class CouponVersionQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_CONDITIONS, $serializedConditions, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the per_customer_usage_count column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByPerCustomerUsageCount(true); // WHERE per_customer_usage_count = true
|
||||
* $query->filterByPerCustomerUsageCount('yes'); // WHERE per_customer_usage_count = true
|
||||
* </code>
|
||||
*
|
||||
* @param boolean|string $perCustomerUsageCount The value to use as filter.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCouponVersionQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPerCustomerUsageCount($perCustomerUsageCount = null, $comparison = null)
|
||||
{
|
||||
if (is_string($perCustomerUsageCount)) {
|
||||
$per_customer_usage_count = in_array(strtolower($perCustomerUsageCount), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT, $perCustomerUsageCount, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
|
||||
@@ -21,6 +21,10 @@ use Thelia\Model\Address as ChildAddress;
|
||||
use Thelia\Model\AddressQuery as ChildAddressQuery;
|
||||
use Thelia\Model\Cart as ChildCart;
|
||||
use Thelia\Model\CartQuery as ChildCartQuery;
|
||||
use Thelia\Model\Coupon as ChildCoupon;
|
||||
use Thelia\Model\CouponCustomerCount as ChildCouponCustomerCount;
|
||||
use Thelia\Model\CouponCustomerCountQuery as ChildCouponCustomerCountQuery;
|
||||
use Thelia\Model\CouponQuery as ChildCouponQuery;
|
||||
use Thelia\Model\Customer as ChildCustomer;
|
||||
use Thelia\Model\CustomerQuery as ChildCustomerQuery;
|
||||
use Thelia\Model\CustomerTitle as ChildCustomerTitle;
|
||||
@@ -182,6 +186,17 @@ abstract class Customer implements ActiveRecordInterface
|
||||
protected $collCarts;
|
||||
protected $collCartsPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCouponCustomerCount[] Collection to store aggregation of ChildCouponCustomerCount objects.
|
||||
*/
|
||||
protected $collCouponCustomerCounts;
|
||||
protected $collCouponCustomerCountsPartial;
|
||||
|
||||
/**
|
||||
* @var ChildCoupon[] Collection to store aggregation of ChildCoupon objects.
|
||||
*/
|
||||
protected $collCoupons;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -190,6 +205,12 @@ abstract class Customer implements ActiveRecordInterface
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $couponsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -208,6 +229,12 @@ abstract class Customer implements ActiveRecordInterface
|
||||
*/
|
||||
protected $cartsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $couponCustomerCountsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\Customer object.
|
||||
*/
|
||||
@@ -1169,6 +1196,9 @@ abstract class Customer implements ActiveRecordInterface
|
||||
|
||||
$this->collCarts = null;
|
||||
|
||||
$this->collCouponCustomerCounts = null;
|
||||
|
||||
$this->collCoupons = null;
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -1314,6 +1344,33 @@ abstract class Customer implements ActiveRecordInterface
|
||||
$this->resetModified();
|
||||
}
|
||||
|
||||
if ($this->couponsScheduledForDeletion !== null) {
|
||||
if (!$this->couponsScheduledForDeletion->isEmpty()) {
|
||||
$pks = array();
|
||||
$pk = $this->getPrimaryKey();
|
||||
foreach ($this->couponsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
|
||||
$pks[] = array($pk, $remotePk);
|
||||
}
|
||||
|
||||
CouponCustomerCountQuery::create()
|
||||
->filterByPrimaryKeys($pks)
|
||||
->delete($con);
|
||||
$this->couponsScheduledForDeletion = null;
|
||||
}
|
||||
|
||||
foreach ($this->getCoupons() as $coupon) {
|
||||
if ($coupon->isModified()) {
|
||||
$coupon->save($con);
|
||||
}
|
||||
}
|
||||
} elseif ($this->collCoupons) {
|
||||
foreach ($this->collCoupons as $coupon) {
|
||||
if ($coupon->isModified()) {
|
||||
$coupon->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->addressesScheduledForDeletion !== null) {
|
||||
if (!$this->addressesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\AddressQuery::create()
|
||||
@@ -1365,6 +1422,23 @@ abstract class Customer implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->couponCustomerCountsScheduledForDeletion !== null) {
|
||||
if (!$this->couponCustomerCountsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CouponCustomerCountQuery::create()
|
||||
->filterByPrimaryKeys($this->couponCustomerCountsScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->couponCustomerCountsScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCouponCustomerCounts !== null) {
|
||||
foreach ($this->collCouponCustomerCounts as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
}
|
||||
@@ -1672,6 +1746,9 @@ abstract class Customer implements ActiveRecordInterface
|
||||
if (null !== $this->collCarts) {
|
||||
$result['Carts'] = $this->collCarts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCouponCustomerCounts) {
|
||||
$result['CouponCustomerCounts'] = $this->collCouponCustomerCounts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -1923,6 +2000,12 @@ abstract class Customer implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCouponCustomerCounts() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCouponCustomerCount($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
} // if ($deepCopy)
|
||||
|
||||
if ($makeNew) {
|
||||
@@ -2024,6 +2107,9 @@ abstract class Customer implements ActiveRecordInterface
|
||||
if ('Cart' == $relationName) {
|
||||
return $this->initCarts();
|
||||
}
|
||||
if ('CouponCustomerCount' == $relationName) {
|
||||
return $this->initCouponCustomerCounts();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2980,6 +3066,432 @@ abstract class Customer implements ActiveRecordInterface
|
||||
return $this->getCarts($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCouponCustomerCounts 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 addCouponCustomerCounts()
|
||||
*/
|
||||
public function clearCouponCustomerCounts()
|
||||
{
|
||||
$this->collCouponCustomerCounts = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCouponCustomerCounts collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCouponCustomerCounts($v = true)
|
||||
{
|
||||
$this->collCouponCustomerCountsPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCouponCustomerCounts collection.
|
||||
*
|
||||
* By default this just sets the collCouponCustomerCounts collection to an empty array (like clearcollCouponCustomerCounts());
|
||||
* 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 initCouponCustomerCounts($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCouponCustomerCounts && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCouponCustomerCounts = new ObjectCollection();
|
||||
$this->collCouponCustomerCounts->setModel('\Thelia\Model\CouponCustomerCount');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCouponCustomerCount 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 ChildCustomer 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|ChildCouponCustomerCount[] List of ChildCouponCustomerCount objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCouponCustomerCounts($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCouponCustomerCountsPartial && !$this->isNew();
|
||||
if (null === $this->collCouponCustomerCounts || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCouponCustomerCounts) {
|
||||
// return empty collection
|
||||
$this->initCouponCustomerCounts();
|
||||
} else {
|
||||
$collCouponCustomerCounts = ChildCouponCustomerCountQuery::create(null, $criteria)
|
||||
->filterByCustomer($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCouponCustomerCountsPartial && count($collCouponCustomerCounts)) {
|
||||
$this->initCouponCustomerCounts(false);
|
||||
|
||||
foreach ($collCouponCustomerCounts as $obj) {
|
||||
if (false == $this->collCouponCustomerCounts->contains($obj)) {
|
||||
$this->collCouponCustomerCounts->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCouponCustomerCountsPartial = true;
|
||||
}
|
||||
|
||||
reset($collCouponCustomerCounts);
|
||||
|
||||
return $collCouponCustomerCounts;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCouponCustomerCounts) {
|
||||
foreach ($this->collCouponCustomerCounts as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCouponCustomerCounts[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCouponCustomerCounts = $collCouponCustomerCounts;
|
||||
$this->collCouponCustomerCountsPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCouponCustomerCounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of CouponCustomerCount 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 $couponCustomerCounts A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCustomer The current object (for fluent API support)
|
||||
*/
|
||||
public function setCouponCustomerCounts(Collection $couponCustomerCounts, ConnectionInterface $con = null)
|
||||
{
|
||||
$couponCustomerCountsToDelete = $this->getCouponCustomerCounts(new Criteria(), $con)->diff($couponCustomerCounts);
|
||||
|
||||
|
||||
$this->couponCustomerCountsScheduledForDeletion = $couponCustomerCountsToDelete;
|
||||
|
||||
foreach ($couponCustomerCountsToDelete as $couponCustomerCountRemoved) {
|
||||
$couponCustomerCountRemoved->setCustomer(null);
|
||||
}
|
||||
|
||||
$this->collCouponCustomerCounts = null;
|
||||
foreach ($couponCustomerCounts as $couponCustomerCount) {
|
||||
$this->addCouponCustomerCount($couponCustomerCount);
|
||||
}
|
||||
|
||||
$this->collCouponCustomerCounts = $couponCustomerCounts;
|
||||
$this->collCouponCustomerCountsPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related CouponCustomerCount objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related CouponCustomerCount objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCouponCustomerCounts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCouponCustomerCountsPartial && !$this->isNew();
|
||||
if (null === $this->collCouponCustomerCounts || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCouponCustomerCounts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCouponCustomerCounts());
|
||||
}
|
||||
|
||||
$query = ChildCouponCustomerCountQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCustomer($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCouponCustomerCounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCouponCustomerCount object to this object
|
||||
* through the ChildCouponCustomerCount foreign key attribute.
|
||||
*
|
||||
* @param ChildCouponCustomerCount $l ChildCouponCustomerCount
|
||||
* @return \Thelia\Model\Customer The current object (for fluent API support)
|
||||
*/
|
||||
public function addCouponCustomerCount(ChildCouponCustomerCount $l)
|
||||
{
|
||||
if ($this->collCouponCustomerCounts === null) {
|
||||
$this->initCouponCustomerCounts();
|
||||
$this->collCouponCustomerCountsPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCouponCustomerCounts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCouponCustomerCount($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CouponCustomerCount $couponCustomerCount The couponCustomerCount object to add.
|
||||
*/
|
||||
protected function doAddCouponCustomerCount($couponCustomerCount)
|
||||
{
|
||||
$this->collCouponCustomerCounts[]= $couponCustomerCount;
|
||||
$couponCustomerCount->setCustomer($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CouponCustomerCount $couponCustomerCount The couponCustomerCount object to remove.
|
||||
* @return ChildCustomer The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCouponCustomerCount($couponCustomerCount)
|
||||
{
|
||||
if ($this->getCouponCustomerCounts()->contains($couponCustomerCount)) {
|
||||
$this->collCouponCustomerCounts->remove($this->collCouponCustomerCounts->search($couponCustomerCount));
|
||||
if (null === $this->couponCustomerCountsScheduledForDeletion) {
|
||||
$this->couponCustomerCountsScheduledForDeletion = clone $this->collCouponCustomerCounts;
|
||||
$this->couponCustomerCountsScheduledForDeletion->clear();
|
||||
}
|
||||
$this->couponCustomerCountsScheduledForDeletion[]= clone $couponCustomerCount;
|
||||
$couponCustomerCount->setCustomer(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Customer is new, it will return
|
||||
* an empty collection; or if this Customer has previously
|
||||
* been saved, it will retrieve related CouponCustomerCounts 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 Customer.
|
||||
*
|
||||
* @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|ChildCouponCustomerCount[] List of ChildCouponCustomerCount objects
|
||||
*/
|
||||
public function getCouponCustomerCountsJoinCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCouponCustomerCountQuery::create(null, $criteria);
|
||||
$query->joinWith('Coupon', $joinBehavior);
|
||||
|
||||
return $this->getCouponCustomerCounts($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCoupons collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addCoupons()
|
||||
*/
|
||||
public function clearCoupons()
|
||||
{
|
||||
$this->collCoupons = null; // important to set this to NULL since that means it is uninitialized
|
||||
$this->collCouponsPartial = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCoupons collection.
|
||||
*
|
||||
* By default this just sets the collCoupons collection to an empty collection (like clearCoupons());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initCoupons()
|
||||
{
|
||||
$this->collCoupons = new ObjectCollection();
|
||||
$this->collCoupons->setModel('\Thelia\Model\Coupon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of ChildCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_customer_count 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 ChildCustomer is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return ObjectCollection|ChildCoupon[] List of ChildCoupon objects
|
||||
*/
|
||||
public function getCoupons($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCoupons) {
|
||||
// return empty collection
|
||||
$this->initCoupons();
|
||||
} else {
|
||||
$collCoupons = ChildCouponQuery::create(null, $criteria)
|
||||
->filterByCustomer($this)
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collCoupons;
|
||||
}
|
||||
$this->collCoupons = $collCoupons;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCoupons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of Coupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_customer_count cross-reference table.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $coupons A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCustomer The current object (for fluent API support)
|
||||
*/
|
||||
public function setCoupons(Collection $coupons, ConnectionInterface $con = null)
|
||||
{
|
||||
$this->clearCoupons();
|
||||
$currentCoupons = $this->getCoupons();
|
||||
|
||||
$this->couponsScheduledForDeletion = $currentCoupons->diff($coupons);
|
||||
|
||||
foreach ($coupons as $coupon) {
|
||||
if (!$currentCoupons->contains($coupon)) {
|
||||
$this->doAddCoupon($coupon);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCoupons = $coupons;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of ChildCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the coupon_customer_count cross-reference table.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param boolean $distinct Set to true to force count distinct
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return int the number of related ChildCoupon objects
|
||||
*/
|
||||
public function countCoupons($criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collCoupons) {
|
||||
return 0;
|
||||
} else {
|
||||
$query = ChildCouponQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCustomer($this)
|
||||
->count($con);
|
||||
}
|
||||
} else {
|
||||
return count($this->collCoupons);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate a ChildCoupon object to this object
|
||||
* through the coupon_customer_count cross reference table.
|
||||
*
|
||||
* @param ChildCoupon $coupon The ChildCouponCustomerCount object to relate
|
||||
* @return ChildCustomer The current object (for fluent API support)
|
||||
*/
|
||||
public function addCoupon(ChildCoupon $coupon)
|
||||
{
|
||||
if ($this->collCoupons === null) {
|
||||
$this->initCoupons();
|
||||
}
|
||||
|
||||
if (!$this->collCoupons->contains($coupon)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCoupon($coupon);
|
||||
$this->collCoupons[] = $coupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Coupon $coupon The coupon object to add.
|
||||
*/
|
||||
protected function doAddCoupon($coupon)
|
||||
{
|
||||
$couponCustomerCount = new ChildCouponCustomerCount();
|
||||
$couponCustomerCount->setCoupon($coupon);
|
||||
$this->addCouponCustomerCount($couponCustomerCount);
|
||||
// set the back reference to this object directly as using provided method either results
|
||||
// in endless loop or in multiple relations
|
||||
if (!$coupon->getCustomers()->contains($this)) {
|
||||
$foreignCollection = $coupon->getCustomers();
|
||||
$foreignCollection[] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a ChildCoupon object to this object
|
||||
* through the coupon_customer_count cross reference table.
|
||||
*
|
||||
* @param ChildCoupon $coupon The ChildCouponCustomerCount object to relate
|
||||
* @return ChildCustomer The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCoupon(ChildCoupon $coupon)
|
||||
{
|
||||
if ($this->getCoupons()->contains($coupon)) {
|
||||
$this->collCoupons->remove($this->collCoupons->search($coupon));
|
||||
|
||||
if (null === $this->couponsScheduledForDeletion) {
|
||||
$this->couponsScheduledForDeletion = clone $this->collCoupons;
|
||||
$this->couponsScheduledForDeletion->clear();
|
||||
}
|
||||
|
||||
$this->couponsScheduledForDeletion[] = $coupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -3035,11 +3547,23 @@ abstract class Customer implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCouponCustomerCounts) {
|
||||
foreach ($this->collCouponCustomerCounts as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCoupons) {
|
||||
foreach ($this->collCoupons as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
$this->collAddresses = null;
|
||||
$this->collOrders = null;
|
||||
$this->collCarts = null;
|
||||
$this->collCouponCustomerCounts = null;
|
||||
$this->collCoupons = null;
|
||||
$this->aCustomerTitle = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ use Thelia\Model\Map\CustomerTableMap;
|
||||
* @method ChildCustomerQuery rightJoinCart($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Cart relation
|
||||
* @method ChildCustomerQuery innerJoinCart($relationAlias = null) Adds a INNER JOIN clause to the query using the Cart relation
|
||||
*
|
||||
* @method ChildCustomerQuery leftJoinCouponCustomerCount($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponCustomerCount relation
|
||||
* @method ChildCustomerQuery rightJoinCouponCustomerCount($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCustomerCount relation
|
||||
* @method ChildCustomerQuery innerJoinCouponCustomerCount($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCustomerCount relation
|
||||
*
|
||||
* @method ChildCustomer findOne(ConnectionInterface $con = null) Return the first ChildCustomer matching the query
|
||||
* @method ChildCustomer findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCustomer matching the query, or a new ChildCustomer object populated from the query conditions when no match is found
|
||||
*
|
||||
@@ -1124,6 +1128,96 @@ abstract class CustomerQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Cart', '\Thelia\Model\CartQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponCustomerCount object
|
||||
*
|
||||
* @param \Thelia\Model\CouponCustomerCount|ObjectCollection $couponCustomerCount the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCustomerQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponCustomerCount($couponCustomerCount, $comparison = null)
|
||||
{
|
||||
if ($couponCustomerCount instanceof \Thelia\Model\CouponCustomerCount) {
|
||||
return $this
|
||||
->addUsingAlias(CustomerTableMap::ID, $couponCustomerCount->getCustomerId(), $comparison);
|
||||
} elseif ($couponCustomerCount instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponCustomerCountQuery()
|
||||
->filterByPrimaryKeys($couponCustomerCount->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponCustomerCount() only accepts arguments of type \Thelia\Model\CouponCustomerCount or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponCustomerCount relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCustomerQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponCustomerCount($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponCustomerCount');
|
||||
|
||||
// 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, 'CouponCustomerCount');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponCustomerCount relation CouponCustomerCount 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\CouponCustomerCountQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponCustomerCountQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponCustomerCount($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponCustomerCount', '\Thelia\Model\CouponCustomerCountQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Coupon object
|
||||
* using the coupon_customer_count table as cross reference
|
||||
*
|
||||
* @param Coupon $coupon the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCustomerQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponCustomerCountQuery()
|
||||
->filterByCoupon($coupon, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -64,6 +64,14 @@ use Thelia\Model\Map\ModuleTableMap;
|
||||
* @method ChildModuleQuery rightJoinModuleImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleImage relation
|
||||
* @method ChildModuleQuery innerJoinModuleImage($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleImage relation
|
||||
*
|
||||
* @method ChildModuleQuery leftJoinCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildModuleQuery rightJoinCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildModuleQuery innerJoinCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @method ChildModuleQuery 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
|
||||
@@ -938,6 +946,152 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'ModuleImage', '\Thelia\Model\ModuleImageQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CouponModule object
|
||||
*
|
||||
* @param \Thelia\Model\CouponModule|ObjectCollection $couponModule the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponModule($couponModule, $comparison = null)
|
||||
{
|
||||
if ($couponModule instanceof \Thelia\Model\CouponModule) {
|
||||
return $this
|
||||
->addUsingAlias(ModuleTableMap::ID, $couponModule->getModuleId(), $comparison);
|
||||
} elseif ($couponModule instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByPrimaryKeys($couponModule->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCouponModule() only accepts arguments of type \Thelia\Model\CouponModule or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CouponModule');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'CouponModule');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CouponModule relation CouponModule object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CouponModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCouponModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponModule', '\Thelia\Model\CouponModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\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
|
||||
*
|
||||
@@ -1011,6 +1165,40 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', '\Thelia\Model\ModuleI18nQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Coupon object
|
||||
* using the coupon_module table as cross reference
|
||||
*
|
||||
* @param Coupon $coupon the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCoupon($coupon, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useCouponModuleQuery()
|
||||
->filterByCoupon($coupon, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
1268
core/lib/Thelia/Model/Base/OrderCouponCountry.php
Normal file
1268
core/lib/Thelia/Model/Base/OrderCouponCountry.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/OrderCouponCountryQuery.php
Normal file
568
core/lib/Thelia/Model/Base/OrderCouponCountryQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\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
|
||||
1268
core/lib/Thelia/Model/Base/OrderCouponModule.php
Normal file
1268
core/lib/Thelia/Model/Base/OrderCouponModule.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/OrderCouponModuleQuery.php
Normal file
568
core/lib/Thelia/Model/Base/OrderCouponModuleQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\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
|
||||
@@ -34,6 +34,7 @@ use Thelia\Model\Map\OrderCouponTableMap;
|
||||
* @method ChildOrderCouponQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column
|
||||
* @method ChildOrderCouponQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column
|
||||
* @method ChildOrderCouponQuery orderBySerializedConditions($order = Criteria::ASC) Order by the serialized_conditions column
|
||||
* @method ChildOrderCouponQuery orderByPerCustomerUsageCount($order = Criteria::ASC) Order by the per_customer_usage_count column
|
||||
* @method ChildOrderCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildOrderCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
@@ -50,6 +51,7 @@ use Thelia\Model\Map\OrderCouponTableMap;
|
||||
* @method ChildOrderCouponQuery groupByIsRemovingPostage() Group by the is_removing_postage column
|
||||
* @method ChildOrderCouponQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column
|
||||
* @method ChildOrderCouponQuery groupBySerializedConditions() Group by the serialized_conditions column
|
||||
* @method ChildOrderCouponQuery groupByPerCustomerUsageCount() Group by the per_customer_usage_count column
|
||||
* @method ChildOrderCouponQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildOrderCouponQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -61,6 +63,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
|
||||
*
|
||||
@@ -77,6 +87,7 @@ use Thelia\Model\Map\OrderCouponTableMap;
|
||||
* @method ChildOrderCoupon findOneByIsRemovingPostage(boolean $is_removing_postage) Return the first ChildOrderCoupon filtered by the is_removing_postage column
|
||||
* @method ChildOrderCoupon findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildOrderCoupon filtered by the is_available_on_special_offers column
|
||||
* @method ChildOrderCoupon findOneBySerializedConditions(string $serialized_conditions) Return the first ChildOrderCoupon filtered by the serialized_conditions column
|
||||
* @method ChildOrderCoupon findOneByPerCustomerUsageCount(boolean $per_customer_usage_count) Return the first ChildOrderCoupon filtered by the per_customer_usage_count column
|
||||
* @method ChildOrderCoupon findOneByCreatedAt(string $created_at) Return the first ChildOrderCoupon filtered by the created_at column
|
||||
* @method ChildOrderCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildOrderCoupon filtered by the updated_at column
|
||||
*
|
||||
@@ -93,6 +104,7 @@ use Thelia\Model\Map\OrderCouponTableMap;
|
||||
* @method array findByIsRemovingPostage(boolean $is_removing_postage) Return ChildOrderCoupon objects filtered by the is_removing_postage column
|
||||
* @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildOrderCoupon objects filtered by the is_available_on_special_offers column
|
||||
* @method array findBySerializedConditions(string $serialized_conditions) Return ChildOrderCoupon objects filtered by the serialized_conditions column
|
||||
* @method array findByPerCustomerUsageCount(boolean $per_customer_usage_count) Return ChildOrderCoupon objects filtered by the per_customer_usage_count column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildOrderCoupon objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildOrderCoupon objects filtered by the updated_at column
|
||||
*
|
||||
@@ -183,7 +195,7 @@ abstract class OrderCouponQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `ID`, `ORDER_ID`, `CODE`, `TYPE`, `AMOUNT`, `TITLE`, `SHORT_DESCRIPTION`, `DESCRIPTION`, `EXPIRATION_DATE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT` FROM `order_coupon` WHERE `ID` = :p0';
|
||||
$sql = 'SELECT `ID`, `ORDER_ID`, `CODE`, `TYPE`, `AMOUNT`, `TITLE`, `SHORT_DESCRIPTION`, `DESCRIPTION`, `EXPIRATION_DATE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `SERIALIZED_CONDITIONS`, `PER_CUSTOMER_USAGE_COUNT`, `CREATED_AT`, `UPDATED_AT` FROM `order_coupon` WHERE `ID` = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -695,6 +707,33 @@ abstract class OrderCouponQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(OrderCouponTableMap::SERIALIZED_CONDITIONS, $serializedConditions, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the per_customer_usage_count column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByPerCustomerUsageCount(true); // WHERE per_customer_usage_count = true
|
||||
* $query->filterByPerCustomerUsageCount('yes'); // WHERE per_customer_usage_count = true
|
||||
* </code>
|
||||
*
|
||||
* @param boolean|string $perCustomerUsageCount The value to use as filter.
|
||||
* Non-boolean arguments are converted using the following rules:
|
||||
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
|
||||
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
|
||||
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPerCustomerUsageCount($perCustomerUsageCount = null, $comparison = null)
|
||||
{
|
||||
if (is_string($perCustomerUsageCount)) {
|
||||
$per_customer_usage_count = in_array(strtolower($perCustomerUsageCount), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCouponTableMap::PER_CUSTOMER_USAGE_COUNT, $perCustomerUsageCount, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
@@ -856,6 +895,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
|
||||
*
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Base\Coupon as BaseCoupon;
|
||||
use Thelia\Model\Exception\InvalidArgumentException;
|
||||
use Thelia\Model\Map\CouponTableMap;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* Used to provide an effect (mostly a discount)
|
||||
@@ -38,7 +41,7 @@ use Thelia\Model\Exception\InvalidArgumentException;
|
||||
class Coupon extends BaseCoupon
|
||||
{
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* Create or Update this Coupon
|
||||
@@ -57,32 +60,85 @@ class Coupon extends BaseCoupon
|
||||
* @param int $maxUsage Coupon quantity
|
||||
* @param string $defaultSerializedRule Serialized default rule added if none found
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
* @param array $freeShippingForCountries ID of Countries to which shipping is free
|
||||
* @param array $freeShippingForMethods ID of Shipping modules for which shipping is free
|
||||
* @param bool $perCustomerUsageCount True if usage coiunt is per customer
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createOrUpdate($code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null)
|
||||
public function createOrUpdate(
|
||||
$code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description,
|
||||
$isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule,
|
||||
$locale, $freeShippingForCountries, $freeShippingForMethods,
|
||||
$perCustomerUsageCount)
|
||||
{
|
||||
$this
|
||||
->setCode($code)
|
||||
->setType($type)
|
||||
->setEffects($effects)
|
||||
->setIsRemovingPostage($isRemovingPostage)
|
||||
->setIsEnabled($isEnabled)
|
||||
->setExpirationDate($expirationDate)
|
||||
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
|
||||
->setIsCumulative($isCumulative)
|
||||
->setMaxUsage($maxUsage)
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
->setShortDescription($shortDescription)
|
||||
->setDescription($description);
|
||||
$con = Propel::getWriteConnection(CouponTableMap::DATABASE_NAME);
|
||||
|
||||
// If no rule given, set default rule
|
||||
if (null === $this->getSerializedConditions()) {
|
||||
$this->setSerializedConditions($defaultSerializedRule);
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
$this
|
||||
->setCode($code)
|
||||
->setType($type)
|
||||
->setEffects($effects)
|
||||
->setIsRemovingPostage($isRemovingPostage)
|
||||
->setIsEnabled($isEnabled)
|
||||
->setExpirationDate($expirationDate)
|
||||
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
|
||||
->setIsCumulative($isCumulative)
|
||||
->setMaxUsage($maxUsage)
|
||||
->setPerCustomerUsageCount($perCustomerUsageCount)
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
->setShortDescription($shortDescription)
|
||||
->setDescription($description)
|
||||
;
|
||||
|
||||
// If no rule given, set default rule
|
||||
if (null === $this->getSerializedConditions()) {
|
||||
$this->setSerializedConditions($defaultSerializedRule);
|
||||
}
|
||||
|
||||
$this->save();
|
||||
|
||||
// Update countries and modules relation for free shipping
|
||||
CouponCountryQuery::create()->filterByCouponId($this->id)->delete();
|
||||
CouponModuleQuery::create()->filterByCouponId($this->id)->delete();
|
||||
|
||||
foreach ($freeShippingForCountries as $countryId) {
|
||||
|
||||
if ($countryId <= 0) continue;
|
||||
|
||||
$couponCountry = new CouponCountry();
|
||||
|
||||
$couponCountry
|
||||
->setCouponId($this->getId())
|
||||
->setCountryId($countryId)
|
||||
->save();
|
||||
;
|
||||
}
|
||||
|
||||
foreach ($freeShippingForMethods as $moduleId) {
|
||||
|
||||
if ($moduleId <= 0) continue;
|
||||
|
||||
$couponModule = new CouponModule();
|
||||
|
||||
$couponModule
|
||||
->setCouponId($this->getId())
|
||||
->setModuleId($moduleId)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,4 +254,51 @@ class Coupon extends BaseCoupon
|
||||
|
||||
return $effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the countries for which free shipping is valid
|
||||
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
|
||||
*/
|
||||
public function getFreeShippingForCountries()
|
||||
{
|
||||
return CouponCountryQuery::create()->filterByCouponId($this->getId())->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the modules for which free shipping is valid
|
||||
*
|
||||
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
|
||||
*/
|
||||
public function getFreeShippingForModules()
|
||||
{
|
||||
return CouponModuleQuery::create()->filterByCouponId($this->getId())->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get coupon usage left, either overall, or per customer.
|
||||
*
|
||||
* @param int|null $customerId the ID of the ordering customer
|
||||
*
|
||||
* @return int the usage left.
|
||||
*/
|
||||
public function getUsagesLeft($customerId = null)
|
||||
{
|
||||
$usageLeft = $this->getMaxUsage();
|
||||
|
||||
if ($this->getPerCustomerUsageCount()) {
|
||||
|
||||
// Get usage left for current customer. If the record is not found,
|
||||
// it means that the customer has not yes used this coupon.
|
||||
if (null !== $couponCustomerCount = CouponCustomerCountQuery::create()
|
||||
->filterByCouponId($this->getId())
|
||||
->filterByCustomerId($customerId)
|
||||
->findOne()) {
|
||||
|
||||
// The coupon has already been used -> remove this customer's usage count
|
||||
$usageLeft -= $couponCustomerCount->getCount();
|
||||
}
|
||||
}
|
||||
|
||||
return $usageLeft;
|
||||
}
|
||||
}
|
||||
|
||||
10
core/lib/Thelia/Model/CouponCountry.php
Normal file
10
core/lib/Thelia/Model/CouponCountry.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CouponCountry as BaseCouponCountry;
|
||||
|
||||
class CouponCountry extends BaseCouponCountry
|
||||
{
|
||||
|
||||
}
|
||||
20
core/lib/Thelia/Model/CouponCountryQuery.php
Normal file
20
core/lib/Thelia/Model/CouponCountryQuery.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CouponCountryQuery as BaseCouponCountryQuery;
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the '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 CouponCountryQuery extends BaseCouponCountryQuery
|
||||
{
|
||||
|
||||
} // CouponCountryQuery
|
||||
10
core/lib/Thelia/Model/CouponCustomerCount.php
Normal file
10
core/lib/Thelia/Model/CouponCustomerCount.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CouponCustomerCount as BaseCouponCustomerCount;
|
||||
|
||||
class CouponCustomerCount extends BaseCouponCustomerCount
|
||||
{
|
||||
|
||||
}
|
||||
20
core/lib/Thelia/Model/CouponCustomerCountQuery.php
Normal file
20
core/lib/Thelia/Model/CouponCustomerCountQuery.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CouponCustomerCountQuery as BaseCouponCustomerCountQuery;
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'coupon_customer_count' 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 CouponCustomerCountQuery extends BaseCouponCustomerCountQuery
|
||||
{
|
||||
|
||||
} // CouponCustomerCountQuery
|
||||
10
core/lib/Thelia/Model/CouponModule.php
Normal file
10
core/lib/Thelia/Model/CouponModule.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CouponModule as BaseCouponModule;
|
||||
|
||||
class CouponModule extends BaseCouponModule
|
||||
{
|
||||
|
||||
}
|
||||
20
core/lib/Thelia/Model/CouponModuleQuery.php
Normal file
20
core/lib/Thelia/Model/CouponModuleQuery.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CouponModuleQuery as BaseCouponModuleQuery;
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the '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 CouponModuleQuery extends BaseCouponModuleQuery
|
||||
{
|
||||
|
||||
} // CouponModuleQuery
|
||||
@@ -194,7 +194,11 @@ class CountryTableMap extends TableMap
|
||||
$this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT');
|
||||
$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()
|
||||
|
||||
/**
|
||||
@@ -218,6 +222,8 @@ class CountryTableMap extends TableMap
|
||||
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
TaxRuleCountryTableMap::clearInstancePool();
|
||||
CouponCountryTableMap::clearInstancePool();
|
||||
OrderCouponCountryTableMap::clearInstancePool();
|
||||
CountryI18nTableMap::clearInstancePool();
|
||||
}
|
||||
|
||||
|
||||
468
core/lib/Thelia/Model/Map/CouponCountryTableMap.php
Normal file
468
core/lib/Thelia/Model/Map/CouponCountryTableMap.php
Normal 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\CouponCountry;
|
||||
use Thelia\Model\CouponCountryQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the '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 CouponCountryTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'Thelia.Model.Map.CouponCountryTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'coupon_country';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\Thelia\\Model\\CouponCountry';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'Thelia.Model.CouponCountry';
|
||||
|
||||
/**
|
||||
* 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 = 'coupon_country.COUPON_ID';
|
||||
|
||||
/**
|
||||
* the column name for the COUNTRY_ID field
|
||||
*/
|
||||
const COUNTRY_ID = '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(CouponCountryTableMap::COUPON_ID, CouponCountryTableMap::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(CouponCountryTableMap::COUPON_ID => 0, CouponCountryTableMap::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('coupon_country');
|
||||
$this->setPhpName('CouponCountry');
|
||||
$this->setClassName('\\Thelia\\Model\\CouponCountry');
|
||||
$this->setPackage('Thelia.Model');
|
||||
$this->setUseIdGenerator(false);
|
||||
$this->setIsCrossRef(true);
|
||||
// columns
|
||||
$this->addForeignPrimaryKey('COUPON_ID', 'CouponId', 'INTEGER' , '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('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('coupon_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\CouponCountry $obj A \Thelia\Model\CouponCountry 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\CouponCountry object or a primary key value.
|
||||
*/
|
||||
public static function removeInstanceFromPool($value)
|
||||
{
|
||||
if (Propel::isInstancePoolingEnabled() && null !== $value) {
|
||||
if (is_object($value) && $value instanceof \Thelia\Model\CouponCountry) {
|
||||
$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\CouponCountry 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 ? CouponCountryTableMap::CLASS_DEFAULT : CouponCountryTableMap::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 (CouponCountry object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = CouponCountryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = CouponCountryTableMap::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 + CouponCountryTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = CouponCountryTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
CouponCountryTableMap::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 = CouponCountryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = CouponCountryTableMap::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;
|
||||
CouponCountryTableMap::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(CouponCountryTableMap::COUPON_ID);
|
||||
$criteria->addSelectColumn(CouponCountryTableMap::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(CouponCountryTableMap::DATABASE_NAME)->getTable(CouponCountryTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponCountryTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(CouponCountryTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new CouponCountryTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a CouponCountry or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or CouponCountry 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(CouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \Thelia\Model\CouponCountry) { // 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(CouponCountryTableMap::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(CouponCountryTableMap::COUPON_ID, $value[0]);
|
||||
$criterion->addAnd($criteria->getNewCriterion(CouponCountryTableMap::COUNTRY_ID, $value[1]));
|
||||
$criteria->addOr($criterion);
|
||||
}
|
||||
}
|
||||
|
||||
$query = CouponCountryQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { CouponCountryTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { CouponCountryTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_country table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
return CouponCountryQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a CouponCountry or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or CouponCountry 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(CouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from CouponCountry object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = CouponCountryQuery::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;
|
||||
}
|
||||
|
||||
} // CouponCountryTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
CouponCountryTableMap::buildTableMap();
|
||||
416
core/lib/Thelia/Model/Map/CouponCustomerCountTableMap.php
Normal file
416
core/lib/Thelia/Model/Map/CouponCustomerCountTableMap.php
Normal file
@@ -0,0 +1,416 @@
|
||||
<?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\CouponCustomerCount;
|
||||
use Thelia\Model\CouponCustomerCountQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'coupon_customer_count' 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 CouponCustomerCountTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'Thelia.Model.Map.CouponCustomerCountTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'coupon_customer_count';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\Thelia\\Model\\CouponCustomerCount';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'Thelia.Model.CouponCustomerCount';
|
||||
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 3;
|
||||
|
||||
/**
|
||||
* 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 = 3;
|
||||
|
||||
/**
|
||||
* the column name for the COUPON_ID field
|
||||
*/
|
||||
const COUPON_ID = 'coupon_customer_count.COUPON_ID';
|
||||
|
||||
/**
|
||||
* the column name for the CUSTOMER_ID field
|
||||
*/
|
||||
const CUSTOMER_ID = 'coupon_customer_count.CUSTOMER_ID';
|
||||
|
||||
/**
|
||||
* the column name for the COUNT field
|
||||
*/
|
||||
const COUNT = 'coupon_customer_count.COUNT';
|
||||
|
||||
/**
|
||||
* 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', 'CustomerId', 'Count', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('couponId', 'customerId', 'count', ),
|
||||
self::TYPE_COLNAME => array(CouponCustomerCountTableMap::COUPON_ID, CouponCustomerCountTableMap::CUSTOMER_ID, CouponCustomerCountTableMap::COUNT, ),
|
||||
self::TYPE_RAW_COLNAME => array('COUPON_ID', 'CUSTOMER_ID', 'COUNT', ),
|
||||
self::TYPE_FIELDNAME => array('coupon_id', 'customer_id', 'count', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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, 'CustomerId' => 1, 'Count' => 2, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('couponId' => 0, 'customerId' => 1, 'count' => 2, ),
|
||||
self::TYPE_COLNAME => array(CouponCustomerCountTableMap::COUPON_ID => 0, CouponCustomerCountTableMap::CUSTOMER_ID => 1, CouponCustomerCountTableMap::COUNT => 2, ),
|
||||
self::TYPE_RAW_COLNAME => array('COUPON_ID' => 0, 'CUSTOMER_ID' => 1, 'COUNT' => 2, ),
|
||||
self::TYPE_FIELDNAME => array('coupon_id' => 0, 'customer_id' => 1, 'count' => 2, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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('coupon_customer_count');
|
||||
$this->setPhpName('CouponCustomerCount');
|
||||
$this->setClassName('\\Thelia\\Model\\CouponCustomerCount');
|
||||
$this->setPackage('Thelia.Model');
|
||||
$this->setUseIdGenerator(false);
|
||||
$this->setIsCrossRef(true);
|
||||
// columns
|
||||
$this->addForeignKey('COUPON_ID', 'CouponId', 'INTEGER', 'coupon', 'ID', true, null, null);
|
||||
$this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
|
||||
$this->addColumn('COUNT', 'Count', 'INTEGER', true, null, 0);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', null);
|
||||
$this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ? CouponCustomerCountTableMap::CLASS_DEFAULT : CouponCustomerCountTableMap::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 (CouponCustomerCount object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = CouponCustomerCountTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = CouponCustomerCountTableMap::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 + CouponCustomerCountTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = CouponCustomerCountTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
CouponCustomerCountTableMap::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 = CouponCustomerCountTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = CouponCustomerCountTableMap::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;
|
||||
CouponCustomerCountTableMap::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(CouponCustomerCountTableMap::COUPON_ID);
|
||||
$criteria->addSelectColumn(CouponCustomerCountTableMap::CUSTOMER_ID);
|
||||
$criteria->addSelectColumn(CouponCustomerCountTableMap::COUNT);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.COUPON_ID');
|
||||
$criteria->addSelectColumn($alias . '.CUSTOMER_ID');
|
||||
$criteria->addSelectColumn($alias . '.COUNT');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(CouponCustomerCountTableMap::DATABASE_NAME)->getTable(CouponCustomerCountTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponCustomerCountTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(CouponCustomerCountTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new CouponCustomerCountTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a CouponCustomerCount or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or CouponCustomerCount 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(CouponCustomerCountTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \Thelia\Model\CouponCustomerCount) { // it's a model object
|
||||
// create criteria based on pk value
|
||||
$criteria = $values->buildCriteria();
|
||||
} else { // it's a primary key, or an array of pks
|
||||
$criteria = new Criteria(CouponCustomerCountTableMap::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) {
|
||||
$criteria->addOr($criterion);
|
||||
}
|
||||
}
|
||||
|
||||
$query = CouponCustomerCountQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { CouponCustomerCountTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { CouponCustomerCountTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_customer_count 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 CouponCustomerCountQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a CouponCustomerCount or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or CouponCustomerCount 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(CouponCustomerCountTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from CouponCustomerCount object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = CouponCustomerCountQuery::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;
|
||||
}
|
||||
|
||||
} // CouponCustomerCountTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
CouponCustomerCountTableMap::buildTableMap();
|
||||
468
core/lib/Thelia/Model/Map/CouponModuleTableMap.php
Normal file
468
core/lib/Thelia/Model/Map/CouponModuleTableMap.php
Normal 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\CouponModule;
|
||||
use Thelia\Model\CouponModuleQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the '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 CouponModuleTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'Thelia.Model.Map.CouponModuleTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'coupon_module';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\Thelia\\Model\\CouponModule';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'Thelia.Model.CouponModule';
|
||||
|
||||
/**
|
||||
* 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 = 'coupon_module.COUPON_ID';
|
||||
|
||||
/**
|
||||
* the column name for the MODULE_ID field
|
||||
*/
|
||||
const MODULE_ID = '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(CouponModuleTableMap::COUPON_ID, CouponModuleTableMap::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(CouponModuleTableMap::COUPON_ID => 0, CouponModuleTableMap::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('coupon_module');
|
||||
$this->setPhpName('CouponModule');
|
||||
$this->setClassName('\\Thelia\\Model\\CouponModule');
|
||||
$this->setPackage('Thelia.Model');
|
||||
$this->setUseIdGenerator(false);
|
||||
$this->setIsCrossRef(true);
|
||||
// columns
|
||||
$this->addForeignPrimaryKey('COUPON_ID', 'CouponId', 'INTEGER' , '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('Coupon', '\\Thelia\\Model\\Coupon', 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\CouponModule $obj A \Thelia\Model\CouponModule 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\CouponModule object or a primary key value.
|
||||
*/
|
||||
public static function removeInstanceFromPool($value)
|
||||
{
|
||||
if (Propel::isInstancePoolingEnabled() && null !== $value) {
|
||||
if (is_object($value) && $value instanceof \Thelia\Model\CouponModule) {
|
||||
$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\CouponModule 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 ? CouponModuleTableMap::CLASS_DEFAULT : CouponModuleTableMap::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 (CouponModule object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = CouponModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = CouponModuleTableMap::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 + CouponModuleTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = CouponModuleTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
CouponModuleTableMap::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 = CouponModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = CouponModuleTableMap::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;
|
||||
CouponModuleTableMap::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(CouponModuleTableMap::COUPON_ID);
|
||||
$criteria->addSelectColumn(CouponModuleTableMap::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(CouponModuleTableMap::DATABASE_NAME)->getTable(CouponModuleTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponModuleTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(CouponModuleTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new CouponModuleTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a CouponModule or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or CouponModule 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(CouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \Thelia\Model\CouponModule) { // 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(CouponModuleTableMap::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(CouponModuleTableMap::COUPON_ID, $value[0]);
|
||||
$criterion->addAnd($criteria->getNewCriterion(CouponModuleTableMap::MODULE_ID, $value[1]));
|
||||
$criteria->addOr($criterion);
|
||||
}
|
||||
}
|
||||
|
||||
$query = CouponModuleQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { CouponModuleTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { CouponModuleTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the coupon_module table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
return CouponModuleQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a CouponModule or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or CouponModule 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(CouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from CouponModule object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = CouponModuleQuery::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;
|
||||
}
|
||||
|
||||
} // CouponModuleTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
CouponModuleTableMap::buildTableMap();
|
||||
@@ -58,7 +58,7 @@ class CouponTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 15;
|
||||
const NUM_COLUMNS = 16;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -68,7 +68,7 @@ class CouponTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 15;
|
||||
const NUM_HYDRATE_COLUMNS = 16;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -130,6 +130,11 @@ class CouponTableMap extends TableMap
|
||||
*/
|
||||
const SERIALIZED_CONDITIONS = 'coupon.SERIALIZED_CONDITIONS';
|
||||
|
||||
/**
|
||||
* the column name for the PER_CUSTOMER_USAGE_COUNT field
|
||||
*/
|
||||
const PER_CUSTOMER_USAGE_COUNT = 'coupon.PER_CUSTOMER_USAGE_COUNT';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
@@ -166,12 +171,12 @@ class CouponTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'SerializedEffects', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'serializedEffects', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
|
||||
self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::SERIALIZED_EFFECTS, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::IS_USED, CouponTableMap::SERIALIZED_CONDITIONS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'SERIALIZED_EFFECTS', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'code', 'type', 'serialized_effects', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'SerializedEffects', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'PerCustomerUsageCount', 'CreatedAt', 'UpdatedAt', 'Version', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'serializedEffects', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'perCustomerUsageCount', 'createdAt', 'updatedAt', 'version', ),
|
||||
self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::SERIALIZED_EFFECTS, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::IS_USED, CouponTableMap::SERIALIZED_CONDITIONS, CouponTableMap::PER_CUSTOMER_USAGE_COUNT, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'SERIALIZED_EFFECTS', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'PER_CUSTOMER_USAGE_COUNT', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'code', 'type', 'serialized_effects', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'per_customer_usage_count', 'created_at', 'updated_at', 'version', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -181,12 +186,12 @@ class CouponTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'SerializedEffects' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serializedEffects' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
|
||||
self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::SERIALIZED_EFFECTS => 3, CouponTableMap::IS_ENABLED => 4, CouponTableMap::EXPIRATION_DATE => 5, CouponTableMap::MAX_USAGE => 6, CouponTableMap::IS_CUMULATIVE => 7, CouponTableMap::IS_REMOVING_POSTAGE => 8, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponTableMap::IS_USED => 10, CouponTableMap::SERIALIZED_CONDITIONS => 11, CouponTableMap::CREATED_AT => 12, CouponTableMap::UPDATED_AT => 13, CouponTableMap::VERSION => 14, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'SERIALIZED_EFFECTS' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serialized_effects' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'SerializedEffects' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'PerCustomerUsageCount' => 12, 'CreatedAt' => 13, 'UpdatedAt' => 14, 'Version' => 15, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serializedEffects' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'perCustomerUsageCount' => 12, 'createdAt' => 13, 'updatedAt' => 14, 'version' => 15, ),
|
||||
self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::SERIALIZED_EFFECTS => 3, CouponTableMap::IS_ENABLED => 4, CouponTableMap::EXPIRATION_DATE => 5, CouponTableMap::MAX_USAGE => 6, CouponTableMap::IS_CUMULATIVE => 7, CouponTableMap::IS_REMOVING_POSTAGE => 8, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponTableMap::IS_USED => 10, CouponTableMap::SERIALIZED_CONDITIONS => 11, CouponTableMap::PER_CUSTOMER_USAGE_COUNT => 12, CouponTableMap::CREATED_AT => 13, CouponTableMap::UPDATED_AT => 14, CouponTableMap::VERSION => 15, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'SERIALIZED_EFFECTS' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'PER_CUSTOMER_USAGE_COUNT' => 12, 'CREATED_AT' => 13, 'UPDATED_AT' => 14, 'VERSION' => 15, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serialized_effects' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'per_customer_usage_count' => 12, 'created_at' => 13, 'updated_at' => 14, 'version' => 15, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -217,6 +222,7 @@ class CouponTableMap extends TableMap
|
||||
$this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('IS_USED', 'IsUsed', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', 'LONGVARCHAR', true, null, null);
|
||||
$this->addColumn('PER_CUSTOMER_USAGE_COUNT', 'PerCustomerUsageCount', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
|
||||
@@ -227,8 +233,14 @@ class CouponTableMap extends TableMap
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('CouponCountry', '\\Thelia\\Model\\CouponCountry', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', null, 'CouponCountries');
|
||||
$this->addRelation('CouponModule', '\\Thelia\\Model\\CouponModule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', null, 'CouponModules');
|
||||
$this->addRelation('CouponCustomerCount', '\\Thelia\\Model\\CouponCustomerCount', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', null, 'CouponCustomerCounts');
|
||||
$this->addRelation('CouponI18n', '\\Thelia\\Model\\CouponI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CouponI18ns');
|
||||
$this->addRelation('CouponVersion', '\\Thelia\\Model\\CouponVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CouponVersions');
|
||||
$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');
|
||||
$this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_MANY, array(), 'CASCADE', null, 'Customers');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
@@ -252,6 +264,9 @@ class CouponTableMap extends TableMap
|
||||
{
|
||||
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
CouponCountryTableMap::clearInstancePool();
|
||||
CouponModuleTableMap::clearInstancePool();
|
||||
CouponCustomerCountTableMap::clearInstancePool();
|
||||
CouponI18nTableMap::clearInstancePool();
|
||||
CouponVersionTableMap::clearInstancePool();
|
||||
}
|
||||
@@ -406,6 +421,7 @@ class CouponTableMap extends TableMap
|
||||
$criteria->addSelectColumn(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS);
|
||||
$criteria->addSelectColumn(CouponTableMap::IS_USED);
|
||||
$criteria->addSelectColumn(CouponTableMap::SERIALIZED_CONDITIONS);
|
||||
$criteria->addSelectColumn(CouponTableMap::PER_CUSTOMER_USAGE_COUNT);
|
||||
$criteria->addSelectColumn(CouponTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(CouponTableMap::UPDATED_AT);
|
||||
$criteria->addSelectColumn(CouponTableMap::VERSION);
|
||||
@@ -422,6 +438,7 @@ class CouponTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS');
|
||||
$criteria->addSelectColumn($alias . '.IS_USED');
|
||||
$criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS');
|
||||
$criteria->addSelectColumn($alias . '.PER_CUSTOMER_USAGE_COUNT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.VERSION');
|
||||
|
||||
@@ -58,7 +58,7 @@ class CouponVersionTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 15;
|
||||
const NUM_COLUMNS = 16;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -68,7 +68,7 @@ class CouponVersionTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 15;
|
||||
const NUM_HYDRATE_COLUMNS = 16;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -130,6 +130,11 @@ class CouponVersionTableMap extends TableMap
|
||||
*/
|
||||
const SERIALIZED_CONDITIONS = 'coupon_version.SERIALIZED_CONDITIONS';
|
||||
|
||||
/**
|
||||
* the column name for the PER_CUSTOMER_USAGE_COUNT field
|
||||
*/
|
||||
const PER_CUSTOMER_USAGE_COUNT = 'coupon_version.PER_CUSTOMER_USAGE_COUNT';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
@@ -157,12 +162,12 @@ class CouponVersionTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'SerializedEffects', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'serializedEffects', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ),
|
||||
self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::SERIALIZED_EFFECTS, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::IS_USED, CouponVersionTableMap::SERIALIZED_CONDITIONS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'SERIALIZED_EFFECTS', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'code', 'type', 'serialized_effects', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'SerializedEffects', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'PerCustomerUsageCount', 'CreatedAt', 'UpdatedAt', 'Version', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'serializedEffects', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'perCustomerUsageCount', 'createdAt', 'updatedAt', 'version', ),
|
||||
self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::SERIALIZED_EFFECTS, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::IS_USED, CouponVersionTableMap::SERIALIZED_CONDITIONS, CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'SERIALIZED_EFFECTS', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'PER_CUSTOMER_USAGE_COUNT', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'code', 'type', 'serialized_effects', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'per_customer_usage_count', 'created_at', 'updated_at', 'version', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -172,12 +177,12 @@ class CouponVersionTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'SerializedEffects' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serializedEffects' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ),
|
||||
self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::SERIALIZED_EFFECTS => 3, CouponVersionTableMap::IS_ENABLED => 4, CouponVersionTableMap::EXPIRATION_DATE => 5, CouponVersionTableMap::MAX_USAGE => 6, CouponVersionTableMap::IS_CUMULATIVE => 7, CouponVersionTableMap::IS_REMOVING_POSTAGE => 8, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponVersionTableMap::IS_USED => 10, CouponVersionTableMap::SERIALIZED_CONDITIONS => 11, CouponVersionTableMap::CREATED_AT => 12, CouponVersionTableMap::UPDATED_AT => 13, CouponVersionTableMap::VERSION => 14, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'SERIALIZED_EFFECTS' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serialized_effects' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'SerializedEffects' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'PerCustomerUsageCount' => 12, 'CreatedAt' => 13, 'UpdatedAt' => 14, 'Version' => 15, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serializedEffects' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'perCustomerUsageCount' => 12, 'createdAt' => 13, 'updatedAt' => 14, 'version' => 15, ),
|
||||
self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::SERIALIZED_EFFECTS => 3, CouponVersionTableMap::IS_ENABLED => 4, CouponVersionTableMap::EXPIRATION_DATE => 5, CouponVersionTableMap::MAX_USAGE => 6, CouponVersionTableMap::IS_CUMULATIVE => 7, CouponVersionTableMap::IS_REMOVING_POSTAGE => 8, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponVersionTableMap::IS_USED => 10, CouponVersionTableMap::SERIALIZED_CONDITIONS => 11, CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT => 12, CouponVersionTableMap::CREATED_AT => 13, CouponVersionTableMap::UPDATED_AT => 14, CouponVersionTableMap::VERSION => 15, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'SERIALIZED_EFFECTS' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'PER_CUSTOMER_USAGE_COUNT' => 12, 'CREATED_AT' => 13, 'UPDATED_AT' => 14, 'VERSION' => 15, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'serialized_effects' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'per_customer_usage_count' => 12, 'created_at' => 13, 'updated_at' => 14, 'version' => 15, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -208,6 +213,7 @@ class CouponVersionTableMap extends TableMap
|
||||
$this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('IS_USED', 'IsUsed', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', 'LONGVARCHAR', true, null, null);
|
||||
$this->addColumn('PER_CUSTOMER_USAGE_COUNT', 'PerCustomerUsageCount', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
|
||||
@@ -288,11 +294,11 @@ class CouponVersionTableMap extends TableMap
|
||||
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
// If the PK cannot be derived from the row, return NULL.
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 14 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 15 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 14 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
|
||||
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 15 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,6 +426,7 @@ class CouponVersionTableMap extends TableMap
|
||||
$criteria->addSelectColumn(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS);
|
||||
$criteria->addSelectColumn(CouponVersionTableMap::IS_USED);
|
||||
$criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_CONDITIONS);
|
||||
$criteria->addSelectColumn(CouponVersionTableMap::PER_CUSTOMER_USAGE_COUNT);
|
||||
$criteria->addSelectColumn(CouponVersionTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(CouponVersionTableMap::UPDATED_AT);
|
||||
$criteria->addSelectColumn(CouponVersionTableMap::VERSION);
|
||||
@@ -436,6 +443,7 @@ class CouponVersionTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS');
|
||||
$criteria->addSelectColumn($alias . '.IS_USED');
|
||||
$criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS');
|
||||
$criteria->addSelectColumn($alias . '.PER_CUSTOMER_USAGE_COUNT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.VERSION');
|
||||
|
||||
@@ -228,6 +228,8 @@ class CustomerTableMap extends TableMap
|
||||
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresses');
|
||||
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'RESTRICT', 'RESTRICT', 'Orders');
|
||||
$this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Carts');
|
||||
$this->addRelation('CouponCustomerCount', '\\Thelia\\Model\\CouponCustomerCount', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', null, 'CouponCustomerCounts');
|
||||
$this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_MANY, array(), 'CASCADE', null, 'Coupons');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
@@ -251,6 +253,7 @@ class CustomerTableMap extends TableMap
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
AddressTableMap::clearInstancePool();
|
||||
CartTableMap::clearInstancePool();
|
||||
CouponCustomerCountTableMap::clearInstancePool();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -190,7 +190,11 @@ class ModuleTableMap extends TableMap
|
||||
$this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules');
|
||||
$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()
|
||||
|
||||
/**
|
||||
@@ -216,6 +220,8 @@ class ModuleTableMap extends TableMap
|
||||
AreaDeliveryModuleTableMap::clearInstancePool();
|
||||
ProfileModuleTableMap::clearInstancePool();
|
||||
ModuleImageTableMap::clearInstancePool();
|
||||
CouponModuleTableMap::clearInstancePool();
|
||||
OrderCouponModuleTableMap::clearInstancePool();
|
||||
ModuleI18nTableMap::clearInstancePool();
|
||||
}
|
||||
|
||||
|
||||
468
core/lib/Thelia/Model/Map/OrderCouponCountryTableMap.php
Normal file
468
core/lib/Thelia/Model/Map/OrderCouponCountryTableMap.php
Normal 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();
|
||||
468
core/lib/Thelia/Model/Map/OrderCouponModuleTableMap.php
Normal file
468
core/lib/Thelia/Model/Map/OrderCouponModuleTableMap.php
Normal 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();
|
||||
@@ -58,7 +58,7 @@ class OrderCouponTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 15;
|
||||
const NUM_COLUMNS = 16;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -68,7 +68,7 @@ class OrderCouponTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 15;
|
||||
const NUM_HYDRATE_COLUMNS = 16;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -135,6 +135,11 @@ class OrderCouponTableMap extends TableMap
|
||||
*/
|
||||
const SERIALIZED_CONDITIONS = 'order_coupon.SERIALIZED_CONDITIONS';
|
||||
|
||||
/**
|
||||
* the column name for the PER_CUSTOMER_USAGE_COUNT field
|
||||
*/
|
||||
const PER_CUSTOMER_USAGE_COUNT = 'order_coupon.PER_CUSTOMER_USAGE_COUNT';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
@@ -157,12 +162,12 @@ class OrderCouponTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'OrderId', 'Code', 'Type', 'Amount', 'Title', 'ShortDescription', 'Description', 'ExpirationDate', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'code', 'type', 'amount', 'title', 'shortDescription', 'description', 'expirationDate', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'serializedConditions', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(OrderCouponTableMap::ID, OrderCouponTableMap::ORDER_ID, OrderCouponTableMap::CODE, OrderCouponTableMap::TYPE, OrderCouponTableMap::AMOUNT, OrderCouponTableMap::TITLE, OrderCouponTableMap::SHORT_DESCRIPTION, OrderCouponTableMap::DESCRIPTION, OrderCouponTableMap::EXPIRATION_DATE, OrderCouponTableMap::IS_CUMULATIVE, OrderCouponTableMap::IS_REMOVING_POSTAGE, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, OrderCouponTableMap::SERIALIZED_CONDITIONS, OrderCouponTableMap::CREATED_AT, OrderCouponTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'CODE', 'TYPE', 'AMOUNT', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'EXPIRATION_DATE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'order_id', 'code', 'type', 'amount', 'title', 'short_description', 'description', 'expiration_date', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'serialized_conditions', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
self::TYPE_PHPNAME => array('Id', 'OrderId', 'Code', 'Type', 'Amount', 'Title', 'ShortDescription', 'Description', 'ExpirationDate', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'SerializedConditions', 'PerCustomerUsageCount', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'code', 'type', 'amount', 'title', 'shortDescription', 'description', 'expirationDate', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'serializedConditions', 'perCustomerUsageCount', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(OrderCouponTableMap::ID, OrderCouponTableMap::ORDER_ID, OrderCouponTableMap::CODE, OrderCouponTableMap::TYPE, OrderCouponTableMap::AMOUNT, OrderCouponTableMap::TITLE, OrderCouponTableMap::SHORT_DESCRIPTION, OrderCouponTableMap::DESCRIPTION, OrderCouponTableMap::EXPIRATION_DATE, OrderCouponTableMap::IS_CUMULATIVE, OrderCouponTableMap::IS_REMOVING_POSTAGE, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, OrderCouponTableMap::SERIALIZED_CONDITIONS, OrderCouponTableMap::PER_CUSTOMER_USAGE_COUNT, OrderCouponTableMap::CREATED_AT, OrderCouponTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'CODE', 'TYPE', 'AMOUNT', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'EXPIRATION_DATE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'SERIALIZED_CONDITIONS', 'PER_CUSTOMER_USAGE_COUNT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'order_id', 'code', 'type', 'amount', 'title', 'short_description', 'description', 'expiration_date', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'serialized_conditions', 'per_customer_usage_count', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -172,12 +177,12 @@ class OrderCouponTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Type' => 3, 'Amount' => 4, 'Title' => 5, 'ShortDescription' => 6, 'Description' => 7, 'ExpirationDate' => 8, 'IsCumulative' => 9, 'IsRemovingPostage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'SerializedConditions' => 12, 'CreatedAt' => 13, 'UpdatedAt' => 14, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'shortDescription' => 6, 'description' => 7, 'expirationDate' => 8, 'isCumulative' => 9, 'isRemovingPostage' => 10, 'isAvailableOnSpecialOffers' => 11, 'serializedConditions' => 12, 'createdAt' => 13, 'updatedAt' => 14, ),
|
||||
self::TYPE_COLNAME => array(OrderCouponTableMap::ID => 0, OrderCouponTableMap::ORDER_ID => 1, OrderCouponTableMap::CODE => 2, OrderCouponTableMap::TYPE => 3, OrderCouponTableMap::AMOUNT => 4, OrderCouponTableMap::TITLE => 5, OrderCouponTableMap::SHORT_DESCRIPTION => 6, OrderCouponTableMap::DESCRIPTION => 7, OrderCouponTableMap::EXPIRATION_DATE => 8, OrderCouponTableMap::IS_CUMULATIVE => 9, OrderCouponTableMap::IS_REMOVING_POSTAGE => 10, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, OrderCouponTableMap::SERIALIZED_CONDITIONS => 12, OrderCouponTableMap::CREATED_AT => 13, OrderCouponTableMap::UPDATED_AT => 14, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'TYPE' => 3, 'AMOUNT' => 4, 'TITLE' => 5, 'SHORT_DESCRIPTION' => 6, 'DESCRIPTION' => 7, 'EXPIRATION_DATE' => 8, 'IS_CUMULATIVE' => 9, 'IS_REMOVING_POSTAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'SERIALIZED_CONDITIONS' => 12, 'CREATED_AT' => 13, 'UPDATED_AT' => 14, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'short_description' => 6, 'description' => 7, 'expiration_date' => 8, 'is_cumulative' => 9, 'is_removing_postage' => 10, 'is_available_on_special_offers' => 11, 'serialized_conditions' => 12, 'created_at' => 13, 'updated_at' => 14, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Type' => 3, 'Amount' => 4, 'Title' => 5, 'ShortDescription' => 6, 'Description' => 7, 'ExpirationDate' => 8, 'IsCumulative' => 9, 'IsRemovingPostage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'SerializedConditions' => 12, 'PerCustomerUsageCount' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'shortDescription' => 6, 'description' => 7, 'expirationDate' => 8, 'isCumulative' => 9, 'isRemovingPostage' => 10, 'isAvailableOnSpecialOffers' => 11, 'serializedConditions' => 12, 'perCustomerUsageCount' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
|
||||
self::TYPE_COLNAME => array(OrderCouponTableMap::ID => 0, OrderCouponTableMap::ORDER_ID => 1, OrderCouponTableMap::CODE => 2, OrderCouponTableMap::TYPE => 3, OrderCouponTableMap::AMOUNT => 4, OrderCouponTableMap::TITLE => 5, OrderCouponTableMap::SHORT_DESCRIPTION => 6, OrderCouponTableMap::DESCRIPTION => 7, OrderCouponTableMap::EXPIRATION_DATE => 8, OrderCouponTableMap::IS_CUMULATIVE => 9, OrderCouponTableMap::IS_REMOVING_POSTAGE => 10, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, OrderCouponTableMap::SERIALIZED_CONDITIONS => 12, OrderCouponTableMap::PER_CUSTOMER_USAGE_COUNT => 13, OrderCouponTableMap::CREATED_AT => 14, OrderCouponTableMap::UPDATED_AT => 15, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'TYPE' => 3, 'AMOUNT' => 4, 'TITLE' => 5, 'SHORT_DESCRIPTION' => 6, 'DESCRIPTION' => 7, 'EXPIRATION_DATE' => 8, 'IS_CUMULATIVE' => 9, 'IS_REMOVING_POSTAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'SERIALIZED_CONDITIONS' => 12, 'PER_CUSTOMER_USAGE_COUNT' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'short_description' => 6, 'description' => 7, 'expiration_date' => 8, 'is_cumulative' => 9, 'is_removing_postage' => 10, 'is_available_on_special_offers' => 11, 'serialized_conditions' => 12, 'per_customer_usage_count' => 13, 'created_at' => 14, 'updated_at' => 15, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -209,6 +214,7 @@ class OrderCouponTableMap extends TableMap
|
||||
$this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', 'LONGVARCHAR', true, null, null);
|
||||
$this->addColumn('PER_CUSTOMER_USAGE_COUNT', 'PerCustomerUsageCount', 'BOOLEAN', true, 1, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -219,6 +225,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 +243,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.
|
||||
@@ -385,6 +404,7 @@ class OrderCouponTableMap extends TableMap
|
||||
$criteria->addSelectColumn(OrderCouponTableMap::IS_REMOVING_POSTAGE);
|
||||
$criteria->addSelectColumn(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS);
|
||||
$criteria->addSelectColumn(OrderCouponTableMap::SERIALIZED_CONDITIONS);
|
||||
$criteria->addSelectColumn(OrderCouponTableMap::PER_CUSTOMER_USAGE_COUNT);
|
||||
$criteria->addSelectColumn(OrderCouponTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(OrderCouponTableMap::UPDATED_AT);
|
||||
} else {
|
||||
@@ -401,6 +421,7 @@ class OrderCouponTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE');
|
||||
$criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS');
|
||||
$criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS');
|
||||
$criteria->addSelectColumn($alias . '.PER_CUSTOMER_USAGE_COUNT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
use Thelia\Model\Base\Module as BaseModule;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use Thelia\Model\Tools\PositionManagementTrait;
|
||||
use Thelia\Module\BaseModuleInterface;
|
||||
|
||||
class Module extends BaseModule
|
||||
{
|
||||
@@ -182,6 +184,21 @@ class Module extends BaseModule
|
||||
return $moduleReflection->implementsInterface("Thelia\Module\PaymentModuleInterface");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container the Thelia container
|
||||
* @return BaseModuleInterface a module instance
|
||||
* @throws \InvalidArgumentException if the module could not be found in the container/
|
||||
*/
|
||||
public function getModuleInstance(ContainerInterface $container)
|
||||
{
|
||||
$instance = $container->get(sprintf('module.%s', $this->getCode()));
|
||||
|
||||
if ($instance == null) {
|
||||
throw new \InvalidArgumentException(sprintf('Undefined module in container: "%s"', $this->getCode()));
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
/**
|
||||
* @return BaseModule a new module instance.
|
||||
*/
|
||||
|
||||
@@ -4,19 +4,54 @@ namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\Order as BaseOrder;
|
||||
use Thelia\Model\Base\OrderProductTaxQuery;
|
||||
use Thelia\Model\Map\OrderProductTaxTableMap;
|
||||
use Thelia\Model\Base\Order as BaseOrder;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
class Order extends BaseOrder
|
||||
{
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use ModelEventDispatcherTrait;
|
||||
|
||||
public $chosenDeliveryAddress = null;
|
||||
public $chosenInvoiceAddress = null;
|
||||
protected $choosenDeliveryAddress = null;
|
||||
protected $choosenInvoiceAddress = null;
|
||||
|
||||
/**
|
||||
* @param null $choosenDeliveryAddress
|
||||
*/
|
||||
public function setChoosenDeliveryAddress($choosenDeliveryAddress)
|
||||
{
|
||||
$this->choosenDeliveryAddress = $choosenDeliveryAddress;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getChoosenDeliveryAddress()
|
||||
{
|
||||
return $this->choosenDeliveryAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $choosenInvoiceAddress
|
||||
*/
|
||||
public function setChoosenInvoiceAddress($choosenInvoiceAddress)
|
||||
{
|
||||
$this->choosenInvoiceAddress = $choosenInvoiceAddress;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getChoosenInvoiceAddress()
|
||||
{
|
||||
return $this->choosenInvoiceAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
||||
@@ -7,4 +7,22 @@ use Thelia\Model\Base\OrderCoupon as BaseOrderCoupon;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
10
core/lib/Thelia/Model/OrderCouponCountry.php
Normal file
10
core/lib/Thelia/Model/OrderCouponCountry.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\OrderCouponCountry as BaseOrderCouponCountry;
|
||||
|
||||
class OrderCouponCountry extends BaseOrderCouponCountry
|
||||
{
|
||||
|
||||
}
|
||||
20
core/lib/Thelia/Model/OrderCouponCountryQuery.php
Normal file
20
core/lib/Thelia/Model/OrderCouponCountryQuery.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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
|
||||
10
core/lib/Thelia/Model/OrderCouponModule.php
Normal file
10
core/lib/Thelia/Model/OrderCouponModule.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\OrderCouponModule as BaseOrderCouponModule;
|
||||
|
||||
class OrderCouponModule extends BaseOrderCouponModule
|
||||
{
|
||||
|
||||
}
|
||||
20
core/lib/Thelia/Model/OrderCouponModuleQuery.php
Normal file
20
core/lib/Thelia/Model/OrderCouponModuleQuery.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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
|
||||
@@ -60,7 +60,7 @@ class RewritingUrlQuery extends BaseRewritingUrlQuery
|
||||
->filterByViewLocale($viewLocale)
|
||||
->filterByViewId($viewId)
|
||||
->filterByRedirected(null)
|
||||
->orderByUpdatedAt(Criteria::DESC)
|
||||
->orderById(Criteria::DESC)
|
||||
->findOne();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class RewritingUrlQuery extends BaseRewritingUrlQuery
|
||||
->filterByViewLocale($viewLocale)
|
||||
->filterByViewId($viewId)
|
||||
->filterByRedirected(null)
|
||||
->orderByUpdatedAt(Criteria::DESC);
|
||||
->orderById(Criteria::DESC);
|
||||
|
||||
$otherParametersCount = count($viewOtherParameters);
|
||||
if ($otherParametersCount > 0) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user