Merge branch 'coupon' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (27) and others # Via Manuel Raynaud (8) and others * 'coupon' of https://github.com/thelia/thelia: (50 commits) WIP : Coupon : unit tests on Rules WIP : Coupon : unit tests on Rules WIP : Coupon : unit tests on Operator WIP : Coupon functional tests Typo Added UrlRewritingTrait to manage URLs from model classes Merge branch 'master' of https://github.com/thelia/thelia into coupon fix typo Started category management add some php doc integrate swiftMailer as mailer solution add swiftmailer in composer use dump autoloader in all compser scripts remove script part of composer.json file fix typo add some information for OSX requirements No alert bloc default country Autofocus on username field for better use Beautiful login page ...
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -24,4 +24,5 @@ phpdoc*.log
|
||||
php-cs
|
||||
xhprof/
|
||||
phpunit.phar
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
phpmyadmin
|
||||
23
Readme.md
23
Readme.md
@@ -12,14 +12,33 @@ Here is the most recent developed code for the next major version (v2). You can
|
||||
|
||||
Most part of the code can possibly change, a large part will be refactor soon, graphical setup does not exist yet.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* php 5.4
|
||||
* apache 2
|
||||
* mysql 5
|
||||
|
||||
If you use Mac OSX, it still doesn't use php 5.4 as default php version... There are many solutions for you :
|
||||
|
||||
* use linux (the best one)
|
||||
* use last MAMP version and put the php bin directory in your path :
|
||||
|
||||
```bash
|
||||
export PATH=/Applications/MAMP/bin/php/php5.4.x/bin/:$PATH
|
||||
```
|
||||
|
||||
* configure a complete development environment : http://php-osx.liip.ch/
|
||||
* use a virtual machine with vagrant and puppet : https://puphpet.com/
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
``` bash
|
||||
$ git clone --recursive https://github.com/thelia/thelia.git
|
||||
$ cd thelia
|
||||
$ wget http://getcomposer.org/composer.phar
|
||||
$ php composer.phar install
|
||||
$ curl -sS https://getcomposer.org/installer | php
|
||||
$ php composer.phar install --optimize-autoloader
|
||||
```
|
||||
|
||||
Finish the installation using cli tools :
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
"simplepie/simplepie": "dev-master",
|
||||
|
||||
"imagine/imagine": "dev-master",
|
||||
"symfony/icu": "1.0"
|
||||
"symfony/icu": "1.0",
|
||||
"swiftmailer/swiftmailer": "5.0.*"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
@@ -53,9 +54,5 @@
|
||||
"": "local/modules/",
|
||||
"Thelia" : "core/lib/"
|
||||
}
|
||||
},
|
||||
"scripts" : {
|
||||
"post-update-cmd": "composer dump-autoload -o",
|
||||
"post-install-cmd": "composer dump-autoload -o"
|
||||
}
|
||||
}
|
||||
|
||||
51
composer.lock
generated
51
composer.lock
generated
@@ -3,7 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "28dfdc7a840f9e70df422581f82a871f",
|
||||
"hash": "a40be01c82e68ba0c446dc204d2667da",
|
||||
"packages": [
|
||||
{
|
||||
"name": "imagine/imagine",
|
||||
@@ -445,6 +445,55 @@
|
||||
],
|
||||
"time": "2013-07-02 16:38:47"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v5.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||
"reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/f3917ecef35a4e4d98b303eb9fee463bc983f379",
|
||||
"reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/swift_required.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Chris Corbyn"
|
||||
}
|
||||
],
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"homepage": "http://swiftmailer.org",
|
||||
"keywords": [
|
||||
"mail",
|
||||
"mailer"
|
||||
],
|
||||
"time": "2013-08-30 12:35:21"
|
||||
},
|
||||
{
|
||||
"name": "symfony-cmf/routing",
|
||||
"version": "1.0.0",
|
||||
|
||||
@@ -41,6 +41,7 @@ use Thelia\Core\Event\CategoryEvent;
|
||||
use Thelia\Core\Event\AttributeEvent;
|
||||
use Thelia\Model\AttributeTemplate;
|
||||
use Thelia\Model\AttributeTemplateQuery;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
|
||||
class Attribute extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -137,23 +138,33 @@ class Attribute extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(AttributeEvent $event)
|
||||
protected function doAddToAllTemplates(AttributeModel $attribute)
|
||||
{
|
||||
$templates = AttributeTemplateQuery::create()->find();
|
||||
$templates = TemplateQuery::create()->find();
|
||||
|
||||
foreach($templates as $template) {
|
||||
$pat = new AttributeTemplate();
|
||||
|
||||
$pat->setTemplate($template->getId())
|
||||
->setAttributeId($event->getAttribute()->getId())
|
||||
->save();
|
||||
$attribute_template = new AttributeTemplate();
|
||||
|
||||
if (null === AttributeTemplateQuery::create()->filterByAttribute($attribute)->filterByTemplate($template)->findOne()) {
|
||||
$attribute_template
|
||||
->setAttribute($attribute)
|
||||
->setTemplate($template)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(AttributeEvent $event)
|
||||
{
|
||||
$this->doAddToAllTemplates($event->getAttribute());
|
||||
}
|
||||
|
||||
public function removeFromAllTemplates(AttributeEvent $event)
|
||||
{
|
||||
// Delete this attribute from all product templates
|
||||
AttributeTemplateQuery::create()->filterByAttributeId($event->getAttribute()->getId())->delete();
|
||||
AttributeTemplateQuery::create()->filterByAttribute($event->getAttribute())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
->filterByProductSaleElementsId($productSaleElementsId)
|
||||
->findOne();
|
||||
|
||||
$this->doAddItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice);
|
||||
$this->doAddItem($cart, $productId, $productPrice->getProductSaleElements(), $quantity, $productPrice);
|
||||
}
|
||||
|
||||
if ($append && $cartItem !== null) {
|
||||
@@ -166,17 +166,18 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
* @param float $quantity
|
||||
* @param ProductPrice $productPrice
|
||||
*/
|
||||
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, $productSaleElementsId, $quantity, ProductPrice $productPrice)
|
||||
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, \Thelia\Model\ProductSaleElements $productSaleElements, $quantity, ProductPrice $productPrice)
|
||||
{
|
||||
$cartItem = new CartItem();
|
||||
$cartItem->setDisptacher($this->getDispatcher());
|
||||
$cartItem
|
||||
->setCart($cart)
|
||||
->setProductId($productId)
|
||||
->setProductSaleElementsId($productSaleElementsId)
|
||||
->setProductSaleElementsId($productSaleElements->getId())
|
||||
->setQuantity($quantity)
|
||||
->setPrice($productPrice->getPrice())
|
||||
->setPromoPrice($productPrice->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30))
|
||||
->save();
|
||||
}
|
||||
|
||||
@@ -24,52 +24,88 @@
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Category as CategoryModel;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\Category as CategoryModel;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Map\CategoryTableMap;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\CategoryUpdateEvent;
|
||||
use Thelia\Core\Event\CategoryCreateEvent;
|
||||
use Thelia\Core\Event\CategoryDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\CategoryChangePositionEvent;
|
||||
|
||||
class Category extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new category entry
|
||||
*
|
||||
* @param CategoryCreateEvent $event
|
||||
*/
|
||||
public function create(CategoryCreateEvent $event)
|
||||
{
|
||||
$category = new CategoryModel();
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->create(
|
||||
$event->getTitle(),
|
||||
$event->getParent(),
|
||||
$event->getLocale()
|
||||
);
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setCategory($category);
|
||||
}
|
||||
|
||||
public function update(CategoryChangeEvent $event)
|
||||
/**
|
||||
* Change a category
|
||||
*
|
||||
* @param CategoryUpdateEvent $event
|
||||
*/
|
||||
public function update(CategoryUpdateEvent $event)
|
||||
{
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setCategory($category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a category
|
||||
* Delete a category entry
|
||||
*
|
||||
* @param ActionEvent $event
|
||||
* @param CategoryDeleteEvent $event
|
||||
*/
|
||||
public function delete(CategoryDeleteEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
|
||||
|
||||
if ($category !== null) {
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$category->setDispatcher($this->getDispatcher())->delete();
|
||||
$event->setCategory($category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,178 +116,48 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function toggleVisibility(CategoryToggleVisibilityEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
$category = $event->getCategory();
|
||||
|
||||
if ($category !== null) {
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible($category->getVisible() ? false : true)
|
||||
->save()
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible($category->getVisible() ? false : true)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $category = CategoryQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$category->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $category->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $category->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $category->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes category position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function changePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
if ($event->getMode() == CategoryChangePositionEvent::POSITION_ABSOLUTE)
|
||||
return $this->changeAbsolutePosition($event);
|
||||
else
|
||||
return $this->exchangePosition($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move up or down a category
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
protected function exchangePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
|
||||
if ($category !== null) {
|
||||
|
||||
// The current position of the category
|
||||
$my_position = $category->getPosition();
|
||||
|
||||
// Find category to exchange position with
|
||||
$search = CategoryQuery::create()
|
||||
->filterByParent($category->getParent());
|
||||
|
||||
// Up or down ?
|
||||
if ($event->getMode() == CategoryChangePositionEvent::POSITION_UP) {
|
||||
// Find the category immediately before me
|
||||
$search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC);
|
||||
} elseif ($event->getMode() == CategoryChangePositionEvent::POSITION_DOWN) {
|
||||
// Find the category immediately after me
|
||||
$search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC);
|
||||
} else
|
||||
|
||||
return;
|
||||
|
||||
$result = $search->findOne();
|
||||
|
||||
// If we found the proper category, exchange their positions
|
||||
if ($result) {
|
||||
|
||||
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
try {
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setPosition($result->getPosition())
|
||||
->save()
|
||||
;
|
||||
|
||||
$result->setPosition($my_position)->save();
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes category position
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
protected function changeAbsolutePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
|
||||
if ($category !== null) {
|
||||
|
||||
// The required position
|
||||
$new_position = $event->getPosition();
|
||||
|
||||
// The current position
|
||||
$current_position = $category->getPosition();
|
||||
|
||||
if ($new_position != null && $new_position > 0 && $new_position != $current_position) {
|
||||
|
||||
// Find categories to offset
|
||||
$search = CategoryQuery::create()->filterByParent($category->getParent());
|
||||
|
||||
if ($new_position > $current_position) {
|
||||
// The new position is after the current position -> we will offset + 1 all categories located between us and the new position
|
||||
$search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position));
|
||||
|
||||
$delta = -1;
|
||||
} else {
|
||||
// The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position
|
||||
$search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1));
|
||||
|
||||
$delta = 1;
|
||||
}
|
||||
|
||||
$results = $search->find();
|
||||
|
||||
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
try {
|
||||
foreach ($results as $result) {
|
||||
$result->setPosition($result->getPosition() + $delta)->save($cnx);
|
||||
}
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setPosition($new_position)
|
||||
->save($cnx)
|
||||
;
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber listens to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CATEGORY_CREATE => array("create", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
|
||||
TheliaEvents::CATEGORY_CREATE => array("create", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
TheliaEvents::CATEGORY_CHANGE_POSITION => array("changePosition", 128),
|
||||
|
||||
"action.updateCategoryPositionU" => array("changePositionUp", 128),
|
||||
"action.updateCategoryPositionDown" => array("changePositionDown", 128),
|
||||
"action.updateCategoryPosition" => array("changePosition", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\ConfigQuery;
|
||||
@@ -45,18 +44,9 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setName($event->getEventName())
|
||||
->setValue($event->getValue())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setHidden($event->getHidden())
|
||||
->setSecured($event->getSecured())
|
||||
|
||||
->save()
|
||||
;
|
||||
$config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue())
|
||||
->setLocale($event->getLocale())->setTitle($event->getTitle())->setHidden($event->getHidden())
|
||||
->setSecured($event->getSecured())->save();
|
||||
|
||||
$event->setConfig($config);
|
||||
}
|
||||
@@ -70,18 +60,13 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = ConfigQuery::create();
|
||||
|
||||
if (null !== $config = $search->findOneById($event->getConfigId())) {
|
||||
if (null !== $config = $search->findPk($event->getConfigId())) {
|
||||
|
||||
if ($event->getValue() !== $config->getValue()) {
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
$config->setDispatcher($this->getDispatcher())->setValue($event->getValue())->save();
|
||||
|
||||
->setValue($event->getValue())
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setConfig($config);
|
||||
$event->setConfig($config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,23 +80,12 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = ConfigQuery::create();
|
||||
|
||||
if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) {
|
||||
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setName($event->getEventName())
|
||||
->setValue($event->getValue())
|
||||
->setHidden($event->getHidden())
|
||||
->setSecured($event->getSecured())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
$config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue())
|
||||
->setHidden($event->getHidden())->setSecured($event->getSecured())->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())->save();
|
||||
|
||||
$event->setConfig($config);
|
||||
}
|
||||
@@ -125,14 +99,11 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
public function delete(ConfigDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) {
|
||||
if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
|
||||
|
||||
if (! $config->getSecured()) {
|
||||
if (!$config->getSecured()) {
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
$config->setDispatcher($this->getDispatcher())->delete();
|
||||
|
||||
$event->setConfig($config);
|
||||
}
|
||||
@@ -145,10 +116,15 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CONFIG_CREATE => array("create", 128),
|
||||
TheliaEvents::CONFIG_SETVALUE => array("setValue", 128),
|
||||
TheliaEvents::CONFIG_UPDATE => array("modify", 128),
|
||||
TheliaEvents::CONFIG_DELETE => array("delete", 128),
|
||||
TheliaEvents::CONFIG_CREATE => array(
|
||||
"create", 128
|
||||
), TheliaEvents::CONFIG_SETVALUE => array(
|
||||
"setValue", 128
|
||||
), TheliaEvents::CONFIG_UPDATE => array(
|
||||
"modify", 128
|
||||
), TheliaEvents::CONFIG_DELETE => array(
|
||||
"delete", 128
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) {
|
||||
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
|
||||
|
||||
$currency
|
||||
->setDispatcher($this->getDispatcher())
|
||||
@@ -97,7 +97,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) {
|
||||
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
|
||||
|
||||
if ($currency->getByDefault() != $event->getIsDefault()) {
|
||||
|
||||
@@ -123,7 +123,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
public function delete(CurrencyDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($currency = CurrencyQuery::create()->findOneById($event->getCurrencyId()))) {
|
||||
if (null !== ($currency = CurrencyQuery::create()->findPk($event->getCurrencyId()))) {
|
||||
|
||||
$currency
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
186
core/lib/Thelia/Action/Feature.php
Normal file
186
core/lib/Thelia/Action/Feature.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Model\Feature as FeatureModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\FeatureUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureCreateEvent;
|
||||
use Thelia\Core\Event\FeatureDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\FeatureAv;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryEvent;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
use Thelia\Model\FeatureTemplate;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
|
||||
class Feature extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new feature entry
|
||||
*
|
||||
* @param FeatureCreateEvent $event
|
||||
*/
|
||||
public function create(FeatureCreateEvent $event)
|
||||
{
|
||||
$feature = new FeatureModel();
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setFeature($feature);
|
||||
|
||||
// Add atribute to all product templates if required
|
||||
if ($event->getAddToAllTemplates() != 0) {
|
||||
// TODO: add to all product template
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product feature
|
||||
*
|
||||
* @param FeatureUpdateEvent $event
|
||||
*/
|
||||
public function update(FeatureUpdateEvent $event)
|
||||
{
|
||||
$search = FeatureQuery::create();
|
||||
|
||||
if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setFeature($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product feature entry
|
||||
*
|
||||
* @param FeatureDeleteEvent $event
|
||||
*/
|
||||
public function delete(FeatureDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setFeature($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $feature = FeatureQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$feature->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $feature->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $feature->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $feature->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
protected function doAddToAllTemplates(FeatureModel $feature)
|
||||
{
|
||||
$templates = TemplateQuery::create()->find();
|
||||
|
||||
foreach($templates as $template) {
|
||||
|
||||
$feature_template = new FeatureTemplate();
|
||||
|
||||
if (null === FeatureTemplateQuery::create()->filterByFeature($feature)->filterByTemplate($template)->findOne()) {
|
||||
$feature_template
|
||||
->setFeature($feature)
|
||||
->setTemplate($template)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(FeatureEvent $event)
|
||||
{
|
||||
$this->doAddToAllTemplates($event->getFeature());
|
||||
}
|
||||
|
||||
public function removeFromAllTemplates(FeatureEvent $event)
|
||||
{
|
||||
// Delete this feature from all product templates
|
||||
FeatureTemplateQuery::create()->filterByFeature($event->getFeature())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FEATURE_CREATE => array("create", 128),
|
||||
TheliaEvents::FEATURE_UPDATE => array("update", 128),
|
||||
TheliaEvents::FEATURE_DELETE => array("delete", 128),
|
||||
TheliaEvents::FEATURE_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES => array("removeFromAllTemplates", 128),
|
||||
TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES => array("addToAllTemplates", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
143
core/lib/Thelia/Action/FeatureAv.php
Normal file
143
core/lib/Thelia/Action/FeatureAv.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Model\FeatureAv as FeatureAvModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureAvCreateEvent;
|
||||
use Thelia\Core\Event\FeatureAvDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
class FeatureAv extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new feature entry
|
||||
*
|
||||
* @param FeatureAvCreateEvent $event
|
||||
*/
|
||||
public function create(FeatureAvCreateEvent $event)
|
||||
{
|
||||
$feature = new FeatureAvModel();
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setFeatureId($event->getFeatureId())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product feature
|
||||
*
|
||||
* @param FeatureAvUpdateEvent $event
|
||||
*/
|
||||
public function update(FeatureAvUpdateEvent $event)
|
||||
{
|
||||
$search = FeatureAvQuery::create();
|
||||
|
||||
if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product feature entry
|
||||
*
|
||||
* @param FeatureAvDeleteEvent $event
|
||||
*/
|
||||
public function delete(FeatureAvDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId()))) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $feature = FeatureAvQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$feature->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $feature->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $feature->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $feature->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FEATURE_AV_CREATE => array("create", 128),
|
||||
TheliaEvents::FEATURE_AV_UPDATE => array("update", 128),
|
||||
TheliaEvents::FEATURE_AV_DELETE => array("delete", 128),
|
||||
TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace Thelia\Action;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
@@ -43,6 +44,10 @@ class HttpException extends BaseAction implements EventSubscriberInterface
|
||||
if ($event->getException() instanceof NotFoundHttpException) {
|
||||
$this->display404($event);
|
||||
}
|
||||
|
||||
if($event->getException() instanceof AccessDeniedHttpException) {
|
||||
$this->display403($event);
|
||||
}
|
||||
}
|
||||
|
||||
protected function display404(GetResponseForExceptionEvent $event)
|
||||
|
||||
@@ -70,7 +70,7 @@ class Message extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = MessageQuery::create();
|
||||
|
||||
if (null !== $message = MessageQuery::create()->findOneById($event->getMessageId())) {
|
||||
if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) {
|
||||
|
||||
$message
|
||||
->setDispatcher($this->getDispatcher())
|
||||
@@ -99,7 +99,7 @@ class Message extends BaseAction implements EventSubscriberInterface
|
||||
public function delete(MessageDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($message = MessageQuery::create()->findOneById($event->getMessageId()))) {
|
||||
if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) {
|
||||
|
||||
$message
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
@@ -42,6 +42,14 @@ use Thelia\Core\Event\TemplateEvent;
|
||||
use Thelia\Model\TemplateTemplate;
|
||||
use Thelia\Model\TemplateTemplateQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||
use Thelia\Model\AttributeTemplateQuery;
|
||||
use Thelia\Model\AttributeTemplate;
|
||||
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
use Thelia\Model\FeatureTemplate;
|
||||
|
||||
class Template extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -113,6 +121,54 @@ class Template extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addAttribute(TemplateAddAttributeEvent $event) {
|
||||
|
||||
if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||
|
||||
$attribute_template = new AttributeTemplate();
|
||||
|
||||
$attribute_template
|
||||
->setAttributeId($event->getAttributeId())
|
||||
->setTemplate($event->getTemplate())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAttribute(TemplateDeleteAttributeEvent $event) {
|
||||
|
||||
$attribute_template = AttributeTemplateQuery::create()
|
||||
->filterByAttributeId($event->getAttributeId())
|
||||
->filterByTemplate($event->getTemplate())->findOne()
|
||||
;
|
||||
|
||||
if ($attribute_template !== null) $attribute_template->delete();
|
||||
}
|
||||
|
||||
public function addFeature(TemplateAddFeatureEvent $event) {
|
||||
|
||||
if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||
|
||||
$feature_template = new FeatureTemplate();
|
||||
|
||||
$feature_template
|
||||
->setFeatureId($event->getFeatureId())
|
||||
->setTemplate($event->getTemplate())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFeature(TemplateDeleteFeatureEvent $event) {
|
||||
|
||||
$feature_template = FeatureTemplateQuery::create()
|
||||
->filterByFeatureId($event->getFeatureId())
|
||||
->filterByTemplate($event->getTemplate())->findOne()
|
||||
;
|
||||
|
||||
if ($feature_template !== null) $feature_template->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -122,6 +178,13 @@ class Template extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::TEMPLATE_CREATE => array("create", 128),
|
||||
TheliaEvents::TEMPLATE_UPDATE => array("update", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE => array("delete", 128),
|
||||
|
||||
TheliaEvents::TEMPLATE_ADD_ATTRIBUTE => array("addAttribute", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE => array("deleteAttribute", 128),
|
||||
|
||||
TheliaEvents::TEMPLATE_ADD_FEATURE => array("addFeature", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE_FEATURE => array("deleteFeature", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -67,11 +67,21 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.feature" class="Thelia\Action\Feature">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.featureav" class="Thelia\Action\FeatureAv">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.httpException" class="Thelia\Action\HttpException">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<form name="thelia.address.update" class="Thelia\Form\AddressUpdateForm" />
|
||||
|
||||
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
|
||||
<form name="thelia.admin.category.deletion" class="Thelia\Form\CategoryModificationForm"/>
|
||||
<form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
|
||||
@@ -72,11 +72,19 @@
|
||||
<form name="thelia.admin.attribute.creation" class="Thelia\Form\AttributeCreationForm"/>
|
||||
<form name="thelia.admin.attribute.modification" class="Thelia\Form\AttributeModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.feature.creation" class="Thelia\Form\FeatureCreationForm"/>
|
||||
<form name="thelia.admin.feature.modification" class="Thelia\Form\FeatureModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.featureav.creation" class="Thelia\Form\FeatureAvCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
|
||||
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
|
||||
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
|
||||
@@ -259,6 +267,10 @@
|
||||
<tag name="thelia.coupon.addCoupon"/>
|
||||
</service>
|
||||
|
||||
<service id="mailer" class="Thelia\Mailer\MailerFactory">
|
||||
<argument type="service" id="event_dispatcher"/>
|
||||
</service>
|
||||
|
||||
|
||||
</services>
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.set-default" path="/admin/categories/toggle-online">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::toggleOnlineAction</default>
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::setToggleVisibilityAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.delete" path="/admin/categories/delete">
|
||||
@@ -234,6 +234,30 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.list" path="/admin/configuration/templates/features/list">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxFeaturesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.add" path="/admin/configuration/templates/features/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::addFeatureAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.delete" path="/admin/configuration/templates/features/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteFeatureAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.list" path="/admin/configuration/templates/attributes/list">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxAttributesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.add" path="/admin/configuration/templates/attributes/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::addAttributeAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.delete" path="/admin/configuration/templates/attributes/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAttributeAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- attribute and attributes value management -->
|
||||
|
||||
@@ -292,6 +316,80 @@
|
||||
|
||||
<!-- end attribute and feature routes management -->
|
||||
|
||||
<!-- Countries routes management -->
|
||||
|
||||
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.create" path="/admin/configuration/countries/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.update.view" path="/admin/configuration/countries/update/{country_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end countries routes management -->
|
||||
|
||||
<!-- feature and features value management -->
|
||||
|
||||
<route id="admin.configuration.features.default" path="/admin/configuration/features">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.create" path="/admin/configuration/features/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.update" path="/admin/configuration/features/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.save" path="/admin/configuration/features/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.delete" path="/admin/configuration/features/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.update-position" path="/admin/configuration/features/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.rem-from-all" path="/admin/configuration/features/remove-from-all-templates">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::removeFromAllTemplates</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.add-to-all" path="/admin/configuration/features/add-to-all-templates">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::addToAllTemplates</default>
|
||||
</route>
|
||||
|
||||
|
||||
<route id="admin.configuration.features-av.create" path="/admin/configuration/features-av/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.update" path="/admin/configuration/features-av/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.save" path="/admin/configuration/features-av/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.delete" path="/admin/configuration/features-av/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.update-position" path="/admin/configuration/features-av/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end feature and feature routes management -->
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
<route id="admin.processTemplate" path="/admin/{template}">
|
||||
|
||||
@@ -99,7 +99,6 @@
|
||||
</route>
|
||||
<route id="cart.add.process" path="/cart/add">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::addItem</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.delete.process" path="/cart/delete/{cart_item}">
|
||||
|
||||
@@ -69,10 +69,10 @@ class ConstraintValidator
|
||||
/**
|
||||
* Do variable comparison
|
||||
*
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param string $o Operator
|
||||
* @param mixed $v2 Variable 2
|
||||
*
|
||||
* @param mixed $v2 Variable 2
|
||||
* @throws \Exception
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -111,8 +111,8 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
|
||||
$this->availableOperators[self::INPUT1]
|
||||
);
|
||||
if (!$isOperator1Legit) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Operator for price field is not legit'
|
||||
throw new InvalidRuleOperatorException(
|
||||
get_class(), 'price'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,15 +121,15 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
|
||||
$this->availableOperators[self::INPUT2]
|
||||
);
|
||||
if (!$isOperator1Legit) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Operator for currency field is not legit'
|
||||
throw new InvalidRuleOperatorException(
|
||||
get_class(), 'price'
|
||||
);
|
||||
}
|
||||
|
||||
$floatType = new FloatType();
|
||||
if (!$floatType->isValid($priceValue) || $priceValue <= 0) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Value for price field is not legit'
|
||||
throw new InvalidRuleValueException(
|
||||
get_class(), 'price'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ use Thelia\Constraint\Validator\QuantityParam;
|
||||
use Thelia\Constraint\Validator\RuleValidator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Exception\InvalidRuleException;
|
||||
use Thelia\Exception\InvalidRuleOperatorException;
|
||||
use Thelia\Exception\InvalidRuleValueException;
|
||||
use Thelia\Type\FloatType;
|
||||
|
||||
@@ -98,14 +99,14 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
|
||||
$this->availableOperators[self::INPUT1]
|
||||
);
|
||||
if (!$isOperator1Legit) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Operator for quantity field is not legit'
|
||||
throw new InvalidRuleOperatorException(
|
||||
get_class(), 'quantity'
|
||||
);
|
||||
}
|
||||
|
||||
if ((int) $quantityValue <= 0) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Value for quantity field is not legit'
|
||||
throw new InvalidRuleValueException(
|
||||
get_class(), 'quantity'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Constraint\Rule;
|
||||
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Constraint\Validator\ComparableInterface;
|
||||
@@ -73,6 +74,9 @@ abstract class CouponRuleAbstract implements CouponRuleInterface
|
||||
/** @var array Values set by Admin in BackOffice */
|
||||
protected $values = array();
|
||||
|
||||
/** @var ConstraintValidator Constaints validator */
|
||||
protected $constraintValidator = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@@ -56,62 +56,6 @@ abstract class Operators
|
||||
/** Param1 is not in Param2 */
|
||||
CONST OUT = 'out';
|
||||
|
||||
// /**
|
||||
// * Check if a parameter is valid against a ComparableInterface from its operator
|
||||
// *
|
||||
// * @param mixed $a Parameter to validate
|
||||
// * @param string $operator Operator to validate against
|
||||
// * @param ComparableInterface $b Comparable to validate against
|
||||
// *
|
||||
// * @return bool
|
||||
// */
|
||||
// public static function isValid($a, $operator, ComparableInterface $b)
|
||||
// {
|
||||
// $ret = false;
|
||||
//
|
||||
// try {
|
||||
// $comparison = $b->compareTo($a);
|
||||
// } catch (\Exception $e) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// switch ($operator) {
|
||||
// case self::INFERIOR:
|
||||
// if ($comparison == 1) {
|
||||
// return true;
|
||||
// }
|
||||
// break;
|
||||
// case self::INFERIOR_OR_EQUAL:
|
||||
// if ($comparison == 1 || $comparison == 0) {
|
||||
// return true;
|
||||
// }
|
||||
// break;
|
||||
// case self::EQUAL:
|
||||
// if ($comparison == 0) {
|
||||
// return true;
|
||||
// }
|
||||
// break;
|
||||
// case self::SUPERIOR_OR_EQUAL:
|
||||
// if ($comparison == -1 || $comparison == 0) {
|
||||
// return true;
|
||||
// }
|
||||
// break;
|
||||
// case self::SUPERIOR:
|
||||
// if ($comparison == -1) {
|
||||
// return true;
|
||||
// }
|
||||
// break;
|
||||
// case self::DIFFERENT:
|
||||
// if ($comparison != 0) {
|
||||
// return true;
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// }
|
||||
//
|
||||
// return $ret;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get operator translation
|
||||
*
|
||||
|
||||
@@ -240,6 +240,17 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in this method post object position change processing if required.
|
||||
*
|
||||
* @param unknown $deleteEvent the delete event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalUpdatePositionAction($positionChangeEvent)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current list order identifier, updating it in the same time.
|
||||
*/
|
||||
@@ -309,14 +320,18 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) created", ucfirst($this->objectName), $this->getObjectLabel($createdObject), $this->getObjectId($createdObject)));
|
||||
}
|
||||
|
||||
$this->performAdditionalCreateAction($createEvent);
|
||||
$response = $this->performAdditionalCreateAction($createEvent);
|
||||
|
||||
// Substitute _ID_ in the URL with the ID of the created object
|
||||
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($successUrl);
|
||||
if ($response == null) {
|
||||
// Substitute _ID_ in the URL with the ID of the created object
|
||||
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($successUrl);
|
||||
}
|
||||
else {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
@@ -396,16 +411,21 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject)));
|
||||
}
|
||||
|
||||
$this->performAdditionalUpdateAction($changeEvent);
|
||||
$response = $this->performAdditionalUpdateAction($changeEvent);
|
||||
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirectToEditionTemplate($this->getRequest());
|
||||
if ($response == null) {
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirectToEditionTemplate($this->getRequest());
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($changeForm->getSuccessUrl());
|
||||
}
|
||||
else {
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($changeForm->getSuccessUrl());
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
@@ -452,7 +472,14 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
$response = $this->performAdditionalUpdatePositionAction($event);
|
||||
|
||||
if ($response == null) {
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
else {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,7 +502,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\AttributeAvCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages attributes-av sent by mail
|
||||
* Manages attributes-av
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ use Thelia\Core\Event\AttributeAvUpdateEvent;
|
||||
use Thelia\Core\Event\AttributeEvent;
|
||||
|
||||
/**
|
||||
* Manages attributes sent by mail
|
||||
* Manages attributes
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -23,226 +23,160 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\CategoryCreateEvent;
|
||||
use Thelia\Form\CategoryCreationForm;
|
||||
use Thelia\Core\Event\CategoryDeleteEvent;
|
||||
use Thelia\Core\Event\CategoryUpdatePositionEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\CategoryUpdateEvent;
|
||||
use Thelia\Core\Event\CategoryCreateEvent;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Form\CategoryModificationForm;
|
||||
use Thelia\Form\CategoryCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
|
||||
|
||||
class CategoryController extends BaseAdminController
|
||||
/**
|
||||
* Manages categories
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class CategoryController extends AbstractCrudController
|
||||
{
|
||||
/**
|
||||
* Render the categories list, ensuring the sort order is set.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
protected function renderList()
|
||||
{
|
||||
return $this->render('categories', $this->getTemplateArgs());
|
||||
public function __construct() {
|
||||
parent::__construct(
|
||||
'category',
|
||||
'manual',
|
||||
'category_order',
|
||||
|
||||
'admin.categories.default',
|
||||
'admin.categories.create',
|
||||
'admin.categories.update',
|
||||
'admin.categories.delete',
|
||||
|
||||
TheliaEvents::CATEGORY_CREATE,
|
||||
TheliaEvents::CATEGORY_UPDATE,
|
||||
TheliaEvents::CATEGORY_DELETE,
|
||||
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::CATEGORY_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getTemplateArgs()
|
||||
{
|
||||
// Get the category ID
|
||||
$category_id = $this->getRequest()->get('category_id', 0);
|
||||
protected function getCreationForm() {
|
||||
return new CategoryCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
// Find the current category order
|
||||
$category_order = $this->getRequest()->get(
|
||||
'order',
|
||||
$this->getSession()->get('admin.category_order', 'manual')
|
||||
protected function getUpdateForm() {
|
||||
return new CategoryModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData) {
|
||||
$createEvent = new CategoryCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
->setParent($formData['parent'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData) {
|
||||
$changeEvent = new CategoryUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setParent($formData['parent'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
|
||||
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('category_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent() {
|
||||
return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event) {
|
||||
return $event->hasCategory();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object) {
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewritenUrl($this->getCurrentEditionLocale()),
|
||||
'parent' => $object->getParent()
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'current_category_id' => $category_id,
|
||||
'category_order' => $category_order,
|
||||
// Setup the object form
|
||||
return new CategoryModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event) {
|
||||
return $event->hasCategory() ? $event->getCategory() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject() {
|
||||
return CategoryQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('category_id', 0));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object) {
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object) {
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder) {
|
||||
return $this->render('categories',
|
||||
array(
|
||||
'category_order' => $currentOrder,
|
||||
'category_id' => $this->getRequest()->get('category_id', 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate() {
|
||||
return $this->render('category-edit', array('category_id' => $this->getRequest()->get('category_id', 0)));
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate() {
|
||||
$this->redirectToRoute(
|
||||
"admin.categories.update",
|
||||
array('category_id' => $this->getRequest()->get('category_id', 0))
|
||||
);
|
||||
|
||||
// Store the current sort order in session
|
||||
$this->getSession()->set('admin.category_order', $category_order);
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default action is displaying the categories list.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.categories.view")) return $response;
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new category object
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.create")) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the Creation Form
|
||||
$creationForm = new CategoryCreationForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
// Validate the form, create the CategoryCreation event and dispatch it.
|
||||
$form = $this->validateForm($creationForm, "POST");
|
||||
|
||||
$data = $form->getData();
|
||||
|
||||
$createEvent = new CategoryCreateEvent(
|
||||
$data["title"],
|
||||
$data["parent"],
|
||||
$data["locale"]
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent);
|
||||
|
||||
if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was created."));
|
||||
|
||||
$createdObject = $createEvent->getCategory();
|
||||
|
||||
// Log category creation
|
||||
$this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getTitle(), $createdObject->getId()));
|
||||
|
||||
// Substitute _ID_ in the URL with the ID of the created object
|
||||
$successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl());
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($successUrl);
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext("category creation", $error_msg, $creationForm, $ex);
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a category object for modification, and display the edit template.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function changeAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
// Load the category object
|
||||
$category = CategoryQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('category_id'));
|
||||
|
||||
if ($category != null) {
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $category->getId(),
|
||||
'locale' => $category->getLocale(),
|
||||
'title' => $category->getTitle(),
|
||||
'chapo' => $category->getChapo(),
|
||||
'description' => $category->getDescription(),
|
||||
'postscriptum' => $category->getPostscriptum(),
|
||||
'parent' => $category->getParent(),
|
||||
'visible' => $category->getVisible() ? true : false,
|
||||
'url' => $category->getUrl($this->getCurrentEditionLocale())
|
||||
// tbc !!!
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
$changeForm = new CategoryModificationForm($this->getRequest(), "form", $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($changeForm);
|
||||
}
|
||||
|
||||
// Render the edition template.
|
||||
return $this->render('category-edit', $this->getTemplateArgs());
|
||||
}
|
||||
|
||||
/**
|
||||
* Save changes on a modified category object, and either go back to the category list, or stay on the edition page.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function saveChangeAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new CategoryModificationForm($this->getRequest());
|
||||
|
||||
// Get the category ID
|
||||
$category_id = $this->getRequest()->get('category_id');
|
||||
|
||||
try {
|
||||
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($changeForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$changeEvent = new CategoryUpdateEvent($data['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setCategoryName($data['name'])
|
||||
->setLocale($data["locale"])
|
||||
->setSymbol($data['symbol'])
|
||||
->setCode($data['code'])
|
||||
->setRate($data['rate'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_UPDATE, $changeEvent);
|
||||
|
||||
if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was updated."));
|
||||
|
||||
// Log category modification
|
||||
$changedObject = $changeEvent->getCategory();
|
||||
|
||||
$this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getTitle(), $changedObject->getId()));
|
||||
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirectToRoute(
|
||||
"admin.categories.update",
|
||||
array('category_id' => $category_id)
|
||||
protected function redirectToListTemplate() {
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $this->getRequest()->get('category_id', 0))
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($changeForm->getSuccessUrl());
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext("category modification", $error_msg, $changeForm, $ex);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->render('category-edit', array('category_id' => $category_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,74 +187,41 @@ class CategoryController extends BaseAdminController
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
$changeEvent = new CategoryUpdateEvent($this->getRequest()->get('category_id', 0));
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent->setIsDefault(true);
|
||||
$event = new CategoryToggleVisibilityEvent($this->getExistingObject());
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
// Ajax response -> no action
|
||||
return $this->nullResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update categoryposition
|
||||
*/
|
||||
public function updatePositionAction()
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $deleteEvent->getCategory()->getParent())
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$mode = $this->getRequest()->get('mode', null);
|
||||
protected function performAdditionalUpdatePositionAction($event)
|
||||
{
|
||||
|
||||
if ($mode == 'up')
|
||||
$mode = CategoryUpdatePositionEvent::POSITION_UP;
|
||||
else if ($mode == 'down')
|
||||
$mode = CategoryUpdatePositionEvent::POSITION_DOWN;
|
||||
else
|
||||
$mode = CategoryUpdatePositionEvent::POSITION_ABSOLUTE;
|
||||
$category = CategoryQuery::create()->findPk($event->getObjectId());
|
||||
|
||||
$position = $this->getRequest()->get('position', null);
|
||||
|
||||
$event = new CategoryUpdatePositionEvent(
|
||||
$this->getRequest()->get('category_id', null),
|
||||
$mode,
|
||||
$this->getRequest()->get('position', null)
|
||||
if ($category != null) {
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $category->getParent())
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a category object
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function deleteAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response;
|
||||
|
||||
// Get the category id, and dispatch the deleted request
|
||||
$event = new CategoryDeleteEvent($this->getRequest()->get('category_id'));
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_DELETE, $event);
|
||||
|
||||
if ($event->hasCategory())
|
||||
$this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $event->getCategory()->getTitle(), $event->getCategory()->getId()));
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\ConfigCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages variables sent by mail
|
||||
* Manages variables
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
52
core/lib/Thelia/Controller/Admin/CountryController.php
Normal file
52
core/lib/Thelia/Controller/Admin/CountryController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class CustomerController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class CountryController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.country.view")) return $response;
|
||||
return $this->render("countries", array("display_country" => 20));
|
||||
}
|
||||
|
||||
/**
|
||||
* update country action
|
||||
*
|
||||
* @param $country_id
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function updateAction($country_id)
|
||||
{
|
||||
return $this->render("country-edit", array(
|
||||
"country_id" => $country_id
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\CurrencyCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages currencies sent by mail
|
||||
* Manages currencies
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
196
core/lib/Thelia/Controller/Admin/FeatureAvController.php
Normal file
196
core/lib/Thelia/Controller/Admin/FeatureAvController.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\FeatureAvDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureAvCreateEvent;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Form\FeatureAvModificationForm;
|
||||
use Thelia\Form\FeatureAvCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages features-av
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FeatureAvController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'featureav',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
'admin.configuration.features-av.view',
|
||||
'admin.configuration.features-av.create',
|
||||
'admin.configuration.features-av.update',
|
||||
'admin.configuration.features-av.delete',
|
||||
|
||||
TheliaEvents::FEATURE_AV_CREATE,
|
||||
TheliaEvents::FEATURE_AV_UPDATE,
|
||||
TheliaEvents::FEATURE_AV_DELETE,
|
||||
null, // No visibility toggle
|
||||
TheliaEvents::FEATURE_AV_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FeatureAvCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FeatureAvModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new FeatureAvCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setFeatureId($formData['feature_id'])
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new FeatureAvUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData["locale"])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('featureav_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FeatureAvDeleteEvent($this->getRequest()->get('featureav_id'));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFeatureAv();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new FeatureAvModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFeatureAv() ? $event->getFeatureAv() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return FeatureAvQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('featureav_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getViewArguments()
|
||||
{
|
||||
return array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'order' => $this->getCurrentListOrder()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render(
|
||||
'feature-edit',
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render('feature-edit', $this->getViewArguments());
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
}
|
||||
289
core/lib/Thelia/Controller/Admin/FeatureController.php
Normal file
289
core/lib/Thelia/Controller/Admin/FeatureController.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\FeatureDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureCreateEvent;
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Form\FeatureModificationForm;
|
||||
use Thelia\Form\FeatureCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Model\FeatureAv;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages features
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FeatureController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'feature',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
'admin.configuration.features.view',
|
||||
'admin.configuration.features.create',
|
||||
'admin.configuration.features.update',
|
||||
'admin.configuration.features.delete',
|
||||
|
||||
TheliaEvents::FEATURE_CREATE,
|
||||
TheliaEvents::FEATURE_UPDATE,
|
||||
TheliaEvents::FEATURE_DELETE,
|
||||
null, // No visibility toggle
|
||||
TheliaEvents::FEATURE_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FeatureCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FeatureModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new FeatureCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
->setAddToAllTemplates($formData['add_to_all'])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new FeatureUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData["locale"])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the features values (fix it in future version to integrate it in the feature form as a collection)
|
||||
*
|
||||
* @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction()
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
$attr_values = $this->getRequest()->get('feature_values', null);
|
||||
|
||||
if ($attr_values !== null) {
|
||||
|
||||
foreach($attr_values as $id => $value) {
|
||||
|
||||
$event = new FeatureAvUpdateEvent($id);
|
||||
|
||||
$event->setTitle($value);
|
||||
$event->setLocale($this->getCurrentEditionLocale());
|
||||
|
||||
$this->dispatch(TheliaEvents::FEATURE_AV_UPDATE, $event);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('feature_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FeatureDeleteEvent($this->getRequest()->get('feature_id'));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFeature();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum()
|
||||
);
|
||||
|
||||
// Setup features values
|
||||
/*
|
||||
* FIXME : doesn't work. "We get a This form should not contain extra fields." error
|
||||
$attr_av_list = FeatureAvQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByFeatureId($object->getId())
|
||||
->find();
|
||||
|
||||
$attr_array = array();
|
||||
|
||||
foreach($attr_av_list as $attr_av) {
|
||||
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
|
||||
}
|
||||
|
||||
$data['feature_values'] = $attr_array;
|
||||
*/
|
||||
|
||||
// Setup the object form
|
||||
return new FeatureModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFeature() ? $event->getFeature() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return FeatureQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('feature_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
return $this->render('features', array('order' => $currentOrder));
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render(
|
||||
'feature-edit',
|
||||
array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'featureav_order' => $this->getFeatureAvListOrder()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'featureav_order' => $this->getFeatureAvListOrder()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.features.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Feature value list order.
|
||||
*
|
||||
* @return string the current list order
|
||||
*/
|
||||
protected function getFeatureAvListOrder()
|
||||
{
|
||||
return $this->getListOrderFromSession(
|
||||
'featureav',
|
||||
'featureav_order',
|
||||
'manual'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Remove from all product templates
|
||||
*/
|
||||
protected function addRemoveFromAllTemplates($eventType)
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.features.update")) return $response;
|
||||
|
||||
try {
|
||||
if (null !== $object = $this->getExistingObject()) {
|
||||
|
||||
$event = new FeatureEvent($object);
|
||||
|
||||
$this->dispatch($eventType, $event);
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove from all product templates
|
||||
*/
|
||||
public function removeFromAllTemplates()
|
||||
{
|
||||
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to all product templates
|
||||
*/
|
||||
public function addToAllTemplates()
|
||||
{
|
||||
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES);
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,13 @@ use Thelia\Model\TemplateAv;
|
||||
use Thelia\Model\TemplateAvQuery;
|
||||
use Thelia\Core\Event\TemplateAvUpdateEvent;
|
||||
use Thelia\Core\Event\TemplateEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages templates sent by mail
|
||||
* Manages product templates
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
@@ -193,4 +197,106 @@ class TemplateController extends AbstractCrudController
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAjaxFeaturesAction() {
|
||||
return $this->render(
|
||||
'ajax/template-feature-list',
|
||||
array('template_id' => $this->getRequest()->get('template_id'))
|
||||
);
|
||||
}
|
||||
|
||||
public function getAjaxAttributesAction() {
|
||||
return $this->render(
|
||||
'ajax/template-attribute-list',
|
||||
array('template_id' => $this->getRequest()->get('template_id'))
|
||||
);
|
||||
}
|
||||
|
||||
public function addAttributeAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
|
||||
|
||||
$attribute_id = intval($this->getRequest()->get('attribute_id'));
|
||||
|
||||
if ($attribute_id > 0) {
|
||||
$event = new TemplateAddAttributeEvent(
|
||||
$this->getExistingObject(),
|
||||
$attribute_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_ADD_ATTRIBUTE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteAttributeAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
|
||||
|
||||
$event = new TemplateDeleteAttributeEvent(
|
||||
$this->getExistingObject(),
|
||||
intval($this->getRequest()->get('attribute_id'))
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function addFeatureAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
|
||||
|
||||
$feature_id = intval($this->getRequest()->get('feature_id'));
|
||||
|
||||
if ($feature_id > 0) {
|
||||
$event = new TemplateAddFeatureEvent(
|
||||
$this->getExistingObject(),
|
||||
$feature_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_ADD_FEATURE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteFeatureAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
|
||||
|
||||
$event = new TemplateDeleteFeatureEvent(
|
||||
$this->getExistingObject(),
|
||||
intval($this->getRequest()->get('feature_id'))
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_FEATURE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -281,4 +281,16 @@ class BaseController extends ContainerAware
|
||||
$this->accessDenied();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* return an instance of \Swift_Mailer with good Transporter configured.
|
||||
*
|
||||
* @return \Swift_Mailer
|
||||
*/
|
||||
public function getMailer()
|
||||
{
|
||||
$mailer = $this->container->get('mailer');
|
||||
return $mailer->getSwiftMailer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class AddressController extends BaseFrontController
|
||||
*/
|
||||
public function generateModalAction($address_id)
|
||||
{
|
||||
|
||||
$this->checkAuth();
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
@@ -62,6 +63,7 @@ class AddressController extends BaseFrontController
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
|
||||
$this->checkAuth();
|
||||
|
||||
$addressCreate = new AddressCreateForm($this->getRequest());
|
||||
|
||||
@@ -28,13 +28,7 @@ class CategoryCreateEvent extends CategoryEvent
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
|
||||
public function __construct($title, $parent, $locale)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->parent = $parent;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
protected $visible;
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
@@ -71,4 +65,16 @@ class CategoryCreateEvent extends CategoryEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
28
core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php
Normal file
28
core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class CategoryToggleVisibilityEvent extends CategoryEvent
|
||||
{
|
||||
}
|
||||
@@ -32,7 +32,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
protected $visibility;
|
||||
protected $parent;
|
||||
|
||||
public function __construct($category_id)
|
||||
@@ -100,18 +99,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisibility()
|
||||
{
|
||||
return $this->visibility;
|
||||
}
|
||||
|
||||
public function setVisibility($visibility)
|
||||
{
|
||||
$this->visibility = $visibility;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
|
||||
68
core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php
Normal file
68
core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureAvCreateEvent extends FeatureAvEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $feature_id;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
46
core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php
Normal file
46
core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureAvDeleteEvent extends FeatureAvEvent
|
||||
{
|
||||
protected $featureAv_id;
|
||||
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
}
|
||||
|
||||
public function getFeatureAvId()
|
||||
{
|
||||
return $this->featureAv_id;
|
||||
}
|
||||
|
||||
public function setFeatureAvId($featureAv_id)
|
||||
{
|
||||
$this->featureAv_id = $featureAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/FeatureAvEvent.php
Normal file
52
core/lib/Thelia/Core/Event/FeatureAvEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\FeatureAv;
|
||||
|
||||
class FeatureAvEvent extends ActionEvent
|
||||
{
|
||||
protected $featureAv = null;
|
||||
|
||||
public function __construct(FeatureAv $featureAv = null)
|
||||
{
|
||||
$this->featureAv = $featureAv;
|
||||
}
|
||||
|
||||
public function hasFeatureAv()
|
||||
{
|
||||
return ! is_null($this->featureAv);
|
||||
}
|
||||
|
||||
public function getFeatureAv()
|
||||
{
|
||||
return $this->featureAv;
|
||||
}
|
||||
|
||||
public function setFeatureAv($featureAv)
|
||||
{
|
||||
$this->featureAv = $featureAv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
86
core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php
Normal file
86
core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureAvUpdateEvent extends FeatureAvCreateEvent
|
||||
{
|
||||
protected $featureAv_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
}
|
||||
|
||||
public function getFeatureAvId()
|
||||
{
|
||||
return $this->featureAv_id;
|
||||
}
|
||||
|
||||
public function setFeatureAvId($featureAv_id)
|
||||
{
|
||||
$this->featureAv_id = $featureAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
68
core/lib/Thelia/Core/Event/FeatureCreateEvent.php
Normal file
68
core/lib/Thelia/Core/Event/FeatureCreateEvent.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureCreateEvent extends FeatureEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $add_to_all_templates;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddToAllTemplates()
|
||||
{
|
||||
return $this->add_to_all_templates;
|
||||
}
|
||||
|
||||
public function setAddToAllTemplates($add_to_all_templates)
|
||||
{
|
||||
$this->add_to_all_templates = $add_to_all_templates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
46
core/lib/Thelia/Core/Event/FeatureDeleteEvent.php
Normal file
46
core/lib/Thelia/Core/Event/FeatureDeleteEvent.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureDeleteEvent extends FeatureEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/FeatureEvent.php
Normal file
52
core/lib/Thelia/Core/Event/FeatureEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Feature;
|
||||
|
||||
class FeatureEvent extends ActionEvent
|
||||
{
|
||||
protected $feature = null;
|
||||
|
||||
public function __construct(Feature $feature = null)
|
||||
{
|
||||
$this->feature = $feature;
|
||||
}
|
||||
|
||||
public function hasFeature()
|
||||
{
|
||||
return ! is_null($this->feature);
|
||||
}
|
||||
|
||||
public function getFeature()
|
||||
{
|
||||
return $this->feature;
|
||||
}
|
||||
|
||||
public function setFeature($feature)
|
||||
{
|
||||
$this->feature = $feature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
86
core/lib/Thelia/Core/Event/FeatureUpdateEvent.php
Normal file
86
core/lib/Thelia/Core/Event/FeatureUpdateEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureUpdateEvent extends FeatureCreateEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/MailTransporterEvent.php
Normal file
52
core/lib/Thelia/Core/Event/MailTransporterEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class MailTransporterEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class MailTransporterEvent extends ActionEvent {
|
||||
/**
|
||||
* @var \Swift_Transport
|
||||
*/
|
||||
protected $transporter;
|
||||
|
||||
public function setMailerTransporter(\Swift_Transport $transporter)
|
||||
{
|
||||
$this->transporter = $transporter;
|
||||
}
|
||||
|
||||
public function getTransporter()
|
||||
{
|
||||
return $this->transporter;
|
||||
}
|
||||
|
||||
public function hasTransporter()
|
||||
{
|
||||
return null !== $this->transporter;
|
||||
}
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Template;
|
||||
class TemplateAddAttributeEvent extends TemplateEvent
|
||||
{
|
||||
protected $attribute_id;
|
||||
|
||||
public function __construct(Template $template, $attribute_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->attribute_id = $attribute_id;
|
||||
}
|
||||
|
||||
public function getAttributeId()
|
||||
{
|
||||
return $this->attribute_id;
|
||||
}
|
||||
|
||||
public function setAttributeId($attribute_id)
|
||||
{
|
||||
$this->attribute_id = $attribute_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Template;
|
||||
class TemplateAddFeatureEvent extends TemplateEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
public function __construct(Template $template, $feature_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->feature_id = $feature_id;
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Template;
|
||||
|
||||
class TemplateDeleteAttributeEvent extends TemplateEvent
|
||||
{
|
||||
protected $attribute_id;
|
||||
|
||||
public function __construct(Template $template, $attribute_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->attribute_id = $attribute_id;
|
||||
}
|
||||
|
||||
public function getAttributeId()
|
||||
{
|
||||
return $this->attribute_id;
|
||||
}
|
||||
|
||||
public function setAttributeId($attribute_id)
|
||||
{
|
||||
$this->attribute_id = $attribute_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
51
core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php
Normal file
51
core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Template;
|
||||
|
||||
class TemplateDeleteFeatureEvent extends TemplateEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
public function __construct(Template $template, $feature_id)
|
||||
{
|
||||
|
||||
parent::__construct($template);
|
||||
|
||||
$this->feature_id = $feature_id;
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -145,50 +145,21 @@ final class TheliaEvents
|
||||
|
||||
// -- END ADDRESS MANAGEMENT ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sent once the category creation form has been successfully validated, and before category insertion in the database.
|
||||
*/
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
// -- Categories management -----------------------------------------------
|
||||
|
||||
/**
|
||||
* Create, change or delete a category
|
||||
*/
|
||||
const CATEGORY_CREATE = "action.createCategory";
|
||||
const CATEGORY_UPDATE = "action.updateCategory";
|
||||
const CATEGORY_DELETE = "action.deleteCategory";
|
||||
|
||||
/**
|
||||
* Toggle category visibility
|
||||
*/
|
||||
const CATEGORY_CREATE = "action.createCategory";
|
||||
const CATEGORY_UPDATE = "action.updateCategory";
|
||||
const CATEGORY_DELETE = "action.deleteCategory";
|
||||
const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility";
|
||||
const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition";
|
||||
|
||||
/**
|
||||
* Change category position
|
||||
*/
|
||||
const CATEGORY_CHANGE_POSITION = "action.updateCategoryPosition";
|
||||
|
||||
/**
|
||||
* Sent just after a successful insert of a new category in the database.
|
||||
*/
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
const AFTER_CREATECATEGORY = "action.after_createcategory";
|
||||
/**
|
||||
* Sent befonre deleting a category
|
||||
*/
|
||||
const BEFORE_DELETECATEGORY = "action.before_deletecategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful delete of a category from the database.
|
||||
*/
|
||||
const BEFORE_DELETECATEGORY = "action.before_deletecategory";
|
||||
const AFTER_DELETECATEGORY = "action.after_deletecategory";
|
||||
|
||||
/**
|
||||
* Sent just before a successful change of a category in the database.
|
||||
*/
|
||||
const BEFORE_UPDATECATEGORY = "action.before_updateCategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful change of a category in the database.
|
||||
*/
|
||||
const AFTER_UPDATECATEGORY = "action.after_updateCategory";
|
||||
|
||||
/**
|
||||
@@ -337,12 +308,19 @@ final class TheliaEvents
|
||||
const BEFORE_DELETECURRENCY = "action.before_deleteCurrency";
|
||||
const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
|
||||
|
||||
const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency';
|
||||
// -- Product templates management -----------------------------------------
|
||||
|
||||
const TEMPLATE_CREATE = "action.createTemplate";
|
||||
const TEMPLATE_UPDATE = "action.updateTemplate";
|
||||
const TEMPLATE_DELETE = "action.deleteTemplate";
|
||||
|
||||
const TEMPLATE_ADD_ATTRIBUTE = "action.templateAddAttribute";
|
||||
const TEMPLATE_DELETE_ATTRIBUTE = "action.templateDeleteAttribute";
|
||||
|
||||
const TEMPLATE_ADD_FEATURE = "action.templateAddFeature";
|
||||
const TEMPLATE_DELETE_FEATURE = "action.templateDeleteFeature";
|
||||
|
||||
const BEFORE_CREATETEMPLATE = "action.before_createTemplate";
|
||||
const AFTER_CREATETEMPLATE = "action.after_createTemplate";
|
||||
|
||||
@@ -371,6 +349,25 @@ final class TheliaEvents
|
||||
const BEFORE_DELETEATTRIBUTE = "action.before_deleteAttribute";
|
||||
const AFTER_DELETEATTRIBUTE = "action.after_deleteAttribute";
|
||||
|
||||
// -- Features management ---------------------------------------------
|
||||
|
||||
const FEATURE_CREATE = "action.createFeature";
|
||||
const FEATURE_UPDATE = "action.updateFeature";
|
||||
const FEATURE_DELETE = "action.deleteFeature";
|
||||
const FEATURE_UPDATE_POSITION = "action.updateFeaturePosition";
|
||||
|
||||
const FEATURE_REMOVE_FROM_ALL_TEMPLATES = "action.addFeatureToAllTemplate";
|
||||
const FEATURE_ADD_TO_ALL_TEMPLATES = "action.removeFeatureFromAllTemplate";
|
||||
|
||||
const BEFORE_CREATEFEATURE = "action.before_createFeature";
|
||||
const AFTER_CREATEFEATURE = "action.after_createFeature";
|
||||
|
||||
const BEFORE_UPDATEFEATURE = "action.before_updateFeature";
|
||||
const AFTER_UPDATEFEATURE = "action.after_updateFeature";
|
||||
|
||||
const BEFORE_DELETEFEATURE = "action.before_deleteFeature";
|
||||
const AFTER_DELETEFEATURE = "action.after_deleteFeature";
|
||||
|
||||
// -- Attributes values management ----------------------------------------
|
||||
|
||||
const ATTRIBUTE_AV_CREATE = "action.createAttributeAv";
|
||||
@@ -386,4 +383,27 @@ final class TheliaEvents
|
||||
|
||||
const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv";
|
||||
const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv";
|
||||
|
||||
|
||||
// -- Features values management ----------------------------------------
|
||||
|
||||
const FEATURE_AV_CREATE = "action.createFeatureAv";
|
||||
const FEATURE_AV_UPDATE = "action.updateFeatureAv";
|
||||
const FEATURE_AV_DELETE = "action.deleteFeatureAv";
|
||||
const FEATURE_AV_UPDATE_POSITION = "action.updateFeatureAvPosition";
|
||||
|
||||
const BEFORE_CREATEFEATURE_AV = "action.before_createFeatureAv";
|
||||
const AFTER_CREATEFEATURE_AV = "action.after_createFeatureAv";
|
||||
|
||||
const BEFORE_UPDATEFEATURE_AV = "action.before_updateFeatureAv";
|
||||
const AFTER_UPDATEFEATURE_AV = "action.after_updateFeatureAv";
|
||||
|
||||
const BEFORE_DELETEFEATURE_AV = "action.before_deleteFeatureAv";
|
||||
const AFTER_DELETEFEATURE_AV = "action.after_deleteFeatureAv";
|
||||
|
||||
/**
|
||||
* sent when system find a mailer transporter.
|
||||
*/
|
||||
const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config';
|
||||
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class ViewListener implements EventSubscriberInterface
|
||||
{
|
||||
$request = $this->container->get('request');
|
||||
|
||||
if (!$view = $request->attributes->get('_view')) {
|
||||
if (null === $view = $request->attributes->get('_view')) {
|
||||
$request->attributes->set('_view', $this->findView($request));
|
||||
}
|
||||
|
||||
|
||||
@@ -164,10 +164,12 @@ class Session extends BaseSession
|
||||
$cart = null;
|
||||
if ($cart_id) {
|
||||
$cart = CartQuery::create()->findPk($cart_id);
|
||||
try {
|
||||
$this->verifyValidCart($cart);
|
||||
} catch (InvalidCartException $e) {
|
||||
$cart = null;
|
||||
if($cart) {
|
||||
try {
|
||||
$this->verifyValidCart($cart);
|
||||
} catch (InvalidCartException $e) {
|
||||
$cart = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ abstract class BaseI18nLoop extends BaseLoop
|
||||
$columns,
|
||||
$foreignTable,
|
||||
$foreignKey,
|
||||
$forceReturn
|
||||
$this->getForce_return()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ abstract class BaseLoop
|
||||
Argument::createIntTypeArgument('page'),
|
||||
Argument::createIntTypeArgument('limit', PHP_INT_MAX),
|
||||
Argument::createBooleanTypeArgument('backend_context', false),
|
||||
Argument::createBooleanTypeArgument('force_return', false),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class LoopResult implements \Iterator
|
||||
public function __construct($modelCollection = null)
|
||||
{
|
||||
$this->position = 0;
|
||||
if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) {
|
||||
if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager || is_array($modelCollection)) {
|
||||
$this->modelCollection = $modelCollection;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,17 @@ class LoopResult implements \Iterator
|
||||
return count($this->collection);
|
||||
}
|
||||
|
||||
public function getModelCollectionCount()
|
||||
{
|
||||
if ($this->modelCollection instanceof ObjectCollection || $this->modelCollection instanceof PropelModelPager) {
|
||||
return $this->modelCollection->count();
|
||||
} elseif (is_array($this->modelCollection)) {
|
||||
return count($this->modelCollection);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Return the current element
|
||||
|
||||
@@ -107,7 +107,7 @@ class LoopResultRow
|
||||
}
|
||||
if (true === $this->countable) {
|
||||
$this->set('LOOP_COUNT', 1 + $this->loopResult->getCount());
|
||||
$this->set('LOOP_TOTAL', $this->loopResult->modelCollection->count());
|
||||
$this->set('LOOP_TOTAL', $this->loopResult->getModelCollectionCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ class Attribute extends BaseI18nLoop
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('product'),
|
||||
Argument::createIntListTypeArgument('template'),
|
||||
Argument::createIntListTypeArgument('exclude_template'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
@@ -115,15 +116,25 @@ class Attribute extends BaseI18nLoop
|
||||
$template = $productObj->getTemplate();
|
||||
}
|
||||
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
if (null !== $template) {
|
||||
$search->filterById(
|
||||
AttributeTemplateQuery::create()->filterByTemplateId($template)->select('id')->find(),
|
||||
AttributeTemplateQuery::create()->filterByTemplateId($template)->select('attribute_id')->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
|
||||
$exclude_template = $this->getExcludeTemplate();
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
if (null !== $exclude_template) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
AttributeTemplateQuery::create()->filterByTemplateId($exclude_template)->select('attribute_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
|
||||
@@ -173,6 +173,22 @@ class Category extends BaseI18nLoop
|
||||
$loopResult = new LoopResult($categories);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
// Find previous and next category
|
||||
$previous = CategoryQuery::create()
|
||||
->filterByParent($category->getParent())
|
||||
->filterByPosition($category->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = CategoryQuery::create()
|
||||
->filterByParent($category->getParent())
|
||||
->filterByPosition($category->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
/*
|
||||
* no cause pagination lost :
|
||||
* if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue;
|
||||
@@ -193,7 +209,13 @@ class Category extends BaseI18nLoop
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
;
|
||||
|
||||
->set("HAS_PREVIOUS", $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
|
||||
->set("PREVIOUS", $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildCategoryTree($parent, $visible, $level, $max_level, array $exclude, LoopResult &$loopResult)
|
||||
protected function buildCategoryTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
@@ -73,7 +73,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN);
|
||||
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -60,7 +61,8 @@ class Feature extends BaseI18nLoop
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('product'),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
Argument::createIntListTypeArgument('template'),
|
||||
Argument::createIntListTypeArgument('exclude_template'),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
@@ -102,22 +104,33 @@ class Feature extends BaseI18nLoop
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$product = $this->getProduct();
|
||||
$category = $this->getCategory();
|
||||
$template = $this->getTemplate();
|
||||
|
||||
if (null !== $product) {
|
||||
$productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData();
|
||||
// Find the template assigned to the product.
|
||||
$productObj = ProductQuery::create()->findPk($product);
|
||||
|
||||
if (null === $category) {
|
||||
$category = $productCategories;
|
||||
} else {
|
||||
$category = array_merge($category, $productCategories);
|
||||
}
|
||||
// Ignore if the product cannot be found.
|
||||
if ($productObj !== null)
|
||||
$template = $productObj->getTemplate();
|
||||
}
|
||||
|
||||
// If we have to filter by template, find all features assigned to this template, and filter by found IDs
|
||||
if (null !== $template) {
|
||||
$search->filterById(
|
||||
FeatureTemplateQuery::create()->filterByTemplateId($template)->select('feature_id')->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
|
||||
if (null !== $category) {
|
||||
$search->filterByCategory(
|
||||
CategoryQuery::create()->filterById($category)->find(),
|
||||
Criteria::IN
|
||||
$exclude_template = $this->getExcludeTemplate();
|
||||
|
||||
// If we have to filter by template, find all features assigned to this template, and filter by found IDs
|
||||
if (null !== $exclude_template) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
FeatureTemplateQuery::create()->filterByTemplateId($exclude_template)->select('feature_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,9 +73,14 @@ class Feed extends BaseLoop
|
||||
|
||||
$limit = min(count($items), $this->getLimit());
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
$indexes = array();
|
||||
for ($idx = 0; $idx < $limit; $idx++) {
|
||||
$indexes[] = $idx;
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($indexes);
|
||||
|
||||
foreach ($indexes as $idx) {
|
||||
|
||||
$item = $items[$idx];
|
||||
|
||||
@@ -87,7 +92,7 @@ class Feed extends BaseLoop
|
||||
|
||||
$date = $item->get_date('d/m/Y');
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
$loopResultRow = new LoopResultRow($loopResult, null, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow->set("URL", $item->get_permalink());
|
||||
$loopResultRow->set("TITLE", $item->get_title());
|
||||
|
||||
@@ -37,6 +37,7 @@ use Thelia\Model\Product;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
use Thelia\Tools\DateTimeFormat;
|
||||
use Thelia\Cart\CartTrait;
|
||||
|
||||
/**
|
||||
* Implementation of data access to main Thelia objects (users, cart, etc.)
|
||||
@@ -46,6 +47,8 @@ use Thelia\Tools\DateTimeFormat;
|
||||
*/
|
||||
class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
{
|
||||
use CartTrait;
|
||||
|
||||
private $securityContext;
|
||||
protected $parserContext;
|
||||
protected $request;
|
||||
@@ -151,6 +154,20 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public function cartDataAccess($params, $smarty)
|
||||
{
|
||||
$cart = $this->getCart($this->request);
|
||||
$result = "";
|
||||
switch($params["attr"]) {
|
||||
case "count_item":
|
||||
|
||||
$result = $cart->getCartItems()->count();
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lang global data
|
||||
*
|
||||
@@ -263,6 +280,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Session;
|
||||
|
||||
use Thelia\Core\Event\CurrencyEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model;
|
||||
|
||||
/**
|
||||
@@ -146,6 +148,9 @@ class TheliaHttpKernel extends HttpKernel
|
||||
$currency = null;
|
||||
if ($request->query->has("currency")) {
|
||||
$currency = Model\CurrencyQuery::create()->findOneByCode($request->query->get("currency"));
|
||||
if($currency) {
|
||||
$this->container->get("event_dispatcher")->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyEvent($currency));
|
||||
}
|
||||
} else {
|
||||
$currency = $request->getSession()->getCurrency(false);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class AdminLogin extends BaseForm
|
||||
{
|
||||
@@ -34,15 +35,27 @@ class AdminLogin extends BaseForm
|
||||
"constraints" => array(
|
||||
new NotBlank(),
|
||||
new Length(array("min" => 3))
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Username *"),
|
||||
"label_attr" => array(
|
||||
"for" => "username"
|
||||
)
|
||||
))
|
||||
->add("password", "password", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Password *"),
|
||||
"label_attr" => array(
|
||||
"for" => "password"
|
||||
)
|
||||
))
|
||||
->add("remember_me", "checkbox", array(
|
||||
'value' => 'yes'
|
||||
'value' => 'yes',
|
||||
"label" => Translator::getInstance()->trans("Remember me ?"),
|
||||
"label_attr" => array(
|
||||
"for" => "remember_me"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ use Thelia\Form\Exception\ProductNotFoundException;
|
||||
use Thelia\Model\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class CartAdd
|
||||
@@ -75,13 +76,15 @@ class CartAdd extends BaseForm
|
||||
))
|
||||
->add("product_sale_elements_id", "text", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(array("methods" => array(
|
||||
array($this, "checkStockAvailability")
|
||||
)))
|
||||
)
|
||||
),
|
||||
"required" => true
|
||||
|
||||
))
|
||||
->add("quantity", "text", array(
|
||||
->add("quantity", "number", array(
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(array("methods" => array(
|
||||
@@ -90,6 +93,10 @@ class CartAdd extends BaseForm
|
||||
new Constraints\GreaterThanOrEqual(array(
|
||||
"value" => 0
|
||||
))
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Quantity"),
|
||||
"label_attr" => array(
|
||||
"for" => "quantity"
|
||||
)
|
||||
))
|
||||
->add("append", "hidden")
|
||||
@@ -126,13 +133,17 @@ class CartAdd extends BaseForm
|
||||
{
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
$productSaleElements = ProductSaleElementsQuery::create()
|
||||
->filterById($data["product_sale_elements_id"])
|
||||
->filterByProductId($data["product"])
|
||||
->findOne();
|
||||
if (null === $data["product_sale_elements_id"]) {
|
||||
$context->addViolationAt("quantity", Translator::getInstance()->trans("Invalid product_sale_elements"));
|
||||
} else {
|
||||
$productSaleElements = ProductSaleElementsQuery::create()
|
||||
->filterById($data["product_sale_elements_id"])
|
||||
->filterByProductId($data["product"])
|
||||
->findOne();
|
||||
|
||||
if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) {
|
||||
$context->addViolation("quantity value is not valid");
|
||||
if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) {
|
||||
$context->addViolation("quantity value is not valid");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ class CategoryCreationForm extends BaseForm
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("parent", "integer", array(
|
||||
->add("parent", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Parent category *"),
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
@@ -49,6 +50,9 @@ class CategoryCreationForm extends BaseForm
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
->add("visible", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("This category is online on the front office.")
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class CategoryModificationForm extends CategoryCreationForm
|
||||
{
|
||||
@@ -36,12 +37,13 @@ class CategoryModificationForm extends CategoryCreationForm
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
|
||||
->add("visible", "checkbox", array(
|
||||
"label" => Translator::getInstance()->trans("This category is online on the front office.")
|
||||
->add("url", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Rewriten URL *"),
|
||||
"constraints" => array(new NotBlank())
|
||||
))
|
||||
;
|
||||
|
||||
// Add standard description fields
|
||||
// Add standard description fields, excluding title and locale, which a re defined in parent class
|
||||
$this->addStandardDescFields(array('title', 'locale'));
|
||||
}
|
||||
|
||||
|
||||
85
core/lib/Thelia/Form/CountryCreationForm.php
Normal file
85
core/lib/Thelia/Form/CountryCreationForm.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class CountryCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("area", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country area *"),
|
||||
"label_attr" => array(
|
||||
"for" => "area"
|
||||
)
|
||||
))
|
||||
->add("isocode", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("ISO Code *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isocode"
|
||||
)
|
||||
))
|
||||
->add("isoalpha2", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 2 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha2"
|
||||
)
|
||||
))
|
||||
->add("isoalpha3", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 3 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha3"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_country_creation";
|
||||
}
|
||||
}
|
||||
107
core/lib/Thelia/Form/CountryModificationForm.php
Normal file
107
core/lib/Thelia/Form/CountryModificationForm.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class CountryModificationForm extends CurrencyCreationForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm(true);
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("short-description", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country short description *"),
|
||||
"label_attr" => array(
|
||||
"for" => "short-description"
|
||||
)
|
||||
))
|
||||
->add("description", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country description *"),
|
||||
"label_attr" => array(
|
||||
"for" => "description"
|
||||
)
|
||||
))
|
||||
->add("area", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Country area *"),
|
||||
"label_attr" => array(
|
||||
"for" => "area"
|
||||
)
|
||||
))
|
||||
->add("isocode", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("ISO Code *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isocode"
|
||||
)
|
||||
))
|
||||
->add("isoalpha2", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 2 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha2"
|
||||
)
|
||||
))
|
||||
->add("isoalpha3", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Alpha code 3 *"),
|
||||
"label_attr" => array(
|
||||
"for" => "isoalpha3"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_country_modification";
|
||||
}
|
||||
}
|
||||
62
core/lib/Thelia/Form/FeatureAvCreationForm.php
Normal file
62
core/lib/Thelia/Form/FeatureAvCreationForm.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class FeatureAvCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
))
|
||||
)
|
||||
->add("locale" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
))
|
||||
)
|
||||
->add("feature_id", "hidden", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_featureav_creation";
|
||||
}
|
||||
}
|
||||
66
core/lib/Thelia/Form/FeatureCreationForm.php
Normal file
66
core/lib/Thelia/Form/FeatureCreationForm.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class FeatureCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
))
|
||||
)
|
||||
->add("locale" , "text" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
))
|
||||
)
|
||||
->add("add_to_all" , "checkbox" , array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Add to all product templates"),
|
||||
"label_attr" => array(
|
||||
"for" => "add_to_all"
|
||||
))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_feature_creation";
|
||||
}
|
||||
}
|
||||
62
core/lib/Thelia/Form/FeatureModificationForm.php
Normal file
62
core/lib/Thelia/Form/FeatureModificationForm.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
|
||||
class FeatureModificationForm extends FeatureCreationForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"constraints" => array(
|
||||
new GreaterThan(
|
||||
array('value' => 0)
|
||||
)
|
||||
)
|
||||
))
|
||||
/* FIXME: doesn't work
|
||||
->add('feature_values', 'collection', array(
|
||||
'type' => 'text',
|
||||
'options' => array('required' => false)
|
||||
))
|
||||
*/
|
||||
;
|
||||
|
||||
// Add standard description fields
|
||||
$this->addStandardDescFields();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_feature_modification";
|
||||
}
|
||||
}
|
||||
91
core/lib/Thelia/Mailer/MailerFactory.php
Normal file
91
core/lib/Thelia/Mailer/MailerFactory.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Mailer;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Event\MailTransporterEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class MailerFactory
|
||||
* @package Thelia\Mailer
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class MailerFactory {
|
||||
/**
|
||||
* @var \Swift_Mailer
|
||||
*/
|
||||
protected $swiftMailer;
|
||||
|
||||
protected $dispatcher;
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
|
||||
$this->dispatcher = $dispatcher;
|
||||
|
||||
$transporterEvent = new MailTransporterEvent();
|
||||
$this->dispatcher->dispatch(TheliaEvents::MAILTRANSPORTER_CONFIG, $transporterEvent);
|
||||
|
||||
if($transporterEvent->hasTransporter()) {
|
||||
$transporter = $transporterEvent->getTransporter();
|
||||
} else {
|
||||
if (ConfigQuery::read("smtp.enabled")) {
|
||||
$transporter = $this->configureSmtp();
|
||||
} else {
|
||||
$transporter = \Swift_MailTransport::newInstance();
|
||||
}
|
||||
}
|
||||
|
||||
$this->swiftMailer = new \Swift_Mailer($transporter);
|
||||
}
|
||||
|
||||
private function configureSmtp()
|
||||
{
|
||||
$smtpTransporter = new \Swift_SmtpTransport();
|
||||
$smtpTransporter->setHost(Configquery::read('smtp.host', 'localhost'))
|
||||
->setPort(ConfigQuery::read('smtp.host'))
|
||||
->setEncryption(ConfigQuery::read('smtp.encryption'))
|
||||
->setUsername(ConfigQuery::read('smtp.username'))
|
||||
->setPassword(ConfigQuery::read('smtp.password'))
|
||||
->setAuthMode(ConfigQuery::read('smtp.authmode'))
|
||||
->setTimeout(ConfigQuery::read('smtp.timeout', 30))
|
||||
->setSourceIp(ConfigQuery::read('smtp.sourceip'))
|
||||
;
|
||||
return $smtpTransporter;
|
||||
}
|
||||
|
||||
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
|
||||
{
|
||||
$this->swiftMailer->send($message, $failedRecipients);
|
||||
}
|
||||
|
||||
public function getSwiftMailer()
|
||||
{
|
||||
return $this->swiftMailer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -116,6 +116,12 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
*/
|
||||
protected $discount;
|
||||
|
||||
/**
|
||||
* The value for the promo field.
|
||||
* @var int
|
||||
*/
|
||||
protected $promo;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
@@ -527,6 +533,17 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
return $this->discount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [promo] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPromo()
|
||||
{
|
||||
|
||||
return $this->promo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
@@ -768,6 +785,27 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setDiscount()
|
||||
|
||||
/**
|
||||
* Set the value of [promo] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return \Thelia\Model\CartItem The current object (for fluent API support)
|
||||
*/
|
||||
public function setPromo($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->promo !== $v) {
|
||||
$this->promo = $v;
|
||||
$this->modifiedColumns[] = CartItemTableMap::PROMO;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setPromo()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
@@ -885,13 +923,16 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->discount = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->promo = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CartItemTableMap::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 ? 10 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -904,7 +945,7 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 11; // 11 = CartItemTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 12; // 12 = CartItemTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\CartItem object", 0, $e);
|
||||
@@ -1189,6 +1230,9 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'DISCOUNT';
|
||||
}
|
||||
if ($this->isColumnModified(CartItemTableMap::PROMO)) {
|
||||
$modifiedColumns[':p' . $index++] = 'PROMO';
|
||||
}
|
||||
if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
@@ -1233,6 +1277,9 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
case 'DISCOUNT':
|
||||
$stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'PROMO':
|
||||
$stmt->bindValue($identifier, $this->promo, 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;
|
||||
@@ -1329,9 +1376,12 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
return $this->getDiscount();
|
||||
break;
|
||||
case 9:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getPromo();
|
||||
break;
|
||||
case 10:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 11:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -1372,8 +1422,9 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
$keys[6] => $this->getPromoPrice(),
|
||||
$keys[7] => $this->getPriceEndOfLife(),
|
||||
$keys[8] => $this->getDiscount(),
|
||||
$keys[9] => $this->getCreatedAt(),
|
||||
$keys[10] => $this->getUpdatedAt(),
|
||||
$keys[9] => $this->getPromo(),
|
||||
$keys[10] => $this->getCreatedAt(),
|
||||
$keys[11] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1453,9 +1504,12 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
$this->setDiscount($value);
|
||||
break;
|
||||
case 9:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setPromo($value);
|
||||
break;
|
||||
case 10:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 11:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1491,8 +1545,9 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[6], $arr)) $this->setPromoPrice($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setPriceEndOfLife($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setDiscount($arr[$keys[8]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setPromo($arr[$keys[9]]);
|
||||
if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]);
|
||||
if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1513,6 +1568,7 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) $criteria->add(CartItemTableMap::PROMO_PRICE, $this->promo_price);
|
||||
if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) $criteria->add(CartItemTableMap::PRICE_END_OF_LIFE, $this->price_end_of_life);
|
||||
if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) $criteria->add(CartItemTableMap::DISCOUNT, $this->discount);
|
||||
if ($this->isColumnModified(CartItemTableMap::PROMO)) $criteria->add(CartItemTableMap::PROMO, $this->promo);
|
||||
if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) $criteria->add(CartItemTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(CartItemTableMap::UPDATED_AT)) $criteria->add(CartItemTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1586,6 +1642,7 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
$copyObj->setPromoPrice($this->getPromoPrice());
|
||||
$copyObj->setPriceEndOfLife($this->getPriceEndOfLife());
|
||||
$copyObj->setDiscount($this->getDiscount());
|
||||
$copyObj->setPromo($this->getPromo());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
if ($makeNew) {
|
||||
@@ -1783,6 +1840,7 @@ abstract class CartItem implements ActiveRecordInterface
|
||||
$this->promo_price = null;
|
||||
$this->price_end_of_life = null;
|
||||
$this->discount = null;
|
||||
$this->promo = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
@@ -30,6 +30,7 @@ use Thelia\Model\Map\CartItemTableMap;
|
||||
* @method ChildCartItemQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column
|
||||
* @method ChildCartItemQuery orderByPriceEndOfLife($order = Criteria::ASC) Order by the price_end_of_life column
|
||||
* @method ChildCartItemQuery orderByDiscount($order = Criteria::ASC) Order by the discount column
|
||||
* @method ChildCartItemQuery orderByPromo($order = Criteria::ASC) Order by the promo column
|
||||
* @method ChildCartItemQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildCartItemQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
@@ -42,6 +43,7 @@ use Thelia\Model\Map\CartItemTableMap;
|
||||
* @method ChildCartItemQuery groupByPromoPrice() Group by the promo_price column
|
||||
* @method ChildCartItemQuery groupByPriceEndOfLife() Group by the price_end_of_life column
|
||||
* @method ChildCartItemQuery groupByDiscount() Group by the discount column
|
||||
* @method ChildCartItemQuery groupByPromo() Group by the promo column
|
||||
* @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -73,6 +75,7 @@ use Thelia\Model\Map\CartItemTableMap;
|
||||
* @method ChildCartItem findOneByPromoPrice(double $promo_price) Return the first ChildCartItem filtered by the promo_price column
|
||||
* @method ChildCartItem findOneByPriceEndOfLife(string $price_end_of_life) Return the first ChildCartItem filtered by the price_end_of_life column
|
||||
* @method ChildCartItem findOneByDiscount(double $discount) Return the first ChildCartItem filtered by the discount column
|
||||
* @method ChildCartItem findOneByPromo(int $promo) Return the first ChildCartItem filtered by the promo column
|
||||
* @method ChildCartItem findOneByCreatedAt(string $created_at) Return the first ChildCartItem filtered by the created_at column
|
||||
* @method ChildCartItem findOneByUpdatedAt(string $updated_at) Return the first ChildCartItem filtered by the updated_at column
|
||||
*
|
||||
@@ -85,6 +88,7 @@ use Thelia\Model\Map\CartItemTableMap;
|
||||
* @method array findByPromoPrice(double $promo_price) Return ChildCartItem objects filtered by the promo_price column
|
||||
* @method array findByPriceEndOfLife(string $price_end_of_life) Return ChildCartItem objects filtered by the price_end_of_life column
|
||||
* @method array findByDiscount(double $discount) Return ChildCartItem objects filtered by the discount column
|
||||
* @method array findByPromo(int $promo) Return ChildCartItem objects filtered by the promo column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCartItem objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildCartItem objects filtered by the updated_at column
|
||||
*
|
||||
@@ -175,7 +179,7 @@ abstract class CartItemQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, DISCOUNT, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, DISCOUNT, PROMO, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -641,6 +645,47 @@ abstract class CartItemQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the promo column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByPromo(1234); // WHERE promo = 1234
|
||||
* $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34)
|
||||
* $query->filterByPromo(array('min' => 12)); // WHERE promo > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $promo 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 ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPromo($promo = null, $comparison = null)
|
||||
{
|
||||
if (is_array($promo)) {
|
||||
$useMinMax = false;
|
||||
if (isset($promo['min'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($promo['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::PROMO, $promo, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
|
||||
@@ -93,6 +93,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $isoalpha3;
|
||||
|
||||
/**
|
||||
* The value for the by_default field.
|
||||
* @var int
|
||||
*/
|
||||
protected $by_default;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var string
|
||||
@@ -477,6 +483,17 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->isoalpha3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [by_default] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getByDefault()
|
||||
{
|
||||
|
||||
return $this->by_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [created_at] column value.
|
||||
*
|
||||
@@ -626,6 +643,27 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setIsoalpha3()
|
||||
|
||||
/**
|
||||
* Set the value of [by_default] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return \Thelia\Model\Country The current object (for fluent API support)
|
||||
*/
|
||||
public function setByDefault($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->by_default !== $v) {
|
||||
$this->by_default = $v;
|
||||
$this->modifiedColumns[] = CountryTableMap::BY_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setByDefault()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
*
|
||||
@@ -720,13 +758,16 @@ abstract class Country implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryTableMap::translateFieldName('Isoalpha3', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->isoalpha3 = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->by_default = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::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 ? 6 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -739,7 +780,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 7; // 7 = CountryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 8; // 8 = CountryTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\Country object", 0, $e);
|
||||
@@ -1043,6 +1084,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ISOALPHA3';
|
||||
}
|
||||
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
|
||||
}
|
||||
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
@@ -1075,6 +1119,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
case 'ISOALPHA3':
|
||||
$stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'BY_DEFAULT':
|
||||
$stmt->bindValue($identifier, $this->by_default, 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;
|
||||
@@ -1152,9 +1199,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->getIsoalpha3();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getByDefault();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 7:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -1191,8 +1241,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
$keys[2] => $this->getIsocode(),
|
||||
$keys[3] => $this->getIsoalpha2(),
|
||||
$keys[4] => $this->getIsoalpha3(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
$keys[5] => $this->getByDefault(),
|
||||
$keys[6] => $this->getCreatedAt(),
|
||||
$keys[7] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1263,9 +1314,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->setIsoalpha3($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setByDefault($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 7:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1297,8 +1351,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[2], $arr)) $this->setIsocode($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1315,6 +1370,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(CountryTableMap::ISOCODE)) $criteria->add(CountryTableMap::ISOCODE, $this->isocode);
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) $criteria->add(CountryTableMap::ISOALPHA2, $this->isoalpha2);
|
||||
if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) $criteria->add(CountryTableMap::ISOALPHA3, $this->isoalpha3);
|
||||
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) $criteria->add(CountryTableMap::BY_DEFAULT, $this->by_default);
|
||||
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) $criteria->add(CountryTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) $criteria->add(CountryTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1385,6 +1441,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$copyObj->setIsocode($this->getIsocode());
|
||||
$copyObj->setIsoalpha2($this->getIsoalpha2());
|
||||
$copyObj->setIsoalpha3($this->getIsoalpha3());
|
||||
$copyObj->setByDefault($this->getByDefault());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
|
||||
@@ -2287,6 +2344,7 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->isocode = null;
|
||||
$this->isoalpha2 = null;
|
||||
$this->isoalpha3 = null;
|
||||
$this->by_default = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
@@ -27,6 +27,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery orderByIsocode($order = Criteria::ASC) Order by the isocode column
|
||||
* @method ChildCountryQuery orderByIsoalpha2($order = Criteria::ASC) Order by the isoalpha2 column
|
||||
* @method ChildCountryQuery orderByIsoalpha3($order = Criteria::ASC) Order by the isoalpha3 column
|
||||
* @method ChildCountryQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column
|
||||
* @method ChildCountryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildCountryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
@@ -35,6 +36,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery groupByIsocode() Group by the isocode column
|
||||
* @method ChildCountryQuery groupByIsoalpha2() Group by the isoalpha2 column
|
||||
* @method ChildCountryQuery groupByIsoalpha3() Group by the isoalpha3 column
|
||||
* @method ChildCountryQuery groupByByDefault() Group by the by_default column
|
||||
* @method ChildCountryQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildCountryQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -66,6 +68,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountry findOneByIsocode(string $isocode) Return the first ChildCountry filtered by the isocode column
|
||||
* @method ChildCountry findOneByIsoalpha2(string $isoalpha2) Return the first ChildCountry filtered by the isoalpha2 column
|
||||
* @method ChildCountry findOneByIsoalpha3(string $isoalpha3) Return the first ChildCountry filtered by the isoalpha3 column
|
||||
* @method ChildCountry findOneByByDefault(int $by_default) Return the first ChildCountry filtered by the by_default column
|
||||
* @method ChildCountry findOneByCreatedAt(string $created_at) Return the first ChildCountry filtered by the created_at column
|
||||
* @method ChildCountry findOneByUpdatedAt(string $updated_at) Return the first ChildCountry filtered by the updated_at column
|
||||
*
|
||||
@@ -74,6 +77,7 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method array findByIsocode(string $isocode) Return ChildCountry objects filtered by the isocode column
|
||||
* @method array findByIsoalpha2(string $isoalpha2) Return ChildCountry objects filtered by the isoalpha2 column
|
||||
* @method array findByIsoalpha3(string $isoalpha3) Return ChildCountry objects filtered by the isoalpha3 column
|
||||
* @method array findByByDefault(int $by_default) Return ChildCountry objects filtered by the by_default column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCountry objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildCountry objects filtered by the updated_at column
|
||||
*
|
||||
@@ -164,7 +168,7 @@ abstract class CountryQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -424,6 +428,47 @@ abstract class CountryQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(CountryTableMap::ISOALPHA3, $isoalpha3, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the by_default column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByByDefault(1234); // WHERE by_default = 1234
|
||||
* $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34)
|
||||
* $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $byDefault 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 ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByByDefault($byDefault = null, $comparison = null)
|
||||
{
|
||||
if (is_array($byDefault)) {
|
||||
$useMinMax = false;
|
||||
if (isset($byDefault['min'])) {
|
||||
$this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($byDefault['max'])) {
|
||||
$this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
|
||||
@@ -44,16 +44,18 @@ class Cart extends BaseCart
|
||||
$item->setQuantity($cartItem->getQuantity());
|
||||
$item->setProductSaleElements($productSaleElements);
|
||||
if ($currentDateTime <= $cartItem->getPriceEndOfLife()) {
|
||||
$item->setPrice($cartItem->getPrice());
|
||||
$item->setPromoPrice($cartItem->getPromoPrice());
|
||||
$item->setPrice($cartItem->getPrice())
|
||||
->setPromoPrice($cartItem->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
// TODO : new price EOF or duplicate current priceEOF from $cartItem ?
|
||||
$item->setPriceEndOfLife($cartItem->getPriceEndOfLife());
|
||||
->setPriceEndOfLife($cartItem->getPriceEndOfLife());
|
||||
} else {
|
||||
$productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne();
|
||||
|
||||
$item->setPrice($productPrices->getPrice());
|
||||
$item->setPromoPrice($productPrices->getPromoPrice());
|
||||
$item->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
|
||||
$item->setPrice($productPrices->getPrice())
|
||||
->setPromoPrice($productPrices->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
|
||||
}
|
||||
$item->save();
|
||||
}
|
||||
@@ -76,4 +78,17 @@ class Cart extends BaseCart
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getTotalAmount()
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
foreach($this->getCartItems() as $cartItem) {
|
||||
$total += $cartItem->getPrice()-$cartItem->getDiscount();
|
||||
}
|
||||
|
||||
$total -= $this->getDiscount();
|
||||
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ class Category extends BaseCategory
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
use \Thelia\Model\Tools\UrlRewritingTrait;
|
||||
|
||||
/**
|
||||
* @return int number of child for the current category
|
||||
*/
|
||||
@@ -23,30 +25,12 @@ class Category extends BaseCategory
|
||||
return CategoryQuery::countChild($this->getId());
|
||||
}
|
||||
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::getInstance()->retrieve('category', $this->getId(), $locale)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new category.
|
||||
*
|
||||
* @param string $title the category title
|
||||
* @param int $parent the ID of the parent category
|
||||
* @param string $locale the locale of the title
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function create($title, $parent, $locale)
|
||||
{
|
||||
$this
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
->setParent($parent)
|
||||
->setVisible(1)
|
||||
->setPosition($this->getNextPosition($parent))
|
||||
;
|
||||
|
||||
$this->save();
|
||||
}
|
||||
protected function getRewritenUrlViewName() {
|
||||
return 'category';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -71,18 +55,38 @@ class Category extends BaseCategory
|
||||
return $countProduct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our parent
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
$query->filterByParent($this->getParent());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->generateRewritenUrl($this->getLocale());
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY, new CategoryEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATECATEGORY, new CategoryEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATECATEGORY, new CategoryEvent($this));
|
||||
@@ -90,16 +94,27 @@ class Category extends BaseCategory
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECATEGORY, new CategoryEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY, new CategoryEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this));
|
||||
|
||||
@@ -65,6 +65,7 @@ class Config extends BaseConfig {
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->resetQueryCache();
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATECONFIG, new ConfigEvent($this));
|
||||
}
|
||||
|
||||
@@ -83,6 +84,12 @@ class Config extends BaseConfig {
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->resetQueryCache();
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETECONFIG, new ConfigEvent($this));
|
||||
}
|
||||
|
||||
public function resetQueryCache()
|
||||
{
|
||||
ConfigQuery::resetCache($this->getName());
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,32 @@ use Thelia\Model\Base\ConfigQuery as BaseConfigQuery;
|
||||
*
|
||||
*/
|
||||
class ConfigQuery extends BaseConfigQuery {
|
||||
|
||||
protected static $cache = array();
|
||||
|
||||
public static function read($search, $default = null)
|
||||
{
|
||||
if (array_key_exists($search, self::$cache)) {
|
||||
return self::$cache[$search];
|
||||
}
|
||||
|
||||
$value = self::create()->findOneByName($search);
|
||||
|
||||
return $value ? $value->getValue() : $default;
|
||||
self::$cache[$search] = $value ? $value->getValue() : $default;
|
||||
|
||||
return self::$cache[$search];
|
||||
}
|
||||
|
||||
public static function resetCache($key = null)
|
||||
{
|
||||
if($key) {
|
||||
if(array_key_exists($key, self::$cache)) {
|
||||
unset(self::$cache[$key]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
self::$cache = array();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getDefaultLangWhenNoTranslationAvailable()
|
||||
|
||||
@@ -4,11 +4,41 @@ namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\Content as BaseContent;
|
||||
use Thelia\Tools\URL;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
|
||||
class Content extends BaseContent
|
||||
{
|
||||
public function getUrl($locale)
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
use \Thelia\Model\Tools\UrlRewritingTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getRewritenUrlViewName() {
|
||||
return 'content';
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our parent
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
|
||||
// TODO: Find the default folder for this content,
|
||||
// and generate the position relative to this folder
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
return URL::getInstance()->retrieve('content', $this->getId(), $locale)->toString();
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->generateRewritenUrl($this->getLocale());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,70 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\Feature as BaseFeature;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
|
||||
class Feature extends BaseFeature {
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE, new FeatureEvent($this));
|
||||
|
||||
// Set the current position for the new object
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE, new FeatureEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE, new FeatureEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE, new FeatureEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE, new FeatureEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE, new FeatureEvent($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,78 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\FeatureAv as BaseFeatureAv;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\FeatureAvEvent;
|
||||
|
||||
class FeatureAv extends BaseFeatureAv {
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
/**
|
||||
* when dealing with position, be sure to work insite the current feature.
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
$query->filterByFeatureId($this->getFeatureId());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
// Set the current position for the new object
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE_AV, new FeatureAvEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE_AV, new FeatureAvEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE_AV, new FeatureAvEvent($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,23 @@ namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\Folder as BaseFolder;
|
||||
use Thelia\Tools\URL;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
|
||||
class Folder extends BaseFolder
|
||||
{
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
use \Thelia\Model\Tools\UrlRewritingTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getRewritenUrlViewName() {
|
||||
return 'folder';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int number of contents for the folder
|
||||
*/
|
||||
@@ -15,11 +29,6 @@ class Folder extends BaseFolder
|
||||
return FolderQuery::countChild($this->getId());
|
||||
}
|
||||
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::getInstance()->retrieve('folder', $this->getId(), $locale)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* count all products for current category and sub categories
|
||||
@@ -43,4 +52,23 @@ class Folder extends BaseFolder
|
||||
return $contentsCount;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our parent
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
$query->filterByParent($this->getParent());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->generateRewritenUrl($this->getLocale());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class CartItemTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 11;
|
||||
const NUM_COLUMNS = 12;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class CartItemTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 11;
|
||||
const NUM_HYDRATE_COLUMNS = 12;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -114,6 +114,11 @@ class CartItemTableMap extends TableMap
|
||||
*/
|
||||
const DISCOUNT = 'cart_item.DISCOUNT';
|
||||
|
||||
/**
|
||||
* the column name for the PROMO field
|
||||
*/
|
||||
const PROMO = 'cart_item.PROMO';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
@@ -136,12 +141,12 @@ class CartItemTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'Discount', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'discount', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::DISCOUNT, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'discount', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
|
||||
self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'Discount', 'Promo', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'discount', 'promo', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::DISCOUNT, CartItemTableMap::PROMO, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'DISCOUNT', 'PROMO', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'discount', 'promo', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -151,12 +156,12 @@ class CartItemTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'Discount' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'discount' => 8, 'createdAt' => 9, 'updatedAt' => 10, ),
|
||||
self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::DISCOUNT => 8, CartItemTableMap::CREATED_AT => 9, CartItemTableMap::UPDATED_AT => 10, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'DISCOUNT' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'discount' => 8, 'created_at' => 9, 'updated_at' => 10, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'Discount' => 8, 'Promo' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'discount' => 8, 'promo' => 9, 'createdAt' => 10, 'updatedAt' => 11, ),
|
||||
self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::DISCOUNT => 8, CartItemTableMap::PROMO => 9, CartItemTableMap::CREATED_AT => 10, CartItemTableMap::UPDATED_AT => 11, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'DISCOUNT' => 8, 'PROMO' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'discount' => 8, 'promo' => 9, 'created_at' => 10, 'updated_at' => 11, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -184,6 +189,7 @@ class CartItemTableMap extends TableMap
|
||||
$this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null);
|
||||
$this->addColumn('PRICE_END_OF_LIFE', 'PriceEndOfLife', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, 0);
|
||||
$this->addColumn('PROMO', 'Promo', 'INTEGER', false, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -358,6 +364,7 @@ class CartItemTableMap extends TableMap
|
||||
$criteria->addSelectColumn(CartItemTableMap::PROMO_PRICE);
|
||||
$criteria->addSelectColumn(CartItemTableMap::PRICE_END_OF_LIFE);
|
||||
$criteria->addSelectColumn(CartItemTableMap::DISCOUNT);
|
||||
$criteria->addSelectColumn(CartItemTableMap::PROMO);
|
||||
$criteria->addSelectColumn(CartItemTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(CartItemTableMap::UPDATED_AT);
|
||||
} else {
|
||||
@@ -370,6 +377,7 @@ class CartItemTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.PROMO_PRICE');
|
||||
$criteria->addSelectColumn($alias . '.PRICE_END_OF_LIFE');
|
||||
$criteria->addSelectColumn($alias . '.DISCOUNT');
|
||||
$criteria->addSelectColumn($alias . '.PROMO');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class CountryTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 7;
|
||||
const NUM_COLUMNS = 8;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class CountryTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 7;
|
||||
const NUM_HYDRATE_COLUMNS = 8;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -94,6 +94,11 @@ class CountryTableMap extends TableMap
|
||||
*/
|
||||
const ISOALPHA3 = 'country.ISOALPHA3';
|
||||
|
||||
/**
|
||||
* the column name for the BY_DEFAULT field
|
||||
*/
|
||||
const BY_DEFAULT = 'country.BY_DEFAULT';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
@@ -125,12 +130,12 @@ class CountryTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'ByDefault', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'byDefault', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::BY_DEFAULT, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'by_default', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -140,12 +145,12 @@ class CountryTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::CREATED_AT => 5, CountryTableMap::UPDATED_AT => 6, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
|
||||
self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::BY_DEFAULT => 5, CountryTableMap::CREATED_AT => 6, CountryTableMap::UPDATED_AT => 7, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -169,6 +174,7 @@ class CountryTableMap extends TableMap
|
||||
$this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null);
|
||||
$this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null);
|
||||
$this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null);
|
||||
$this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -351,6 +357,7 @@ class CountryTableMap extends TableMap
|
||||
$criteria->addSelectColumn(CountryTableMap::ISOCODE);
|
||||
$criteria->addSelectColumn(CountryTableMap::ISOALPHA2);
|
||||
$criteria->addSelectColumn(CountryTableMap::ISOALPHA3);
|
||||
$criteria->addSelectColumn(CountryTableMap::BY_DEFAULT);
|
||||
$criteria->addSelectColumn(CountryTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(CountryTableMap::UPDATED_AT);
|
||||
} else {
|
||||
@@ -359,6 +366,7 @@ class CountryTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.ISOCODE');
|
||||
$criteria->addSelectColumn($alias . '.ISOALPHA2');
|
||||
$criteria->addSelectColumn($alias . '.ISOALPHA3');
|
||||
$criteria->addSelectColumn($alias . '.BY_DEFAULT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
@@ -6,19 +6,29 @@ use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\Base\Product as BaseProduct;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\TaxEngine\Calculator;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
|
||||
class Product extends BaseProduct
|
||||
{
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::getInstance()->retrieve('product', $this->getId(), $locale)->toString();
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
use \Thelia\Model\Tools\UrlRewritingTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getRewritenUrlViewName() {
|
||||
return 'product';
|
||||
}
|
||||
|
||||
public function getRealLowestPrice($virtualColumnName = 'real_lowest_price')
|
||||
{
|
||||
try {
|
||||
$amount = $this->getVirtualColumn($virtualColumnName);
|
||||
} catch(PropelException $e) {
|
||||
}
|
||||
catch(PropelException $e) {
|
||||
throw new PropelException("Virtual column `$virtualColumnName` does not exist in Product::getRealLowestPrice");
|
||||
}
|
||||
|
||||
@@ -30,4 +40,26 @@ class Product extends BaseProduct
|
||||
$taxCalculator = new Calculator();
|
||||
return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our default category
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
|
||||
// TODO: Find the default category for this product,
|
||||
// and generate the position relative to this category
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->generateRewritenUrl($this->getLocale());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
78
core/lib/Thelia/Model/Tools/UrlRewritingTrait.php
Normal file
78
core/lib/Thelia/Model/Tools/UrlRewritingTrait.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Model\Tools;
|
||||
|
||||
use Thelia\Tools\URL;
|
||||
/**
|
||||
* A trait for managing Rewriten URLs from model classes
|
||||
*/
|
||||
trait UrlRewritingTrait {
|
||||
|
||||
/**
|
||||
* @returns string the view name of the rewriten object (e.g., 'category', 'product')
|
||||
*/
|
||||
protected abstract function getRewritenUrlViewName();
|
||||
|
||||
/**
|
||||
* Get the object URL for the given locale, rewriten if rewriting is enabled.
|
||||
*
|
||||
* @param string $locale a valid locale (e.g. en_US)
|
||||
*/
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::getInstance()->retrieve($this->getRewritenUrlViewName(), $this->getId(), $locale)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a rewriten URL from the object title, and store it in the rewriting table
|
||||
*
|
||||
* @param string $locale a valid locale (e.g. en_US)
|
||||
*/
|
||||
public function generateRewritenUrl($locale)
|
||||
{
|
||||
URL::getInstance()->generateRewritenUrl($this->getRewritenUrlViewName(), $this->getId(), $locale, $this->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* return the rewriten URL for the given locale
|
||||
*
|
||||
* @param string $locale a valid locale (e.g. en_US)
|
||||
*/
|
||||
public function getRewritenUrl($locale)
|
||||
{
|
||||
return "fake url - TODO";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the rewriten URL for the given locale
|
||||
*
|
||||
* @param string $locale a valid locale (e.g. en_US)
|
||||
*/
|
||||
public function setRewritenUrl($locale, $url)
|
||||
{
|
||||
// TODO - code me !
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -99,6 +102,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -136,6 +142,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(5));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -183,6 +192,9 @@ class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(5));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue($ConstraintValidator));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
|
||||
@@ -23,21 +23,23 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
use Thelia\Exception\InvalidRuleValueException;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/19/13
|
||||
* Time: 3:24 PM
|
||||
*
|
||||
* Unit Test AvailableForTotalAmount Class
|
||||
* Unit Test AvailableForTotalAmountManager Class
|
||||
*
|
||||
* @package Constraint
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var CouponAdapterInterface $stubTheliaAdapter */
|
||||
protected $stubTheliaAdapter = null;
|
||||
@@ -48,108 +50,168 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
// /** @var CouponAdapterInterface $stubTheliaAdapter */
|
||||
// $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock();
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Generate valid CouponBaseAdapter
|
||||
// *
|
||||
// * @param float $cartTotalPrice Total amount of the current Cart
|
||||
// *
|
||||
// * @return CouponAdapterInterface
|
||||
// */
|
||||
// protected function generateValidCouponBaseAdapterMock($cartTotalPrice = 421.23)
|
||||
// {
|
||||
// /** @var CouponAdapterInterface $stubTheliaAdapter */
|
||||
// $stubTheliaAdapter = $this->getMock(
|
||||
// 'Thelia\Coupon\CouponBaseAdapter',
|
||||
// array('getCartTotalPrice'),
|
||||
// array()
|
||||
// );
|
||||
// $stubTheliaAdapter->expects($this->any())
|
||||
// ->method('getCartTotalPrice')
|
||||
// ->will($this->returnValue($cartTotalPrice));
|
||||
//
|
||||
// return $stubTheliaAdapter;
|
||||
// }
|
||||
/**
|
||||
* Check if validity test on BackOffice inputs are working
|
||||
*
|
||||
* @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators
|
||||
* @expectedException \Thelia\Exception\InvalidRuleOperatorException
|
||||
*
|
||||
*/
|
||||
public function testInValidBackOfficeInputOperator()
|
||||
{
|
||||
$stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
// /**
|
||||
// * Check if validity test on BackOffice inputs are working
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput
|
||||
// *
|
||||
// */
|
||||
// public function testValidBackOfficeInput()
|
||||
// {
|
||||
// $adapter = new CouponBaseAdapter();
|
||||
//
|
||||
// $validators = array(
|
||||
// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
|
||||
// Operators::SUPERIOR,
|
||||
// new PriceParam(
|
||||
// $adapter, 421.23, 'EUR'
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
// $rule = new AvailableForTotalAmount($adapter, $validators);
|
||||
//
|
||||
// $expected = true;
|
||||
// $actual = $rule->checkBackOfficeInput();
|
||||
// $this->assertEquals($expected, $actual);
|
||||
// }
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCartTotalPrice')
|
||||
->will($this->returnValue(399));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
// /**
|
||||
// * Check if validity test on BackOffice inputs are working
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput
|
||||
// * @expectedException \Thelia\Exception\InvalidRuleOperatorException
|
||||
// *
|
||||
// */
|
||||
// public function testInValidBackOfficeInputOperator()
|
||||
// {
|
||||
// $adapter = new CouponBaseAdapter();
|
||||
//
|
||||
// $validators = array(
|
||||
// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
|
||||
// 'X',
|
||||
// new PriceParam(
|
||||
// $adapter, 421.23, 'EUR'
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// $rule = new AvailableForTotalAmount($adapter, $validators);
|
||||
//
|
||||
// $expected = false;
|
||||
// $actual = $rule->checkBackOfficeInput();
|
||||
// $this->assertEquals($expected, $actual);
|
||||
// }
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => Operators::IN,
|
||||
AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL
|
||||
);
|
||||
$values = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => '400',
|
||||
AvailableForTotalAmountManager::INPUT2 => 'EUR');
|
||||
$rule1->setValidatorsFromForm($operators, $values);
|
||||
|
||||
// /**
|
||||
// * Check if validity test on BackOffice inputs are working
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput
|
||||
// * @expectedException \ErrorException
|
||||
// *
|
||||
// */
|
||||
// public function testInValidBackOfficeInputValue()
|
||||
// {
|
||||
// $adapter = $this->generateValidCouponBaseAdapterMock();
|
||||
//
|
||||
// $validators = array(
|
||||
// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator(
|
||||
// Operators::SUPERIOR,
|
||||
// 421
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// $rule = new AvailableForTotalAmount($adapter, $validators);
|
||||
//
|
||||
// $expected = false;
|
||||
// $actual = $rule->checkBackOfficeInput();
|
||||
// $this->assertEquals($expected, $actual);
|
||||
// }
|
||||
$isValid = $rule1->isMatching();
|
||||
|
||||
$expected = true;
|
||||
$actual =$isValid;
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if validity test on BackOffice inputs are working
|
||||
*
|
||||
* @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators
|
||||
* @expectedException \Thelia\Exception\InvalidRuleOperatorException
|
||||
*
|
||||
*/
|
||||
public function testInValidBackOfficeInputOperator2()
|
||||
{
|
||||
$stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCartTotalPrice')
|
||||
->will($this->returnValue(399));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
||||
AvailableForTotalAmountManager::INPUT2 => Operators::INFERIOR
|
||||
);
|
||||
$values = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => '400',
|
||||
AvailableForTotalAmountManager::INPUT2 => 'EUR');
|
||||
$rule1->setValidatorsFromForm($operators, $values);
|
||||
|
||||
$isValid = $rule1->isMatching();
|
||||
|
||||
$expected = true;
|
||||
$actual =$isValid;
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if validity test on BackOffice inputs are working
|
||||
*
|
||||
* @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators
|
||||
* @expectedException \Thelia\Exception\InvalidRuleValueException
|
||||
*
|
||||
*/
|
||||
public function testInValidBackOfficeInputValue()
|
||||
{
|
||||
$stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCartTotalPrice')
|
||||
->will($this->returnValue(399));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
||||
AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL
|
||||
);
|
||||
$values = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => 'X',
|
||||
AvailableForTotalAmountManager::INPUT2 => 'EUR');
|
||||
$rule1->setValidatorsFromForm($operators, $values);
|
||||
|
||||
$isValid = $rule1->isMatching();
|
||||
|
||||
$expected = true;
|
||||
$actual =$isValid;
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if validity test on BackOffice inputs are working
|
||||
*
|
||||
* @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators
|
||||
* @expectedException \Thelia\Exception\InvalidRuleValueException
|
||||
*
|
||||
*/
|
||||
public function testInValidBackOfficeInputValue2()
|
||||
{
|
||||
$stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCartTotalPrice')
|
||||
->will($this->returnValue(399));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR,
|
||||
AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL
|
||||
);
|
||||
$values = array(
|
||||
AvailableForTotalAmountManager::INPUT1 => 400,
|
||||
AvailableForTotalAmountManager::INPUT2 => 'FLA');
|
||||
$rule1->setValidatorsFromForm($operators, $values);
|
||||
|
||||
$isValid = $rule1->isMatching();
|
||||
|
||||
$expected = true;
|
||||
$actual =$isValid;
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if test inferior operator is working
|
||||
@@ -169,6 +231,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -205,6 +270,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -241,6 +309,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -277,6 +348,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -313,6 +387,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -349,6 +426,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -385,6 +465,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -421,6 +504,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -457,6 +543,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -493,6 +582,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -529,6 +621,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -565,6 +660,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -601,6 +699,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -637,6 +738,9 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getCheckoutCurrency')
|
||||
->will($this->returnValue('EUR'));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForTotalAmountManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Constraint\Rule\AvailableForXArticlesManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
use Thelia\Constraint\Rule\SerializableRule;
|
||||
@@ -32,13 +33,13 @@ use Thelia\Constraint\Rule\SerializableRule;
|
||||
* Date: 8/19/13
|
||||
* Time: 3:24 PM
|
||||
*
|
||||
* Unit Test AvailableForXArticles Class
|
||||
* Unit Test AvailableForXArticlesManager Class
|
||||
*
|
||||
* @package Constraint
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
// /** @var CouponAdapterInterface $stubTheliaAdapter */
|
||||
@@ -50,132 +51,78 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
// /** @var CouponAdapterInterface $stubTheliaAdapter */
|
||||
// $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock();
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Generate valid CouponBaseAdapter
|
||||
// *
|
||||
// * @param int $nbArticlesInCart Total articles in the current Cart
|
||||
// *
|
||||
// * @return CouponAdapterInterface
|
||||
// */
|
||||
// protected function generateValidCouponBaseAdapterMock($nbArticlesInCart = 4)
|
||||
// {
|
||||
// /** @var CouponAdapterInterface $stubTheliaAdapter */
|
||||
// $stubTheliaAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter')
|
||||
// ->disableOriginalConstructor()
|
||||
// ->setMethods(array('getNbArticlesInCart'))
|
||||
// ->getMock();
|
||||
// $stubTheliaAdapter->expects($this->any())
|
||||
// ->method('getNbArticlesInCart')
|
||||
// ->will($this->returnValue($nbArticlesInCart));
|
||||
//
|
||||
// return $stubTheliaAdapter;
|
||||
// }
|
||||
/**
|
||||
* Check if validity test on BackOffice inputs are working
|
||||
*
|
||||
* @covers Thelia\Coupon\Rule\AvailableForXArticlesManager::setValidators
|
||||
* @expectedException \Thelia\Exception\InvalidRuleOperatorException
|
||||
*/
|
||||
public function testInValidBackOfficeInputOperator()
|
||||
{
|
||||
$stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
// /**
|
||||
// * Check if validity test on BackOffice inputs are working
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput
|
||||
// *
|
||||
// */
|
||||
// public function testValidBackOfficeInput()
|
||||
// {
|
||||
// $translator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
|
||||
// ->disableOriginalConstructor()
|
||||
// ->getMock();
|
||||
//
|
||||
// $rule = new AvailableForXArticles($translator);
|
||||
// $operators = array(AvailableForXArticles::PARAM1_QUANTITY => Operators::SUPERIOR);
|
||||
// $values = array(
|
||||
// AvailableForXArticles::PARAM1_QUANTITY => 4
|
||||
// );
|
||||
// $rule->populateFromForm($operators, $values);
|
||||
//
|
||||
// $expected = true;
|
||||
// $actual = $rule->checkBackOfficeInput();
|
||||
// $this->assertEquals($expected, $actual);
|
||||
// }
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
// /**
|
||||
// * Check if validity test on BackOffice inputs are working
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput
|
||||
// * @expectedException \Thelia\Exception\InvalidRuleValueException
|
||||
// */
|
||||
// public function testInValidBackOfficeInputFloat()
|
||||
// {
|
||||
// $adapter = $this->stubTheliaAdapter;
|
||||
//
|
||||
// $validators = array(
|
||||
// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator(
|
||||
// Operators::SUPERIOR,
|
||||
// new QuantityParam(
|
||||
// $adapter,
|
||||
// 4.5
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
// $rule = new AvailableForXArticles($adapter, $validators);
|
||||
//
|
||||
// $expected = false;
|
||||
// $actual = $rule->checkBackOfficeInput();
|
||||
// $this->assertEquals($expected, $actual);
|
||||
// }
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
AvailableForXArticlesManager::INPUT1 => Operators::IN
|
||||
);
|
||||
$values = array(
|
||||
AvailableForXArticlesManager::INPUT1 => 5
|
||||
);
|
||||
$rule1->setValidatorsFromForm($operators, $values);
|
||||
|
||||
// /**
|
||||
// * Check if validity test on BackOffice inputs are working
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput
|
||||
// * @expectedException \Thelia\Exception\InvalidRuleValueException
|
||||
// */
|
||||
// public function testInValidBackOfficeInputNegative()
|
||||
// {
|
||||
// $adapter = $this->stubTheliaAdapter;
|
||||
//
|
||||
// $validators = array(
|
||||
// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator(
|
||||
// Operators::SUPERIOR,
|
||||
// new QuantityParam(
|
||||
// $adapter,
|
||||
// -1
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
// $rule = new AvailableForXArticles($adapter, $validators);
|
||||
//
|
||||
// $expected = false;
|
||||
// $actual = $rule->checkBackOfficeInput();
|
||||
// $this->assertEquals($expected, $actual);
|
||||
// }
|
||||
$isValid = $rule1->isMatching();
|
||||
|
||||
// /**
|
||||
// * Check if validity test on BackOffice inputs are working
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput
|
||||
// * @expectedException \Thelia\Exception\InvalidRuleValueException
|
||||
// */
|
||||
// public function testInValidBackOfficeInputString()
|
||||
// {
|
||||
// $adapter = $this->stubTheliaAdapter;
|
||||
//
|
||||
// $validators = array(
|
||||
// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator(
|
||||
// Operators::SUPERIOR,
|
||||
// new QuantityParam(
|
||||
// $adapter,
|
||||
// 'bad'
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
// $rule = new AvailableForXArticles($adapter, $validators);
|
||||
//
|
||||
// $expected = false;
|
||||
// $actual = $rule->checkBackOfficeInput();
|
||||
// $this->assertEquals($expected, $actual);
|
||||
// }
|
||||
$expected = true;
|
||||
$actual =$isValid;
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if validity test on BackOffice inputs are working
|
||||
*
|
||||
* @covers Thelia\Coupon\Rule\AvailableForXArticlesManager::setValidators
|
||||
* @expectedException \Thelia\Exception\InvalidRuleValueException
|
||||
*/
|
||||
public function testInValidBackOfficeInputValue()
|
||||
{
|
||||
$stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
AvailableForXArticlesManager::INPUT1 => Operators::SUPERIOR
|
||||
);
|
||||
$values = array(
|
||||
AvailableForXArticlesManager::INPUT1 => 'X'
|
||||
);
|
||||
$rule1->setValidatorsFromForm($operators, $values);
|
||||
|
||||
$isValid = $rule1->isMatching();
|
||||
|
||||
$expected = true;
|
||||
$actual =$isValid;
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if test inferior operator is working
|
||||
@@ -192,6 +139,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -224,6 +174,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -256,6 +209,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -288,6 +244,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -320,6 +279,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -352,6 +314,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -384,6 +349,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -416,6 +384,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -448,6 +419,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -480,6 +454,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -512,6 +489,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -544,6 +524,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -570,6 +553,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -602,6 +588,9 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getNbArticlesInCart')
|
||||
->will($this->returnValue(4));
|
||||
$stubAdapter->expects($this->any())
|
||||
->method('getConstraintValidator')
|
||||
->will($this->returnValue(new ConstraintValidator()));
|
||||
|
||||
$rule1 = new AvailableForXArticlesManager($stubAdapter);
|
||||
$operators = array(
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace Thelia\Coupon;
|
||||
|
||||
use Thelia\Constraint\Validator\QuantityParam;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
|
||||
/**
|
||||
@@ -48,14 +47,62 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
||||
|
||||
public function testSomething()
|
||||
// public function testSomething()
|
||||
// {
|
||||
// // Stop here and mark this test as incomplete.
|
||||
// $this->markTestIncomplete(
|
||||
// 'This test has not been implemented yet.'
|
||||
// );
|
||||
// }
|
||||
|
||||
public function testOperatorI18n()
|
||||
{
|
||||
// Stop here and mark this test as incomplete.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$stubTranslator = $this->getMockBuilder('\Symfony\Component\Translation\Translator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$stubTranslator->expects($this->any())
|
||||
->method('trans')
|
||||
->will($this->returnCallback((array($this, 'callbackI18n'))));
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::INFERIOR);
|
||||
$expected = 'inferior to';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::INFERIOR_OR_EQUAL);
|
||||
$expected = 'inferior or equal to';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::EQUAL);
|
||||
$expected = 'equal to';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR_OR_EQUAL);
|
||||
$expected = 'superior or equal to';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR);
|
||||
$expected = 'superior to';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::DIFFERENT);
|
||||
$expected = 'different from';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::IN);
|
||||
$expected = 'in';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, Operators::OUT);
|
||||
$expected = 'not in';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = Operators::getI18n($stubTranslator, 'unexpected operator');
|
||||
$expected = 'unexpected operator';
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// *
|
||||
// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator
|
||||
@@ -424,4 +471,11 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
}
|
||||
|
||||
function callbackI18n() {
|
||||
$args = func_get_args();
|
||||
|
||||
return $args[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@ class URL
|
||||
|
||||
return $this->absoluteUrl($path, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a rewritten URL from a view, a view id and a locale
|
||||
*
|
||||
@@ -261,4 +262,50 @@ class URL
|
||||
|
||||
return $this->resolver;
|
||||
}
|
||||
|
||||
protected function sanitize($string, $force_lowercase = true, $alphabetic_only = false)
|
||||
{
|
||||
static $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
|
||||
"}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—",
|
||||
"—", "–", ",", "<", ".", ">", "/", "?");
|
||||
|
||||
$clean = trim(str_replace($strip, "", strip_tags($string)));
|
||||
|
||||
$clean = preg_replace('/\s+/', "-", $clean);
|
||||
|
||||
$clean = ($alphabetic_only) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
|
||||
|
||||
return ($force_lowercase) ?
|
||||
(function_exists('mb_strtolower')) ?
|
||||
mb_strtolower($clean, 'UTF-8') :
|
||||
strtolower($clean) :
|
||||
$clean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Genenerate the file part of a rewriten URL from a given baseString, using a view, a view id and a locale
|
||||
*
|
||||
* @param $view
|
||||
* @param $viewId
|
||||
* @param $viewLocale
|
||||
* @param $baseString the string to be converted in a valid URL
|
||||
*
|
||||
* @return A valid file part URL.
|
||||
*/
|
||||
public function generateRewritenUrl($view, $viewId, $viewLocale, $baseString)
|
||||
{
|
||||
// Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe
|
||||
|
||||
// Replace all weird characters with dashes
|
||||
$string = preg_replace('/[^\w\-~_\.]+/u', '-', $baseString);
|
||||
|
||||
// Only allow one dash separator at a time (and make string lowercase)
|
||||
$cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8');
|
||||
|
||||
$urlFilePart = $cleanString . ".html";
|
||||
|
||||
// TODO :
|
||||
// check if URL url already exists, and add a numeric suffix, or the like
|
||||
// insert the URL in the rewriting table
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
use Thelia\Constraint\ConstraintFactory;
|
||||
use Thelia\Constraint\ConstraintManager;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmount;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
|
||||
use Thelia\Constraint\Rule\AvailableForXArticlesManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
@@ -39,14 +37,6 @@ try {
|
||||
->find();
|
||||
$categoryAssociatedContent->delete();
|
||||
|
||||
$attributeCategory = Thelia\Model\AttributeCategoryQuery::create()
|
||||
->find();
|
||||
$attributeCategory->delete();
|
||||
|
||||
$featureCategory = Thelia\Model\FeatureCategoryQuery::create()
|
||||
->find();
|
||||
$featureCategory->delete();
|
||||
|
||||
$featureProduct = Thelia\Model\FeatureProductQuery::create()
|
||||
->find();
|
||||
$featureProduct->delete();
|
||||
@@ -327,22 +317,6 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
//attribute_category and feature_category (all categories got all features/attributes)
|
||||
foreach($categoryIdList as $categoryId) {
|
||||
foreach($attributeList as $attributeId => $attributeAvId) {
|
||||
$attributeCategory = new Thelia\Model\AttributeCategory();
|
||||
$attributeCategory->setCategoryId($categoryId)
|
||||
->setAttributeId($attributeId)
|
||||
->save();
|
||||
}
|
||||
foreach($featureList as $featureId => $featureAvId) {
|
||||
$featureCategory = new Thelia\Model\FeatureCategory();
|
||||
$featureCategory->setCategoryId($categoryId)
|
||||
->setFeatureId($featureId)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
foreach($productIdList as $productId) {
|
||||
//add random accessories - or not
|
||||
$alreadyPicked = array();
|
||||
@@ -366,6 +340,7 @@ try {
|
||||
$productAssociatedContent = new Thelia\Model\ProductAssociatedContent();
|
||||
do {
|
||||
$pick = array_rand($contentIdList, 1);
|
||||
\Thelia\Log\Tlog::getInstance()->debug("pick : $pick");
|
||||
} while(in_array($pick, $alreadyPicked));
|
||||
|
||||
$alreadyPicked[] = $pick;
|
||||
@@ -623,6 +598,8 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
||||
$coupon1->setMaxUsage(40);
|
||||
$coupon1->setIsCumulative(1);
|
||||
$coupon1->setIsRemovingPostage(0);
|
||||
$coupon1->setIsAvailableOnSpecialOffers(1);
|
||||
|
||||
$coupon1->save();
|
||||
|
||||
|
||||
@@ -671,8 +648,10 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
|
||||
$serializedRules = $constraintFactory->serializeCouponRuleCollection($rules);
|
||||
$coupon2->setSerializedRules($serializedRules);
|
||||
|
||||
$coupon1->setMaxUsage(-1);
|
||||
$coupon2->setMaxUsage(-1);
|
||||
$coupon2->setIsCumulative(0);
|
||||
$coupon2->setIsRemovingPostage(1);
|
||||
$coupon2->setIsAvailableOnSpecialOffers(1);
|
||||
|
||||
$coupon2->save();
|
||||
}
|
||||
|
||||
@@ -59,271 +59,271 @@ VALUES
|
||||
(3, 'en_US', 'UK Pound');
|
||||
|
||||
|
||||
INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at`) VALUES
|
||||
(1, NULL, '4', 'AF', 'AFG', NOW(), NOW()),
|
||||
(2, NULL, '710', 'ZA', 'ZAF', NOW(), NOW()),
|
||||
(3, NULL, '8', 'AL', 'ALB', NOW(), NOW()),
|
||||
(4, NULL, '12', 'DZ', 'DZA', NOW(), NOW()),
|
||||
(5, NULL, '276', 'DE', 'DEU', NOW(), NOW()),
|
||||
(6, NULL, '20', 'AD', 'AND', NOW(), NOW()),
|
||||
(7, NULL, '24', 'AO', 'AGO', NOW(), NOW()),
|
||||
(8, NULL, '28', 'AG', 'ATG', NOW(), NOW()),
|
||||
(9, NULL, '682', 'SA', 'SAU', NOW(), NOW()),
|
||||
(10, NULL, '32', 'AR', 'ARG', NOW(), NOW()),
|
||||
(11, NULL, '51', 'AM', 'ARM', NOW(), NOW()),
|
||||
(12, NULL, '36', 'AU', 'AUS', NOW(), NOW()),
|
||||
(13, NULL, '40', 'AT', 'AUT', NOW(), NOW()),
|
||||
(14, NULL, '31', 'AZ', 'AZE', NOW(), NOW()),
|
||||
(15, NULL, '44', 'BS', 'BHS', NOW(), NOW()),
|
||||
(16, NULL, '48', 'BR', 'BHR', NOW(), NOW()),
|
||||
(17, NULL, '50', 'BD', 'BGD', NOW(), NOW()),
|
||||
(18, NULL, '52', 'BB', 'BRB', NOW(), NOW()),
|
||||
(19, NULL, '585', 'PW', 'PLW', NOW(), NOW()),
|
||||
(20, NULL, '56', 'BE', 'BEL', NOW(), NOW()),
|
||||
(21, NULL, '84', 'BL', 'BLZ', NOW(), NOW()),
|
||||
(22, NULL, '204', 'BJ', 'BEN', NOW(), NOW()),
|
||||
(23, NULL, '64', 'BT', 'BTN', NOW(), NOW()),
|
||||
(24, NULL, '112', 'BY', 'BLR', NOW(), NOW()),
|
||||
(25, NULL, '104', 'MM', 'MMR', NOW(), NOW()),
|
||||
(26, NULL, '68', 'BO', 'BOL', NOW(), NOW()),
|
||||
(27, NULL, '70', 'BA', 'BIH', NOW(), NOW()),
|
||||
(28, NULL, '72', 'BW', 'BWA', NOW(), NOW()),
|
||||
(29, NULL, '76', 'BR', 'BRA', NOW(), NOW()),
|
||||
(30, NULL, '96', 'BN', 'BRN', NOW(), NOW()),
|
||||
(31, NULL, '100', 'BG', 'BGR', NOW(), NOW()),
|
||||
(32, NULL, '854', 'BF', 'BFA', NOW(), NOW()),
|
||||
(33, NULL, '108', 'BI', 'BDI', NOW(), NOW()),
|
||||
(34, NULL, '116', 'KH', 'KHM', NOW(), NOW()),
|
||||
(35, NULL, '120', 'CM', 'CMR', NOW(), NOW()),
|
||||
(37, NULL, '132', 'CV', 'CPV', NOW(), NOW()),
|
||||
(38, NULL, '152', 'CL', 'CHL', NOW(), NOW()),
|
||||
(39, NULL, '156', 'CN', 'CHN', NOW(), NOW()),
|
||||
(40, NULL, '196', 'CY', 'CYP', NOW(), NOW()),
|
||||
(41, NULL, '170', 'CO', 'COL', NOW(), NOW()),
|
||||
(42, NULL, '174', 'KM', 'COM', NOW(), NOW()),
|
||||
(43, NULL, '178', 'CG', 'COG', NOW(), NOW()),
|
||||
(44, NULL, '184', 'CK', 'COK', NOW(), NOW()),
|
||||
(45, NULL, '408', 'KP', 'PRK', NOW(), NOW()),
|
||||
(46, NULL, '410', 'KR', 'KOR', NOW(), NOW()),
|
||||
(47, NULL, '188', 'CR', 'CRI', NOW(), NOW()),
|
||||
(48, NULL, '384', 'CI', 'CIV', NOW(), NOW()),
|
||||
(49, NULL, '191', 'HR', 'HRV', NOW(), NOW()),
|
||||
(50, NULL, '192', 'CU', 'CUB', NOW(), NOW()),
|
||||
(51, NULL, '208', 'DK', 'DNK', NOW(), NOW()),
|
||||
(52, NULL, '262', 'DJ', 'DJI', NOW(), NOW()),
|
||||
(53, NULL, '212', 'DM', 'DMA', NOW(), NOW()),
|
||||
(54, NULL, '818', 'EG', 'EGY', NOW(), NOW()),
|
||||
(55, NULL, '784', 'AE', 'ARE', NOW(), NOW()),
|
||||
(56, NULL, '218', 'EC', 'ECU', NOW(), NOW()),
|
||||
(57, NULL, '232', 'ER', 'ERI', NOW(), NOW()),
|
||||
(58, NULL, '724', 'ES', 'ESP', NOW(), NOW()),
|
||||
(59, NULL, '233', 'EE', 'EST', NOW(), NOW()),
|
||||
(61, NULL, '231', 'ET', 'ETH', NOW(), NOW()),
|
||||
(62, NULL, '242', 'FJ', 'FJI', NOW(), NOW()),
|
||||
(63, NULL, '246', 'FI', 'FIN', NOW(), NOW()),
|
||||
(64, NULL, '250', 'FR', 'FRA', NOW(), NOW()),
|
||||
(65, NULL, '266', 'GA', 'GAB', NOW(), NOW()),
|
||||
(66, NULL, '270', 'GM', 'GMB', NOW(), NOW()),
|
||||
(67, NULL, '268', 'GE', 'GEO', NOW(), NOW()),
|
||||
(68, NULL, '288', 'GH', 'GHA', NOW(), NOW()),
|
||||
(69, NULL, '300', 'GR', 'GRC', NOW(), NOW()),
|
||||
(70, NULL, '308', 'GD', 'GRD', NOW(), NOW()),
|
||||
(71, NULL, '320', 'GT', 'GTM', NOW(), NOW()),
|
||||
(72, NULL, '324', 'GN', 'GIN', NOW(), NOW()),
|
||||
(73, NULL, '624', 'GW', 'GNB', NOW(), NOW()),
|
||||
(74, NULL, '226', 'GQ', 'GNQ', NOW(), NOW()),
|
||||
(75, NULL, '328', 'GY', 'GUY', NOW(), NOW()),
|
||||
(76, NULL, '332', 'HT', 'HTI', NOW(), NOW()),
|
||||
(77, NULL, '340', 'HN', 'HND', NOW(), NOW()),
|
||||
(78, NULL, '348', 'HU', 'HUN', NOW(), NOW()),
|
||||
(79, NULL, '356', 'IN', 'IND', NOW(), NOW()),
|
||||
(80, NULL, '360', 'ID', 'IDN', NOW(), NOW()),
|
||||
(81, NULL, '364', 'IR', 'IRN', NOW(), NOW()),
|
||||
(82, NULL, '368', 'IQ', 'IRQ', NOW(), NOW()),
|
||||
(83, NULL, '372', 'IE', 'IRL', NOW(), NOW()),
|
||||
(84, NULL, '352', 'IS', 'ISL', NOW(), NOW()),
|
||||
(85, NULL, '376', 'IL', 'ISR', NOW(), NOW()),
|
||||
(86, NULL, '380', 'IT', 'ITA', NOW(), NOW()),
|
||||
(87, NULL, '388', 'JM', 'JAM', NOW(), NOW()),
|
||||
(88, NULL, '392', 'JP', 'JPN', NOW(), NOW()),
|
||||
(89, NULL, '400', 'JO', 'JOR', NOW(), NOW()),
|
||||
(90, NULL, '398', 'KZ', 'KAZ', NOW(), NOW()),
|
||||
(91, NULL, '404', 'KE', 'KEN', NOW(), NOW()),
|
||||
(92, NULL, '417', 'KG', 'KGZ', NOW(), NOW()),
|
||||
(93, NULL, '296', 'KI', 'KIR', NOW(), NOW()),
|
||||
(94, NULL, '414', 'KW', 'KWT', NOW(), NOW()),
|
||||
(95, NULL, '418', 'LA', 'LAO', NOW(), NOW()),
|
||||
(96, NULL, '426', 'LS', 'LSO', NOW(), NOW()),
|
||||
(97, NULL, '428', 'LV', 'LVA', NOW(), NOW()),
|
||||
(98, NULL, '422', 'LB', 'LBN', NOW(), NOW()),
|
||||
(99, NULL, '430', 'LR', 'LBR', NOW(), NOW()),
|
||||
(100, NULL, '343', 'LY', 'LBY', NOW(), NOW()),
|
||||
(101, NULL, '438', 'LI', 'LIE', NOW(), NOW()),
|
||||
(102, NULL, '440', 'LT', 'LTU', NOW(), NOW()),
|
||||
(103, NULL, '442', 'LU', 'LUX', NOW(), NOW()),
|
||||
(104, NULL, '807', 'MK', 'MKD', NOW(), NOW()),
|
||||
(105, NULL, '450', 'MD', 'MDG', NOW(), NOW()),
|
||||
(106, NULL, '458', 'MY', 'MYS', NOW(), NOW()),
|
||||
(107, NULL, '454', 'MW', 'MWI', NOW(), NOW()),
|
||||
(108, NULL, '462', 'MV', 'MDV', NOW(), NOW()),
|
||||
(109, NULL, '466', 'ML', 'MLI', NOW(), NOW()),
|
||||
(110, NULL, '470', 'MT', 'MLT', NOW(), NOW()),
|
||||
(111, NULL, '504', 'MA', 'MAR', NOW(), NOW()),
|
||||
(112, NULL, '584', 'MH', 'MHL', NOW(), NOW()),
|
||||
(113, NULL, '480', 'MU', 'MUS', NOW(), NOW()),
|
||||
(114, NULL, '478', 'MR', 'MRT', NOW(), NOW()),
|
||||
(115, NULL, '484', 'MX', 'MEX', NOW(), NOW()),
|
||||
(116, NULL, '583', 'FM', 'FSM', NOW(), NOW()),
|
||||
(117, NULL, '498', 'MD', 'MDA', NOW(), NOW()),
|
||||
(118, NULL, '492', 'MC', 'MCO', NOW(), NOW()),
|
||||
(119, NULL, '496', 'MN', 'MNG', NOW(), NOW()),
|
||||
(120, NULL, '508', 'MZ', 'MOZ', NOW(), NOW()),
|
||||
(121, NULL, '516', 'NA', 'NAM', NOW(), NOW()),
|
||||
(122, NULL, '520', 'NR', 'NRU', NOW(), NOW()),
|
||||
(123, NULL, '524', 'NP', 'NPL', NOW(), NOW()),
|
||||
(124, NULL, '558', 'NI', 'NIC', NOW(), NOW()),
|
||||
(125, NULL, '562', 'NE', 'NER', NOW(), NOW()),
|
||||
(126, NULL, '566', 'NG', 'NGA', NOW(), NOW()),
|
||||
(127, NULL, '570', 'NU', 'NIU', NOW(), NOW()),
|
||||
(128, NULL, '578', 'NO', 'NOR', NOW(), NOW()),
|
||||
(129, NULL, '554', 'NZ', 'NZL', NOW(), NOW()),
|
||||
(130, NULL, '512', 'OM', 'OMN', NOW(), NOW()),
|
||||
(131, NULL, '800', 'UG', 'UGA', NOW(), NOW()),
|
||||
(132, NULL, '860', 'UZ', 'UZB', NOW(), NOW()),
|
||||
(133, NULL, '586', 'PK', 'PAK', NOW(), NOW()),
|
||||
(134, NULL, '591', 'PA', 'PAN', NOW(), NOW()),
|
||||
(135, NULL, '598', 'PG', 'PNG', NOW(), NOW()),
|
||||
(136, NULL, '600', 'PY', 'PRY', NOW(), NOW()),
|
||||
(137, NULL, '528', 'NL', 'NLD', NOW(), NOW()),
|
||||
(138, NULL, '604', 'PE', 'PER', NOW(), NOW()),
|
||||
(139, NULL, '608', 'PH', 'PHL', NOW(), NOW()),
|
||||
(140, NULL, '616', 'PL', 'POL', NOW(), NOW()),
|
||||
(141, NULL, '620', 'PT', 'PRT', NOW(), NOW()),
|
||||
(142, NULL, '634', 'QA', 'QAT', NOW(), NOW()),
|
||||
(143, NULL, '140', 'CF', 'CAF', NOW(), NOW()),
|
||||
(144, NULL, '214', 'DO', 'DOM', NOW(), NOW()),
|
||||
(145, NULL, '203', 'CZ', 'CZE', NOW(), NOW()),
|
||||
(146, NULL, '642', 'RO', 'ROU', NOW(), NOW()),
|
||||
(147, NULL, '826', 'GB', 'GBR', NOW(), NOW()),
|
||||
(148, NULL, '643', 'RU', 'RUS', NOW(), NOW()),
|
||||
(149, NULL, '646', 'RW', 'RWA', NOW(), NOW()),
|
||||
(150, NULL, '659', 'KN', 'KNA', NOW(), NOW()),
|
||||
(151, NULL, '662', 'LC', 'LCA', NOW(), NOW()),
|
||||
(152, NULL, '674', 'SM', 'SMR', NOW(), NOW()),
|
||||
(153, NULL, '670', 'VC', 'VCT', NOW(), NOW()),
|
||||
(154, NULL, '90', 'SB', 'SLB', NOW(), NOW()),
|
||||
(155, NULL, '222', 'SV', 'SLV', NOW(), NOW()),
|
||||
(156, NULL, '882', 'WS', 'WSM', NOW(), NOW()),
|
||||
(157, NULL, '678', 'ST', 'STP', NOW(), NOW()),
|
||||
(158, NULL, '686', 'SN', 'SEN', NOW(), NOW()),
|
||||
(159, NULL, '690', 'SC', 'SYC', NOW(), NOW()),
|
||||
(160, NULL, '694', 'SL', 'SLE', NOW(), NOW()),
|
||||
(161, NULL, '702', 'SG', 'SGP', NOW(), NOW()),
|
||||
(162, NULL, '703', 'SK', 'SVK', NOW(), NOW()),
|
||||
(163, NULL, '705', 'SI', 'SVN', NOW(), NOW()),
|
||||
(164, NULL, '706', 'SO', 'SOM', NOW(), NOW()),
|
||||
(165, NULL, '729', 'SD', 'SDN', NOW(), NOW()),
|
||||
(166, NULL, '144', 'LK', 'LKA', NOW(), NOW()),
|
||||
(167, NULL, '752', 'SE', 'SWE', NOW(), NOW()),
|
||||
(168, NULL, '756', 'CH', 'CHE', NOW(), NOW()),
|
||||
(169, NULL, '740', 'SR', 'SUR', NOW(), NOW()),
|
||||
(170, NULL, '748', 'SZ', 'SWZ', NOW(), NOW()),
|
||||
(171, NULL, '760', 'SY', 'SYR', NOW(), NOW()),
|
||||
(172, NULL, '762', 'TJ', 'TJK', NOW(), NOW()),
|
||||
(173, NULL, '834', 'TZ', 'TZA', NOW(), NOW()),
|
||||
(174, NULL, '148', 'TD', 'TCD', NOW(), NOW()),
|
||||
(175, NULL, '764', 'TH', 'THA', NOW(), NOW()),
|
||||
(176, NULL, '768', 'TG', 'TGO', NOW(), NOW()),
|
||||
(177, NULL, '776', 'TO', 'TON', NOW(), NOW()),
|
||||
(178, NULL, '780', 'TT', 'TTO', NOW(), NOW()),
|
||||
(179, NULL, '788', 'TN', 'TUN', NOW(), NOW()),
|
||||
(180, NULL, '795', 'TM', 'TKM', NOW(), NOW()),
|
||||
(181, NULL, '792', 'TR', 'TUR', NOW(), NOW()),
|
||||
(182, NULL, '798', 'TV', 'TUV', NOW(), NOW()),
|
||||
(183, NULL, '804', 'UA', 'UKR', NOW(), NOW()),
|
||||
(184, NULL, '858', 'UY', 'URY', NOW(), NOW()),
|
||||
(185, NULL, '336', 'VA', 'VAT', NOW(), NOW()),
|
||||
(186, NULL, '548', 'VU', 'VUT', NOW(), NOW()),
|
||||
(187, NULL, '862', 'VE', 'VEN', NOW(), NOW()),
|
||||
(188, NULL, '704', 'VN', 'VNM', NOW(), NOW()),
|
||||
(189, NULL, '887', 'YE', 'YEM', NOW(), NOW()),
|
||||
(190, NULL, '807', 'MK', 'MKD', NOW(), NOW()),
|
||||
(191, NULL, '180', 'CD', 'COD', NOW(), NOW()),
|
||||
(192, NULL, '894', 'ZM', 'ZMB', NOW(), NOW()),
|
||||
(193, NULL, '716', 'ZW', 'ZWE', NOW(), NOW()),
|
||||
(196, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(197, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(198, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(199, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(200, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(201, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(202, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(203, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(204, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(205, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(206, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(207, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(208, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(209, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(210, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(211, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(212, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(213, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(214, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(215, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(216, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(217, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(218, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(219, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(220, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(221, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(222, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(223, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(224, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(225, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(226, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(227, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(228, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(229, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(230, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(231, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(232, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(233, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(234, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(235, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(236, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(237, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(238, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(239, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(240, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(241, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(242, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(243, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(244, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(245, NULL, '840', 'US', 'USA', NOW(), NOW()),
|
||||
(246, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(247, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(248, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(249, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(250, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(251, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(252, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(253, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(254, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(255, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(256, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(257, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(258, NULL, '124', 'CA', 'CAN', NOW(), NOW()),
|
||||
(259, NULL, '312', 'GP', 'GLP', NOW(), NOW()),
|
||||
(260, NULL, '254', 'GF', 'GUF', NOW(), NOW()),
|
||||
(261, NULL, '474', 'MQ', 'MTQ', NOW(), NOW()),
|
||||
(262, NULL, '175', 'YT', 'MYT', NOW(), NOW()),
|
||||
(263, NULL, '638', 'RE', 'REU', NOW(), NOW()),
|
||||
(264, NULL, '666', 'PM', 'SPM', NOW(), NOW()),
|
||||
(265, NULL, '540', 'NC', 'NCL', NOW(), NOW()),
|
||||
(266, NULL, '258', 'PF', 'PYF', NOW(), NOW()),
|
||||
(267, NULL, '876', 'WF', 'WLF', NOW(), NOW()),
|
||||
(268, NULL, '840', 'US', 'USA', NOW(), NOW());
|
||||
INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `by_default`, `created_at`, `updated_at`) VALUES
|
||||
(1, NULL, '4', 'AF', 'AFG', 0, NOW(), NOW()),
|
||||
(2, NULL, '710', 'ZA', 'ZAF', 0, NOW(), NOW()),
|
||||
(3, NULL, '8', 'AL', 'ALB', 0, NOW(), NOW()),
|
||||
(4, NULL, '12', 'DZ', 'DZA', 0, NOW(), NOW()),
|
||||
(5, NULL, '276', 'DE', 'DEU', 0, NOW(), NOW()),
|
||||
(6, NULL, '20', 'AD', 'AND', 0, NOW(), NOW()),
|
||||
(7, NULL, '24', 'AO', 'AGO', 0, NOW(), NOW()),
|
||||
(8, NULL, '28', 'AG', 'ATG', 0, NOW(), NOW()),
|
||||
(9, NULL, '682', 'SA', 'SAU', 0, NOW(), NOW()),
|
||||
(10, NULL, '32', 'AR', 'ARG', 0, NOW(), NOW()),
|
||||
(11, NULL, '51', 'AM', 'ARM', 0, NOW(), NOW()),
|
||||
(12, NULL, '36', 'AU', 'AUS', 0, NOW(), NOW()),
|
||||
(13, NULL, '40', 'AT', 'AUT', 0, NOW(), NOW()),
|
||||
(14, NULL, '31', 'AZ', 'AZE', 0, NOW(), NOW()),
|
||||
(15, NULL, '44', 'BS', 'BHS', 0, NOW(), NOW()),
|
||||
(16, NULL, '48', 'BR', 'BHR', 0, NOW(), NOW()),
|
||||
(17, NULL, '50', 'BD', 'BGD', 0, NOW(), NOW()),
|
||||
(18, NULL, '52', 'BB', 'BRB', 0, NOW(), NOW()),
|
||||
(19, NULL, '585', 'PW', 'PLW', 0, NOW(), NOW()),
|
||||
(20, NULL, '56', 'BE', 'BEL', 0, NOW(), NOW()),
|
||||
(21, NULL, '84', 'BL', 'BLZ', 0, NOW(), NOW()),
|
||||
(22, NULL, '204', 'BJ', 'BEN', 0, NOW(), NOW()),
|
||||
(23, NULL, '64', 'BT', 'BTN', 0, NOW(), NOW()),
|
||||
(24, NULL, '112', 'BY', 'BLR', 0, NOW(), NOW()),
|
||||
(25, NULL, '104', 'MM', 'MMR', 0, NOW(), NOW()),
|
||||
(26, NULL, '68', 'BO', 'BOL', 0, NOW(), NOW()),
|
||||
(27, NULL, '70', 'BA', 'BIH', 0, NOW(), NOW()),
|
||||
(28, NULL, '72', 'BW', 'BWA', 0, NOW(), NOW()),
|
||||
(29, NULL, '76', 'BR', 'BRA', 0, NOW(), NOW()),
|
||||
(30, NULL, '96', 'BN', 'BRN', 0, NOW(), NOW()),
|
||||
(31, NULL, '100', 'BG', 'BGR', 0, NOW(), NOW()),
|
||||
(32, NULL, '854', 'BF', 'BFA', 0, NOW(), NOW()),
|
||||
(33, NULL, '108', 'BI', 'BDI', 0, NOW(), NOW()),
|
||||
(34, NULL, '116', 'KH', 'KHM', 0, NOW(), NOW()),
|
||||
(35, NULL, '120', 'CM', 'CMR', 0, NOW(), NOW()),
|
||||
(37, NULL, '132', 'CV', 'CPV', 0, NOW(), NOW()),
|
||||
(38, NULL, '152', 'CL', 'CHL', 0, NOW(), NOW()),
|
||||
(39, NULL, '156', 'CN', 'CHN', 0, NOW(), NOW()),
|
||||
(40, NULL, '196', 'CY', 'CYP', 0, NOW(), NOW()),
|
||||
(41, NULL, '170', 'CO', 'COL', 0, NOW(), NOW()),
|
||||
(42, NULL, '174', 'KM', 'COM', 0, NOW(), NOW()),
|
||||
(43, NULL, '178', 'CG', 'COG', 0, NOW(), NOW()),
|
||||
(44, NULL, '184', 'CK', 'COK', 0, NOW(), NOW()),
|
||||
(45, NULL, '408', 'KP', 'PRK', 0, NOW(), NOW()),
|
||||
(46, NULL, '410', 'KR', 'KOR', 0, NOW(), NOW()),
|
||||
(47, NULL, '188', 'CR', 'CRI', 0, NOW(), NOW()),
|
||||
(48, NULL, '384', 'CI', 'CIV', 0, NOW(), NOW()),
|
||||
(49, NULL, '191', 'HR', 'HRV', 0, NOW(), NOW()),
|
||||
(50, NULL, '192', 'CU', 'CUB', 0, NOW(), NOW()),
|
||||
(51, NULL, '208', 'DK', 'DNK', 0, NOW(), NOW()),
|
||||
(52, NULL, '262', 'DJ', 'DJI', 0, NOW(), NOW()),
|
||||
(53, NULL, '212', 'DM', 'DMA', 0, NOW(), NOW()),
|
||||
(54, NULL, '818', 'EG', 'EGY', 0, NOW(), NOW()),
|
||||
(55, NULL, '784', 'AE', 'ARE', 0, NOW(), NOW()),
|
||||
(56, NULL, '218', 'EC', 'ECU', 0, NOW(), NOW()),
|
||||
(57, NULL, '232', 'ER', 'ERI', 0, NOW(), NOW()),
|
||||
(58, NULL, '724', 'ES', 'ESP', 0, NOW(), NOW()),
|
||||
(59, NULL, '233', 'EE', 'EST', 0, NOW(), NOW()),
|
||||
(61, NULL, '231', 'ET', 'ETH', 0, NOW(), NOW()),
|
||||
(62, NULL, '242', 'FJ', 'FJI', 0, NOW(), NOW()),
|
||||
(63, NULL, '246', 'FI', 'FIN', 0, NOW(), NOW()),
|
||||
(64, NULL, '250', 'FR', 'FRA', 1, NOW(), NOW()),
|
||||
(65, NULL, '266', 'GA', 'GAB', 0, NOW(), NOW()),
|
||||
(66, NULL, '270', 'GM', 'GMB', 0, NOW(), NOW()),
|
||||
(67, NULL, '268', 'GE', 'GEO', 0, NOW(), NOW()),
|
||||
(68, NULL, '288', 'GH', 'GHA', 0, NOW(), NOW()),
|
||||
(69, NULL, '300', 'GR', 'GRC', 0, NOW(), NOW()),
|
||||
(70, NULL, '308', 'GD', 'GRD', 0, NOW(), NOW()),
|
||||
(71, NULL, '320', 'GT', 'GTM', 0, NOW(), NOW()),
|
||||
(72, NULL, '324', 'GN', 'GIN', 0, NOW(), NOW()),
|
||||
(73, NULL, '624', 'GW', 'GNB', 0, NOW(), NOW()),
|
||||
(74, NULL, '226', 'GQ', 'GNQ', 0, NOW(), NOW()),
|
||||
(75, NULL, '328', 'GY', 'GUY', 0, NOW(), NOW()),
|
||||
(76, NULL, '332', 'HT', 'HTI', 0, NOW(), NOW()),
|
||||
(77, NULL, '340', 'HN', 'HND', 0, NOW(), NOW()),
|
||||
(78, NULL, '348', 'HU', 'HUN', 0, NOW(), NOW()),
|
||||
(79, NULL, '356', 'IN', 'IND', 0, NOW(), NOW()),
|
||||
(80, NULL, '360', 'ID', 'IDN', 0, NOW(), NOW()),
|
||||
(81, NULL, '364', 'IR', 'IRN', 0, NOW(), NOW()),
|
||||
(82, NULL, '368', 'IQ', 'IRQ', 0, NOW(), NOW()),
|
||||
(83, NULL, '372', 'IE', 'IRL', 0, NOW(), NOW()),
|
||||
(84, NULL, '352', 'IS', 'ISL', 0, NOW(), NOW()),
|
||||
(85, NULL, '376', 'IL', 'ISR', 0, NOW(), NOW()),
|
||||
(86, NULL, '380', 'IT', 'ITA', 0, NOW(), NOW()),
|
||||
(87, NULL, '388', 'JM', 'JAM', 0, NOW(), NOW()),
|
||||
(88, NULL, '392', 'JP', 'JPN', 0, NOW(), NOW()),
|
||||
(89, NULL, '400', 'JO', 'JOR', 0, NOW(), NOW()),
|
||||
(90, NULL, '398', 'KZ', 'KAZ', 0, NOW(), NOW()),
|
||||
(91, NULL, '404', 'KE', 'KEN', 0, NOW(), NOW()),
|
||||
(92, NULL, '417', 'KG', 'KGZ', 0, NOW(), NOW()),
|
||||
(93, NULL, '296', 'KI', 'KIR', 0, NOW(), NOW()),
|
||||
(94, NULL, '414', 'KW', 'KWT', 0, NOW(), NOW()),
|
||||
(95, NULL, '418', 'LA', 'LAO', 0, NOW(), NOW()),
|
||||
(96, NULL, '426', 'LS', 'LSO', 0, NOW(), NOW()),
|
||||
(97, NULL, '428', 'LV', 'LVA', 0, NOW(), NOW()),
|
||||
(98, NULL, '422', 'LB', 'LBN', 0, NOW(), NOW()),
|
||||
(99, NULL, '430', 'LR', 'LBR', 0, NOW(), NOW()),
|
||||
(100, NULL, '343', 'LY', 'LBY', 0, NOW(), NOW()),
|
||||
(101, NULL, '438', 'LI', 'LIE', 0, NOW(), NOW()),
|
||||
(102, NULL, '440', 'LT', 'LTU', 0, NOW(), NOW()),
|
||||
(103, NULL, '442', 'LU', 'LUX', 0, NOW(), NOW()),
|
||||
(104, NULL, '807', 'MK', 'MKD', 0, NOW(), NOW()),
|
||||
(105, NULL, '450', 'MD', 'MDG', 0, NOW(), NOW()),
|
||||
(106, NULL, '458', 'MY', 'MYS', 0, NOW(), NOW()),
|
||||
(107, NULL, '454', 'MW', 'MWI', 0, NOW(), NOW()),
|
||||
(108, NULL, '462', 'MV', 'MDV', 0, NOW(), NOW()),
|
||||
(109, NULL, '466', 'ML', 'MLI', 0, NOW(), NOW()),
|
||||
(110, NULL, '470', 'MT', 'MLT', 0, NOW(), NOW()),
|
||||
(111, NULL, '504', 'MA', 'MAR', 0, NOW(), NOW()),
|
||||
(112, NULL, '584', 'MH', 'MHL', 0, NOW(), NOW()),
|
||||
(113, NULL, '480', 'MU', 'MUS', 0, NOW(), NOW()),
|
||||
(114, NULL, '478', 'MR', 'MRT', 0, NOW(), NOW()),
|
||||
(115, NULL, '484', 'MX', 'MEX', 0, NOW(), NOW()),
|
||||
(116, NULL, '583', 'FM', 'FSM', 0, NOW(), NOW()),
|
||||
(117, NULL, '498', 'MD', 'MDA', 0, NOW(), NOW()),
|
||||
(118, NULL, '492', 'MC', 'MCO', 0, NOW(), NOW()),
|
||||
(119, NULL, '496', 'MN', 'MNG', 0, NOW(), NOW()),
|
||||
(120, NULL, '508', 'MZ', 'MOZ', 0, NOW(), NOW()),
|
||||
(121, NULL, '516', 'NA', 'NAM', 0, NOW(), NOW()),
|
||||
(122, NULL, '520', 'NR', 'NRU', 0, NOW(), NOW()),
|
||||
(123, NULL, '524', 'NP', 'NPL', 0, NOW(), NOW()),
|
||||
(124, NULL, '558', 'NI', 'NIC', 0, NOW(), NOW()),
|
||||
(125, NULL, '562', 'NE', 'NER', 0, NOW(), NOW()),
|
||||
(126, NULL, '566', 'NG', 'NGA', 0, NOW(), NOW()),
|
||||
(127, NULL, '570', 'NU', 'NIU', 0, NOW(), NOW()),
|
||||
(128, NULL, '578', 'NO', 'NOR', 0, NOW(), NOW()),
|
||||
(129, NULL, '554', 'NZ', 'NZL', 0, NOW(), NOW()),
|
||||
(130, NULL, '512', 'OM', 'OMN', 0, NOW(), NOW()),
|
||||
(131, NULL, '800', 'UG', 'UGA', 0, NOW(), NOW()),
|
||||
(132, NULL, '860', 'UZ', 'UZB', 0, NOW(), NOW()),
|
||||
(133, NULL, '586', 'PK', 'PAK', 0, NOW(), NOW()),
|
||||
(134, NULL, '591', 'PA', 'PAN', 0, NOW(), NOW()),
|
||||
(135, NULL, '598', 'PG', 'PNG', 0, NOW(), NOW()),
|
||||
(136, NULL, '600', 'PY', 'PRY', 0, NOW(), NOW()),
|
||||
(137, NULL, '528', 'NL', 'NLD', 0, NOW(), NOW()),
|
||||
(138, NULL, '604', 'PE', 'PER', 0, NOW(), NOW()),
|
||||
(139, NULL, '608', 'PH', 'PHL', 0, NOW(), NOW()),
|
||||
(140, NULL, '616', 'PL', 'POL', 0, NOW(), NOW()),
|
||||
(141, NULL, '620', 'PT', 'PRT', 0, NOW(), NOW()),
|
||||
(142, NULL, '634', 'QA', 'QAT', 0, NOW(), NOW()),
|
||||
(143, NULL, '140', 'CF', 'CAF', 0, NOW(), NOW()),
|
||||
(144, NULL, '214', 'DO', 'DOM', 0, NOW(), NOW()),
|
||||
(145, NULL, '203', 'CZ', 'CZE', 0, NOW(), NOW()),
|
||||
(146, NULL, '642', 'RO', 'ROU', 0, NOW(), NOW()),
|
||||
(147, NULL, '826', 'GB', 'GBR', 0, NOW(), NOW()),
|
||||
(148, NULL, '643', 'RU', 'RUS', 0, NOW(), NOW()),
|
||||
(149, NULL, '646', 'RW', 'RWA', 0, NOW(), NOW()),
|
||||
(150, NULL, '659', 'KN', 'KNA', 0, NOW(), NOW()),
|
||||
(151, NULL, '662', 'LC', 'LCA', 0, NOW(), NOW()),
|
||||
(152, NULL, '674', 'SM', 'SMR', 0, NOW(), NOW()),
|
||||
(153, NULL, '670', 'VC', 'VCT', 0, NOW(), NOW()),
|
||||
(154, NULL, '90', 'SB', 'SLB', 0, NOW(), NOW()),
|
||||
(155, NULL, '222', 'SV', 'SLV', 0, NOW(), NOW()),
|
||||
(156, NULL, '882', 'WS', 'WSM', 0, NOW(), NOW()),
|
||||
(157, NULL, '678', 'ST', 'STP', 0, NOW(), NOW()),
|
||||
(158, NULL, '686', 'SN', 'SEN', 0, NOW(), NOW()),
|
||||
(159, NULL, '690', 'SC', 'SYC', 0, NOW(), NOW()),
|
||||
(160, NULL, '694', 'SL', 'SLE', 0, NOW(), NOW()),
|
||||
(161, NULL, '702', 'SG', 'SGP', 0, NOW(), NOW()),
|
||||
(162, NULL, '703', 'SK', 'SVK', 0, NOW(), NOW()),
|
||||
(163, NULL, '705', 'SI', 'SVN', 0, NOW(), NOW()),
|
||||
(164, NULL, '706', 'SO', 'SOM', 0, NOW(), NOW()),
|
||||
(165, NULL, '729', 'SD', 'SDN', 0, NOW(), NOW()),
|
||||
(166, NULL, '144', 'LK', 'LKA', 0, NOW(), NOW()),
|
||||
(167, NULL, '752', 'SE', 'SWE', 0, NOW(), NOW()),
|
||||
(168, NULL, '756', 'CH', 'CHE', 0, NOW(), NOW()),
|
||||
(169, NULL, '740', 'SR', 'SUR', 0, NOW(), NOW()),
|
||||
(170, NULL, '748', 'SZ', 'SWZ', 0, NOW(), NOW()),
|
||||
(171, NULL, '760', 'SY', 'SYR', 0, NOW(), NOW()),
|
||||
(172, NULL, '762', 'TJ', 'TJK', 0, NOW(), NOW()),
|
||||
(173, NULL, '834', 'TZ', 'TZA', 0, NOW(), NOW()),
|
||||
(174, NULL, '148', 'TD', 'TCD', 0, NOW(), NOW()),
|
||||
(175, NULL, '764', 'TH', 'THA', 0, NOW(), NOW()),
|
||||
(176, NULL, '768', 'TG', 'TGO', 0, NOW(), NOW()),
|
||||
(177, NULL, '776', 'TO', 'TON', 0, NOW(), NOW()),
|
||||
(178, NULL, '780', 'TT', 'TTO', 0, NOW(), NOW()),
|
||||
(179, NULL, '788', 'TN', 'TUN', 0, NOW(), NOW()),
|
||||
(180, NULL, '795', 'TM', 'TKM', 0, NOW(), NOW()),
|
||||
(181, NULL, '792', 'TR', 'TUR', 0, NOW(), NOW()),
|
||||
(182, NULL, '798', 'TV', 'TUV', 0, NOW(), NOW()),
|
||||
(183, NULL, '804', 'UA', 'UKR', 0, NOW(), NOW()),
|
||||
(184, NULL, '858', 'UY', 'URY', 0, NOW(), NOW()),
|
||||
(185, NULL, '336', 'VA', 'VAT', 0, NOW(), NOW()),
|
||||
(186, NULL, '548', 'VU', 'VUT', 0, NOW(), NOW()),
|
||||
(187, NULL, '862', 'VE', 'VEN', 0, NOW(), NOW()),
|
||||
(188, NULL, '704', 'VN', 'VNM', 0, NOW(), NOW()),
|
||||
(189, NULL, '887', 'YE', 'YEM', 0, NOW(), NOW()),
|
||||
(190, NULL, '807', 'MK', 'MKD', 0, NOW(), NOW()),
|
||||
(191, NULL, '180', 'CD', 'COD', 0, NOW(), NOW()),
|
||||
(192, NULL, '894', 'ZM', 'ZMB', 0, NOW(), NOW()),
|
||||
(193, NULL, '716', 'ZW', 'ZWE', 0, NOW(), NOW()),
|
||||
(196, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(197, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(198, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(199, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(200, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(201, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(202, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(203, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(204, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(205, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(206, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(207, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(208, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(209, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(210, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(211, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(212, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(213, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(214, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(215, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(216, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(217, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(218, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(219, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(220, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(221, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(222, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(223, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(224, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(225, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(226, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(227, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(228, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(229, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(230, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(231, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(232, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(233, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(234, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(235, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(236, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(237, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(238, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(239, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(240, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(241, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(242, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(243, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(244, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(245, NULL, '840', 'US', 'USA', 0, NOW(), NOW()),
|
||||
(246, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(247, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(248, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(249, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(250, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(251, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(252, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(253, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(254, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(255, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(256, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(257, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(258, NULL, '124', 'CA', 'CAN', 0, NOW(), NOW()),
|
||||
(259, NULL, '312', 'GP', 'GLP', 0, NOW(), NOW()),
|
||||
(260, NULL, '254', 'GF', 'GUF', 0, NOW(), NOW()),
|
||||
(261, NULL, '474', 'MQ', 'MTQ', 0, NOW(), NOW()),
|
||||
(262, NULL, '175', 'YT', 'MYT', 0, NOW(), NOW()),
|
||||
(263, NULL, '638', 'RE', 'REU', 0, NOW(), NOW()),
|
||||
(264, NULL, '666', 'PM', 'SPM', 0, NOW(), NOW()),
|
||||
(265, NULL, '540', 'NC', 'NCL', 0, NOW(), NOW()),
|
||||
(266, NULL, '258', 'PF', 'PYF', 0, NOW(), NOW()),
|
||||
(267, NULL, '876', 'WF', 'WLF', 0, NOW(), NOW()),
|
||||
(268, NULL, '840', 'US', 'USA', 0, NOW(), NOW());
|
||||
|
||||
INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES
|
||||
(1, 'en_US', 'Afghanistan', '', '', ''),
|
||||
|
||||
@@ -45,7 +45,7 @@ CREATE TABLE `product`
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `ref_UNIQUE` (`ref`),
|
||||
INDEX `idx_product_tax_rule_id` (`tax_rule_id`),
|
||||
INDEX `fk_product_template1_idx` (`template_id`),
|
||||
INDEX `fk_product_template_id` (`template_id`),
|
||||
CONSTRAINT `fk_product_tax_rule_id`
|
||||
FOREIGN KEY (`tax_rule_id`)
|
||||
REFERENCES `tax_rule` (`id`)
|
||||
@@ -96,6 +96,7 @@ CREATE TABLE `country`
|
||||
`isocode` VARCHAR(4) NOT NULL,
|
||||
`isoalpha2` VARCHAR(2),
|
||||
`isoalpha3` VARCHAR(4),
|
||||
`by_default` TINYINT,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
@@ -1198,6 +1199,7 @@ CREATE TABLE `cart_item`
|
||||
`promo_price` FLOAT,
|
||||
`price_end_of_life` DATETIME,
|
||||
`discount` FLOAT DEFAULT 0,
|
||||
`promo` INTEGER,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user