diff --git a/.travis.yml b/.travis.yml index 3ee2064b8..84e25866b 100755 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,5 @@ before_script: - sh -c "mysql -u$DB_USER -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS thelia;SET FOREIGN_KEY_CHECKS = 1;'; fi" - php Thelia thelia:install --db_host=localhost --db_username=$DB_USER --db_name=thelia - php install/faker.php + - php Thelia module:activate Colissimo + - php Thelia module:activate Cheque \ No newline at end of file diff --git a/Readme.md b/Readme.md index ac0862dae..66d831f94 100755 --- a/Readme.md +++ b/Readme.md @@ -5,10 +5,10 @@ Thelia ------ [![Build Status](https://travis-ci.org/thelia/thelia.png?branch=master)](https://travis-ci.org/thelia/thelia) -Thelia is an open source tool for creating e-business websites and managing online content. This software is published under GPL. +[Thelia](http://thelia.net) is an open source tool for creating e-business websites and managing online content. This software is published under GPL. Here is the current developping next major version. You can download this version for testing or see the code. -Here is the most recent developed code for the next major version (v2). You can download this version for testing or having a look on the code (or anything you wish, respecting GPL). +Here is the most recent developed code for the next major version (v2). You can download this version for testing or having a look on the code (or anything you wish, respecting GPL). See http://thelia.net/v2 web site for more information. Most part of the code can possibly change, a large part will be refactor soon, graphical setup does not exist yet. @@ -35,10 +35,10 @@ Installation ------------ ``` bash -$ git clone --recursive https://github.com/thelia/thelia.git +$ git clone https://github.com/thelia/thelia.git $ cd thelia $ curl -sS https://getcomposer.org/installer | php -$ php composer.phar install --optimize-autoloader +$ php composer.phar install --prefer-dist --optimize-autoloader ``` Finish the installation using cli tools : diff --git a/composer.json b/composer.json index 4a3798384..afef9e30b 100755 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "imagine/imagine": "dev-master", "symfony/icu": "1.0", - "swiftmailer/swiftmailer": "5.0.*" + "swiftmailer/swiftmailer": "5.0.*", + "symfony/serializer": "2.3.*" }, "require-dev" : { "phpunit/phpunit": "3.7.*", diff --git a/composer.lock b/composer.lock index b0310c075..a89768ef1 100755 --- a/composer.lock +++ b/composer.lock @@ -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": "a40be01c82e68ba0c446dc204d2667da", + "hash": "097481390dc87b3482d895b3b6a65479", "packages": [ { "name": "imagine/imagine", @@ -214,12 +214,12 @@ "source": { "type": "git", "url": "https://github.com/propelorm/Propel2.git", - "reference": "58a25ded43c3d04313cad2b738342d307988b1b5" + "reference": "fb9a10939abdd6efea7a066f0ef28f82ad06e435" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/propelorm/Propel2/zipball/58a25ded43c3d04313cad2b738342d307988b1b5", - "reference": "58a25ded43c3d04313cad2b738342d307988b1b5", + "url": "https://api.github.com/repos/propelorm/Propel2/zipball/fb9a10939abdd6efea7a066f0ef28f82ad06e435", + "reference": "fb9a10939abdd6efea7a066f0ef28f82ad06e435", "shasum": "" }, "require": { @@ -266,7 +266,7 @@ "orm", "persistence" ], - "time": "2013-09-01 13:29:51" + "time": "2013-09-30 08:26:26" }, { "name": "psr/log", @@ -845,17 +845,17 @@ }, { "name": "symfony/finder", - "version": "v2.3.4", + "version": "v2.3.5", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1" + "reference": "a175521f680b178e63c5d0ab87c6b046c0990c3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1", - "reference": "4a0fee5b86f5bbd9dfdc11ec124eba2915737ce1", + "url": "https://api.github.com/repos/symfony/Finder/zipball/a175521f680b178e63c5d0ab87c6b046c0990c3f", + "reference": "a175521f680b178e63c5d0ab87c6b046c0990c3f", "shasum": "" }, "require": { @@ -888,7 +888,7 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2013-08-13 20:18:00" + "time": "2013-09-19 09:45:20" }, { "name": "symfony/form", @@ -1456,6 +1456,53 @@ "homepage": "http://symfony.com", "time": "2013-08-23 14:06:02" }, + { + "name": "symfony/serializer", + "version": "v2.3.4", + "target-dir": "Symfony/Component/Serializer", + "source": { + "type": "git", + "url": "https://github.com/symfony/Serializer.git", + "reference": "457ba76395955926a67ea692957b0872dead5278" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Serializer/zipball/457ba76395955926a67ea692957b0872dead5278", + "reference": "457ba76395955926a67ea692957b0872dead5278", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Serializer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Serializer Component", + "homepage": "http://symfony.com", + "time": "2013-07-21 12:12:18" + }, { "name": "symfony/translation", "version": "v2.2.6", diff --git a/core/lib/Thelia/Action/Address.php b/core/lib/Thelia/Action/Address.php index a912888c8..b25c9c4ba 100644 --- a/core/lib/Thelia/Action/Address.php +++ b/core/lib/Thelia/Action/Address.php @@ -25,8 +25,8 @@ namespace Thelia\Action; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Propel; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\AddressCreateOrUpdateEvent; -use Thelia\Core\Event\AddressEvent; +use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent; +use Thelia\Core\Event\Address\AddressEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Address as AddressModel; use Thelia\Model\Map\AddressTableMap; @@ -86,14 +86,14 @@ class Address extends BaseAction implements EventSubscriberInterface ->save() ; - if($event->getIsDefault()) { + if ($event->getIsDefault()) { $addressModel->makeItDefault(); } $event->setAddress($addressModel); $con->commit(); - } catch(PropelException $e) { + } catch (PropelException $e) { $con->rollback(); throw $e; } diff --git a/core/lib/Thelia/Action/Attribute.php b/core/lib/Thelia/Action/Attribute.php index 44c5968a4..7db04518a 100644 --- a/core/lib/Thelia/Action/Attribute.php +++ b/core/lib/Thelia/Action/Attribute.php @@ -30,15 +30,11 @@ use Thelia\Model\Attribute as AttributeModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\AttributeUpdateEvent; -use Thelia\Core\Event\AttributeCreateEvent; -use Thelia\Core\Event\AttributeDeleteEvent; -use Thelia\Model\ConfigQuery; -use Thelia\Model\AttributeAv; -use Thelia\Model\AttributeAvQuery; +use Thelia\Core\Event\Attribute\AttributeUpdateEvent; +use Thelia\Core\Event\Attribute\AttributeCreateEvent; +use Thelia\Core\Event\Attribute\AttributeDeleteEvent; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\CategoryEvent; -use Thelia\Core\Event\AttributeEvent; +use Thelia\Core\Event\Attribute\AttributeEvent; use Thelia\Model\AttributeTemplate; use Thelia\Model\AttributeTemplateQuery; use Thelia\Model\TemplateQuery; @@ -123,26 +119,14 @@ class Attribute extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $attribute = AttributeQuery::create()->findPk($event->getObjectId())) { - - $attribute->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $attribute->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $attribute->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $attribute->movePositionDown(); - } + return $this->genericUpdatePosition(AttributeQuery::create(), $event); } protected function doAddToAllTemplates(AttributeModel $attribute) { $templates = TemplateQuery::create()->find(); - foreach($templates as $template) { + foreach ($templates as $template) { $attribute_template = new AttributeTemplate(); @@ -183,4 +167,4 @@ class Attribute extends BaseAction implements EventSubscriberInterface ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/AttributeAv.php b/core/lib/Thelia/Action/AttributeAv.php index a6b442fa2..83d85b398 100644 --- a/core/lib/Thelia/Action/AttributeAv.php +++ b/core/lib/Thelia/Action/AttributeAv.php @@ -30,10 +30,9 @@ use Thelia\Model\AttributeAv as AttributeAvModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\AttributeAvUpdateEvent; -use Thelia\Core\Event\AttributeAvCreateEvent; -use Thelia\Core\Event\AttributeAvDeleteEvent; -use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent; +use Thelia\Core\Event\Attribute\AttributeAvCreateEvent; +use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent; use Thelia\Core\Event\UpdatePositionEvent; class AttributeAv extends BaseAction implements EventSubscriberInterface @@ -63,7 +62,7 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface /** * Change a product attribute * - * @param AttributeAvUpdateEvent $event + * @param \Thelia\Core\Event\Attribute\AttributeAvUpdateEvent $event */ public function update(AttributeAvUpdateEvent $event) { @@ -112,22 +111,9 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getObjectId())) { - - $attribute->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $attribute->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $attribute->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $attribute->movePositionDown(); - } + return $this->genericUpdatePosition(AttributeAvQuery::create(), $event); } - /** * {@inheritDoc} */ @@ -140,4 +126,4 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128), ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index 56565ddc6..33deddf2b 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -23,6 +23,9 @@ namespace Thelia\Action; use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Model\AdminLog; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Thelia\Core\Event\UpdatePositionEvent; class BaseAction { @@ -45,4 +48,41 @@ class BaseAction { return $this->container->get('event_dispatcher'); } + + /** + * Changes object position, selecting absolute ou relative change. + * + * @param $query the query to retrieve the object to move + * @param UpdatePositionEvent $event + */ + protected function genericUpdatePosition(ModelCriteria $query, UpdatePositionEvent $event) + { + if (null !== $object = $query->findPk($event->getObjectId())) { + + $object->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $object->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $object->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $object->movePositionDown(); + } + } + + /** + * Helper to append a message to the admin log. + * + * @param string $message + */ + public function adminLogAppend($message) + { + AdminLog::append( + $message, + $this->container->get('request'), + $this->container->get('thelia.securityContext')->getAdminUser() + ); + } } diff --git a/core/lib/Thelia/Action/BaseCachedFile.php b/core/lib/Thelia/Action/BaseCachedFile.php index b66496e07..caa7c8ada 100644 --- a/core/lib/Thelia/Action/BaseCachedFile.php +++ b/core/lib/Thelia/Action/BaseCachedFile.php @@ -23,10 +23,7 @@ namespace Thelia\Action; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - use Thelia\Core\Event\CachedFileEvent; -use Thelia\Model\ConfigQuery; use Thelia\Tools\URL; /** @@ -50,7 +47,7 @@ abstract class BaseCachedFile extends BaseAction /** * @return string root of the file cache directory in web space */ - protected abstract function getCacheDirFromWebRoot(); + abstract protected function getCacheDirFromWebRoot(); /** * Clear the file cache. Is a subdirectory is specified, only this directory is cleared. @@ -104,9 +101,9 @@ abstract class BaseCachedFile extends BaseAction /** * Return the full path of the cached file * - * @param string $subdir the subdirectory related to cache base - * @param string $filename the filename - * @param string $hashed_options a hash of transformation options, or null if no transformations have been applied + * @param string $subdir the subdirectory related to cache base + * @param string $filename the filename + * @param string $hashed_options a hash of transformation options, or null if no transformations have been applied * @param boolean $forceOriginalDocument if true, the original file path in the cache dir is returned. * @return string the cache directory path relative to Web Root */ @@ -175,4 +172,4 @@ abstract class BaseCachedFile extends BaseAction return $path; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 22760a4c7..89be6ea0a 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -25,7 +25,7 @@ namespace Thelia\Action; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\Cart\CartEvent; use Thelia\Model\ProductPrice; use Thelia\Model\ProductPriceQuery; use Thelia\Model\CartItem; @@ -45,7 +45,7 @@ class Cart extends BaseAction implements EventSubscriberInterface /** * * add an article in the current cart - * @param \Thelia\Core\Event\CartEvent $event + * @param \Thelia\Core\Event\Cart\CartEvent $event */ public function addItem(CartEvent $event) { @@ -77,7 +77,7 @@ class Cart extends BaseAction implements EventSubscriberInterface * * Delete specify article present into cart * - * @param \Thelia\Core\Event\CartEvent $event + * @param \Thelia\Core\Event\Cart\CartEvent $event */ public function deleteItem(CartEvent $event) { @@ -97,7 +97,7 @@ class Cart extends BaseAction implements EventSubscriberInterface * * don't use Form here just test the Request. * - * @param \Thelia\Core\Event\CartEvent $event + * @param \Thelia\Core\Event\Cart\CartEvent $event */ public function changeItem(CartEvent $event) { diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 25a94711f..815ea162a 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -30,14 +30,13 @@ use Thelia\Model\Category as CategoryModel; 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\Category\CategoryUpdateEvent; +use Thelia\Core\Event\Category\CategoryCreateEvent; +use Thelia\Core\Event\Category\CategoryDeleteEvent; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\CategoryToggleVisibilityEvent; -use Thelia\Core\Event\CategoryAddContentEvent; -use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\Category\CategoryAddContentEvent; +use Thelia\Core\Event\Category\CategoryDeleteContentEvent; use Thelia\Model\CategoryAssociatedContent; use Thelia\Model\CategoryAssociatedContentQuery; @@ -46,7 +45,7 @@ class Category extends BaseAction implements EventSubscriberInterface /** * Create a new category entry * - * @param CategoryCreateEvent $event + * @param \Thelia\Core\Event\Category\CategoryCreateEvent $event */ public function create(CategoryCreateEvent $event) { @@ -69,7 +68,7 @@ class Category extends BaseAction implements EventSubscriberInterface /** * Change a category * - * @param CategoryUpdateEvent $event + * @param \Thelia\Core\Event\Category\CategoryUpdateEvent $event */ public function update(CategoryUpdateEvent $event) { @@ -98,7 +97,7 @@ class Category extends BaseAction implements EventSubscriberInterface /** * Delete a category entry * - * @param CategoryDeleteEvent $event + * @param \Thelia\Core\Event\Category\CategoryDeleteEvent $event */ public function delete(CategoryDeleteEvent $event) { @@ -136,23 +135,11 @@ class Category extends BaseAction implements EventSubscriberInterface */ 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(); - } + return $this->genericUpdatePosition(CategoryQuery::create(), $event); } - public function addContent(CategoryAddContentEvent $event) { - + public function addContent(CategoryAddContentEvent $event) + { if (CategoryAssociatedContentQuery::create() ->filterByContentId($event->getContentId()) ->filterByCategory($event->getCategory())->count() <= 0) { @@ -168,8 +155,8 @@ class Category extends BaseAction implements EventSubscriberInterface } } - public function removeContent(CategoryDeleteContentEvent $event) { - + public function removeContent(CategoryDeleteContentEvent $event) + { $content = CategoryAssociatedContentQuery::create() ->filterByContentId($event->getContentId()) ->filterByCategory($event->getCategory())->findOne() @@ -182,7 +169,6 @@ class Category extends BaseAction implements EventSubscriberInterface } } - /** * {@inheritDoc} */ diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php index f8a7c027c..e925811d3 100644 --- a/core/lib/Thelia/Action/Config.php +++ b/core/lib/Thelia/Action/Config.php @@ -29,16 +29,16 @@ use Thelia\Model\Config as ConfigModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\ConfigUpdateEvent; -use Thelia\Core\Event\ConfigCreateEvent; -use Thelia\Core\Event\ConfigDeleteEvent; +use Thelia\Core\Event\Config\ConfigUpdateEvent; +use Thelia\Core\Event\Config\ConfigCreateEvent; +use Thelia\Core\Event\Config\ConfigDeleteEvent; class Config extends BaseAction implements EventSubscriberInterface { /** * Create a new configuration entry * - * @param ConfigCreateEvent $event + * @param \Thelia\Core\Event\Config\ConfigCreateEvent $event */ public function create(ConfigCreateEvent $event) { @@ -54,7 +54,7 @@ class Config extends BaseAction implements EventSubscriberInterface /** * Change a configuration entry value * - * @param ConfigUpdateEvent $event + * @param \Thelia\Core\Event\Config\ConfigUpdateEvent $event */ public function setValue(ConfigUpdateEvent $event) { @@ -74,7 +74,7 @@ class Config extends BaseAction implements EventSubscriberInterface /** * Change a configuration entry * - * @param ConfigUpdateEvent $event + * @param \Thelia\Core\Event\Config\ConfigUpdateEvent $event */ public function modify(ConfigUpdateEvent $event) { @@ -94,7 +94,7 @@ class Config extends BaseAction implements EventSubscriberInterface /** * Delete a configuration entry * - * @param ConfigDeleteEvent $event + * @param \Thelia\Core\Event\Config\ConfigDeleteEvent $event */ public function delete(ConfigDeleteEvent $event) { diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php new file mode 100644 index 000000000..8560aa00e --- /dev/null +++ b/core/lib/Thelia/Action/Content.php @@ -0,0 +1,203 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Content\ContentAddFolderEvent; +use Thelia\Core\Event\Content\ContentCreateEvent; +use Thelia\Core\Event\Content\ContentDeleteEvent; +use Thelia\Core\Event\Content\ContentRemoveFolderEvent; +use Thelia\Core\Event\Content\ContentToggleVisibilityEvent; +use Thelia\Core\Event\Content\ContentUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\ContentFolder; +use Thelia\Model\ContentFolderQuery; +use Thelia\Model\ContentQuery; +use Thelia\Model\Content as ContentModel; + +/** + * Class Content + * @package Thelia\Action + * @author manuel raynaud + */ +class Content extends BaseAction implements EventSubscriberInterface +{ + + public function create(ContentCreateEvent $event) + { + $content = new ContentModel(); + + $content + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->create($event->getDefaultFolder()) + ; + + $event->setContent($content); + } + + /** + * process update content + * + * @param ContentUpdateEvent $event + */ + public function update(ContentUpdateEvent $event) + { + if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) { + $content->setDispatcher($this->getDispatcher()); + + $content + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + ->save() + ; + + $content->updateDefaultFolder($event->getDefaultFolder()); + + $event->setContent($content); + } + } + + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $content = ContentQuery::create()->findPk($event->getObjectId())) { + $content->setDispatcher($this->getDispatcher()); + + switch ($event->getMode()) { + case UpdatePositionEvent::POSITION_ABSOLUTE: + $content->changeAbsolutePosition($event->getPosition()); + break; + case UpdatePositionEvent::POSITION_DOWN: + $content->movePositionDown(); + break; + case UpdatePositionEvent::POSITION_UP: + $content->movePositionUp(); + break; + } + } + } + + public function toggleVisibility(ContentToggleVisibilityEvent $event) + { + $content = $event->getContent(); + + $content + ->setDispatcher($this->getDispatcher()) + ->setVisible(!$content->getVisible()) + ->save(); + + $event->setContent($content); + + } + + public function delete(ContentDeleteEvent $event) + { + if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) { + $defaultFolderId = $content->getDefaultFolderId(); + + $content->setDispatcher($this->getDispatcher()) + ->delete(); + + $event->setDefaultFolderId($defaultFolderId); + $event->setContent($content); + } + } + + /** + * + * associate a folder to a content if the association already does not exists + * + * @param ContentAddFolderEvent $event + */ + public function addFolder(ContentAddFolderEvent $event) + { + if(ContentFolderQuery::create() + ->filterByContent($event->getContent()) + ->filterByFolderId($event->getFolderId()) + ->count() <= 0 + ) { + $contentFolder = new ContentFolder(); + + $contentFolder + ->setFolderId($event->getFolderId()) + ->setContent($event->getContent()) + ->setDefaultFolder(false) + ->save(); + } + } + + public function removeFolder(ContentRemoveFolderEvent $event) + { + $contentFolder = ContentFolderQuery::create() + ->filterByContent($event->getContent()) + ->filterByFolderId($event->getFolderId()) + ->findOne(); + + if(null !== $contentFolder) { + $contentFolder->delete(); + } + } + + /** + * Returns an array of event names this subscriber wants to listen 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 + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::CONTENT_CREATE => array('create', 128), + TheliaEvents::CONTENT_UPDATE => array('update', 128), + TheliaEvents::CONTENT_DELETE => array('delete', 128), + TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array('toggleVisibility', 128), + + TheliaEvents::CONTENT_UPDATE_POSITION => array('updatePosition', 128), + + TheliaEvents::CONTENT_ADD_FOLDER => array('addFolder', 128), + TheliaEvents::CONTENT_REMOVE_FOLDER => array('removeFolder', 128), + ); + } + +} diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 036502c68..b3086c266 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -23,15 +23,16 @@ namespace Thelia\Action; -use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Constraint\ConstraintFactory; +use Thelia\Condition\ConditionFactory; +use Thelia\Condition\ConditionManagerInterface; use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\HttpFoundation\Request; use Thelia\Coupon\CouponFactory; use Thelia\Coupon\CouponManager; +use Thelia\Coupon\ConditionCollection; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon as CouponModel; @@ -73,19 +74,19 @@ class Coupon extends BaseAction implements EventSubscriberInterface } /** - * Occurring when a Coupon rule is about to be updated + * Occurring when a Coupon condition is about to be updated * * @param CouponCreateOrUpdateEvent $event Event creation or update Coupon Rule */ - public function updateRule(CouponCreateOrUpdateEvent $event) + public function updateCondition(CouponCreateOrUpdateEvent $event) { $coupon = $event->getCoupon(); - $this->createOrUpdateRule($coupon, $event); + $this->createOrUpdateCondition($coupon, $event); } /** - * Occurring when a Coupon rule is about to be consumed + * Occurring when a Coupon condition is about to be consumed * * @param CouponConsumeEvent $event Event consuming Coupon */ @@ -137,11 +138,22 @@ class Coupon extends BaseAction implements EventSubscriberInterface { $coupon->setDispatcher($this->getDispatcher()); + // Set default condition if none found + /** @var ConditionManagerInterface $noConditionRule */ + $noConditionRule = $this->container->get('thelia.condition.match_for_everyone'); + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $this->container->get('thelia.condition.factory'); + $couponRuleCollection = new ConditionCollection(); + $couponRuleCollection->add($noConditionRule); + $defaultSerializedRule = $conditionFactory->serializeConditionCollection( + $couponRuleCollection + ); + $coupon->createOrUpdate( $event->getCode(), $event->getTitle(), $event->getAmount(), - $event->getEffect(), + $event->getType(), $event->isRemovingPostage(), $event->getShortDescription(), $event->getDescription(), @@ -150,6 +162,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface $event->isAvailableOnSpecialOffers(), $event->isCumulative(), $event->getMaxUsage(), + $defaultSerializedRule, $event->getLocale() ); @@ -163,15 +176,15 @@ class Coupon extends BaseAction implements EventSubscriberInterface * @param CouponModel $coupon Model to save * @param CouponCreateOrUpdateEvent $event Event containing data */ - protected function createOrUpdateRule(CouponModel $coupon, CouponCreateOrUpdateEvent $event) + protected function createOrUpdateCondition(CouponModel $coupon, CouponCreateOrUpdateEvent $event) { $coupon->setDispatcher($this->getDispatcher()); - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $this->container->get('thelia.constraint.factory'); + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $this->container->get('thelia.condition.factory'); - $coupon->createOrUpdateRules( - $constraintFactory->serializeCouponRuleCollection($event->getRules()), + $coupon->createOrUpdateConditions( + $conditionFactory->serializeConditionCollection($event->getConditions()), $event->getLocale() ); @@ -204,7 +217,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface TheliaEvents::COUPON_CREATE => array("create", 128), TheliaEvents::COUPON_UPDATE => array("update", 128), TheliaEvents::COUPON_CONSUME => array("consume", 128), - TheliaEvents::COUPON_RULE_UPDATE => array("updateRule", 128) + TheliaEvents::COUPON_CONDITION_UPDATE => array("updateCondition", 128) ); } } diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 946fee375..3fe24326a 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -30,9 +30,9 @@ use Thelia\Model\Currency as CurrencyModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CurrencyUpdateEvent; -use Thelia\Core\Event\CurrencyCreateEvent; -use Thelia\Core\Event\CurrencyDeleteEvent; +use Thelia\Core\Event\Currency\CurrencyUpdateEvent; +use Thelia\Core\Event\Currency\CurrencyCreateEvent; +use Thelia\Core\Event\Currency\CurrencyDeleteEvent; use Thelia\Model\ConfigQuery; use Thelia\Core\Event\UpdatePositionEvent; @@ -41,7 +41,7 @@ class Currency extends BaseAction implements EventSubscriberInterface /** * Create a new currencyuration entry * - * @param CurrencyCreateEvent $event + * @param \Thelia\Core\Event\Currency\CurrencyCreateEvent $event */ public function create(CurrencyCreateEvent $event) { @@ -65,7 +65,7 @@ class Currency extends BaseAction implements EventSubscriberInterface /** * Change a currency * - * @param CurrencyUpdateEvent $event + * @param \Thelia\Core\Event\Currency\CurrencyUpdateEvent $event */ public function update(CurrencyUpdateEvent $event) { @@ -118,7 +118,7 @@ class Currency extends BaseAction implements EventSubscriberInterface /** * Delete a currencyuration entry * - * @param CurrencyDeleteEvent $event + * @param \Thelia\Core\Event\Currency\CurrencyDeleteEvent $event */ public function delete(CurrencyDeleteEvent $event) { @@ -166,20 +166,7 @@ class Currency extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $currency = CurrencyQuery::create()->findPk($event->getObjectId())) { - - $currency->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - echo "loaded $mode !"; - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $currency->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $currency->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $currency->movePositionDown(); - } + return $this->genericUpdatePosition(CurrencyQuery::create(), $event); } /** diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index f132a01da..061dba028 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -25,11 +25,11 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; -use Thelia\Core\Event\CustomerCreateOrUpdateEvent; -use Thelia\Core\Event\CustomerEvent; +use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; +use Thelia\Core\Event\Customer\CustomerEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Customer as CustomerModel; -use Thelia\Core\Event\CustomerLoginEvent; +use Thelia\Core\Event\Customer\CustomerLoginEvent; /** * diff --git a/core/lib/Thelia/Action/Document.php b/core/lib/Thelia/Action/Document.php index 86fc51ac5..f048c208e 100644 --- a/core/lib/Thelia/Action/Document.php +++ b/core/lib/Thelia/Action/Document.php @@ -25,15 +25,15 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\DocumentEvent; +use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; +use Thelia\Core\Event\Document\DocumentDeleteEvent; +use Thelia\Core\Event\Document\DocumentEvent; +use Thelia\Exception\ImageException; use Thelia\Model\ConfigQuery; +use Thelia\Tools\FileManager; use Thelia\Tools\URL; -use Imagine\Document\ImagineInterface; -use Imagine\Document\DocumentInterface; -use Imagine\Document\Box; use Imagine\Document\Color; -use Imagine\Document\Point; use Thelia\Exception\DocumentException; use Thelia\Core\Event\TheliaEvents; @@ -76,7 +76,8 @@ class Document extends BaseCachedFile implements EventSubscriberInterface /** * @return string root of the document cache directory in web space */ - protected function getCacheDirFromWebRoot() { + protected function getCacheDirFromWebRoot() + { return ConfigQuery::read('document_cache_dir_from_web_root', 'cache'); } @@ -88,45 +89,175 @@ class Document extends BaseCachedFile implements EventSubscriberInterface * * This method updates the cache_file_path and file_url attributes of the event * - * @param DocumentEvent $event - * @throws \InvalidArgumentException, DocumentException + * @param DocumentEvent $event Event + * + * @throws \Thelia\Exception\DocumentException + * @throws \InvalidArgumentException , DocumentException */ public function processDocument(DocumentEvent $event) { $subdir = $event->getCacheSubdirectory(); - $source_file = $event->getSourceFilepath(); + $sourceFile = $event->getSourceFilepath(); - if (null == $subdir || null == $source_file) { + if (null == $subdir || null == $sourceFile) { throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null"); } - $originalDocumentPathInCache = $this->getCacheFilePath($subdir, $source_file, true); + $originalDocumentPathInCache = $this->getCacheFilePath($subdir, $sourceFile, true); if (! file_exists($originalDocumentPathInCache)) { - if (! file_exists($source_file)) { - throw new DocumentException(sprintf("Source document file %s does not exists.", $source_file)); + if (! file_exists($sourceFile)) { + throw new DocumentException(sprintf("Source document file %s does not exists.", $sourceFile)); } $mode = ConfigQuery::read('original_document_delivery_mode', 'symlink'); if ($mode == 'symlink') { - if (false == symlink($source_file, $originalDocumentPathInCache)) { - throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($source_file), $subdir)); + if (false == symlink($sourceFile, $originalDocumentPathInCache)) { + throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($sourceFile), $subdir)); } - } else {// mode = 'copy' - if (false == @copy($source_file, $originalDocumentPathInCache)) { - throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($source_file), $subdir)); + } else { + // mode = 'copy' + if (false == @copy($sourceFile, $originalDocumentPathInCache)) { + throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($sourceFile), $subdir)); } } } // Compute the document URL - $document_url = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache)); + $documentUrl = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache)); // Update the event with file path and file URL - $event->setDocumentPath($originalDocumentPathInCache); - $event->setDocumentUrl(URL::getInstance()->absoluteUrl($document_url, null, URL::PATH_TO_FILE)); + $event->setDocumentPath($documentUrl); + $event->setDocumentUrl(URL::getInstance()->absoluteUrl($documentUrl, null, URL::PATH_TO_FILE)); + } + + /** + * Take care of saving document in the database and file storage + * + * @param \Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent $event Document event + * + * @throws \Thelia\Exception\ImageException + * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action + */ + public function saveDocument(DocumentCreateOrUpdateEvent $event) + { + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Saving documents for %parentName% parent id %parentId% (%parentType%)', + array( + '%parentName%' => $event->getParentName(), + '%parentId%' => $event->getParentId(), + '%parentType%' => $event->getDocumentType() + ), + 'document' + ) + ); + + $fileManager = new FileManager($this->container); + $model = $event->getModelDocument(); + + $nbModifiedLines = $model->save(); + + $event->setModelDocument($model); + + if (!$nbModifiedLines) { + throw new ImageException( + sprintf( + 'Document "%s" with parent id %s (%s) failed to be saved', + $event->getParentName(), + $event->getParentId(), + $event->getDocumentType() + ) + ); + } + + $newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getDocumentType(), $event->getModelDocument(), $event->getUploadedFile(), FileManager::FILE_TYPE_DOCUMENTS); + $event->setUploadedFile($newUploadedFile); + } + + /** + * Take care of updating document in the database and file storage + * + * @param \Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent $event Document event + * + * @throws \Thelia\Exception\ImageException + * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action + */ + public function updateDocument(DocumentCreateOrUpdateEvent $event) + { + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Updating documents for %parentName% parent id %parentId% (%parentType%)', + array( + '%parentName%' => $event->getParentName(), + '%parentId%' => $event->getParentId(), + '%parentType%' => $event->getDocumentType() + ), + 'image' + ) + ); + + if (null !== $event->getUploadedFile()) { + $event->getModelDocument()->setTitle($event->getUploadedFile()->getClientOriginalName()); + } + + $fileManager = new FileManager($this->container); + // Copy and save file + if ($event->getUploadedFile()) { + // Remove old picture file from file storage + $url = $fileManager->getUploadDir($event->getDocumentType(), FileManager::FILE_TYPE_DOCUMENTS) . '/' . $event->getOldModelDocument()->getFile(); + unlink(str_replace('..', '', $url)); + + $newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getDocumentType(), $event->getModelDocument(), $event->getUploadedFile(), FileManager::FILE_TYPE_DOCUMENTS); + $event->setUploadedFile($newUploadedFile); + } + + // Update document modifications + $event->getModelDocument()->save(); + $event->setModelDocument($event->getModelDocument()); + } + + /** + * Take care of deleting document in the database and file storage + * + * @param \Thelia\Core\Event\Document\DocumentDeleteEvent $event Image event + * + * @throws \Exception + * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action + */ + public function deleteDocument(DocumentDeleteEvent $event) + { + $fileManager = new FileManager($this->container); + + try { + $fileManager->deleteFile($event->getDocumentToDelete(), $event->getDocumentType(), FileManager::FILE_TYPE_DOCUMENTS); + + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Deleting document for %id% with parent id %parentId%', + array( + '%id%' => $event->getDocumentToDelete()->getId(), + '%parentId%' => $event->getDocumentToDelete()->getParentId(), + ), + 'document' + ) + ); + } catch (\Exception $e) { + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Fail to delete document for %id% with parent id %parentId% (Exception : %e%)', + array( + '%id%' => $event->getDocumentToDelete()->getId(), + '%parentId%' => $event->getDocumentToDelete()->getParentId(), + '%e%' => $e->getMessage() + ), + 'document' + ) + ); + throw $e; + } } public static function getSubscribedEvents() @@ -134,6 +265,9 @@ class Document extends BaseCachedFile implements EventSubscriberInterface return array( TheliaEvents::DOCUMENT_PROCESS => array("processDocument", 128), TheliaEvents::DOCUMENT_CLEAR_CACHE => array("clearCache", 128), + TheliaEvents::DOCUMENT_DELETE => array("deleteDocument", 128), + TheliaEvents::DOCUMENT_SAVE => array("saveDocument", 128), + TheliaEvents::DOCUMENT_UPDATE => array("updateDocument", 128), ); } } diff --git a/core/lib/Thelia/Action/Feature.php b/core/lib/Thelia/Action/Feature.php index a746ce4e2..6ae7645e3 100644 --- a/core/lib/Thelia/Action/Feature.php +++ b/core/lib/Thelia/Action/Feature.php @@ -30,15 +30,11 @@ 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\Feature\FeatureUpdateEvent; +use Thelia\Core\Event\Feature\FeatureCreateEvent; +use Thelia\Core\Event\Feature\FeatureDeleteEvent; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\CategoryEvent; -use Thelia\Core\Event\FeatureEvent; +use Thelia\Core\Event\Feature\FeatureEvent; use Thelia\Model\FeatureTemplate; use Thelia\Model\FeatureTemplateQuery; use Thelia\Model\TemplateQuery; @@ -48,7 +44,7 @@ class Feature extends BaseAction implements EventSubscriberInterface /** * Create a new feature entry * - * @param FeatureCreateEvent $event + * @param \Thelia\Core\Event\Feature\FeatureCreateEvent $event */ public function create(FeatureCreateEvent $event) { @@ -74,7 +70,7 @@ class Feature extends BaseAction implements EventSubscriberInterface /** * Change a product feature * - * @param FeatureUpdateEvent $event + * @param \Thelia\Core\Event\Feature\FeatureUpdateEvent $event */ public function update(FeatureUpdateEvent $event) { @@ -123,26 +119,14 @@ class Feature extends BaseAction implements EventSubscriberInterface */ 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(); - } + return $this->genericUpdatePosition(FeatureQuery::create(), $event); } protected function doAddToAllTemplates(FeatureModel $feature) { $templates = TemplateQuery::create()->find(); - foreach($templates as $template) { + foreach ($templates as $template) { $feature_template = new FeatureTemplate(); @@ -183,4 +167,4 @@ class Feature extends BaseAction implements EventSubscriberInterface ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/FeatureAv.php b/core/lib/Thelia/Action/FeatureAv.php index 2bd117b4b..c2ef4f7bc 100644 --- a/core/lib/Thelia/Action/FeatureAv.php +++ b/core/lib/Thelia/Action/FeatureAv.php @@ -30,10 +30,9 @@ 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\Feature\FeatureAvUpdateEvent; +use Thelia\Core\Event\Feature\FeatureAvCreateEvent; +use Thelia\Core\Event\Feature\FeatureAvDeleteEvent; use Thelia\Core\Event\UpdatePositionEvent; class FeatureAv extends BaseAction implements EventSubscriberInterface @@ -112,22 +111,9 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface */ 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(); - } + return $this->genericUpdatePosition(FeatureAvQuery::create(), $event); } - /** * {@inheritDoc} */ @@ -140,4 +126,4 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128), ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Folder.php b/core/lib/Thelia/Action/Folder.php new file mode 100644 index 000000000..a42330e47 --- /dev/null +++ b/core/lib/Thelia/Action/Folder.php @@ -0,0 +1,154 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Folder\FolderCreateEvent; +use Thelia\Core\Event\Folder\FolderDeleteEvent; +use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent; +use Thelia\Core\Event\Folder\FolderUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\FolderQuery; +use Thelia\Model\Folder as FolderModel; + +/** + * Class Folder + * @package Thelia\Action + * @author Manuel Raynaud + */ +class Folder extends BaseAction implements EventSubscriberInterface +{ + public function update(FolderUpdateEvent $event) + { + + if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { + $folder->setDispatcher($this->getDispatcher()); + + $folder + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + ->save(); + ; + + $event->setFolder($folder); + } + } + + public function delete(FolderDeleteEvent $event) + { + if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { + $folder->setDispatcher($this->getDispatcher()) + ->delete(); + + $event->setFolder($folder); + } + } + + /** + * @param FolderCreateEvent $event + */ + public function create(FolderCreateEvent $event) + { + $folder = new FolderModel(); + $folder->setDispatcher($this->getDispatcher()); + + $folder + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->save(); + + $event->setFolder($folder); + } + + public function toggleVisibility(FolderToggleVisibilityEvent $event) + { + $folder = $event->getFolder(); + + $folder + ->setDispatcher($this->getDispatcher()) + ->setVisible(!$folder->getVisible()) + ->save(); + + $event->setFolder($folder); + + } + + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) { + $folder->setDispatcher($this->getDispatcher()); + + switch ($event->getMode()) { + case UpdatePositionEvent::POSITION_ABSOLUTE: + $folder->changeAbsolutePosition($event->getPosition()); + break; + case UpdatePositionEvent::POSITION_DOWN: + $folder->movePositionDown(); + break; + case UpdatePositionEvent::POSITION_UP: + $folder->movePositionUp(); + break; + } + } + } + + /** + * Returns an array of event names this subscriber wants to listen 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 + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::FOLDER_CREATE => array("create", 128), + TheliaEvents::FOLDER_UPDATE => array("update", 128), + TheliaEvents::FOLDER_DELETE => array("delete", 128), + TheliaEvents::FOLDER_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + + TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128), + ); + } +} diff --git a/core/lib/Thelia/Action/HttpException.php b/core/lib/Thelia/Action/HttpException.php index 9beadeb7b..50ee92d5e 100755 --- a/core/lib/Thelia/Action/HttpException.php +++ b/core/lib/Thelia/Action/HttpException.php @@ -45,7 +45,7 @@ class HttpException extends BaseAction implements EventSubscriberInterface $this->display404($event); } - if($event->getException() instanceof AccessDeniedHttpException) { + if ($event->getException() instanceof AccessDeniedHttpException) { $this->display403($event); } } diff --git a/core/lib/Thelia/Action/Image.php b/core/lib/Thelia/Action/Image.php index 4660f93b8..97d4bd095 100755 --- a/core/lib/Thelia/Action/Image.php +++ b/core/lib/Thelia/Action/Image.php @@ -25,8 +25,11 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\ImageEvent; +use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; +use Thelia\Core\Event\Image\ImageDeleteEvent; +use Thelia\Core\Event\Image\ImageEvent; use Thelia\Model\ConfigQuery; +use Thelia\Tools\FileManager; use Thelia\Tools\URL; use Imagine\Image\ImagineInterface; @@ -39,10 +42,10 @@ use Thelia\Core\Event\TheliaEvents; /** * - * Image management actions. This class handles image processing an caching. + * Image management actions. This class handles image processing and caching. * - * Basically, images are stored outside the web space (by default in local/media/images), - * and cached in the web space (by default in web/local/images). + * Basically, images are stored outside of the web space (by default in local/media/images), + * and cached inside the web space (by default in web/local/images). * * In the images caches directory, a subdirectory for images categories (eg. product, category, folder, etc.) is * automatically created, and the cached image is created here. Plugin may use their own subdirectory as required. @@ -81,7 +84,8 @@ class Image extends BaseCachedFile implements EventSubscriberInterface /** * @return string root of the image cache directory in web space */ - protected function getCacheDirFromWebRoot() { + protected function getCacheDirFromWebRoot() + { return ConfigQuery::read('image_cache_dir_from_web_root', 'cache'); } @@ -94,8 +98,8 @@ class Image extends BaseCachedFile implements EventSubscriberInterface * * This method updates the cache_file_path and file_url attributes of the event * - * @param ImageEvent $event - * @throws \InvalidArgumentException, ImageException + * @param \Thelia\Core\Event\Image\ImageEvent $event + * @throws \InvalidArgumentException, ImageException */ public function processImage(ImageEvent $event) { @@ -229,7 +233,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface // Compute the image URL $processed_image_url = $this->getCacheFileURL($subdir, basename($cacheFilePath)); - // compute the full resulution image path in cache + // compute the full resolution image path in cache $original_image_url = $this->getCacheFileURL($subdir, basename($originalImagePathInCache)); // Update the event with file path and file URL @@ -240,6 +244,128 @@ class Image extends BaseCachedFile implements EventSubscriberInterface $event->setOriginalFileUrl(URL::getInstance()->absoluteUrl($original_image_url, null, URL::PATH_TO_FILE)); } + /** + * Take care of saving image in the database and file storage + * + * @param \Thelia\Core\Event\Image\ImageCreateOrUpdateEvent $event Image event + * + * @throws \Thelia\Exception\ImageException + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function saveImage(ImageCreateOrUpdateEvent $event) + { + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Saving images for %parentName% parent id %parentId% (%parentType%)', + array( + '%parentName%' => $event->getParentName(), + '%parentId%' => $event->getParentId(), + '%parentType%' => $event->getImageType() + ), + 'image' + ) + ); + + $fileManager = new FileManager($this->container); + $model = $event->getModelImage(); + + $nbModifiedLines = $model->save(); + $event->setModelImage($model); + + if (!$nbModifiedLines) { + throw new ImageException( + sprintf( + 'Image "%s" with parent id %s (%s) failed to be saved', + $event->getParentName(), + $event->getParentId(), + $event->getImageType() + ) + ); + } + + $newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getImageType(), $event->getModelImage(), $event->getUploadedFile(), FileManager::FILE_TYPE_IMAGES); + $event->setUploadedFile($newUploadedFile); + } + + /** + * Take care of updating image in the database and file storage + * + * @param ImageCreateOrUpdateEvent $event Image event + * + * @throws \Thelia\Exception\ImageException + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function updateImage(ImageCreateOrUpdateEvent $event) + { + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Updating images for %parentName% parent id %parentId% (%parentType%)', + array( + '%parentName%' => $event->getParentName(), + '%parentId%' => $event->getParentId(), + '%parentType%' => $event->getImageType() + ), + 'image' + ) + ); + + $fileManager = new FileManager($this->container); + // Copy and save file + if ($event->getUploadedFile()) { + // Remove old picture file from file storage + $url = $fileManager->getUploadDir($event->getImageType(), FileManager::FILE_TYPE_IMAGES) . '/' . $event->getOldModelImage()->getFile(); + unlink(str_replace('..', '', $url)); + + $newUploadedFile = $fileManager->copyUploadedFile($event->getParentId(), $event->getImageType(), $event->getModelImage(), $event->getUploadedFile(), FileManager::FILE_TYPE_IMAGES); + $event->setUploadedFile($newUploadedFile); + } + + // Update image modifications + $event->getModelImage()->save(); + $event->setModelImage($event->getModelImage()); + } + + /** + * Take care of deleting image in the database and file storage + * + * @param ImageDeleteEvent $event Image event + * + * @throws \Exception + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function deleteImage(ImageDeleteEvent $event) + { + $fileManager = new FileManager($this->container); + + try { + $fileManager->deleteFile($event->getImageToDelete(), $event->getImageType(), FileManager::FILE_TYPE_IMAGES); + + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Deleting image for %id% with parent id %parentId%', + array( + '%id%' => $event->getImageToDelete()->getId(), + '%parentId%' => $event->getImageToDelete()->getParentId(), + ), + 'image' + ) + ); + } catch (\Exception $e) { + $this->adminLogAppend( + $this->container->get('thelia.translator')->trans( + 'Fail to delete image for %id% with parent id %parentId% (Exception : %e%)', + array( + '%id%' => $event->getImageToDelete()->getId(), + '%parentId%' => $event->getImageToDelete()->getParentId(), + '%e%' => $e->getMessage() + ), + 'image' + ) + ); + throw $e; + } + } + /** * Process image resizing, with borders or cropping. If $dest_width and $dest_height * are both null, no resize is performed. @@ -362,6 +488,9 @@ class Image extends BaseCachedFile implements EventSubscriberInterface return array( TheliaEvents::IMAGE_PROCESS => array("processImage", 128), TheliaEvents::IMAGE_CLEAR_CACHE => array("clearCache", 128), + TheliaEvents::IMAGE_DELETE => array("deleteImage", 128), + TheliaEvents::IMAGE_SAVE => array("saveImage", 128), + TheliaEvents::IMAGE_UPDATE => array("updateImage", 128), ); } } diff --git a/core/lib/Thelia/Action/Message.php b/core/lib/Thelia/Action/Message.php index 8918913fe..fa9b13db5 100644 --- a/core/lib/Thelia/Action/Message.php +++ b/core/lib/Thelia/Action/Message.php @@ -30,16 +30,16 @@ use Thelia\Model\Message as MessageModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\MessageUpdateEvent; -use Thelia\Core\Event\MessageCreateEvent; -use Thelia\Core\Event\MessageDeleteEvent; +use Thelia\Core\Event\Message\MessageUpdateEvent; +use Thelia\Core\Event\Message\MessageCreateEvent; +use Thelia\Core\Event\Message\MessageDeleteEvent; class Message extends BaseAction implements EventSubscriberInterface { /** * Create a new messageuration entry * - * @param MessageCreateEvent $event + * @param \Thelia\Core\Event\Message\MessageCreateEvent $event */ public function create(MessageCreateEvent $event) { @@ -64,7 +64,7 @@ class Message extends BaseAction implements EventSubscriberInterface /** * Change a message * - * @param MessageUpdateEvent $event + * @param \Thelia\Core\Event\Message\MessageUpdateEvent $event */ public function modify(MessageUpdateEvent $event) { @@ -94,7 +94,7 @@ class Message extends BaseAction implements EventSubscriberInterface /** * Delete a messageuration entry * - * @param MessageDeleteEvent $event + * @param \Thelia\Core\Event\Message\MessageDeleteEvent $event */ public function delete(MessageDeleteEvent $event) { diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 4a982673a..b48f72439 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -23,18 +23,21 @@ namespace Thelia\Action; -use Propel\Runtime\Exception\PropelException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\Order\OrderAddressEvent; +use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Model\Base\AddressQuery; +use Thelia\Exception\TheliaProcessException; +use Thelia\Model\AddressQuery; +use Thelia\Model\OrderProductAttributeCombination; use Thelia\Model\ModuleQuery; +use Thelia\Model\OrderProduct; use Thelia\Model\OrderStatus; use Thelia\Model\Map\OrderTableMap; use Thelia\Model\OrderAddress; use Thelia\Model\OrderStatusQuery; -use Thelia\Model\ConfigQuery; +use Thelia\Tools\I18n; /** * @@ -45,7 +48,7 @@ use Thelia\Model\ConfigQuery; class Order extends BaseAction implements EventSubscriberInterface { /** - * @param \Thelia\Core\Event\OrderEvent $event + * @param \Thelia\Core\Event\Order\OrderEvent $event */ public function setDeliveryAddress(OrderEvent $event) { @@ -57,7 +60,7 @@ class Order extends BaseAction implements EventSubscriberInterface } /** - * @param \Thelia\Core\Event\OrderEvent $event + * @param \Thelia\Core\Event\Order\OrderEvent $event */ public function setDeliveryModule(OrderEvent $event) { @@ -70,7 +73,7 @@ class Order extends BaseAction implements EventSubscriberInterface } /** - * @param \Thelia\Core\Event\OrderEvent $event + * @param \Thelia\Core\Event\Order\OrderEvent $event */ public function setInvoiceAddress(OrderEvent $event) { @@ -82,7 +85,7 @@ class Order extends BaseAction implements EventSubscriberInterface } /** - * @param \Thelia\Core\Event\OrderEvent $event + * @param \Thelia\Core\Event\Order\OrderEvent $event */ public function setPaymentModule(OrderEvent $event) { @@ -94,7 +97,7 @@ class Order extends BaseAction implements EventSubscriberInterface } /** - * @param \Thelia\Core\Event\OrderEvent $event + * @param \Thelia\Core\Event\Order\OrderEvent $event */ public function create(OrderEvent $event) { @@ -108,14 +111,18 @@ class Order extends BaseAction implements EventSubscriberInterface /* use a copy to avoid errored reccord in session */ $placedOrder = $sessionOrder->copy(); + $placedOrder->setDispatcher($this->getDispatcher()); $customer = $this->getSecurityContext()->getCustomerUser(); $currency = $this->getSession()->getCurrency(); $lang = $this->getSession()->getLang(); $deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress); + $taxCountry = $deliveryAddress->getCountry(); $invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress); + $cart = $this->getSession()->getCart(); + $cartItems = $cart->getCartItems(); - $paymentModule = ModuleQuery::findPk($placedOrder->getPaymentModuleId()); + $paymentModule = ModuleQuery::create()->findPk($placedOrder->getPaymentModuleId()); /* fulfill order */ $placedOrder->setCustomerId($customer->getId()); @@ -135,6 +142,7 @@ class Order extends BaseAction implements EventSubscriberInterface ->setAddress3($deliveryAddress->getAddress3()) ->setZipcode($deliveryAddress->getZipcode()) ->setCity($deliveryAddress->getCity()) + ->setPhone($deliveryAddress->getPhone()) ->setCountryId($deliveryAddress->getCountryId()) ->save($con) ; @@ -150,6 +158,7 @@ class Order extends BaseAction implements EventSubscriberInterface ->setAddress3($invoiceAddress->getAddress3()) ->setZipcode($invoiceAddress->getZipcode()) ->setCity($invoiceAddress->getCity()) + ->setPhone($invoiceAddress->getPhone()) ->setCountryId($invoiceAddress->getCountryId()) ->save($con) ; @@ -163,39 +172,168 @@ class Order extends BaseAction implements EventSubscriberInterface $placedOrder->save($con); - /* fulfill order_products and decrease stock // @todo dispatch event */ + /* fulfill order_products and decrease stock */ + + foreach ($cartItems as $cartItem) { + $product = $cartItem->getProduct(); + + /* get translation */ + $productI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Product', $product->getId()); + + $pse = $cartItem->getProductSaleElements(); + + /* check still in stock */ + if ($cartItem->getQuantity() > $pse->getQuantity()) { + throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem); + } + + /* decrease stock */ + $pse->setQuantity( + $pse->getQuantity() - $cartItem->getQuantity() + ); + $pse->save($con); + + /* get tax */ + $taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId()); + + $taxDetail = $product->getTaxRule()->getTaxDetail( + $taxCountry, + $cartItem->getPrice(), + $cartItem->getPromoPrice(), + $this->getSession()->getLang()->getLocale() + ); + + $orderProduct = new OrderProduct(); + $orderProduct + ->setOrderId($placedOrder->getId()) + ->setProductRef($product->getRef()) + ->setProductSaleElementsRef($pse->getRef()) + ->setTitle($productI18n->getTitle()) + ->setChapo($productI18n->getChapo()) + ->setDescription($productI18n->getDescription()) + ->setPostscriptum($productI18n->getPostscriptum()) + ->setQuantity($cartItem->getQuantity()) + ->setPrice($cartItem->getPrice()) + ->setPromoPrice($cartItem->getPromoPrice()) + ->setWasNew($pse->getNewness()) + ->setWasInPromo($cartItem->getPromo()) + ->setWeight($pse->getWeight()) + ->setTaxRuleTitle($taxRuleI18n->getTitle()) + ->setTaxRuleDescription($taxRuleI18n->getDescription()) + ; + $orderProduct->setDispatcher($this->getDispatcher()); + $orderProduct->save($con); + + /* fulfill order_product_tax */ + foreach ($taxDetail as $tax) { + $tax->setOrderProductId($orderProduct->getId()); + $tax->save($con); + } + + /* fulfill order_attribute_combination and decrease stock */ + foreach ($pse->getAttributeCombinations() as $attributeCombination) { + $attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId()); + $attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId()); + + $orderAttributeCombination = new OrderProductAttributeCombination(); + $orderAttributeCombination + ->setOrderProductId($orderProduct->getId()) + ->setAttributeTitle($attribute->getTitle()) + ->setAttributeChapo($attribute->getChapo()) + ->setAttributeDescription($attribute->getDescription()) + ->setAttributePostscriptum($attribute->getPostscriptum()) + ->setAttributeAvTitle($attributeAv->getTitle()) + ->setAttributeAvChapo($attributeAv->getChapo()) + ->setAttributeAvDescription($attributeAv->getDescription()) + ->setAttributeAvPostscriptum($attributeAv->getPostscriptum()) + ; + + $orderAttributeCombination->save($con); + } + } /* discount @todo */ $con->commit(); - /* T1style : dispatch mail event ? */ + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); - /* clear session ? */ + /* clear session */ + /* but memorize placed order */ + $sessionOrder = new \Thelia\Model\Order(); + $event->setOrder($sessionOrder); + $event->setPlacedOrder($placedOrder); + $this->getSession()->setOrder($sessionOrder); + + /* empty cart @todo */ /* call pay method */ $paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); $paymentModuleInstance = $paymentModuleReflection->newInstance(); - $paymentModuleInstance->setRequest($this->request); - $paymentModuleInstance->setDispatcher($this->dispatcher); + $paymentModuleInstance->setRequest($this->getRequest()); + $paymentModuleInstance->setDispatcher($this->getDispatcher()); - $paymentModuleInstance->pay(); + $paymentModuleInstance->pay($placedOrder); } /** - * @param \Thelia\Core\Event\OrderEvent $event + * @param \Thelia\Core\Event\Order\OrderEvent $event */ - public function setReference(OrderEvent $event) + public function sendOrderEmail(OrderEvent $event) { - $x = true; - - $this->setRef($this->generateRef()); + /* @todo */ } - public function generateRef() + /** + * @param OrderEvent $event + */ + public function updateStatus(OrderEvent $event) { - return sprintf('O', uniqid('', true), $this->getId()); + $order = $event->getOrder(); + + $order->setStatusId($event->getStatus()); + $order->save(); + + $event->setOrder($order); + } + + /** + * @param OrderEvent $event + */ + public function updateDeliveryRef(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->setDeliveryRef($event->getDeliveryRef()); + $order->save(); + + $event->setOrder($order); + } + + /** + * @param OrderAddressEvent $event + */ + public function updateAddress(OrderAddressEvent $event) + { + $orderAddress = $event->getOrderAddress(); + + $orderAddress + ->setCustomerTitleId($event->getTitle()) + ->setCompany($event->getCompany()) + ->setFirstname($event->getFirstname()) + ->setLastname($event->getLastname()) + ->setAddress1($event->getAddress1()) + ->setAddress2($event->getAddress2()) + ->setAddress3($event->getAddress3()) + ->setZipcode($event->getZipcode()) + ->setCity($event->getCity()) + ->setCountryId($event->getCountry()) + ->setPhone($event->getPhone()) + ; + $orderAddress->save(); + + $event->setOrderAddress($orderAddress); } /** @@ -226,7 +364,10 @@ class Order extends BaseAction implements EventSubscriberInterface TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128), TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128), TheliaEvents::ORDER_PAY => array("create", 128), - TheliaEvents::ORDER_SET_REFERENCE => array("setReference", 128), + TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128), + TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 128), + TheliaEvents::ORDER_UPDATE_DELIVERY_REF => array("updateDeliveryRef", 128), + TheliaEvents::ORDER_UPDATE_ADDRESS => array("updateAddress", 128), ); } diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 69a07c157..bd918c5e6 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -30,31 +30,45 @@ use Thelia\Model\Product as ProductModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\ProductUpdateEvent; -use Thelia\Core\Event\ProductCreateEvent; -use Thelia\Core\Event\ProductDeleteEvent; -use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\Product\ProductUpdateEvent; +use Thelia\Core\Event\Product\ProductCreateEvent; +use Thelia\Core\Event\Product\ProductDeleteEvent; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\ProductToggleVisibilityEvent; -use Thelia\Core\Event\ProductAddContentEvent; -use Thelia\Core\Event\ProductDeleteContentEvent; +use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; +use Thelia\Core\Event\Product\ProductAddContentEvent; +use Thelia\Core\Event\Product\ProductDeleteContentEvent; use Thelia\Model\ProductAssociatedContent; use Thelia\Model\ProductAssociatedContentQuery; use Thelia\Model\ProductCategory; -use Thelia\Model\TaxRule; use Thelia\Model\TaxRuleQuery; -use Thelia\Model\TaxQuery; use Thelia\Model\AccessoryQuery; use Thelia\Model\Accessory; -use Thelia\Core\Event\ProductAddAccessoryEvent; -use Thelia\Core\Event\ProductDeleteAccessoryEvent; +use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent; +use Thelia\Model\FeatureProduct; +use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent; +use Thelia\Model\FeatureProductQuery; +use Thelia\Model\ProductCategoryQuery; +use Thelia\Core\Event\Product\ProductSetTemplateEvent; +use Thelia\Model\ProductSaleElementsQuery; +use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; +use Thelia\Core\Event\Product\ProductAddCategoryEvent; +use Thelia\Model\AttributeAvQuery; +use Thelia\Model\AttributeCombination; +use Thelia\Core\Event\Product\ProductCreateCombinationEvent; +use Propel\Runtime\Propel; +use Thelia\Model\Map\ProductTableMap; +use Thelia\Core\Event\Product\ProductDeleteCombinationEvent; +use Thelia\Model\ProductPrice; +use Thelia\Model\ProductSaleElements; +use Thelia\Core\Event\Product\ProductAddAccessoryEvent; +use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent; class Product extends BaseAction implements EventSubscriberInterface { /** * Create a new product entry * - * @param ProductCreateEvent $event + * @param \Thelia\Core\Event\Product\ProductCreateEvent $event */ public function create(ProductCreateEvent $event) { @@ -71,7 +85,15 @@ class Product extends BaseAction implements EventSubscriberInterface // Set the default tax rule to this product ->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true)) - ->create($event->getDefaultCategory()) + //public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) { + + ->create( + $event->getDefaultCategory(), + $event->getBasePrice(), + $event->getCurrencyId(), + $event->getTaxRuleId(), + $event->getBaseWeight() + ); ; $event->setProduct($product); @@ -80,12 +102,10 @@ class Product extends BaseAction implements EventSubscriberInterface /** * Change a product * - * @param ProductUpdateEvent $event + * @param \Thelia\Core\Event\Product\ProductUpdateEvent $event */ public function update(ProductUpdateEvent $event) { - $search = ProductQuery::create(); - if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { $product @@ -96,11 +116,16 @@ class Product extends BaseAction implements EventSubscriberInterface ->setDescription($event->getDescription()) ->setChapo($event->getChapo()) ->setPostscriptum($event->getPostscriptum()) - - ->setParent($event->getParent()) ->setVisible($event->getVisible()) - ->save(); + ->save() + ; + + // Update the rewriten URL, if required + $product->setRewrittenUrl($event->getLocale(), $event->getUrl()); + + // Update default category (ifd required) + $product->updateDefaultCategory($event->getDefaultCategory()); $event->setProduct($product); } @@ -109,7 +134,7 @@ class Product extends BaseAction implements EventSubscriberInterface /** * Delete a product entry * - * @param ProductDeleteEvent $event + * @param \Thelia\Core\Event\Product\ProductDeleteEvent $event */ public function delete(ProductDeleteEvent $event) { @@ -147,23 +172,11 @@ class Product extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $product = ProductQuery::create()->findPk($event->getObjectId())) { - - $product->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $product->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $product->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $product->movePositionDown(); - } + return $this->genericUpdatePosition(ProductQuery::create(), $event); } - public function addContent(ProductAddContentEvent $event) { - + public function addContent(ProductAddContentEvent $event) + { if (ProductAssociatedContentQuery::create() ->filterByContentId($event->getContentId()) ->filterByProduct($event->getProduct())->count() <= 0) { @@ -179,8 +192,8 @@ class Product extends BaseAction implements EventSubscriberInterface } } - public function removeContent(ProductDeleteContentEvent $event) { - + public function removeContent(ProductDeleteContentEvent $event) + { $content = ProductAssociatedContentQuery::create() ->filterByContentId($event->getContentId()) ->filterByProduct($event->getProduct())->findOne() @@ -193,8 +206,36 @@ class Product extends BaseAction implements EventSubscriberInterface ; } - public function addAccessory(ProductAddAccessoryEvent $event) { + public function addCategory(ProductAddCategoryEvent $event) + { + if (ProductCategoryQuery::create() + ->filterByProduct($event->getProduct()) + ->filterByCategoryId($event->getCategoryId()) + ->count() <= 0) { + $productCategory = new ProductCategory(); + + $productCategory + ->setProduct($event->getProduct()) + ->setCategoryId($event->getCategoryId()) + ->setDefaultCategory(false) + ->save() + ; + } + } + + public function removeCategory(ProductDeleteCategoryEvent $event) + { + $productCategory = ProductCategoryQuery::create() + ->filterByProduct($event->getProduct()) + ->filterByCategoryId($event->getCategoryId()) + ->findOne(); + + if ($productCategory != null) $productCategory->delete(); + } + + public function addAccessory(ProductAddAccessoryEvent $event) + { if (AccessoryQuery::create() ->filterByAccessory($event->getAccessoryId()) ->filterByProductId($event->getProduct()->getId())->count() <= 0) { @@ -210,8 +251,8 @@ class Product extends BaseAction implements EventSubscriberInterface } } - public function removeAccessory(ProductDeleteAccessoryEvent $event) { - + public function removeAccessory(ProductDeleteAccessoryEvent $event) + { $accessory = AccessoryQuery::create() ->filterByAccessory($event->getAccessoryId()) ->filterByProductId($event->getProduct()->getId())->findOne() @@ -224,26 +265,163 @@ class Product extends BaseAction implements EventSubscriberInterface ; } + public function setProductTemplate(ProductSetTemplateEvent $event) + { + $product = $event->getProduct(); + + // Delete all product feature relations + FeatureProductQuery::create()->filterByProduct($product)->delete(); + + // Delete all product attributes sale elements + ProductSaleElementsQuery::create()->filterByProduct($product)->delete(); + + // Update the product template + $template_id = $event->getTemplateId(); + + // Set it to null if it's zero. + if ($template_id <= 0) $template_id = NULL; + + $product->setTemplateId($template_id)->save(); + } + + /** + * Changes accessry position, selecting absolute ou relative change. + * + * @param ProductChangePositionEvent $event + */ + public function updateAccessoryPosition(UpdatePositionEvent $event) + { + return $this->genericUpdatePosition(AccessoryQuery::create(), $event); + } /** * Changes position, selecting absolute ou relative change. * * @param ProductChangePositionEvent $event */ - public function updateAccessoryPosition(UpdatePositionEvent $event) + public function updateContentPosition(UpdatePositionEvent $event) { - if (null !== $accessory = AccessoryQuery::create()->findPk($event->getObjectId())) { + return $this->genericUpdatePosition(ProductAssociatedContentQuery::create(), $event); + } - $accessory->setDispatcher($this->getDispatcher()); + public function updateFeatureProductValue(FeatureProductUpdateEvent $event) + { + // If the feature is not free text, it may have one ore more values. + // If the value exists, we do not change it + // If the value does not exists, we create it. + // + // If the feature is free text, it has only a single value. + // Etiher create or update it. - $mode = $event->getMode(); + $featureProductQuery = FeatureProductQuery::create() + ->filterByFeatureId($event->getFeatureId()) + ->filterByProductId($event->getProductId()) + ; - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $accessory->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $accessory->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $accessory->movePositionDown(); + if ($event->getIsTextValue() !== true) { + $featureProductQuery->filterByFeatureAvId($event->getFeatureValue()); + } + + $featureProduct = $featureProductQuery->findOne(); + + if ($featureProduct == null) { + $featureProduct = new FeatureProduct(); + + $featureProduct + ->setDispatcher($this->getDispatcher()) + + ->setProductId($event->getProductId()) + ->setFeatureId($event->getFeatureId()) + ; + } + + if ($event->getIsTextValue() == true) { + $featureProduct->setFreeTextValue($event->getFeatureValue()); + } else { + $featureProduct->setFeatureAvId($event->getFeatureValue()); + } + + $featureProduct->save(); + + $event->setFeatureProduct($featureProduct); + } + + public function deleteFeatureProductValue(FeatureProductDeleteEvent $event) + { + $featureProduct = FeatureProductQuery::create() + ->filterByProductId($event->getProductId()) + ->filterByFeatureId($event->getFeatureId()) + ->delete() + ; + } + + public function createProductCombination(ProductCreateCombinationEvent $event) + { + $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME); + + $con->beginTransaction(); + + try { + $product = $event->getProduct(); + + // Create an empty product sale element + $salesElement = new ProductSaleElements(); + + $salesElement + ->setProduct($product) + ->setRef($product->getRef()) + ->setPromo(0) + ->setNewness(0) + ->setWeight(0) + ->setIsDefault(false) + ->save($con) + ; + + // Create an empty product price in the default currency + $product_price = new ProductPrice(); + + $product_price + ->setProductSaleElements($salesElement) + ->setPromoPrice(0) + ->setPrice(0) + ->setCurrencyId($event->getCurrencyId()) + ->save($con) + ; + + $combinationAttributes = $event->getAttributeAvList(); + + if (count($combinationAttributes) > 0) { + + foreach ($combinationAttributes as $attributeAvId) { + + $attributeAv = AttributeAvQuery::create()->findPk($attributeAvId); + + if ($attributeAv !== null) { + $attributeCombination = new AttributeCombination(); + + $attributeCombination + ->setAttributeAvId($attributeAvId) + ->setAttribute($attributeAv->getAttribute()) + ->setProductSaleElements($salesElement) + ->save(); + } + } + } + + // Store all the stuff ! + $con->commit(); + } catch (\Exception $ex) { + + $con->rollback(); + + throw $ex; + } + } + + public function deleteProductCombination(ProductDeleteCombinationEvent $event) + { + if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) { + $pse->delete(); } } @@ -263,9 +441,22 @@ class Product extends BaseAction implements EventSubscriberInterface TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128), TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128), TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128), + TheliaEvents::PRODUCT_UPDATE_CONTENT_POSITION => array("updateContentPosition", 128), + + TheliaEvents::PRODUCT_ADD_COMBINATION => array("createProductCombination", 128), + TheliaEvents::PRODUCT_DELETE_COMBINATION => array("deleteProductCombination", 128), TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128), TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128), + + TheliaEvents::PRODUCT_ADD_CATEGORY => array("addCategory", 128), + TheliaEvents::PRODUCT_REMOVE_CATEGORY => array("removeCategory", 128), + + TheliaEvents::PRODUCT_SET_TEMPLATE => array("setProductTemplate", 128), + + TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE => array("updateFeatureProductValue", 128), + TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE => array("deleteFeatureProductValue", 128), + ); } } diff --git a/core/lib/Thelia/Action/Template.php b/core/lib/Thelia/Action/Template.php index 18174dd26..c5ea6b03e 100644 --- a/core/lib/Thelia/Action/Template.php +++ b/core/lib/Thelia/Action/Template.php @@ -30,24 +30,17 @@ use Thelia\Model\Template as TemplateModel; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\TemplateUpdateEvent; -use Thelia\Core\Event\TemplateCreateEvent; -use Thelia\Core\Event\TemplateDeleteEvent; -use Thelia\Model\ConfigQuery; -use Thelia\Model\TemplateAv; -use Thelia\Model\TemplateAvQuery; +use Thelia\Core\Event\Template\TemplateUpdateEvent; +use Thelia\Core\Event\Template\TemplateCreateEvent; +use Thelia\Core\Event\Template\TemplateDeleteEvent; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\CategoryEvent; -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\Core\Event\Template\TemplateAddAttributeEvent; +use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent; use Thelia\Model\AttributeTemplateQuery; use Thelia\Model\AttributeTemplate; -use Thelia\Core\Event\TemplateDeleteFeatureEvent; -use Thelia\Core\Event\TemplateAddFeatureEvent; +use Thelia\Core\Event\Template\TemplateDeleteFeatureEvent; +use Thelia\Core\Event\Template\TemplateAddFeatureEvent; use Thelia\Model\FeatureTemplateQuery; use Thelia\Model\FeatureTemplate; @@ -56,7 +49,7 @@ class Template extends BaseAction implements EventSubscriberInterface /** * Create a new template entry * - * @param TemplateCreateEvent $event + * @param \Thelia\Core\Event\Template\TemplateCreateEvent $event */ public function create(TemplateCreateEvent $event) { @@ -77,7 +70,7 @@ class Template extends BaseAction implements EventSubscriberInterface /** * Change a product template * - * @param TemplateUpdateEvent $event + * @param \Thelia\Core\Event\Template\TemplateUpdateEvent $event */ public function update(TemplateUpdateEvent $event) { @@ -99,7 +92,7 @@ class Template extends BaseAction implements EventSubscriberInterface /** * Delete a product template entry * - * @param TemplateDeleteEvent $event + * @param \Thelia\Core\Event\Template\TemplateDeleteEvent $event */ public function delete(TemplateDeleteEvent $event) { @@ -121,8 +114,8 @@ class Template extends BaseAction implements EventSubscriberInterface } } - public function addAttribute(TemplateAddAttributeEvent $event) { - + public function addAttribute(TemplateAddAttributeEvent $event) + { if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) { $attribute_template = new AttributeTemplate(); @@ -135,8 +128,28 @@ class Template extends BaseAction implements EventSubscriberInterface } } - public function deleteAttribute(TemplateDeleteAttributeEvent $event) { + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updateAttributePosition(UpdatePositionEvent $event) + { + return $this->genericUpdatePosition(AttributeTemplateQuery::create(), $event); + } + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updateFeaturePosition(UpdatePositionEvent $event) + { + return $this->genericUpdatePosition(FeatureTemplateQuery::create(), $event); + } + + public function deleteAttribute(TemplateDeleteAttributeEvent $event) + { $attribute_template = AttributeTemplateQuery::create() ->filterByAttributeId($event->getAttributeId()) ->filterByTemplate($event->getTemplate())->findOne() @@ -145,8 +158,8 @@ class Template extends BaseAction implements EventSubscriberInterface if ($attribute_template !== null) $attribute_template->delete(); } - public function addFeature(TemplateAddFeatureEvent $event) { - + public function addFeature(TemplateAddFeatureEvent $event) + { if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) { $feature_template = new FeatureTemplate(); @@ -159,8 +172,8 @@ class Template extends BaseAction implements EventSubscriberInterface } } - public function deleteFeature(TemplateDeleteFeatureEvent $event) { - + public function deleteFeature(TemplateDeleteFeatureEvent $event) + { $feature_template = FeatureTemplateQuery::create() ->filterByFeatureId($event->getFeatureId()) ->filterByTemplate($event->getTemplate())->findOne() @@ -185,6 +198,9 @@ class Template extends BaseAction implements EventSubscriberInterface TheliaEvents::TEMPLATE_ADD_FEATURE => array("addFeature", 128), TheliaEvents::TEMPLATE_DELETE_FEATURE => array("deleteFeature", 128), + TheliaEvents::TEMPLATE_CHANGE_ATTRIBUTE_POSITION => array('updateAttributePosition', 128), + TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION => array('updateFeaturePosition', 128), + ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php index 8ced1b6c1..116a26da9 100755 --- a/core/lib/Thelia/Cart/CartTrait.php +++ b/core/lib/Thelia/Cart/CartTrait.php @@ -29,7 +29,7 @@ use Thelia\Model\Customer; use Symfony\Component\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\Cart\CartEvent; /** * managed cart diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index 1126f99a6..e85e29741 100755 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -73,10 +73,11 @@ class CacheClear extends ContainerAwareCommand try { $directoryBrowser = new \DirectoryIterator($dir); - } catch(\UnexpectedValueException $e) { + } catch (\UnexpectedValueException $e) { // throws same exception code for does not exist and permission denied ... - if(!file_exists($dir)) { + if (!file_exists($dir)) { $output->writeln(sprintf("%s cache dir already clear", $dir)); + return; } diff --git a/core/lib/Thelia/Command/ClearImageCache.php b/core/lib/Thelia/Command/ClearImageCache.php index d2010ead1..8401e47f3 100755 --- a/core/lib/Thelia/Command/ClearImageCache.php +++ b/core/lib/Thelia/Command/ClearImageCache.php @@ -27,7 +27,7 @@ use Thelia\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Thelia\Core\Event\ImageEvent; +use Thelia\Core\Event\Image\ImageEvent; use Thelia\Core\HttpFoundation\Request; use Symfony\Component\Console\Input\InputArgument; use Thelia\Core\Event\TheliaEvents; diff --git a/core/lib/Thelia/Command/ModuleActivateCommand.php b/core/lib/Thelia/Command/ModuleActivateCommand.php index cddfd5290..d5ca8156d 100755 --- a/core/lib/Thelia/Command/ModuleActivateCommand.php +++ b/core/lib/Thelia/Command/ModuleActivateCommand.php @@ -25,12 +25,9 @@ namespace Thelia\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Filesystem\Exception\IOException; -use Thelia\Command\ContainerAwareCommand; use Thelia\Model\ModuleQuery; /** @@ -62,7 +59,7 @@ class ModuleActivateCommand extends BaseModuleGenerate $module = ModuleQuery::create()->findOneByCode($moduleCode); - if(null === $module) { + if (null === $module) { throw new \RuntimeException(sprintf("module %s not found", $moduleCode)); } @@ -74,7 +71,7 @@ class ModuleActivateCommand extends BaseModuleGenerate $moduleInstance = $moduleReflection->newInstance(); $moduleInstance->activate(); - } catch(\Exception $e) { + } catch (\Exception $e) { throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage())); } diff --git a/core/lib/Thelia/Command/ReloadDatabaseCommand.php b/core/lib/Thelia/Command/ReloadDatabaseCommand.php index 311b20552..20aad0265 100644 --- a/core/lib/Thelia/Command/ReloadDatabaseCommand.php +++ b/core/lib/Thelia/Command/ReloadDatabaseCommand.php @@ -56,7 +56,7 @@ class ReloadDatabaseCommand extends BaseModuleGenerate $tables = $connection->query("SHOW TABLES"); $connection->query("SET FOREIGN_KEY_CHECKS = 0"); - foreach($tables as $table) { + foreach ($tables as $table) { $connection->query(sprintf("DROP TABLE `%s`", $table[0])); } $connection->query("SET FOREIGN_KEY_CHECKS = 1"); diff --git a/core/lib/Thelia/Condition/ConditionEvaluator.php b/core/lib/Thelia/Condition/ConditionEvaluator.php new file mode 100644 index 000000000..327c80a3d --- /dev/null +++ b/core/lib/Thelia/Condition/ConditionEvaluator.php @@ -0,0 +1,144 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Condition\Operators; +use Thelia\Coupon\ConditionCollection; + + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Validate Conditions + * + * @package Condition + * @author Guillaume MOREL + * + */ +class ConditionEvaluator +{ + /** + * Check if an Event matches SerializableCondition + * + * @param ConditionCollection $conditions Conditions to check against the Event + * + * @return bool + */ + public function isMatching(ConditionCollection $conditions) + { + $isMatching = true; + /** @var ConditionManagerInterface $condition */ + foreach ($conditions->getConditions() as $condition) { + if (!$condition->isMatching()) { + $isMatching = false; + } + } + + return $isMatching; + + } + + /** + * Do variable comparison + * + * @param mixed $v1 Variable 1 + * @param string $o Operator ex : Operators::DIFFERENT + * @param mixed $v2 Variable 2 + * + * @throws \Exception + * @return bool + */ + public function variableOpComparison($v1, $o, $v2) + { + if ($o == Operators::DIFFERENT) { + return ($v1 != $v2); + } + + switch ($o) { + case Operators::SUPERIOR : + // > + if ($v1 > $v2) { + return true; + } else { + continue; + } + break; + case Operators::SUPERIOR_OR_EQUAL : + // >= + if ($v1 >= $v2) { + return true; + } else { + continue; + } + break; + case Operators::INFERIOR : + // < + if ($v1 < $v2) { + return true; + } else { + continue; + } + break; + case Operators::INFERIOR_OR_EQUAL : + // <= + if ($v1 <= $v2) { + return true; + } else { + continue; + } + break; + case Operators::EQUAL : + // == + if ($v1 == $v2) { + return true; + } else { + continue; + } + break; + case Operators::IN: + // in + if (in_array($v1, $v2)) { + return true; + } else { + continue; + } + break; + case Operators::OUT: + // not in + if (!in_array($v1, $v2)) { + return true; + } else { + continue; + } + break; + default: + throw new \Exception('Unrecognized operator ' . $o); + } + + return false; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Condition/ConditionFactory.php b/core/lib/Thelia/Condition/ConditionFactory.php new file mode 100644 index 000000000..ff024ecae --- /dev/null +++ b/core/lib/Thelia/Condition/ConditionFactory.php @@ -0,0 +1,169 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Coupon\AdapterInterface; +use Thelia\Coupon\ConditionCollection; + + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Manage how Condition could interact with the current application state (Thelia) + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class ConditionFactory +{ + /** @var ContainerInterface Service Container */ + protected $container = null; + + /** @var AdapterInterface Provide necessary value from Thelia */ + protected $adapter; + + /** @var array ConditionCollection to process*/ + protected $conditions = null; + + /** + * Constructor + * + * @param ContainerInterface $container Service container + */ + public function __construct(ContainerInterface $container) + { + $this->container = $container; + $this->adapter = $container->get('thelia.adapter'); + } + + /** + * Serialize a collection of conditions + * + * @param ConditionCollection $collection A collection of conditions + * + * @return string A ready to be stored Condition collection + */ + public function serializeConditionCollection(ConditionCollection $collection) + { + if ($collection->isEmpty()) { + /** @var ConditionManagerInterface $conditionNone */ + $conditionNone = $this->container->get( + 'thelia.condition.match_for_everyone' + ); + $collection->add($conditionNone); + } + $serializableConditions = array(); + $conditions = $collection->getConditions(); + if ($conditions !== null) { + /** @var $condition ConditionManagerInterface */ + foreach ($conditions as $condition) { + // Remove all condition if the "no condition" condition is found +// if ($condition->getServiceId() == 'thelia.condition.match_for_everyone') { +// return base64_encode(json_encode(array($condition->getSerializableRule()))); +// } + $serializableConditions[] = $condition->getSerializableCondition(); + } + } + + return base64_encode(json_encode($serializableConditions)); + } + + /** + * Unserialize a collection of conditions + * + * @param string $serializedConditions Serialized Conditions + * + * @return ConditionCollection Conditions ready to be processed + */ + public function unserializeConditionCollection($serializedConditions) + { + $unserializedConditions = json_decode(base64_decode($serializedConditions)); + + $collection = new ConditionCollection(); + + if (!empty($unserializedConditions) && !empty($unserializedConditions)) { + /** @var SerializableCondition $condition */ + foreach ($unserializedConditions as $condition) { + if ($this->container->has($condition->conditionServiceId)) { + /** @var ConditionManagerInterface $conditionManager */ + $conditionManager = $this->build( + $condition->conditionServiceId, + (array) $condition->operators, + (array) $condition->values + ); + $collection->add(clone $conditionManager); + } + } + } + + return $collection; + } + + + /** + * Build a Condition from form + * + * @param string $conditionServiceId Condition class name + * @param array $operators Condition Operator (<, >, = ) + * @param array $values Values setting this Condition + * + * @throws \InvalidArgumentException + * @return ConditionManagerInterface Ready to use Condition or false + */ + public function build($conditionServiceId, array $operators, array $values) + { + if (!$this->container->has($conditionServiceId)) { + return false; + } + + /** @var ConditionManagerInterface $condition */ + $condition = $this->container->get($conditionServiceId); + $condition->setValidatorsFromForm($operators, $values); + + return $condition; + } + + /** + * Get Condition inputs from serviceId + * + * @param string $conditionServiceId ConditionManager class name + * + * @return array Ready to be drawn condition inputs + */ + public function getInputs($conditionServiceId) + { + if (!$this->container->has($conditionServiceId)) { + return false; + } + + /** @var ConditionManagerInterface $condition */ + $condition = $this->container->get($conditionServiceId); + + return $condition->getValidators(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Condition/ConditionManagerAbstract.php similarity index 72% rename from core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php rename to core/lib/Thelia/Condition/ConditionManagerAbstract.php index 0986daa50..e5c8aed1a 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Condition/ConditionManagerAbstract.php @@ -21,16 +21,14 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Constraint\ConstraintValidator; use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Constraint\Validator\ComparableInterface; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleOperatorException; +use Thelia\Coupon\AdapterInterface; +use Thelia\Exception\InvalidConditionValueException; +use Thelia\Model\Currency; +use Thelia\Type\FloatType; /** * Created by JetBrains PhpStorm. @@ -43,7 +41,7 @@ use Thelia\Exception\InvalidRuleOperatorException; * @author Guillaume MOREL * */ -abstract class CouponRuleAbstract implements CouponRuleInterface +abstract class ConditionManagerAbstract implements ConditionManagerInterface { // /** Operator key in $validators */ // CONST OPERATOR = 'operator'; @@ -62,7 +60,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // /** @var array Parameters to be validated */ // protected $paramsToValidate = array(); - /** @var CouponAdapterInterface Provide necessary value from Thelia */ + /** @var AdapterInterface Provide necessary value from Thelia */ protected $adapter = null; /** @var Translator Service Translator */ @@ -74,19 +72,19 @@ abstract class CouponRuleAbstract implements CouponRuleInterface /** @var array Values set by Admin in BackOffice */ protected $values = array(); - /** @var ConstraintValidator Constaints validator */ - protected $constraintValidator = null; + /** @var ConditionEvaluator Conditions validator */ + protected $conditionValidator = null; /** * Constructor * - * @param CouponAdapterInterface $adapter Service adapter + * @param AdapterInterface $adapter Service adapter */ - function __construct(CouponAdapterInterface $adapter) + public function __construct(AdapterInterface $adapter) { $this->adapter = $adapter; $this->translator = $adapter->getTranslator(); - $this->constraintValidator = $adapter->getConstraintValidator(); + $this->conditionValidator = $adapter->getConditionEvaluator(); } // /** @@ -96,16 +94,16 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // * validating $paramsToValidate against // * // * @return $this -// * @throws InvalidRuleException +// * @throws InvalidConditionException // */ // protected function setValidators(array $validators) // { // foreach ($validators as $validator) { // if (!$validator instanceof RuleValidator) { -// throw new InvalidRuleException(get_class()); +// throw new InvalidConditionException(get_class()); // } // if (!in_array($validator->getOperator(), $this->availableOperators)) { -// throw new InvalidRuleOperatorException( +// throw new InvalidConditionOperatorException( // get_class(), // $validator->getOperator() // ); @@ -146,7 +144,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // } /** - * Return all available Operators for this Rule + * Return all available Operators for this Condition * * @return array Operators::CONST */ @@ -158,7 +156,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // /** // * Check if Operators set for this Rule in the BackOffice are legit // * -// * @throws InvalidRuleOperatorException if Operator is not allowed +// * @throws InvalidConditionOperatorException if Operator is not allowed // * @return bool // */ // protected function checkBackOfficeInputsOperators() @@ -169,7 +167,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // if (!isset($operator) // ||!in_array($operator, $this->availableOperators) // ) { -// throw new InvalidRuleOperatorException(get_class(), $key); +// throw new InvalidConditionOperatorException(get_class(), $key); // } // } // return true; @@ -230,7 +228,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface } /** - * Get Rule Service id + * Get ConditionManager Service id * * @return string */ @@ -240,7 +238,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface } /** - * Validate if Operator given is available for this Coupon + * Validate if Operator given is available for this Condition * * @param string $operator Operator to validate ex < * @param array $availableOperators Available operators @@ -253,19 +251,67 @@ abstract class CouponRuleAbstract implements CouponRuleInterface } /** - * Return a serializable Rule + * Return a serializable Condition * - * @return SerializableRule + * @return SerializableCondition */ - public function getSerializableRule() + public function getSerializableCondition() { - $serializableRule = new SerializableRule(); - $serializableRule->ruleServiceId = $this->serviceId; - $serializableRule->operators = $this->operators; + $serializableCondition = new SerializableCondition(); + $serializableCondition->conditionServiceId = $this->serviceId; + $serializableCondition->operators = $this->operators; - $serializableRule->values = $this->values; + $serializableCondition->values = $this->values; - return $serializableRule; + return $serializableCondition; + } + + + /** + * Check if currency if valid or not + * + * @param string $currencyValue Currency EUR|USD|.. + * + * @return bool + * @throws \Thelia\Exception\InvalidConditionValueException + */ + protected function IsCurrencyValid($currencyValue) + { + $availableCurrencies = $this->adapter->getAvailableCurrencies(); + /** @var Currency $currency */ + $currencyFound = false; + foreach ($availableCurrencies as $currency) { + if ($currencyValue == $currency->getCode()) { + $currencyFound = true; + } + } + if (!$currencyFound) { + throw new InvalidConditionValueException( + get_class(), 'currency' + ); + } + + return true; + } + + /** + * Check if price is valid + * + * @param float $priceValue Price value to check + * + * @return bool + * @throws \Thelia\Exception\InvalidConditionValueException + */ + protected function isPriceValid($priceValue) + { + $floatType = new FloatType(); + if (!$floatType->isValid($priceValue) || $priceValue <= 0) { + throw new InvalidConditionValueException( + get_class(), 'price' + ); + } + + return true; } } \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php b/core/lib/Thelia/Condition/ConditionManagerInterface.php similarity index 82% rename from core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php rename to core/lib/Thelia/Condition/ConditionManagerInterface.php index ac9579094..0e7fc99b1 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php +++ b/core/lib/Thelia/Condition/ConditionManagerInterface.php @@ -21,30 +21,30 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition; use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Coupon\AdapterInterface; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Represents a condition of whether the Rule is applied or not + * Manage how the application checks its state in order to check if it matches the implemented condition * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -interface CouponRuleInterface +interface ConditionManagerInterface { /** * Constructor * - * @param CouponAdapterInterface $adapter Service adapter + * @param AdapterInterface $adapter Service adapter */ - function __construct(CouponAdapterInterface $adapter); + function __construct(AdapterInterface $adapter); /** * Get Rule Service id @@ -86,14 +86,14 @@ interface CouponRuleInterface // public function isMatching(); /** - * Test if Customer meets conditions + * Test if the current application state matches conditions * * @return bool */ public function isMatching(); /** - * Return all available Operators for this Rule + * Return all available Operators for this condition * * @return array Operators::CONST */ @@ -122,10 +122,10 @@ interface CouponRuleInterface public function getValidators(); // /** -// * Populate a Rule from a form admin +// * Populate a Condition from a form admin // * -// * @param array $operators Rule Operator set by the Admin -// * @param array $values Rule Values set by the Admin +// * @param array $operators Condition Operator set by the Admin +// * @param array $values Condition Values set by the Admin // * // * @return bool // */ @@ -133,14 +133,10 @@ interface CouponRuleInterface /** - * Return a serializable Rule + * Return a serializable Condition * - * @return SerializableRule + * @return SerializableCondition */ - public function getSerializableRule(); - - - - + public function getSerializableCondition(); } diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForEveryoneManager.php b/core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php similarity index 86% rename from core/lib/Thelia/Constraint/Rule/AvailableForEveryoneManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php index 15e0e3ab7..00108a3b0 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForEveryoneManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php @@ -21,17 +21,10 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Symfony\Component\Translation\Translator; -use Thelia\Constraint\ConstraintValidator; -use Thelia\Constraint\Validator\QuantityParam; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleValueException; -use Thelia\Type\FloatType; +use Thelia\Condition\ConditionManagerAbstract; /** * Created by JetBrains PhpStorm. @@ -40,14 +33,14 @@ use Thelia\Type\FloatType; * * Allow every one, perform no check * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -class AvailableForEveryoneManager extends CouponRuleAbstract +class MatchForEveryoneManager extends ConditionManagerAbstract { /** @var string Service Id from Resources/config.xml */ - protected $serviceId = 'thelia.constraint.rule.available_for_everyone'; + protected $serviceId = 'thelia.condition.match_for_everyone'; /** @var array Available Operators (Operators::CONST) */ protected $availableOperators = array(); @@ -102,7 +95,7 @@ class AvailableForEveryoneManager extends CouponRuleAbstract return $this->translator->trans( 'Everybody can use it (no condition)', array(), - 'constraint' + 'condition' ); } @@ -116,7 +109,7 @@ class AvailableForEveryoneManager extends CouponRuleAbstract $toolTip = $this->translator->trans( 'Will return always true', array(), - 'constraint' + 'condition' ); return $toolTip; diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php similarity index 83% rename from core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php index 30bc86ad6..bc158c878 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php @@ -21,42 +21,37 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition\Implementation; use Symfony\Component\Intl\Exception\NotImplementedException; -use Symfony\Component\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Constraint\Validator\PriceParam; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleOperatorException; -use Thelia\Exception\InvalidRuleValueException; +use Thelia\Condition\ConditionManagerAbstract; +use Thelia\Condition\Operators; +use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Model\Currency; use Thelia\Model\CurrencyQuery; -use Thelia\Type\FloatType; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Rule AvailableForTotalAmount + * Condition AvailableForTotalAmount * Check if a Checkout total amount match criteria * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -class AvailableForTotalAmountManager extends CouponRuleAbstract +class MatchForTotalAmountManager extends ConditionManagerAbstract { - /** Rule 1st parameter : price */ + /** Condition 1st parameter : price */ CONST INPUT1 = 'price'; - /** Rule 1st parameter : currency */ + /** Condition 1st parameter : currency */ CONST INPUT2 = 'currency'; /** @var string Service Id from Resources/config.xml */ - protected $serviceId = 'thelia.constraint.rule.available_for_total_amount'; + protected $serviceId = 'thelia.condition.match_for_total_amount'; /** @var array Available Operators (Operators::CONST) */ protected $availableOperators = array( @@ -101,7 +96,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract * @param string $currencyOperator Currency Operator ex = * @param string $currencyValue Currency set to meet condition * - * @throws \InvalidArgumentException + * @throws \Thelia\Exception\InvalidConditionOperatorException * @return $this */ protected function setValidators($priceOperator, $priceValue, $currencyOperator, $currencyValue) @@ -111,8 +106,8 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for price field is not legit' + throw new InvalidConditionOperatorException( + get_class(), 'price' ); } @@ -121,19 +116,16 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT2] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for currency field is not legit' + throw new InvalidConditionOperatorException( + get_class(), 'price' ); } - $floatType = new FloatType(); - if (!$floatType->isValid($priceValue) || $priceValue <= 0) { - throw new \InvalidArgumentException( - 'Value for price field is not legit' - ); - } + $this->isPriceValid($priceValue); + + + $this->IsCurrencyValid($currencyValue); - // @todo check currency is legit or not $this->operators = array( self::INPUT1 => $priceOperator, @@ -167,19 +159,20 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract return false; } - $constraint1 = $this->constraintValidator->variableOpComparison( + $condition1 = $this->conditionValidator->variableOpComparison( $this->adapter->getCartTotalPrice(), $this->operators[self::INPUT1], $this->values[self::INPUT1] ); - $constraint2 = $this->constraintValidator->variableOpComparison( + $condition2 = $this->conditionValidator->variableOpComparison( $this->adapter->getCheckoutCurrency(), $this->operators[self::INPUT2], $this->values[self::INPUT2] ); - if ($constraint1 && $constraint2) { + if ($condition1 && $condition2) { return true; } + return false; } @@ -193,7 +186,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract return $this->translator->trans( 'Cart total amount', array(), - 'constraint' + 'condition' ); } @@ -215,7 +208,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract '%amount%' => $this->values[self::INPUT1], '%currency%' => $this->values[self::INPUT2] ), - 'constraint' + 'condition' ); return $toolTip; @@ -238,12 +231,12 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $name1 = $this->translator->trans( 'Price', array(), - 'constraint' + 'condition' ); $name2 = $this->translator->trans( 'Currency', array(), - 'constraint' + 'condition' ); return array( diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php b/core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php similarity index 84% rename from core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php index 572d39b1d..05de953d0 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php @@ -21,17 +21,13 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Symfony\Component\Translation\Translator; -use Thelia\Constraint\ConstraintValidator; -use Thelia\Constraint\Validator\QuantityParam; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleValueException; -use Thelia\Type\FloatType; +use Thelia\Condition\ConditionManagerAbstract; +use Thelia\Condition\Operators; +use Thelia\Exception\InvalidConditionOperatorException; +use Thelia\Exception\InvalidConditionValueException; /** * Created by JetBrains PhpStorm. @@ -40,17 +36,17 @@ use Thelia\Type\FloatType; * * Check a Checkout against its Product number * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -class AvailableForXArticlesManager extends CouponRuleAbstract +class MatchForXArticlesManager extends ConditionManagerAbstract { - /** Rule 1st parameter : quantity */ + /** Condition 1st parameter : quantity */ CONST INPUT1 = 'quantity'; /** @var string Service Id from Resources/config.xml */ - protected $serviceId = 'thelia.constraint.rule.available_for_x_articles'; + protected $serviceId = 'thelia.condition.match_for_x_articles'; /** @var array Available Operators (Operators::CONST) */ protected $availableOperators = array( @@ -88,7 +84,8 @@ class AvailableForXArticlesManager extends CouponRuleAbstract * @param string $quantityOperator Quantity Operator ex < * @param int $quantityValue Quantity set to meet condition * - * @throws \InvalidArgumentException + * @throws \Thelia\Exception\InvalidConditionValueException + * @throws \Thelia\Exception\InvalidConditionOperatorException * @return $this */ protected function setValidators($quantityOperator, $quantityValue) @@ -98,14 +95,14 @@ class AvailableForXArticlesManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for quantity field is not legit' + throw new InvalidConditionOperatorException( + get_class(), 'quantity' ); } if ((int) $quantityValue <= 0) { - throw new \InvalidArgumentException( - 'Value for quantity field is not legit' + throw new InvalidConditionValueException( + get_class(), 'quantity' ); } @@ -126,15 +123,16 @@ class AvailableForXArticlesManager extends CouponRuleAbstract */ public function isMatching() { - $constraint1 = $this->constraintValidator->variableOpComparison( + $condition1 = $this->conditionValidator->variableOpComparison( $this->adapter->getNbArticlesInCart(), $this->operators[self::INPUT1], $this->values[self::INPUT1] ); - if ($constraint1) { + if ($condition1) { return true; } + return false; } @@ -148,7 +146,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract return $this->translator->trans( 'Number of articles in cart', array(), - 'constraint' + 'condition' ); } @@ -169,7 +167,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract '%operator%' => $i18nOperator, '%quantity%' => $this->values[self::INPUT1] ), - 'constraint' + 'condition' ); return $toolTip; @@ -185,7 +183,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract $name1 = $this->translator->trans( 'Quantity', array(), - 'constraint' + 'condition' ); return array( @@ -199,5 +197,4 @@ class AvailableForXArticlesManager extends CouponRuleAbstract ) ); } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Constraint/Rule/Operators.php b/core/lib/Thelia/Condition/Operators.php similarity index 67% rename from core/lib/Thelia/Constraint/Rule/Operators.php rename to core/lib/Thelia/Condition/Operators.php index 2ed5c2909..57be8e0bf 100644 --- a/core/lib/Thelia/Constraint/Rule/Operators.php +++ b/core/lib/Thelia/Condition/Operators.php @@ -21,17 +21,16 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition; -use Symfony\Component\Translation\Translator; -use Thelia\Constraint\Validator\ComparableInterface; +use Thelia\Core\Translation\Translator; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Represent available Operations in rule checking + * Represent available Operations in condition checking * * @package Constraint * @author Guillaume MOREL @@ -56,62 +55,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 * @@ -128,56 +71,56 @@ abstract class Operators $ret = $translator->trans( 'inferior to', array(), - 'constraint' + 'condition' ); break; case self::INFERIOR_OR_EQUAL: $ret = $translator->trans( 'inferior or equal to', array(), - 'constraint' + 'condition' ); break; case self::EQUAL: $ret = $translator->trans( 'equal to', array(), - 'constraint' + 'condition' ); break; case self::SUPERIOR_OR_EQUAL: $ret = $translator->trans( 'superior or equal to', array(), - 'constraint' + 'condition' ); break; case self::SUPERIOR: $ret = $translator->trans( 'superior to', array(), - 'constraint' + 'condition' ); break; case self::DIFFERENT: $ret = $translator->trans( 'different from', array(), - 'constraint' + 'condition' ); break; case self::IN: $ret = $translator->trans( 'in', array(), - 'constraint' + 'condition' ); break; case self::OUT: $ret = $translator->trans( 'not in', array(), - 'constraint' + 'condition' ); break; default: diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php b/core/lib/Thelia/Condition/SerializableCondition.php similarity index 68% rename from core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php rename to core/lib/Thelia/Condition/SerializableCondition.php index ac13d4ea0..426052506 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentForCategoryYTest.php +++ b/core/lib/Thelia/Condition/SerializableCondition.php @@ -21,50 +21,57 @@ /* */ /**********************************************************************************/ -namespace Thelia\Coupon; +namespace Thelia\Condition; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test RemoveXPercentForCategoryY Class + * A condition set by an admin ready to be serialized and stored in DataBase * - * @package Coupon + * @package Condition * @author Guillaume MOREL * */ -class RemoveXPercentForCategoryYTest extends \PHPUnit_Framework_TestCase +class SerializableCondition { - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } + /** @var string Condition Service id */ + public $conditionServiceId = null; + + /** @var array Operators set by Admin for this Condition */ + public $operators = array(); + + /** @var array Values set by Admin for this Condition */ + public $values = array(); // /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. +// * Get Operators set by Admin for this Condition +// * +// * @return array // */ -// protected function setUp() +// public function getOperators() // { -// } -// -// public function incompleteTest() -// { -// $this->markTestIncomplete( -// 'This test has not been implemented yet.' -// ); +// return $this->operators; // } // // /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. +// * Get Condition Service id +// * +// * @return string // */ -// protected function tearDown() +// public function getConditionServiceId() // { +// return $this->conditionServiceId; +// } +// +// /** +// * Get Values set by Admin for this Condition +// * +// * @return array +// */ +// public function getValues() +// { +// return $this->values; // } - } diff --git a/core/lib/Thelia/Config/DatabaseConfiguration.php b/core/lib/Thelia/Config/DatabaseConfiguration.php index 1c0622623..6d74a03fb 100755 --- a/core/lib/Thelia/Config/DatabaseConfiguration.php +++ b/core/lib/Thelia/Config/DatabaseConfiguration.php @@ -60,7 +60,7 @@ class DatabaseConfiguration implements ConfigurationInterface ->cannotBeEmpty() ->end() ->scalarNode("classname") - ->defaultValue("\Propel\Runtime\Connection\PropelPDO") + ->defaultValue("\Propel\Runtime\Connection\ConnectionWrapper") ->end() ->end() ->end() diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index f7ef4806d..f153a8de0 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -36,6 +36,10 @@ + + + + @@ -97,6 +101,16 @@ + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 6731152c4..66b2a8c35 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -21,7 +21,12 @@ + + + + + @@ -34,6 +39,7 @@ + @@ -57,23 +63,32 @@
+ + + + + - + + + + + @@ -198,6 +213,10 @@ + + + + @@ -242,6 +261,11 @@ + + + + + @@ -256,7 +280,7 @@ - + @@ -266,24 +290,6 @@ - - - - - - - - - - - - - - - - - - @@ -293,6 +299,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 2f043c2f4..5639c0b38 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -37,6 +37,70 @@ Thelia\Controller\Admin\CategoryController::defaultAction + + + + Thelia\Controller\Admin\FileController::saveImageAjaxAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::getImageFormAjaxAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::getImageListAjaxAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::viewImageAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::updateImageAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::deleteImageAction + .* + \d+ + + + + Thelia\Controller\Admin\FileController::saveDocumentAjaxAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::getDocumentFormAjaxAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::getDocumentListAjaxAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::viewDocumentAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::updateDocumentAction + .* + \d+ + + + Thelia\Controller\Admin\FileController::deleteDocumentAction + .* + \d+ + + @@ -59,9 +123,9 @@ - + - + Thelia\Controller\Admin\OrderController::indexAction @@ -70,7 +134,23 @@ \d+ - + + Thelia\Controller\Admin\OrderController::updateStatus + + + + Thelia\Controller\Admin\OrderController::updateStatus + + + + Thelia\Controller\Admin\OrderController::updateDeliveryRef + + + + Thelia\Controller\Admin\OrderController::updateAddress + + + @@ -106,6 +186,10 @@ Thelia\Controller\Admin\CategoryController::addRelatedContentAction + + Thelia\Controller\Admin\CategoryController::addRelatedPictureAction + + Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction @@ -150,22 +234,47 @@ Thelia\Controller\Admin\ProductController::updatePositionAction - - + + Thelia\Controller\Admin\ProductController::loadGeneralAjaxTabAction + + + + + + Thelia\Controller\Admin\ProductController::loadRelatedAjaxTabAction + + + + + + Thelia\Controller\Admin\ProductController::addAdditionalCategoryAction + + + + Thelia\Controller\Admin\ProductController::deleteAdditionalCategoryAction + + + + + Thelia\Controller\Admin\ProductController::addRelatedContentAction - + Thelia\Controller\Admin\ProductController::deleteRelatedContentAction - + Thelia\Controller\Admin\ProductController::getAvailableRelatedContentAction xml|json - + + Thelia\Controller\Admin\ProductController::updateContentPositionAction + + + Thelia\Controller\Admin\ProductController::addAccessoryAction @@ -180,53 +289,148 @@ xml|json - + Thelia\Controller\Admin\ProductController::updateAccessoryPositionAction - + + + + Thelia\Controller\Admin\ProductController::loadAttributesAjaxTabAction + + + + Thelia\Controller\Admin\ProductController::setProductTemplateAction + Thelia\Controller\Admin\ProductController::updateAttributesAndFeaturesAction + + + + Thelia\Controller\Admin\ProductController::getAttributeValuesAction + xml|json + + + + Thelia\Controller\Admin\ProductController::addAttributeValueToCombinationAction + xml|json + + + + Thelia\Controller\Admin\ProductController::addCombinationAction + + + + Thelia\Controller\Admin\ProductController::deleteCombinationAction + + + + Thelia\Controller\Admin\ProductController::updateCombinationAction + + + + Thelia\Controller\Admin\ProductController::updateDefaultPriceAction + + + + + - Thelia\Controller\Admin\FolderController::indexAction + Thelia\Controller\Admin\FolderController::defaultAction Thelia\Controller\Admin\FolderController::createAction - + Thelia\Controller\Admin\FolderController::updateAction \d+ + + Thelia\Controller\Admin\FolderController::setToggleVisibilityAction + + + + Thelia\Controller\Admin\FolderController::processUpdateAction + + + + Thelia\Controller\Admin\FolderController::deleteAction + + + + Thelia\Controller\Admin\FolderController::updatePositionAction + + + + + Thelia\Controller\Admin\ContentController::createAction + + + + Thelia\Controller\Admin\ContentController::updateAction + \d+ + + + + Thelia\Controller\Admin\ContentController::processUpdateAction + + + + Thelia\Controller\Admin\ContentController::updatePositionAction + + + + Thelia\Controller\Admin\ContentController::setToggleVisibilityAction + + + + Thelia\Controller\Admin\ContentController::deleteAction + + + + Thelia\Controller\Admin\ContentController::addAdditionalFolderAction + + + + Thelia\Controller\Admin\ContentController::removeAdditionalFolderAction + + + - + Thelia\Controller\Admin\CouponController::browseAction - + Thelia\Controller\Admin\CouponController::createAction - + Thelia\Controller\Admin\CouponController::updateAction + \d+ - + Thelia\Controller\Admin\CouponController::readAction + \d+ - - Thelia\Controller\Admin\CouponController::getRuleInputAction + + Thelia\Controller\Admin\CouponController::getConditionInputAction + .* - - Thelia\Controller\Admin\CouponController::updateRulesAction + + Thelia\Controller\Admin\CouponController::updateConditionsAction + \d+ - + Thelia\Controller\Admin\CouponController::consumeAction + .* @@ -350,6 +554,10 @@ Thelia\Controller\Admin\TemplateController::deleteFeatureAction + + Thelia\Controller\Admin\TemplateController::updateFeaturePositionAction + + Thelia\Controller\Admin\TemplateController::getAjaxAttributesAction @@ -362,6 +570,10 @@ Thelia\Controller\Admin\TemplateController::deleteAttributeAction + + Thelia\Controller\Admin\TemplateController::updateAttributePositionAction + + diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index f254a817e..53a0408a0 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -117,27 +117,31 @@ Thelia\Controller\Front\OrderController::deliver - order_delivery + order-delivery Thelia\Controller\Front\DefaultController::noAction - order_delivery + order-delivery Thelia\Controller\Front\OrderController::invoice - order_invoice + order-invoice Thelia\Controller\Front\DefaultController::noAction - order_invoice + order-invoice Thelia\Controller\Front\OrderController::pay - order_payment + + + + Thelia\Controller\Front\OrderController::orderPlaced + order-placed diff --git a/core/lib/Thelia/Constraint/ConstraintFactory.php b/core/lib/Thelia/Constraint/ConstraintFactory.php deleted file mode 100644 index e13d1d2aa..000000000 --- a/core/lib/Thelia/Constraint/ConstraintFactory.php +++ /dev/null @@ -1,174 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Thelia\Constraint\Rule\AvailableForEveryoneManager; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; -use Thelia\Constraint\Rule\CouponRuleInterface; -use Thelia\Constraint\Rule\SerializableRule; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\CouponRuleCollection; - - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Manage how Constraint could interact - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class ConstraintFactory -{ - /** @var ContainerInterface Service Container */ - protected $container = null; - - /** @var CouponAdapterInterface Provide necessary value from Thelia*/ - protected $adapter; - - /** @var array CouponRuleCollection to process*/ - protected $rules = null; - - /** - * Constructor - * - * @param ContainerInterface $container Service container - */ - function __construct(ContainerInterface $container) - { - $this->container = $container; - $this->adapter = $container->get('thelia.adapter'); - } - - /** - * Serialize a collection of rules - * - * @param CouponRuleCollection $collection A collection of rules - * - * @return string A ready to be stored Rule collection - */ - public function serializeCouponRuleCollection(CouponRuleCollection $collection) - { - if ($collection->isEmpty()) { - /** @var CouponRuleInterface $ruleNoCondition */ - $ruleNoCondition = $this->container->get( - 'thelia.constraint.rule.available_for_everyone' - ); - $collection->add($ruleNoCondition); - } - $serializableRules = array(); - $rules = $collection->getRules(); - if ($rules !== null) { - /** @var $rule CouponRuleInterface */ - foreach ($rules as $rule) { - // Remove all rule if the "no condition" rule is found -// if ($rule->getServiceId() == 'thelia.constraint.rule.available_for_everyone') { -// return base64_encode(json_encode(array($rule->getSerializableRule()))); -// } - $serializableRules[] = $rule->getSerializableRule(); - } - } - - return base64_encode(json_encode($serializableRules)); - } - - /** - * Unserialize a collection of rules - * - * @param string $serializedRules Serialized Rules - * - * @return CouponRuleCollection Rules ready to be processed - */ - public function unserializeCouponRuleCollection($serializedRules) - { - $unserializedRules = json_decode(base64_decode($serializedRules)); - - $collection = new CouponRuleCollection(); - - if (!empty($serializedRules) && !empty($unserializedRules)) { - /** @var SerializableRule $rule */ - foreach ($unserializedRules as $rule) { - if ($this->container->has($rule->ruleServiceId)) { - /** @var CouponRuleInterface $couponRule */ - $couponRule = $this->build( - $rule->ruleServiceId, - (array) $rule->operators, - (array) $rule->values - ); - $collection->add(clone $couponRule); - } - } - } - - return $collection; - } - - - /** - * Build a Coupon Rule from form - * - * @param string $ruleServiceId Rule class name - * @param array $operators Rule Operator (<, >, = ) - * @param array $values Values setting this Rule - * - * @throws \InvalidArgumentException - * @return CouponRuleInterface Ready to use Rule or false - */ - public function build($ruleServiceId, array $operators, array $values) - { - if (!$this->container->has($ruleServiceId)) { - return false; - } - - /** @var CouponRuleInterface $rule */ - $rule = $this->container->get($ruleServiceId); - $rule->setValidatorsFromForm($operators, $values); - - return $rule; - } - - /** - * Get Coupon Rule inputs from serviceId - * - * @param string $ruleServiceId Rule class name - * - * @return array Ready to be drawn rule inputs - */ - public function getInputs($ruleServiceId) - { - if (!$this->container->has($ruleServiceId)) { - return false; - } - - /** @var CouponRuleInterface $rule */ - $rule = $this->container->get($ruleServiceId); - - return $rule->getValidators(); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/ConstraintValidator.php b/core/lib/Thelia/Constraint/ConstraintValidator.php deleted file mode 100644 index d3fe69a34..000000000 --- a/core/lib/Thelia/Constraint/ConstraintValidator.php +++ /dev/null @@ -1,133 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; -use Thelia\Constraint\Rule\CouponRuleInterface; -use Thelia\Constraint\Rule\Operators; -use Thelia\Coupon\CouponRuleCollection; - - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Validate Constraints - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class ConstraintValidator -{ - - /** - * Check if a Customer meets SerializableRule - * - * @param CouponRuleCollection $rules Rules to check against the Customer - * - * @return bool - */ - public function isMatching(CouponRuleCollection $rules) - { - $isMatching = true; - /** @var CouponRuleInterface $rule */ - foreach ($rules->getRules() as $rule) { - if (!$rule->isMatching()) { - $isMatching = false; - } - } - - return $isMatching; - - } - - /** - * Do variable comparison - * - * @param mixed $v1 Variable 1 - * @param string $o Operator - * @param mixed $v2 Variable 2 - * - * @throws \Exception - * @return bool - */ - public function variableOpComparison($v1, $o, $v2) { - if ($o == Operators::DIFFERENT) { - return ($v1 != $v2); - } // could put this elsewhere... -// $operators = str_split($o); -// foreach($o as $operator) { - switch ($o) { // return will exit switch, foreach loop, function - case Operators::SUPERIOR : // > - if ($v1 > $v2) { - return true; - } else { - continue; - } break; - case Operators::SUPERIOR_OR_EQUAL : // >= - if ($v1 >= $v2) { - return true; - } else { - continue; - } break; - case Operators::INFERIOR : // < - if ($v1 < $v2) { - return true; - } else { - continue; - } break; - case Operators::INFERIOR_OR_EQUAL : // <= - if ($v1 <= $v2) { - return true; - } else { - continue; - } break; - case Operators::EQUAL : // == - if ($v1 == $v2) { - return true; - } else { - continue; - } break; - case Operators::IN: - if (in_array($v1, $v2)) { // in - return true; - } else { - continue; - } break; - case Operators::OUT: - if (!in_array($v1, $v2)) { // not in - return true; - } else { - continue; - } break; - default: throw new \Exception('Unrecognized operator ' . $o); - } -// } - return false; - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForCustomer.php b/core/lib/Thelia/Constraint/Rule/AvailableForCustomer.php deleted file mode 100644 index ad722eb5c..000000000 --- a/core/lib/Thelia/Constraint/Rule/AvailableForCustomer.php +++ /dev/null @@ -1,178 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Rule; - -use Thelia\Constraint\Validator\CustomerParam; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleOperatorException; -use Thelia\Exception\InvalidRuleValueException; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class AvailableForCustomer extends CouponRuleAbstract -{ - - /** Rule 1st parameter : customer id */ - CONST PARAM1 = 'customerId'; - - /** @var array Available Operators (Operators::CONST) */ - protected $availableOperators = array( - Operators::EQUAL, - ); - - /** @var RuleValidator Customer Validator */ - protected $customerValidator = null; - - /** - * Check if backoffice inputs are relevant or not - * - * @throws InvalidRuleOperatorException if Operator is not allowed - * @throws InvalidRuleValueException if Value is not allowed - * @return bool - */ - public function checkBackOfficeInput() - { - if (!isset($this->validators) - || empty($this->validators) - ||!isset($this->validators[self::PARAM1]) - ||!isset($this->validators[self::PARAM1]) - ) { - throw new InvalidRuleValueException(get_class(), self::PARAM1); - } - - /** @var RuleValidator $ruleValidator */ - $ruleValidator = $this->validators[self::PARAM1]; - /** @var CustomerParam $customer */ - $customer = $ruleValidator->getParam(); - - if (!$customer instanceof CustomerParam) { - throw new InvalidRuleValueException(get_class(), self::PARAM1); - } - - $this->checkBackOfficeInputsOperators(); - - return $this->isCustomerValid($customer->getInteger()); - } - - /** - * Generate current Rule param to be validated from adapter - * - * @return $this - */ - protected function setParametersToValidate() - { - $this->paramsToValidate = array( - self::PARAM1 => $this->adapter->getCustomer()->getId() - ); - - return $this; - } - - /** - * Check if Checkout inputs are relevant or not - * - * @throws \Thelia\Exception\InvalidRuleValueException - * @return bool - */ - public function checkCheckoutInput() - { - if (!isset($this->paramsToValidate) - || empty($this->paramsToValidate) - ||!isset($this->paramsToValidate[self::PARAM1]) - ) { - throw new InvalidRuleValueException(get_class(), self::PARAM1); - } - - $customerId = $this->paramsToValidate[self::PARAM1]; - - return $this->isCustomerValid($customerId); - } - - /** - * Check if a Customer is valid - * - * @param int $customerId Customer to check - * - * @throws InvalidRuleValueException if Value is not allowed - * @return bool - */ - protected function isCustomerValid($customerId) - { - $customerValidator = $this->customerValidator; - try { - $customerValidator->getParam()->compareTo($customerId); - } catch(\InvalidArgumentException $e) { - throw new InvalidRuleValueException(get_class(), self::PARAM1); - } - - return true; - } - - /** - * Get I18n name - * - * @return string - */ - public function getName() - { - return $this->adapter - ->getTranslator() - ->trans('Customer', null, 'constraint'); - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - /** @var CustomerParam $param */ - $param = $this->customerValidator->getParam(); - $toolTip = $this->adapter - ->getTranslator() - ->trans( - 'If customer is %fistname% %lastname% (%email%)', - array( - '%fistname%' => $param->getFirstName(), - '%lastname%' => $param->getLastName(), - '%email%' => $param->getEmail(), - ), - 'constraint' - ); - - return $toolTip; - } - - -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedDate.php b/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedDate.php deleted file mode 100644 index 3449a7f5b..000000000 --- a/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedDate.php +++ /dev/null @@ -1,57 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Rule; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class AvailableForRepeatedDate extends AvailableForDate -{ - - /** - * Check if backoffice inputs are relevant or not - * - * @return bool - */ - public function checkBackOfficeInput() - { - // TODO: Implement checkBackOfficeInput() method. - } - - /** - * Check if Checkout inputs are relevant or not - * - * @return bool - */ - public function checkCheckoutInput() - { - // TODO: Implement checkCheckoutInput() method. - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/SerializableRule.php b/core/lib/Thelia/Constraint/Rule/SerializableRule.php deleted file mode 100644 index 011c3e261..000000000 --- a/core/lib/Thelia/Constraint/Rule/SerializableRule.php +++ /dev/null @@ -1,81 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Rule; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * A rule set by an admin ready to be serialized and stored in DataBase - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class SerializableRule -{ - /** @var string Rule Service id */ - public $ruleServiceId = null; - - /** @var array Operators set by Admin for this Rule */ - public $operators = array(); - - /** @var array Values set by Admin for this Rule */ - public $values = array(); - - /** - * Get Operators set by Admin for this Rule - * - * @return array - */ - public function getOperators() - { - return $this->operators; - } - - /** - * Get Rule Service id - * - * @return string - */ - public function getRuleServiceId() - { - return $this->ruleServiceId; - } - - /** - * Get Values set by Admin for this Rule - * - * @return array - */ - public function getValues() - { - return $this->values; - } - - - - -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/ComparableInterface.php b/core/lib/Thelia/Constraint/Validator/ComparableInterface.php deleted file mode 100644 index d06187fb0..000000000 --- a/core/lib/Thelia/Constraint/Validator/ComparableInterface.php +++ /dev/null @@ -1,49 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -/** - * Comparable interface - * Allows to compare two value objects to each other for similarity. - * - * @author Benjamin Eberlei - * @author Guilherme Blanco - */ -interface ComparableInterface -{ - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @return int - */ - public function compareTo($other); -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/CustomerParam.php b/core/lib/Thelia/Constraint/Validator/CustomerParam.php deleted file mode 100644 index 5b4390ddc..000000000 --- a/core/lib/Thelia/Constraint/Validator/CustomerParam.php +++ /dev/null @@ -1,158 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use InvalidArgumentException; -use Propel\Runtime\ActiveQuery\ModelCriteria; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Model\Customer; -use Thelia\Model\CustomerQuery; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent a Customer - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class CustomerParam extends IntegerParam -{ - /** @var string Model Class name */ - protected $modelClass = '\Thelia\Model\Customer'; - - /** @var ModelCriteria */ - protected $queryBuilder = null; - - /** @var string Customer firstname */ - protected $firstName = null; - - /** @var string Customer lastname */ - protected $lastName = null; - - /** @var string Customer email */ - protected $email = null; - - /** - * Constructor - * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - * @param int $integer Integer - * - * @throws InvalidArgumentException - */ - public function __construct(CouponAdapterInterface $adapter, $integer) - { - $this->integer = $integer; - $this->adapter = $adapter; - - $this->queryBuilder = CustomerQuery::create(); - /** @var Customer $customer */ - $customer = $this->queryBuilder->findById($integer); - if ($customer !== null) { - $this->firstName = $customer->getFirstname(); - $this->lastName = $customer->getLastname(); - $this->email = $customer->getEmail(); - } else { - throw new \InvalidArgumentException( - 'CustomerParam can compare only existing Customers' - ); - } - } - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!is_integer($other) || $other < 0) { - throw new InvalidArgumentException( - 'IntegerParam can compare only positive int' - ); - } - - return parent::compareTo($other); - } - - /** - * Customer email - * - * @return string - */ - public function getEmail() - { - return $this->email; - } - - /** - * Customer first name - * - * @return string - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * Customer last name - * - * @return string - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->adapter - ->getTranslator() - ->trans( - 'A Customer', - null, - 'constraint' - ); - } - -} diff --git a/core/lib/Thelia/Constraint/Validator/DateParam.php b/core/lib/Thelia/Constraint/Validator/DateParam.php deleted file mode 100644 index ae7eff858..000000000 --- a/core/lib/Thelia/Constraint/Validator/DateParam.php +++ /dev/null @@ -1,120 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use Thelia\Coupon\CouponAdapterInterface; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent a DateTime - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class DateParam extends RuleParameterAbstract -{ - /** @var \DateTime Date */ - protected $dateTime = null; - - /** - * Constructor - * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - * @param \DateTime $dateTime DateTime - */ - public function __construct(CouponAdapterInterface $adapter, \DateTime $dateTime) - { - $this->dateTime = $dateTime; - $this->adapter = $adapter; - } - - /** - * Get DateTime - * - * @return \DateTime - */ - public function getDateTime() - { - return clone $this->dateTime; - } - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws \InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!$other instanceof \DateTime) { - throw new \InvalidArgumentException('DateParam can compare only DateTime'); - } - - $ret = -1; - if ($this->dateTime == $other) { - $ret = 0; - } elseif ($this->dateTime > $other) { - $ret = 1; - } else { - $ret = -1; - } - - return $ret; - } - - /** - * Get Parameter value to test against - * - * @return \Datetime - */ - public function getValue() - { - return clone $this->dateTime; - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->adapter - ->getTranslator() - ->trans('A date (ex: YYYY-MM-DD HH:MM:SS)', null, 'constraint'); - } - -} diff --git a/core/lib/Thelia/Constraint/Validator/IntegerParam.php b/core/lib/Thelia/Constraint/Validator/IntegerParam.php deleted file mode 100644 index c783655c8..000000000 --- a/core/lib/Thelia/Constraint/Validator/IntegerParam.php +++ /dev/null @@ -1,121 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use Thelia\Coupon\CouponAdapterInterface; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent an Integer - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class IntegerParam extends RuleParameterAbstract -{ - /** @var int Integer to compare with */ - protected $integer = 0; - - /** - * Constructor - * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - * @param int $integer Integer - */ - public function __construct(CouponAdapterInterface $adapter, $integer) - { - $this->integer = $integer; - $this->adapter = $adapter; - } - - /** - * Get integer - * - * @return int - */ - public function getInteger() - { - return $this->integer; - } - - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws \InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!is_integer($other)) { - throw new \InvalidArgumentException('IntegerParam can compare only int'); - } - - $ret = -1; - if ($this->integer == $other) { - $ret = 0; - } elseif ($this->integer > $other) { - $ret = 1; - } else { - $ret = -1; - } - - return $ret; - } - - /** - * Get Parameter value to test against - * - * @return int - */ - public function getValue() - { - return $this->integer; - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->adapter - ->getTranslator() - ->trans('A number (ex: 42)', null, 'constraint'); - } - -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/IntervalParam.php b/core/lib/Thelia/Constraint/Validator/IntervalParam.php deleted file mode 100644 index a4554760a..000000000 --- a/core/lib/Thelia/Constraint/Validator/IntervalParam.php +++ /dev/null @@ -1,165 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use Thelia\Coupon\CouponAdapterInterface; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent an DateTime period - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class IntervalParam extends RuleParameterAbstract -{ - /** @var \DatePeriod Date period */ - protected $datePeriod = null; - - /** @var \DateTime Start date */ - protected $start = null; - - /** @var \DateInterval Interval date */ - protected $interval = null; - - /** - * Constructor - * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - * @param \DateTime $start Start interval - * @param \DateInterval $interval Period - */ - public function __construct(CouponAdapterInterface $adapter, \DateTime $start, \DateInterval $interval) - { - $this->datePeriod = new \DatePeriod($start, $interval, 1); - $this->adapter = $adapter; - - $this->start = $start; - $this->interval = $interval; - } - - /** - * Get Interval - * - * @return \DateInterval - */ - public function getInterval() - { - return $this->interval; - } - - /** - * Get start date - * - * @return \DateTime - */ - public function getStart() - { - return $this->start; - } - - - - /** - * Get DatePeriod - * - * @return \DatePeriod - */ - public function getDatePeriod() - { - return clone $this->datePeriod; - } - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws \InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!$other instanceof \DateTime) { - throw new \InvalidArgumentException('IntervalParam can compare only DateTime'); - } - - /** @var \DateTime Start Date */ - $startDate = null; - /** @var \DateTime End Date */ - $endDate = null; - - foreach ($this->datePeriod as $key => $value) { - if ($key == 0) { - $startDate = $value; - } - if ($key == 1) { - $endDate = $value; - } - } - - $ret = -1; - if ($startDate <= $other && $other <= $endDate) { - $ret = 0; - } elseif ($startDate > $other) { - $ret = 1; - } else { - $ret = -1; - } - - return $ret; - } - - /** - * Get Parameter value to test against - * - * @return \DatePeriod - */ - public function getValue() - { - return clone $this->datePeriod; - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->adapter - ->getTranslator() - ->trans('An interval between two dates', null, 'constraint'); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/ModelParam.php b/core/lib/Thelia/Constraint/Validator/ModelParam.php deleted file mode 100644 index 7ff4567b8..000000000 --- a/core/lib/Thelia/Constraint/Validator/ModelParam.php +++ /dev/null @@ -1,115 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use InvalidArgumentException; -use Thelia\Coupon\CouponAdapterInterface; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent a Model - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class ModelParam extends IntegerParam -{ - /** @var string Model Class name */ - protected $modelClass = null; - - /** @var ModelCriteria */ - protected $queryBuilder = null; - - /** - * Constructor - * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - * @param int $integer Integer - * @param string $modelClass Model class name - * - * @throws InvalidArgumentException - */ - public function __construct(CouponAdapterInterface $adapter, $integer, $modelClass) - { - if ($integer < 0) { - $integer = 0; - } - $this->integer = $integer; - $this->adapter = $adapter; - - $this->modelClass = $modelClass; - $queryClassName = $modelClass . 'Query'; - try { - $this->queryBuilder = $queryClassName::create(); - } catch (\Exception $e) { - throw new InvalidArgumentException('ModelParam can only compare Models'); - } - } - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!is_integer($other) || $other < 0) { - throw new InvalidArgumentException( - 'IntegerParam can compare only positive int' - ); - } - - return parent::compareTo($other); - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->adapter - ->getTranslator() - ->trans( - 'A Model', - null, - 'constraint' - ); - } - -} diff --git a/core/lib/Thelia/Constraint/Validator/PriceParam.php b/core/lib/Thelia/Constraint/Validator/PriceParam.php deleted file mode 100644 index e965d6aba..000000000 --- a/core/lib/Thelia/Constraint/Validator/PriceParam.php +++ /dev/null @@ -1,145 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent a Price - * Positive value with currency - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class PriceParam extends RuleParameterAbstract -{ - /** @var float Positive Float to compare with */ - protected $price = null; - - /** @var string Currency Code ISO 4217 EUR|USD|GBP */ - protected $currency = null; - - /** - * Constructor - * - * @param Translator $translator Service translator - * @param float $price Positive float - * @param string $currency Currency Code ISO 4217 EUR|USD|GBP - */ - public function __construct(Translator $translator, $price, $currency) - { - $this->price = $price; - $this->currency = $currency; - $this->translator = $translator; - } - - /** - * Get currency code - * - * @return string - */ - public function getCurrency() - { - return $this->currency; - } - - /** - * Get price - * - * @return float - */ - public function getPrice() - { - return $this->price; - } - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws \InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!is_float($other)) { - throw new \InvalidArgumentException( - 'PriceParam can compare only positive float' - ); - } - - $epsilon = 0.00001; - - $ret = -1; - if (abs($this->price - $other) < $epsilon) { - $ret = 0; - } elseif ($this->price > $other) { - $ret = 1; - } else { - $ret = -1; - } - - return $ret; - } - - /** - * Get Parameter value to test against - * - * @return float - */ - public function getValue() - { - return $this->price; - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->translator - ->trans( - 'A price in %currency% (ex: 14.50)', - array( - '%currency%' => $this->currency - ), - 'constraint' - ); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/RepeatedDateParam.php b/core/lib/Thelia/Constraint/Validator/RepeatedDateParam.php deleted file mode 100644 index 0e8a558cf..000000000 --- a/core/lib/Thelia/Constraint/Validator/RepeatedDateParam.php +++ /dev/null @@ -1,117 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use Thelia\Coupon\CouponAdapterInterface; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent A repeated Date across the time - * Ex : - * A date repeated every 1 months 5 times - * ---------*---*---*---*---*---*---------------------------> time - * 1 2 3 4 5 6 - * 1 : $this->from Start date of the repetition - * *--- : $this->interval Duration of a whole cycle - * x5 : $this->recurrences How many repeated cycle, 1st excluded - * x6 : How many occurrence - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class RepeatedDateParam extends RepeatedParam -{ - /** - * Constructor - * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - */ - public function __construct(CouponAdapterInterface $adapter) - { - $this->defaultConstructor(); - $this->adapter = $adapter; - } - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws \InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!$other instanceof \DateTime) { - throw new \InvalidArgumentException('RepeatedDateParam can compare only DateTime'); - } - - $ret = -1; - $dates = array(); - /** @var $value \DateTime */ - foreach ($this->datePeriod as $value) { - $dates[$value->getTimestamp()] = $value; - } - - foreach ($dates as $date) { - if ($date == $other) { - return 0; - } - } - - return $ret; - } - - /** - * Get Parameter value to test against - * - * @return \DatePeriod - */ - public function getValue() - { - return clone $this->datePeriod; - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->adapter - ->getTranslator() - ->trans('A date (ex: YYYY-MM-DD HH:MM:SS)', null, 'constraint'); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/RepeatedIntervalParam.php b/core/lib/Thelia/Constraint/Validator/RepeatedIntervalParam.php deleted file mode 100644 index e37cd3b45..000000000 --- a/core/lib/Thelia/Constraint/Validator/RepeatedIntervalParam.php +++ /dev/null @@ -1,151 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use Thelia\Coupon\CouponAdapterInterface; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Represent A repeated DateInterval across the time - * Ex : - * A duration of 1 month repeated every 2 months 5 times - * ---------****----****----****----****----****----****-----------------> time - * 1 2 3 4 5 6 - * 1 : $this->from Start date of the repetition - * ****---- : $this->interval Duration of a whole cycle - * x5 : $this->recurrences How many repeated cycle, 1st excluded - * x6 : How many occurrence - * **** : $this->durationInDays Duration of a period - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class RepeatedIntervalParam extends RepeatedParam -{ - - /** @var int duration of the param */ - protected $durationInDays = 1; - - /** - * Get how many day a Param is lasting - * - * @return int - */ - public function getDurationInDays() - { - return $this->durationInDays; - } - - /** - * Set how many day a Param is lasting - * - * @param int $durationInDays How many day a Param is lasting - * - * @return $this - */ - public function setDurationInDays($durationInDays = 1) - { - $this->durationInDays = $durationInDays; - - return $this; - } - - /** - * Constructor - * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - */ - public function __construct(CouponAdapterInterface $adapter) - { - $this->defaultConstructor(); - $this->adapter = $adapter; - } - - /** - * Compare the current object to the passed $other. - * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws \InvalidArgumentException - * @return int - */ - public function compareTo($other) - { - if (!$other instanceof \DateTime) { - throw new \InvalidArgumentException('RepeatedIntervalParam can compare only DateTime'); - } - - $ret = -1; - $dates = array(); - /** @var $value \DateTime */ - foreach ($this->datePeriod as $value) { - $dates[$value->getTimestamp()]['startDate'] = $value; - $endDate = new \DateTime(); - $dates[$value->getTimestamp()]['endDate'] = $endDate->setTimestamp( - $value->getTimestamp() + ($this->durationInDays * 60 *60 *24) - ); - } - - foreach ($dates as $date) { - if ($date['startDate'] <= $other && $other <= $date['endDate']) { - return 0; - } - } - - return $ret; - - } - - /** - * Get Parameter value to test against - * - * @return \DatePeriod - */ - public function getValue() - { - return clone $this->datePeriod; - } - - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() - { - return $this->adapter - ->getTranslator() - ->trans('A date (ex: YYYY-MM-DD HH:MM:SS)', null, 'constraint'); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/RepeatedParam.php b/core/lib/Thelia/Constraint/Validator/RepeatedParam.php deleted file mode 100644 index 1188e4fbb..000000000 --- a/core/lib/Thelia/Constraint/Validator/RepeatedParam.php +++ /dev/null @@ -1,297 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -use DateInterval; -use DatePeriod; -use DateTime; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Allow to set the way a parameter can be repeated across the time - * - * @package Constraint - * @author Guillaume MOREL - * - */ -abstract class RepeatedParam extends RuleParameterAbstract -{ - /** @var DateTime The start date of the period. */ - protected $from = null; - - /** @var DateInterval The interval between recurrences within the period. */ - protected $interval = null; - - /** @var int Nb time the object will be repeated (1st occurrence excluded). */ - protected $recurrences = null; - - /** @var DatePeriod dates recurring at regular intervals, over a given period */ - protected $datePeriod = null; - - /** @var int Frequency the object will be repeated */ - protected $frequency = null; - - /** @var int $nbRepetition Time the object will be repeated */ - protected $nbRepetition = null; - - /** - * Get frequency - * - * @return int - */ - public function getFrequency() - { - return $this->frequency; - } - - /** - * Get Interval - * - * @return \DateInterval - */ - public function getInterval() - { - return $this->interval; - } - - /** - * Get number of time it will be repeated - * - * @return int - */ - public function getNbRepetition() - { - return $this->nbRepetition; - } - - /** - * Get number of recurrences - * - * @return int - */ - public function getRecurrences() - { - return $this->recurrences; - } - - /** - * Generate default repetition - * Every 1 week 100 times from now - * - * @return $this - */ - protected function defaultConstructor() - { - $this->from = new \DateTime(); - $this->interval = new \DateInterval('P1W'); // 1 week - $this->recurrences = 100; - $this->generateDatePeriod(); - - return $this; - } - - /** - * Generate DatePeriod from class attributes - * Will repeat every DatePeriod - * - * @return $this - */ - protected function generateDatePeriod() - { - $this->datePeriod = new DatePeriod( - $this->from, - $this->interval, - $this->recurrences - ); - - return $this; - } - - /** - * Set the Object to be repeated every days - * Ex : $obj->repeatEveryDay() will occur once - * $obj->repeatEveryDay(10) will occur once - * $obj->repeatEveryDay(10, 0) will occur once - * $obj->repeatEveryDay(10, 4) will occur every 10 days 5 times - * - * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated - * - * @return $this - */ - public function repeatEveryDay($frequency = 1, $nbRepetition = 0) - { - $this->_repeatEveryPeriod($period = 'D', $frequency, $nbRepetition); - - return $this; - } - - /** - * Set the Object to be repeated every week - * Ex : $obj->repeatEveryWeek() will occur once - * $obj->repeatEveryWeek(10) will occur once - * $obj->repeatEveryWeek(10, 0) will occur once - * $obj->repeatEveryWeek(10, 4) will occur every 10 weeks (70days) 5 times - * - * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated - * - * @return $this - */ - public function repeatEveryWeek($frequency = 1, $nbRepetition = 0) - { - $this->_repeatEveryPeriod($period = 'W', $frequency, $nbRepetition); - - return $this; - } - - /** - * Set the Object to be repeated every month - * Ex : $obj->repeatEveryWeek() will occur once - * $obj->repeatEveryWeek(10) will occur once - * $obj->repeatEveryWeek(10, 0) will occur once - * $obj->repeatEveryWeek(10, 4) will occur every 10 month (70days) 5times - * - * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated - * - * @return $this - */ - public function repeatEveryMonth($frequency = 1, $nbRepetition = 0) - { - $this->_repeatEveryPeriod($period = 'M', $frequency, $nbRepetition); - - return $this; - } - - /** - * Set the Object to be repeated every year - * Ex : $obj->repeatEveryWeek() will occur once - * $obj->repeatEveryWeek(10) will occur once - * $obj->repeatEveryWeek(10, 0) will occur once - * $obj->repeatEveryWeek(10, 4) will occur every 10 year 5 times - * - * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated - * - * @return $this - */ - public function repeatEveryYear($frequency = 1, $nbRepetition = 0) - { - $this->_repeatEveryPeriod($period = 'Y', $frequency, $nbRepetition); - - return $this; - } - - /** - * Set the Object to be repeated every Period - * Ex : $obj->repeatEveryPeriod('D') will occur once - * $obj->repeatEveryPeriod('W', 10) will occur once - * $obj->repeatEveryPeriod('W', 10, 0) will occur once - * $obj->repeatEveryPeriod('M', 10, 4) will occur every 10 month 5 times - * - * @param string $period Period Y|M||D|W - * @param int $frequency Frequency the object will be repeated - * @param int $nbRepetition Time the object will be repeated - * - * @return $this - */ - private function _repeatEveryPeriod($period, $frequency = 1, $nbRepetition = 0) - { - if (is_numeric($frequency) && $frequency > 0) { - $this->interval = new \DateInterval('P' . $frequency . $period); - } - - if (is_numeric($nbRepetition) && $nbRepetition >= 0) { - $this->recurrences = $nbRepetition; - } - - $this->generateDatePeriod(); - - return $this; - } - - - - /** - * Set Start time - * - * @param \DateTime $from Start time - * - * @return $this - */ - public function setFrom($from) - { - $this->from = $from; - - return $this; - } - - /** - * Get Start time - * - * @return \DateTime - */ - public function getFrom() - { - return clone $this->from; - } - - /** - * Set DatePeriod - * - * @param DatePeriod $datePeriod DatePeriod - * - * @return $this - */ - public function setDatePeriod(DatePeriod $datePeriod) - { - $this->datePeriod = $datePeriod; - - return $this; - } - - /** - * Get date DatePeriod - * - * @return \DatePeriod - */ - public function getDatePeriod() - { - return clone $this->datePeriod; - } - - /** - * Get Parameter value to test against - * - * @return \DatePeriod - */ - public function getValue() - { - return clone $this->datePeriod; - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Validator/RuleValidator.php b/core/lib/Thelia/Constraint/Validator/RuleValidator.php deleted file mode 100644 index 9b0093bc9..000000000 --- a/core/lib/Thelia/Constraint/Validator/RuleValidator.php +++ /dev/null @@ -1,77 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint\Validator; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Allow to validate parameters - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class RuleValidator -{ - /** @var string Operator ex: Operators::INFERIOR */ - protected $operator = null; - - /** @var ComparableInterface Validator */ - protected $param = null; - - /** - * Constructor - * - * @param string $operator Operator ex: Operators::INFERIOR - * @param ComparableInterface $param Validator ex: PriceParam - */ - function __construct($operator, ComparableInterface $param) - { - $this->operator = $operator; - $this->param = $param; - } - - /** - * Get Validator Operator - * - * @return string - */ - public function getOperator() - { - return $this->operator; - } - - /** - * Get Validator Param - * - * @return ComparableInterface - */ - public function getParam() - { - return $this->param; - } - -} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 7b9550610..170c35c4f 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -25,7 +25,6 @@ namespace Thelia\Controller\Admin; use Thelia\Form\Exception\FormValidationException; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\ToggleVisibilityEvent; /** * An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object. @@ -53,13 +52,13 @@ abstract class AbstractCrudController extends BaseAdminController protected $visibilityToggleEventIdentifier; protected $changePositionEventIdentifier; - /** * @param string $objectName the lower case object name. Example. "message" * - * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual + * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual + * @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable) * - * @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view" + * @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view" * @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create" * @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update" * @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete" @@ -69,7 +68,7 @@ abstract class AbstractCrudController extends BaseAdminController * @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE * * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY - * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION + * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION */ public function __construct( $objectName, @@ -108,94 +107,93 @@ abstract class AbstractCrudController extends BaseAdminController /** * Return the creation form for this object */ - protected abstract function getCreationForm(); + abstract protected function getCreationForm(); /** * Return the update form for this object */ - protected abstract function getUpdateForm(); + abstract protected function getUpdateForm(); /** * Hydrate the update form for this object, before passing it to the update template * * @param unknown $object */ - protected abstract function hydrateObjectForm($object); + abstract protected function hydrateObjectForm($object); /** * Creates the creation event with the provided form data * * @param unknown $formData */ - protected abstract function getCreationEvent($formData); + abstract protected function getCreationEvent($formData); /** * Creates the update event with the provided form data * * @param unknown $formData */ - protected abstract function getUpdateEvent($formData); + abstract protected function getUpdateEvent($formData); /** * Creates the delete event with the provided form data */ - protected abstract function getDeleteEvent(); + abstract protected function getDeleteEvent(); /** * Return true if the event contains the object, e.g. the action has updated the object in the event. * * @param unknown $event */ - protected abstract function eventContainsObject($event); + abstract protected function eventContainsObject($event); /** * Get the created object from an event. * * @param unknown $createEvent */ - protected abstract function getObjectFromEvent($event); + abstract protected function getObjectFromEvent($event); /** * Load an existing object from the database */ - protected abstract function getExistingObject(); + abstract protected function getExistingObject(); /** * Returns the object label form the object event (name, title, etc.) * * @param unknown $object */ - protected abstract function getObjectLabel($object); + abstract protected function getObjectLabel($object); /** * Returns the object ID from the object * * @param unknown $object */ - protected abstract function getObjectId($object); + abstract protected function getObjectId($object); /** * Render the main list template * * @param unknown $currentOrder, if any, null otherwise. */ - protected abstract function renderListTemplate($currentOrder); + abstract protected function renderListTemplate($currentOrder); /** * Render the edition template */ - protected abstract function renderEditionTemplate(); + abstract protected function renderEditionTemplate(); /** * Redirect to the edition template */ - protected abstract function redirectToEditionTemplate(); + abstract protected function redirectToEditionTemplate(); /** * Redirect to the list template */ - protected abstract function redirectToListTemplate(); - + abstract protected function redirectToListTemplate(); protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { @@ -210,7 +208,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Put in this method post object creation processing if required. * - * @param unknown $createEvent the create event + * @param unknown $createEvent the create event * @return Response a response, or null to continue normal processing */ protected function performAdditionalCreateAction($createEvent) @@ -221,7 +219,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Put in this method post object update processing if required. * - * @param unknown $updateEvent the update event + * @param unknown $updateEvent the update event * @return Response a response, or null to continue normal processing */ protected function performAdditionalUpdateAction($updateEvent) @@ -232,7 +230,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Put in this method post object delete processing if required. * - * @param unknown $deleteEvent the delete event + * @param unknown $deleteEvent the delete event * @return Response a response, or null to continue normal processing */ protected function performAdditionalDeleteAction($deleteEvent) @@ -243,7 +241,7 @@ abstract class AbstractCrudController extends BaseAdminController /** * Put in this method post object position change processing if required. * - * @param unknown $deleteEvent the delete event + * @param unknown $deleteEvent the delete event * @return Response a response, or null to continue normal processing */ protected function performAdditionalUpdatePositionAction($positionChangeEvent) @@ -281,7 +279,6 @@ abstract class AbstractCrudController extends BaseAdminController public function defaultAction() { if (null !== $response = $this->checkAuth($this->viewPermissionIdentifier)) return $response; - return $this->renderList(); } @@ -322,22 +319,19 @@ abstract class AbstractCrudController extends BaseAdminController $response = $this->performAdditionalCreateAction($createEvent); - if ($response == null) { + 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 { + } else { return $response; } - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $error_msg = $ex->getMessage(); } @@ -422,16 +416,13 @@ abstract class AbstractCrudController extends BaseAdminController // Redirect to the success URL $this->redirect($changeForm->getSuccessUrl()); - } - else { + } else { return $response; } - } - catch (FormValidationException $ex) { + } catch (FormValidationException $ex) { // Form cannot be validated $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any other error $error_msg = $ex->getMessage(); } @@ -445,6 +436,8 @@ abstract class AbstractCrudController extends BaseAdminController /** * Update object position (only for objects whichsupport that) + * + * FIXME: integrate with genericUpdatePositionAction */ public function updatePositionAction() { @@ -466,8 +459,7 @@ abstract class AbstractCrudController extends BaseAdminController $event = $this->createUpdatePositionEvent($mode, $position); $this->dispatch($this->changePositionEventIdentifier, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -476,12 +468,42 @@ abstract class AbstractCrudController extends BaseAdminController if ($response == null) { $this->redirectToListTemplate(); - } - else { + } else { return $response; } } + protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true) + { + // Check current user authorization + if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + + if ($object != null) { + + try { + $mode = $this->getRequest()->get('mode', null); + + if ($mode == 'up') + $mode = UpdatePositionEvent::POSITION_UP; + else if ($mode == 'down') + $mode = UpdatePositionEvent::POSITION_DOWN; + else + $mode = UpdatePositionEvent::POSITION_ABSOLUTE; + + $position = $this->getRequest()->get('position', null); + + $event = new UpdatePositionEvent($object->getId(), $mode, $position); + + $this->dispatch($eventName, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + if ($doFinalRedirect) $this->redirectToEditionTemplate(); + } + /** * Online status toggle (only for object which support it) */ @@ -492,9 +514,6 @@ abstract class AbstractCrudController extends BaseAdminController $changeEvent = $this->createToggleVisibilityEvent($this->getRequest()); - // Create and dispatch the change event - $changeEvent->setIsDefault(true); - try { $this->dispatch($this->visibilityToggleEventIdentifier, $changeEvent); } catch (\Exception $ex) { @@ -502,7 +521,7 @@ abstract class AbstractCrudController extends BaseAdminController return $this->errorPage($ex); } - $this->redirectToListTemplate(); + return $this->nullResponse(); } /** diff --git a/core/lib/Thelia/Controller/Admin/AdminController.php b/core/lib/Thelia/Controller/Admin/AdminController.php index 2d3d80df1..0b76c79ff 100755 --- a/core/lib/Thelia/Controller/Admin/AdminController.php +++ b/core/lib/Thelia/Controller/Admin/AdminController.php @@ -23,10 +23,6 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Security\Authentication\AdminTokenAuthenticator; -use Thelia\Model\ConfigQuery; -use Thelia\Core\Security\Exception\TokenAuthenticationException; - class AdminController extends BaseAdminController { public function indexAction() @@ -36,6 +32,6 @@ class AdminController extends BaseAdminController public function updateAction() { - return $this->render("profile-edit"); + return $this->render("profile-edit"); } } diff --git a/core/lib/Thelia/Controller/Admin/AttributeAvController.php b/core/lib/Thelia/Controller/Admin/AttributeAvController.php index 1ab12a081..bc6984e9e 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeAvController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeAvController.php @@ -23,10 +23,10 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AttributeAvDeleteEvent; +use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\AttributeAvUpdateEvent; -use Thelia\Core\Event\AttributeAvCreateEvent; +use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent; +use Thelia\Core\Event\Attribute\AttributeAvCreateEvent; use Thelia\Model\AttributeAvQuery; use Thelia\Form\AttributeAvModificationForm; use Thelia\Form\AttributeAvCreationForm; @@ -193,4 +193,4 @@ class AttributeAvController extends AbstractCrudController $this->getViewArguments() ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index 48a65baa7..689b92a01 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -23,18 +23,18 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\AttributeDeleteEvent; +use Thelia\Core\Event\Attribute\AttributeDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\AttributeUpdateEvent; -use Thelia\Core\Event\AttributeCreateEvent; +use Thelia\Core\Event\Attribute\AttributeUpdateEvent; +use Thelia\Core\Event\Attribute\AttributeCreateEvent; use Thelia\Model\AttributeQuery; use Thelia\Form\AttributeModificationForm; use Thelia\Form\AttributeCreationForm; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Model\AttributeAv; use Thelia\Model\AttributeAvQuery; -use Thelia\Core\Event\AttributeAvUpdateEvent; -use Thelia\Core\Event\AttributeEvent; +use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent; +use Thelia\Core\Event\Attribute\AttributeEvent; /** * Manages attributes @@ -113,7 +113,7 @@ class AttributeController extends AbstractCrudController if ($attr_values !== null) { - foreach($attr_values as $id => $value) { + foreach ($attr_values as $id => $value) { $event = new AttributeAvUpdateEvent($id); @@ -168,7 +168,7 @@ class AttributeController extends AbstractCrudController $attr_array = array(); - foreach($attr_av_list as $attr_av) { + foreach ($attr_av_list as $attr_av) { $attr_array[$attr_av->getId()] = $attr_av->getTitle(); } @@ -262,8 +262,7 @@ class AttributeController extends AbstractCrudController $this->dispatch($eventType, $event); } - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -286,4 +285,4 @@ class AttributeController extends AbstractCrudController { return $this->addRemoveFromAllTemplates(TheliaEvents::ATTRIBUTE_ADD_TO_ALL_TEMPLATES); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 1e0f65055..d80d8ce9f 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -42,6 +42,7 @@ use Thelia\Log\Tlog; use Symfony\Component\Routing\Router; use Thelia\Model\Admin; use Thelia\Core\Security\Token\CookieTokenProvider; +use Thelia\Model\CurrencyQuery; class BaseAdminController extends BaseController { @@ -250,6 +251,23 @@ class BaseAdminController extends BaseController $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters)); } + /** + * Get the current edition currency ID, checking if a change was requested in the current request. + */ + protected function getCurrentEditionCurrency() + { + // Return the new language if a change is required. + if (null !== $edit_currency_id = $this->getRequest()->get('edit_currency_id', null)) { + + if (null !== $edit_currency = CurrencyQuery::create()->findOneById($edit_currency_id)) { + return $edit_currency; + } + } + + // Otherwise return the lang stored in session. + return $this->getSession()->getAdminEditionCurrency(); + } + /** * Get the current edition lang ID, checking if a change was requested in the current request. */ @@ -275,20 +293,19 @@ class BaseAdminController extends BaseController return $this->getCurrentEditionLang()->getLocale(); } - /** * Return the current list order identifier for a given object name, * updating in using the current request. * - * @param unknown $objectName the object name (e.g. 'attribute', 'message') + * @param unknown $objectName the object name (e.g. 'attribute', 'message') * @param unknown $requestParameterName the name of the request parameter that defines the list order - * @param unknown $defaultListOrder the default order to use, if none is defined - * @param string $updateSession if true, the session will be updated with the current order. + * @param unknown $defaultListOrder the default order to use, if none is defined + * @param string $updateSession if true, the session will be updated with the current order. * * @return String the current liste order. */ - protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true) { - + protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true) + { $order = $defaultListOrder; $orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName); @@ -300,7 +317,6 @@ class BaseAdminController extends BaseController ); if ($updateSession) $this->getSession()->set($orderSessionIdentifier, $order); - return $order; } @@ -335,8 +351,8 @@ class BaseAdminController extends BaseController /** Clear the remember me cookie. * */ - protected function clearRememberMeCookie() { - + protected function clearRememberMeCookie() + { $ctp = new CookieTokenProvider(); $cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn'); @@ -376,6 +392,9 @@ class BaseAdminController extends BaseController // Find the current edit language ID $edition_language = $this->getCurrentEditionLang(); + // Find the current edit currency ID + $edition_currency = $this->getCurrentEditionCurrency(); + // Prepare common template variables $args = array_merge($args, array( 'locale' => $session->getLang()->getLocale(), @@ -385,11 +404,16 @@ class BaseAdminController extends BaseController 'edit_language_id' => $edition_language->getId(), 'edit_language_locale' => $edition_language->getLocale(), + 'edit_currency_id' => $edition_currency->getId(), + 'current_url' => $this->getRequest()->getUri() )); - // Update the current edition language in session - $this->getSession()->setAdminEditionLang($edition_language); + // Update the current edition language & currency in session + $this->getSession() + ->setAdminEditionLang($edition_language) + ->setAdminEditionCurrency($edition_currency) + ; // Render the template. try { diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 4d0d15ef1..ff2dae1e4 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -23,18 +23,18 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\CategoryDeleteEvent; +use Symfony\Component\HttpFoundation\Response; +use Thelia\Core\Event\Category\CategoryDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CategoryUpdateEvent; -use Thelia\Core\Event\CategoryCreateEvent; +use Thelia\Core\Event\Category\CategoryUpdateEvent; +use Thelia\Core\Event\Category\CategoryCreateEvent; use Thelia\Model\CategoryQuery; use Thelia\Form\CategoryModificationForm; use Thelia\Form\CategoryCreationForm; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\CategoryToggleVisibilityEvent; -use Thelia\Core\Event\CategoryDeleteContentEvent; -use Thelia\Core\Event\CategoryAddContentEvent; -use Thelia\Model\CategoryAssociatedContent; +use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\Category\CategoryDeleteContentEvent; +use Thelia\Core\Event\Category\CategoryAddContentEvent; use Thelia\Model\FolderQuery; use Thelia\Model\ContentQuery; use Propel\Runtime\ActiveQuery\Criteria; @@ -47,7 +47,8 @@ use Thelia\Model\CategoryAssociatedContentQuery; */ class CategoryController extends AbstractCrudController { - public function __construct() { + public function __construct() + { parent::__construct( 'category', 'manual', @@ -66,15 +67,18 @@ class CategoryController extends AbstractCrudController ); } - protected function getCreationForm() { + protected function getCreationForm() + { return new CategoryCreationForm($this->getRequest()); } - protected function getUpdateForm() { + protected function getUpdateForm() + { return new CategoryModificationForm($this->getRequest()); } - protected function getCreationEvent($formData) { + protected function getCreationEvent($formData) + { $createEvent = new CategoryCreateEvent(); $createEvent @@ -87,7 +91,8 @@ class CategoryController extends AbstractCrudController return $createEvent; } - protected function getUpdateEvent($formData) { + protected function getUpdateEvent($formData) + { $changeEvent = new CategoryUpdateEvent($formData['id']); // Create and dispatch the change event @@ -105,8 +110,8 @@ class CategoryController extends AbstractCrudController return $changeEvent; } - protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { - + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { return new UpdatePositionEvent( $this->getRequest()->get('category_id', null), $positionChangeMode, @@ -114,16 +119,18 @@ class CategoryController extends AbstractCrudController ); } - protected function getDeleteEvent() { + protected function getDeleteEvent() + { return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0)); } - protected function eventContainsObject($event) { + protected function eventContainsObject($event) + { return $event->hasCategory(); } - protected function hydrateObjectForm($object) { - + protected function hydrateObjectForm($object) + { // Prepare the data that will hydrate the form $data = array( 'id' => $object->getId(), @@ -141,21 +148,25 @@ class CategoryController extends AbstractCrudController return new CategoryModificationForm($this->getRequest(), "form", $data); } - protected function getObjectFromEvent($event) { + protected function getObjectFromEvent($event) + { return $event->hasCategory() ? $event->getCategory() : null; } - protected function getExistingObject() { + protected function getExistingObject() + { return CategoryQuery::create() ->joinWithI18n($this->getCurrentEditionLocale()) ->findOneById($this->getRequest()->get('category_id', 0)); } - protected function getObjectLabel($object) { + protected function getObjectLabel($object) + { return $object->getTitle(); } - protected function getObjectId($object) { + protected function getObjectId($object) + { return $object->getId(); } @@ -168,8 +179,8 @@ class CategoryController extends AbstractCrudController ); } - protected function renderListTemplate($currentOrder) { - + protected function renderListTemplate($currentOrder) + { // Get product order $product_order = $this->getListOrderFromSession('product', 'product_order', 'manual'); @@ -181,19 +192,21 @@ class CategoryController extends AbstractCrudController )); } - protected function redirectToListTemplate() { + protected function redirectToListTemplate() + { $this->redirectToRoute( 'admin.categories.default', array('category_id' => $this->getRequest()->get('category_id', 0)) ); } - protected function renderEditionTemplate() { - + protected function renderEditionTemplate() + { return $this->render('category-edit', $this->getEditionArguments()); } - protected function redirectToEditionTemplate() { + protected function redirectToEditionTemplate() + { $this->redirectToRoute("admin.categories.update", $this->getEditionArguments()); } @@ -255,8 +268,8 @@ class CategoryController extends AbstractCrudController return null; } - public function getAvailableRelatedContentAction($categoryId, $folderId) { - + public function getAvailableRelatedContentAction($categoryId, $folderId) + { $result = array(); $folders = FolderQuery::create()->filterById($folderId)->find(); @@ -271,7 +284,7 @@ class CategoryController extends AbstractCrudController ; if ($list !== null) { - foreach($list as $item) { + foreach ($list as $item) { $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); } } @@ -280,8 +293,8 @@ class CategoryController extends AbstractCrudController return $this->jsonResponse(json_encode($result)); } - public function addRelatedContentAction() { - + public function addRelatedContentAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; @@ -296,8 +309,7 @@ class CategoryController extends AbstractCrudController try { $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -306,8 +318,41 @@ class CategoryController extends AbstractCrudController $this->redirectToEditionTemplate(); } - public function deleteRelatedContentAction() { + /** + * Add category pictures + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function addRelatedPictureAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.categories.update")) { + return $response; + } +// $content_id = intval($this->getRequest()->get('content_id')); +// +// if ($content_id > 0) { +// +// $event = new CategoryAddContentEvent( +// $this->getExistingObject(), +// $content_id +// ); +// +// try { +// $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); +// } +// catch (\Exception $ex) { +// // Any error +// return $this->errorPage($ex); +// } +// } + + $this->redirectToEditionTemplate(); + } + + public function deleteRelatedContentAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; @@ -322,8 +367,7 @@ class CategoryController extends AbstractCrudController try { $this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -331,4 +375,5 @@ class CategoryController extends AbstractCrudController $this->redirectToEditionTemplate(); } + } diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index 8701710b0..dc19107d8 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -23,14 +23,13 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\ConfigDeleteEvent; +use Thelia\Core\Event\Config\ConfigDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\ConfigUpdateEvent; -use Thelia\Core\Event\ConfigCreateEvent; +use Thelia\Core\Event\Config\ConfigUpdateEvent; +use Thelia\Core\Event\Config\ConfigCreateEvent; use Thelia\Model\ConfigQuery; use Thelia\Form\ConfigModificationForm; use Thelia\Form\ConfigCreationForm; -use Thelia\Core\Event\UpdatePositionEvent; /** * Manages variables @@ -39,7 +38,8 @@ use Thelia\Core\Event\UpdatePositionEvent; */ class ConfigController extends AbstractCrudController { - public function __construct() { + public function __construct() + { parent::__construct( 'variable', 'name', @@ -58,15 +58,18 @@ class ConfigController extends AbstractCrudController ); } - protected function getCreationForm() { + protected function getCreationForm() + { return new ConfigCreationForm($this->getRequest()); } - protected function getUpdateForm() { + protected function getUpdateForm() + { return new ConfigModificationForm($this->getRequest()); } - protected function getCreationEvent($data) { + protected function getCreationEvent($data) + { $createEvent = new ConfigCreateEvent(); $createEvent @@ -78,11 +81,11 @@ class ConfigController extends AbstractCrudController ->setSecured($data['secured']) ; - return $createEvent; } - protected function getUpdateEvent($data) { + protected function getUpdateEvent($data) + { $changeEvent = new ConfigUpdateEvent($data['id']); // Create and dispatch the change event @@ -101,16 +104,18 @@ class ConfigController extends AbstractCrudController return $changeEvent; } - protected function getDeleteEvent() { + protected function getDeleteEvent() + { return new ConfigDeleteEvent($this->getRequest()->get('variable_id')); } - protected function eventContainsObject($event) { + protected function eventContainsObject($event) + { return $event->hasConfig(); } - protected function hydrateObjectForm($object) { - + protected function hydrateObjectForm($object) + { // Prepare the data that will hydrate the form $data = array( 'id' => $object->getId(), @@ -129,40 +134,48 @@ class ConfigController extends AbstractCrudController return new ConfigModificationForm($this->getRequest(), "form", $data); } - protected function getObjectFromEvent($event) { + protected function getObjectFromEvent($event) + { return $event->hasConfig() ? $event->getConfig() : null; } - protected function getExistingObject() { + protected function getExistingObject() + { return ConfigQuery::create() ->joinWithI18n($this->getCurrentEditionLocale()) ->findOneById($this->getRequest()->get('variable_id')); } - protected function getObjectLabel($object) { + protected function getObjectLabel($object) + { return $object->getName(); } - protected function getObjectId($object) { + protected function getObjectId($object) + { return $object->getId(); } - protected function renderListTemplate($currentOrder) { + protected function renderListTemplate($currentOrder) + { return $this->render('variables', array('order' => $currentOrder)); } - protected function renderEditionTemplate() { + protected function renderEditionTemplate() + { return $this->render('variable-edit', array('variable_id' => $this->getRequest()->get('variable_id'))); } - protected function redirectToEditionTemplate() { + protected function redirectToEditionTemplate() + { $this->redirectToRoute( "admin.configuration.variables.update", array('variable_id' => $this->getRequest()->get('variable_id')) ); } - protected function redirectToListTemplate() { + protected function redirectToListTemplate() + { $this->redirectToRoute('admin.configuration.variables.default'); } @@ -188,4 +201,4 @@ class ConfigController extends AbstractCrudController $this->redirectToRoute('admin.configuration.variables.default'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php new file mode 100644 index 000000000..c3811695f --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ContentController.php @@ -0,0 +1,405 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; +use Thelia\Core\Event\Content\ContentAddFolderEvent; +use Thelia\Core\Event\Content\ContentCreateEvent; +use Thelia\Core\Event\Content\ContentDeleteEvent; +use Thelia\Core\Event\Content\ContentRemoveFolderEvent; +use Thelia\Core\Event\Content\ContentToggleVisibilityEvent; +use Thelia\Core\Event\Content\ContentUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Form\ContentCreationForm; +use Thelia\Form\ContentModificationForm; +use Thelia\Model\ContentQuery; + +/** + * Class ContentController + * @package Thelia\Controller\Admin + * @author manuel raynaud + */ +class ContentController extends AbstractCrudController +{ + + public function __construct() + { + parent::__construct( + 'content', + 'manual', + 'content_order', + + 'admin.content.default', + 'admin.content.create', + 'admin.content.update', + 'admin.content.delete', + + TheliaEvents::CONTENT_CREATE, + TheliaEvents::CONTENT_UPDATE, + TheliaEvents::CONTENT_DELETE, + TheliaEvents::CONTENT_TOGGLE_VISIBILITY, + TheliaEvents::CONTENT_UPDATE_POSITION + ); + } + + /** + * controller adding content to additional folder + * + * @return mixed|\Symfony\Component\HttpFoundation\Response + */ + public function addAdditionalFolderAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth('admin.content.update')) return $response; + + $folder_id = intval($this->getRequest()->request->get('additional_folder_id')); + + if ($folder_id > 0) { + $event = new ContentAddFolderEvent( + $this->getExistingObject(), + $folder_id + ); + + try { + $this->dispatch(TheliaEvents::CONTENT_ADD_FOLDER, $event); + } catch (\Exception $e) { + return $this->errorPage($e); + } + } + + $this->redirectToEditionTemplate(); + } + + /** + * controller removing additional folder to a content + * + * @return mixed|\Symfony\Component\HttpFoundation\Response + */ + public function removeAdditionalFolderAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth('admin.content.update')) return $response; + + $folder_id = intval($this->getRequest()->request->get('additional_folder_id')); + + if ($folder_id > 0) { + $event = new ContentRemoveFolderEvent( + $this->getExistingObject(), + $folder_id + ); + + try { + $this->dispatch(TheliaEvents::CONTENT_REMOVE_FOLDER, $event); + } catch (\Exception $e) { + return $this->errorPage($e); + } + } + + $this->redirectToEditionTemplate(); + } + + /** + * Return the creation form for this object + */ + protected function getCreationForm() + { + return new ContentCreationForm($this->getRequest()); + } + + /** + * Return the update form for this object + */ + protected function getUpdateForm() + { + return new ContentModificationForm($this->getRequest()); + } + + /** + * Hydrate the update form for this object, before passing it to the update template + * + * @param \Thelia\Form\ContentModificationForm $object + */ + 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->getRewrittenUrl($this->getCurrentEditionLocale()), + ); + + // Setup the object form + return new ContentModificationForm($this->getRequest(), "form", $data); + } + + /** + * Creates the creation event with the provided form data + * + * @param unknown $formData + */ + protected function getCreationEvent($formData) + { + $contentCreateEvent = new ContentCreateEvent(); + + $contentCreateEvent + ->setLocale($formData['locale']) + ->setDefaultFolder($formData['default_folder']) + ->setTitle($formData['title']) + ->setVisible($formData['visible']) + ; + + return $contentCreateEvent; + } + + /** + * Creates the update event with the provided form data + * + * @param unknown $formData + */ + protected function getUpdateEvent($formData) + { + $contentUpdateEvent = new ContentUpdateEvent($formData['id']); + + $contentUpdateEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setDefaultFolder($formData['default_folder']); + + return $contentUpdateEvent; + } + + /** + * Creates the delete event with the provided form data + */ + protected function getDeleteEvent() + { + return new ContentDeleteEvent($this->getRequest()->get('content_id')); + } + + /** + * Return true if the event contains the object, e.g. the action has updated the object in the event. + * + * @param \Thelia\Core\Event\Content\ContentEvent $event + */ + protected function eventContainsObject($event) + { + return $event->hasContent(); + } + + /** + * Get the created object from an event. + * + * @param $event \Thelia\Core\Event\Content\ContentEvent + * + * @return null|\Thelia\Model\Content + */ + protected function getObjectFromEvent($event) + { + return $event->getContent(); + } + + /** + * Load an existing object from the database + * + * @return \Thelia\Model\Content + */ + protected function getExistingObject() + { + return ContentQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('content_id', 0)); + } + + /** + * Returns the object label form the object event (name, title, etc.) + * + * @param $object \Thelia\Model\Content + * + * @return string content title + * + */ + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + /** + * Returns the object ID from the object + * + * @param $object \Thelia\Model\Content + * + * @return int content id + */ + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function getFolderId() + { + $folderId = $this->getRequest()->get('folder_id', null); + + if (null === $folderId) { + $content = $this->getExistingObject(); + + if ($content) { + $folderId = $content->getDefaultFolderId(); + } + } + + return $folderId ?: 0; + } + + /** + * Render the main list template + * + * @param unknown $currentOrder, if any, null otherwise. + */ + protected function renderListTemplate($currentOrder) + { + $this->getListOrderFromSession('content', 'content_order', 'manual'); + + return $this->render('folders', + array( + 'content_order' => $currentOrder, + 'parent' => $this->getFolderId() + )); + } + + protected function getEditionArguments() + { + return array( + 'content_id' => $this->getRequest()->get('content_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general'), + 'folder_id' => $this->getFolderId(), + ); + } + + /** + * Render the edition template + */ + protected function renderEditionTemplate() + { + return $this->render('content-edit', $this->getEditionArguments()); + } + + /** + * Redirect to the edition template + */ + protected function redirectToEditionTemplate() + { + $this->redirect($this->getRoute('admin.content.update', $this->getEditionArguments())); + } + + /** + * Redirect to the list template + */ + protected function redirectToListTemplate() + { + $this->redirectToRoute( + 'admin.content.default', + array('parent' => $this->getFolderId()) + ); + } + + /** + * @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent + * @return Response|void + */ + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $this->getFolderId()) + ); + } + } + + /** + * Put in this method post object delete processing if required. + * + * @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalDeleteAction($deleteEvent) + { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $deleteEvent->getDefaultFolderId()) + ); + } + + /** + * @param $event \Thelia\Core\Event\UpdatePositionEvent + * @return null|Response + */ + protected function performAdditionalUpdatePositionAction($event) + { + + if (null !== $content = ContentQuery::create()->findPk($event->getObjectId())) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $content->getDefaultFolderId()) + ); + } + + return null; + } + + /** + * @param $positionChangeMode + * @param $positionValue + * @return UpdatePositionEvent|void + */ + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('content_id', null), + $positionChangeMode, + $positionValue + ); + } + + /** + * @return ContentToggleVisibilityEvent|void + */ + protected function createToggleVisibilityEvent() + { + return new ContentToggleVisibilityEvent($this->getExistingObject()); + } +} diff --git a/core/lib/Thelia/Controller/Admin/CountryController.php b/core/lib/Thelia/Controller/Admin/CountryController.php index fadca1e92..404c062a4 100644 --- a/core/lib/Thelia/Controller/Admin/CountryController.php +++ b/core/lib/Thelia/Controller/Admin/CountryController.php @@ -43,10 +43,10 @@ class CountryController extends BaseAdminController * @return mixed|\Symfony\Component\HttpFoundation\Response */ public function updateAction($country_id) - { + { return $this->render("country-edit", array( "country_id" => $country_id )); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 6803addfd..eaecacbda 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -25,24 +25,14 @@ namespace Thelia\Controller\Admin; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Router; -use Thelia\Constraint\ConstraintFactory; -use Thelia\Constraint\ConstraintFactoryTest; -use Thelia\Constraint\Rule\AvailableForTotalAmount; -use Thelia\Constraint\Rule\CouponRuleInterface; -use Thelia\Constraint\Validator\PriceParam; +use Thelia\Condition\ConditionFactory; +use Thelia\Condition\ConditionManagerInterface; +use Thelia\Core\Event\Condition\ConditionCreateOrUpdateEvent; use Thelia\Core\Event\Coupon\CouponConsumeEvent; -use Thelia\Core\Event\Coupon\CouponCreateEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; -use Thelia\Core\Event\Coupon\CouponEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\HttpFoundation\Session\Session; -use Thelia\Core\Security\Exception\AuthenticationException; -use Thelia\Core\Security\Exception\AuthorizationException; -use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\CouponFactory; use Thelia\Coupon\CouponManager; -use Thelia\Coupon\CouponRuleCollection; +use Thelia\Coupon\ConditionCollection; use Thelia\Coupon\Type\CouponInterface; use Thelia\Form\CouponCreationForm; use Thelia\Form\Exception\FormValidationException; @@ -76,13 +66,13 @@ class CouponController extends BaseAdminController $args['urlReadCoupon'] = $this->getRoute( 'admin.coupon.read', - array('couponId' => 'couponId'), + array('couponId' => 0), Router::ABSOLUTE_URL ); $args['urlEditCoupon'] = $this->getRoute( 'admin.coupon.update', - array('couponId' => 'couponId'), + array('couponId' => 0), Router::ABSOLUTE_URL ); @@ -162,7 +152,7 @@ class CouponController extends BaseAdminController $args['dateFormat'] = $this->getSession()->getLang()->getDateFormat(); $args['availableCoupons'] = $this->getAvailableCoupons(); - $args['formAction'] = 'admin/coupon/create/'; + $args['formAction'] = 'admin/coupon/create'; return $this->render( 'coupon-create', @@ -187,8 +177,9 @@ class CouponController extends BaseAdminController /** @var Coupon $coupon */ $coupon = CouponQuery::create()->findPk($couponId); - if (!$coupon) { - $this->pageNotFound(); + if (null === $coupon) { + return $this->pageNotFound(); + } // Parameters given to the template @@ -199,7 +190,7 @@ class CouponController extends BaseAdminController $lang = $this->getSession()->getLang(); $eventToDispatch = TheliaEvents::COUPON_UPDATE; - // Create + // Update if ($this->getRequest()->isMethod('POST')) { $this->validateCreateOrUpdateForm( $i18n, @@ -208,20 +199,23 @@ class CouponController extends BaseAdminController 'updated', 'update' ); - } else { // Update - + } else { + // Display // Prepare the data that will hydrate the form - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $this->container->get('thelia.constraint.factory'); - $rules = $constraintFactory->unserializeCouponRuleCollection( - $coupon->getSerializedRules() + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $this->container->get('thelia.condition.factory'); + $conditions = $conditionFactory->unserializeConditionCollection( + $coupon->getSerializedConditions() ); - +var_dump($coupon->getIsEnabled());; +var_dump($coupon->getIsAvailableOnSpecialOffers());; +var_dump($coupon->getIsCumulative());; +var_dump($coupon->getIsRemovingPostage());; $data = array( 'code' => $coupon->getCode(), 'title' => $coupon->getTitle(), 'amount' => $coupon->getAmount(), - 'effect' => $coupon->getType(), + 'type' => $coupon->getType(), 'shortDescription' => $coupon->getShortDescription(), 'description' => $coupon->getDescription(), 'isEnabled' => ($coupon->getIsEnabled() == 1), @@ -230,23 +224,23 @@ class CouponController extends BaseAdminController 'isCumulative' => ($coupon->getIsCumulative() == 1), 'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1), 'maxUsage' => $coupon->getMaxUsage(), - 'rules' => $rules, + 'conditions' => $conditions, 'locale' => $coupon->getLocale(), ); - $args['rulesObject'] = array(); + $args['conditionsObject'] = array(); - /** @var CouponRuleInterface $rule */ - foreach ($rules->getRules() as $rule) { - $args['rulesObject'][] = array( - 'serviceId' => $rule->getServiceId(), - 'name' => $rule->getName(), - 'tooltip' => $rule->getToolTip(), - 'validators' => $rule->getValidators() + /** @var ConditionManagerInterface $condition */ + foreach ($conditions->getConditions() as $condition) { + $args['conditionsObject'][] = array( + 'serviceId' => $condition->getServiceId(), + 'name' => $condition->getName(), + 'tooltip' => $condition->getToolTip(), + 'validators' => $condition->getValidators() ); } - $args['rules'] = $this->cleanRuleForTemplate($rules); + $args['conditions'] = $this->cleanConditionForTemplate($conditions); // Setup the object form $changeForm = new CouponCreationForm($this->getRequest(), 'form', $data); @@ -256,20 +250,20 @@ class CouponController extends BaseAdminController } $args['couponCode'] = $coupon->getCode(); $args['availableCoupons'] = $this->getAvailableCoupons(); - $args['availableRules'] = $this->getAvailableRules(); - $args['urlAjaxGetRuleInput'] = $this->getRoute( - 'admin.coupon.rule.input', - array('ruleId' => 'ruleId'), + $args['availableConditions'] = $this->getAvailableConditions(); + $args['urlAjaxGetConditionInput'] = $this->getRoute( + 'admin.coupon.condition.input', + array('conditionId' => 'conditionId'), Router::ABSOLUTE_URL ); - $args['urlAjaxUpdateRules'] = $this->getRoute( - 'admin.coupon.rule.update', + $args['urlAjaxUpdateConditions'] = $this->getRoute( + 'admin.coupon.condition.update', array('couponId' => $couponId), Router::ABSOLUTE_URL ); - $args['formAction'] = 'admin/coupon/update/' . $couponId; + $args['formAction'] = 'admin/coupon/update' . $couponId; return $this->render('coupon-update', $args); } @@ -277,34 +271,33 @@ class CouponController extends BaseAdminController /** * Manage Coupons read display * - * @param string $ruleId Rule service id + * @param string $conditionId Condition service id * * @return \Symfony\Component\HttpFoundation\Response */ - public function getRuleInputAction($ruleId) + public function getConditionInputAction($conditionId) { $this->checkAuth('ADMIN', 'admin.coupon.read'); $this->checkXmlHttpRequest(); - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $this->container->get('thelia.constraint.factory'); - $inputs = $constraintFactory->getInputs($ruleId); + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $this->container->get('thelia.condition.factory'); + $inputs = $conditionFactory->getInputs($conditionId); if ($inputs === null) { return $this->pageNotFound(); } return $this->render( - 'coupon/rule-input-ajax', + 'coupon/condition-input-ajax', array( - 'ruleId' => $ruleId, + 'conditionId' => $conditionId, 'inputs' => $inputs ) ); } - /** * Manage Coupons read display * @@ -312,7 +305,7 @@ class CouponController extends BaseAdminController * * @return \Symfony\Component\HttpFoundation\Response */ - public function updateRulesAction($couponId) + public function updateConditionsAction($couponId) { $this->checkAuth('ADMIN', 'admin.coupon.read'); @@ -326,64 +319,51 @@ class CouponController extends BaseAdminController return $this->pageNotFound(); } - $rules = new CouponRuleCollection(); + $conditions = new ConditionCollection(); - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $this->container->get('thelia.constraint.factory'); - $rulesReceived = json_decode($this->getRequest()->get('rules')); - foreach ($rulesReceived as $ruleReceived) { - $rule = $constraintFactory->build( - $ruleReceived->serviceId, - (array) $ruleReceived->operators, - (array) $ruleReceived->values + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $this->container->get('thelia.condition.factory'); + $conditionsReceived = json_decode($this->getRequest()->get('conditions')); + foreach ($conditionsReceived as $conditionReceived) { + $condition = $conditionFactory->build( + $conditionReceived->serviceId, + (array) $conditionReceived->operators, + (array) $conditionReceived->values ); - $rules->add(clone $rule); + $conditions->add(clone $condition); } - $coupon->setSerializedRules( - $constraintFactory->serializeCouponRuleCollection($rules) - ); +// $coupon->setSerializedConditions( +// $conditionFactory->serializeCouponConditionCollection($conditions) +// ); - $couponEvent = new CouponCreateOrUpdateEvent( - $coupon->getCode(), - $coupon->getTitle(), - $coupon->getAmount(), - $coupon->getType(), - $coupon->getShortDescription(), - $coupon->getDescription(), - $coupon->getIsEnabled(), - $coupon->getExpirationDate(), - $coupon->getIsAvailableOnSpecialOffers(), - $coupon->getIsCumulative(), - $coupon->getIsRemovingPostage(), - $coupon->getMaxUsage(), - $rules, - $coupon->getLocale() + $conditionEvent = new ConditionCreateOrUpdateEvent( + $conditions ); - $couponEvent->setCoupon($coupon); + $conditionEvent->setCouponModel($coupon); - $eventToDispatch = TheliaEvents::COUPON_RULE_UPDATE; + $eventToDispatch = TheliaEvents::COUPON_CONDITION_UPDATE; // Dispatch Event to the Action $this->dispatch( $eventToDispatch, - $couponEvent + $conditionEvent ); $this->adminLogAppend( sprintf( - 'Coupon %s (ID %s) rules updated', - $couponEvent->getTitle(), - $couponEvent->getCoupon()->getId() + 'Coupon %s (ID %s) conditions updated', + $conditionEvent->getCouponModel()->getTitle(), + $conditionEvent->getCouponModel()->getServiceId() ) ); - $cleanedRules = $this->cleanRuleForTemplate($rules); + $cleanedConditions = $this->cleanConditionForTemplate($conditions); return $this->render( - 'coupon/rules', + 'coupon/conditions', array( 'couponId' => $couponId, - 'rules' => $cleanedRules, + 'conditions' => $cleanedConditions, 'urlEdit' => $couponId, 'urlDelete' => $couponId ) @@ -395,6 +375,8 @@ class CouponController extends BaseAdminController * * @param string $couponCode Coupon code * + * @todo remove (event dispatcher testing purpose) + * */ public function consumeAction($couponCode) { @@ -431,8 +413,8 @@ class CouponController extends BaseAdminController $couponBeingCreated->setAmount($data['amount']); $couponBeingCreated->setIsEnabled($data['isEnabled']); $couponBeingCreated->setExpirationDate($data['expirationDate']); - $couponBeingCreated->setSerializedRules( - new CouponRuleCollection( + $couponBeingCreated->setSerializedConditions( + new ConditionCollection( array() ) ); @@ -488,26 +470,14 @@ class CouponController extends BaseAdminController $message = false; try { - // Check the form against constraints violations + // Check the form against conditions violations $form = $this->validateForm($creationForm, 'POST'); // Get the form field values $data = $form->getData(); + $couponEvent = new CouponCreateOrUpdateEvent( - $data['code'], - $data['title'], - $data['amount'], - $data['effect'], - $data['shortDescription'], - $data['description'], - $data['isEnabled'], - \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), - $data['isAvailableOnSpecialOffers'], - $data['isCumulative'], - $data['isRemovingPostage'], - $data['maxUsage'], - new CouponRuleCollection(array()), - $data['locale'] + $data['code'], $data['title'], $data['amount'], $data['type'], $data['shortDescription'], $data['description'], $data['isEnabled'], \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), $data['isAvailableOnSpecialOffers'], $data['isCumulative'], $data['isRemovingPostage'], $data['maxUsage'], $data['locale'] ); // Dispatch Event to the Action @@ -535,7 +505,6 @@ class CouponController extends BaseAdminController } catch (FormValidationException $e) { // Invalid data entered $message = 'Please check your input:'; - $this->logError($action, $message, $e); } catch (\Exception $e) { // Any other error @@ -557,26 +526,26 @@ class CouponController extends BaseAdminController } /** - * Get all available rules + * Get all available conditions * * @return array */ - protected function getAvailableRules() + protected function getAvailableConditions() { /** @var CouponManager $couponManager */ $couponManager = $this->container->get('thelia.coupon.manager'); - $availableRules = $couponManager->getAvailableRules(); - $cleanedRules = array(); - /** @var CouponRuleInterface $availableRule */ - foreach ($availableRules as $availableRule) { - $rule = array(); - $rule['serviceId'] = $availableRule->getServiceId(); - $rule['name'] = $availableRule->getName(); - $rule['toolTip'] = $availableRule->getToolTip(); - $cleanedRules[] = $rule; + $availableConditions = $couponManager->getAvailableConditions(); + $cleanedConditions = array(); + /** @var ConditionManagerInterface $availableCondition */ + foreach ($availableConditions as $availableCondition) { + $condition = array(); + $condition['serviceId'] = $availableCondition->getServiceId(); + $condition['name'] = $availableCondition->getName(); + $condition['toolTip'] = $availableCondition->getToolTip(); + $cleanedConditions[] = $condition; } - return $cleanedRules; + return $cleanedConditions; } /** @@ -592,53 +561,54 @@ class CouponController extends BaseAdminController $cleanedCoupons = array(); /** @var CouponInterface $availableCoupon */ foreach ($availableCoupons as $availableCoupon) { - $rule = array(); - $rule['serviceId'] = $availableCoupon->getServiceId(); - $rule['name'] = $availableCoupon->getName(); - $rule['toolTip'] = $availableCoupon->getToolTip(); - $cleanedCoupons[] = $rule; + $condition = array(); + $condition['serviceId'] = $availableCoupon->getServiceId(); + $condition['name'] = $availableCoupon->getName(); + $condition['toolTip'] = $availableCoupon->getToolTip(); + $cleanedCoupons[] = $condition; } return $cleanedCoupons; } /** - * @param $rules + * Clean condition for template + * + * @param ConditionCollection $conditions Condition collection + * * @return array */ - protected function cleanRuleForTemplate($rules) + protected function cleanConditionForTemplate(ConditionCollection $conditions) { - $cleanedRules = array(); - /** @var $rule CouponRuleInterface */ - foreach ($rules->getRules() as $rule) { - $cleanedRules[] = $rule->getToolTip(); + $cleanedConditions = array(); + /** @var $condition ConditionManagerInterface */ + foreach ($conditions->getConditions() as $condition) { + $cleanedConditions[] = $condition->getToolTip(); } - return $cleanedRules; + return $cleanedConditions; } // /** -// * Validation Rule creation +// * Validation Condition creation // * -// * @param string $type Rule class type -// * @param string $operator Rule operator (<, >, =, etc) -// * @param array $values Rules values +// * @param string $type Condition class type +// * @param string $operator Condition operator (<, >, =, etc) +// * @param array $values Condition values // * // * @return bool // */ -// protected function validateRulesCreation($type, $operator, $values) +// protected function validateConditionsCreation($type, $operator, $values) // { -// /** @var CouponAdapterInterface $adapter */ +// /** @var AdapterInterface $adapter */ // $adapter = $this->container->get('thelia.adapter'); // $validator = new PriceParam() // try { -// $rule = new AvailableForTotalAmount($adapter, $validators); -// $rule = new $type($adapter, $validators); +// $condition = new AvailableForTotalAmount($adapter, $validators); +// $condition = new $type($adapter, $validators); // } catch (\Exception $e) { // return false; // } // } - - } diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index f0081d698..6fd98983b 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -23,10 +23,10 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\CurrencyDeleteEvent; +use Thelia\Core\Event\Currency\CurrencyDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CurrencyUpdateEvent; -use Thelia\Core\Event\CurrencyCreateEvent; +use Thelia\Core\Event\Currency\CurrencyUpdateEvent; +use Thelia\Core\Event\Currency\CurrencyCreateEvent; use Thelia\Model\CurrencyQuery; use Thelia\Form\CurrencyModificationForm; use Thelia\Form\CurrencyCreationForm; @@ -39,7 +39,8 @@ use Thelia\Core\Event\UpdatePositionEvent; */ class CurrencyController extends AbstractCrudController { - public function __construct() { + public function __construct() + { parent::__construct( 'currency', 'manual', @@ -58,15 +59,18 @@ class CurrencyController extends AbstractCrudController ); } - protected function getCreationForm() { + protected function getCreationForm() + { return new CurrencyCreationForm($this->getRequest()); } - protected function getUpdateForm() { + protected function getUpdateForm() + { return new CurrencyModificationForm($this->getRequest()); } - protected function getCreationEvent($formData) { + protected function getCreationEvent($formData) + { $createEvent = new CurrencyCreateEvent(); $createEvent @@ -80,7 +84,8 @@ class CurrencyController extends AbstractCrudController return $createEvent; } - protected function getUpdateEvent($formData) { + protected function getUpdateEvent($formData) + { $changeEvent = new CurrencyUpdateEvent($formData['id']); // Create and dispatch the change event @@ -95,8 +100,8 @@ class CurrencyController extends AbstractCrudController return $changeEvent; } - protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { - + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { return new UpdatePositionEvent( $this->getRequest()->get('currency_id', null), $positionChangeMode, @@ -104,16 +109,18 @@ class CurrencyController extends AbstractCrudController ); } - protected function getDeleteEvent() { + protected function getDeleteEvent() + { return new CurrencyDeleteEvent($this->getRequest()->get('currency_id')); } - protected function eventContainsObject($event) { + protected function eventContainsObject($event) + { return $event->hasCurrency(); } - protected function hydrateObjectForm($object) { - + protected function hydrateObjectForm($object) + { // Prepare the data that will hydrate the form $data = array( 'id' => $object->getId(), @@ -128,44 +135,51 @@ class CurrencyController extends AbstractCrudController return new CurrencyModificationForm($this->getRequest(), "form", $data); } - protected function getObjectFromEvent($event) { + protected function getObjectFromEvent($event) + { return $event->hasCurrency() ? $event->getCurrency() : null; } - protected function getExistingObject() { + protected function getExistingObject() + { return CurrencyQuery::create() ->joinWithI18n($this->getCurrentEditionLocale()) ->findOneById($this->getRequest()->get('currency_id')); } - protected function getObjectLabel($object) { + protected function getObjectLabel($object) + { return $object->getName(); } - protected function getObjectId($object) { + protected function getObjectId($object) + { return $object->getId(); } - protected function renderListTemplate($currentOrder) { + protected function renderListTemplate($currentOrder) + { return $this->render('currencies', array('order' => $currentOrder)); } - protected function renderEditionTemplate() { + protected function renderEditionTemplate() + { return $this->render('currency-edit', array('currency_id' => $this->getRequest()->get('currency_id'))); } - protected function redirectToEditionTemplate() { + protected function redirectToEditionTemplate() + { $this->redirectToRoute( "admin.configuration.currencies.update", array('currency_id' => $this->getRequest()->get('currency_id')) ); } - protected function redirectToListTemplate() { + protected function redirectToListTemplate() + { $this->redirectToRoute('admin.configuration.currencies.default'); } - /** * Update currencies rates */ diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index 9209cb361..f559a5bb0 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -24,8 +24,8 @@ namespace Thelia\Controller\Admin; use Propel\Runtime\Exception\PropelException; use Symfony\Component\Form\Form; -use Thelia\Core\Event\CustomerCreateOrUpdateEvent; -use Thelia\Core\Event\CustomerEvent; +use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; +use Thelia\Core\Event\Customer\CustomerEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\CustomerModification; use Thelia\Form\Exception\FormValidationException; @@ -48,10 +48,9 @@ class CustomerController extends BaseAdminController public function viewAction($customer_id) { if (null !== $response = $this->checkAuth("admin.customer.view")) return $response; - - return $this->render("customer-edit", array( - "customer_id" => $customer_id - )); + return $this->render("customer-edit", array( + "customer_id" => $customer_id + )); } /** @@ -71,8 +70,8 @@ class CustomerController extends BaseAdminController try { $customer = CustomerQuery::create()->findPk($customer_id); - if(null === $customer) { - throw new \InvalidArgumentException(sprintf("%d customer id does not exists", $customer_id)); + if (null === $customer) { + throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id)); } $form = $this->validateForm($customerModification); @@ -86,7 +85,7 @@ class CustomerController extends BaseAdminController $this->adminLogAppend(sprintf("Customer with Ref %s (ID %d) modified", $customerUpdated->getRef() , $customerUpdated->getId())); - if($this->getRequest()->get("save_mode") == "close") { + if ($this->getRequest()->get("save_mode") == "close") { $this->redirectToRoute("admin.customers"); } else { $this->redirectSuccess($customerModification); @@ -126,14 +125,14 @@ class CustomerController extends BaseAdminController $customer_id = $this->getRequest()->get("customer_id"); $customer = CustomerQuery::create()->findPk($customer_id); - if(null === $customer) { - throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exists")); + if (null === $customer) { + throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exist")); } $event = new CustomerEvent($customer); $this->dispatch(TheliaEvents::CUSTOMER_DELETEACCOUNT, $event); - } catch(\Exception $e) { + } catch (\Exception $e) { $message = $e->getMessage(); } @@ -151,7 +150,7 @@ class CustomerController extends BaseAdminController /** * @param $data - * @return CustomerCreateOrUpdateEvent + * @return \Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent */ private function createEventInstance($data) { @@ -178,4 +177,4 @@ class CustomerController extends BaseAdminController return $customerCreateEvent; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/FeatureAvController.php b/core/lib/Thelia/Controller/Admin/FeatureAvController.php index fc6571ccc..e8684ef04 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureAvController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureAvController.php @@ -23,10 +23,10 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\FeatureAvDeleteEvent; +use Thelia\Core\Event\Feature\FeatureAvDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\FeatureAvUpdateEvent; -use Thelia\Core\Event\FeatureAvCreateEvent; +use Thelia\Core\Event\Feature\FeatureAvUpdateEvent; +use Thelia\Core\Event\Feature\FeatureAvCreateEvent; use Thelia\Model\FeatureAvQuery; use Thelia\Form\FeatureAvModificationForm; use Thelia\Form\FeatureAvCreationForm; @@ -193,4 +193,4 @@ class FeatureAvController extends AbstractCrudController $this->getViewArguments() ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php index f81f55919..a8fde8880 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -23,18 +23,18 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\FeatureDeleteEvent; +use Thelia\Core\Event\Feature\FeatureDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\FeatureUpdateEvent; -use Thelia\Core\Event\FeatureCreateEvent; +use Thelia\Core\Event\Feature\FeatureUpdateEvent; +use Thelia\Core\Event\Feature\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; +use Thelia\Core\Event\Feature\FeatureAvUpdateEvent; +use Thelia\Core\Event\Feature\FeatureEvent; /** * Manages features @@ -113,7 +113,7 @@ class FeatureController extends AbstractCrudController if ($attr_values !== null) { - foreach($attr_values as $id => $value) { + foreach ($attr_values as $id => $value) { $event = new FeatureAvUpdateEvent($id); @@ -168,7 +168,7 @@ class FeatureController extends AbstractCrudController $attr_array = array(); - foreach($attr_av_list as $attr_av) { + foreach ($attr_av_list as $attr_av) { $attr_array[$attr_av->getId()] = $attr_av->getTitle(); } @@ -262,8 +262,7 @@ class FeatureController extends AbstractCrudController $this->dispatch($eventType, $event); } - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -286,4 +285,4 @@ class FeatureController extends AbstractCrudController { return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/FileController.php b/core/lib/Thelia/Controller/Admin/FileController.php new file mode 100755 index 000000000..e99b857f7 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/FileController.php @@ -0,0 +1,671 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Propel\Runtime\Exception\PropelException; +use Symfony\Component\HttpFoundation\File\UploadedFile; +use Symfony\Component\HttpFoundation\Response; +use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; +use Thelia\Core\Event\Document\DocumentDeleteEvent; +use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; +use Thelia\Core\Event\Image\ImageDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Log\Tlog; +use Thelia\Model\CategoryDocument; +use Thelia\Model\CategoryImage; +use Thelia\Model\ContentDocument; +use Thelia\Model\ContentImage; +use Thelia\Model\FolderDocument; +use Thelia\Model\FolderImage; +use Thelia\Model\ProductDocument; +use Thelia\Model\ProductImage; +use Thelia\Tools\FileManager; +use Thelia\Tools\Rest\ResponseRest; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Control View and Action (Model) via Events + * Control Files and Images + * + * @package File + * @author Guillaume MOREL + * + */ +class FileController extends BaseAdminController +{ + + /** + * Manage how a image collection has to be saved + * + * @param int $parentId Parent id owning images being saved + * @param string $parentType Parent Type owning images being saved + * + * @return Response + */ + public function saveImageAjaxAction($parentId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.image.save'); + $this->checkXmlHttpRequest(); + + if ($this->isParentTypeValid($parentType)) { + if ($this->getRequest()->isMethod('POST')) { + + /** @var UploadedFile $fileBeingUploaded */ + $fileBeingUploaded = $this->getRequest()->files->get('file'); + + $fileManager = new FileManager($this->container); + + // Validate if file is too big + if ($fileBeingUploaded->getError() == 1) { + $message = $this->getTranslator() + ->trans( + 'File is too heavy, please retry with a file having a size less than %size%.', + array('%size%' => ini_get('post_max_size')), + 'image' + ); + + return new ResponseRest($message, 'text', 403); + } + // Validate if it is a image or file + if (!$fileManager->isImage($fileBeingUploaded->getMimeType())) { + $message = $this->getTranslator() + ->trans( + 'You can only upload images (.png, .jpg, .jpeg, .gif)', + array(), + 'image' + ); + + return new ResponseRest($message, 'text', 415); + } + + $parentModel = $fileManager->getParentFileModel($parentType, $parentId); + $imageModel = $fileManager->getImageModel($parentType); + + if ($parentModel === null || $imageModel === null || $fileBeingUploaded === null) { + return new Response('', 404); + } + + $defaultTitle = $parentModel->getTitle(); + $imageModel->setParentId($parentId); + $imageModel->setTitle($defaultTitle); + + $imageCreateOrUpdateEvent = new ImageCreateOrUpdateEvent( + $parentType, + $parentId + ); + $imageCreateOrUpdateEvent->setModelImage($imageModel); + $imageCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded); + $imageCreateOrUpdateEvent->setParentName($parentModel->getTitle()); + + // Dispatch Event to the Action + $this->dispatch( + TheliaEvents::IMAGE_SAVE, + $imageCreateOrUpdateEvent + ); + + return new ResponseRest(array('status' => true, 'message' => '')); + } + } + + return new Response('', 404); + } + + /** + * Manage how a document collection has to be saved + * + * @param int $parentId Parent id owning documents being saved + * @param string $parentType Parent Type owning documents being saved + * + * @return Response + */ + public function saveDocumentAjaxAction($parentId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.document.save'); + $this->checkXmlHttpRequest(); + + if ($this->isParentTypeValid($parentType)) { + if ($this->getRequest()->isMethod('POST')) { + + /** @var UploadedFile $fileBeingUploaded */ + $fileBeingUploaded = $this->getRequest()->files->get('file'); + + $fileManager = new FileManager($this->container); + + // Validate if file is too big + if ($fileBeingUploaded->getError() == 1) { + $message = $this->getTranslator() + ->trans( + 'File is too heavy, please retry with a file having a size less than %size%.', + array('%size%' => ini_get('post_max_size')), + 'document' + ); + + return new ResponseRest($message, 'text', 403); + } + + $parentModel = $fileManager->getParentFileModel($parentType, $parentId); + $documentModel = $fileManager->getDocumentModel($parentType); + + if ($parentModel === null || $documentModel === null || $fileBeingUploaded === null) { + return new Response('', 404); + } + + $documentModel->setParentId($parentId); + $documentModel->setTitle($fileBeingUploaded->getClientOriginalName()); + + $documentCreateOrUpdateEvent = new DocumentCreateOrUpdateEvent( + $parentType, + $parentId + ); + $documentCreateOrUpdateEvent->setModelDocument($documentModel); + $documentCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded); + $documentCreateOrUpdateEvent->setParentName($parentModel->getTitle()); + + // Dispatch Event to the Action + $this->dispatch( + TheliaEvents::DOCUMENT_SAVE, + $documentCreateOrUpdateEvent + ); + + return new ResponseRest(array('status' => true, 'message' => '')); + } + } + + return new Response('', 404); + } + + /** + * Manage how a image list will be displayed in AJAX + * + * @param int $parentId Parent id owning images being saved + * @param string $parentType Parent Type owning images being saved + * + * @return Response + */ + public function getImageListAjaxAction($parentId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.image.save'); + $this->checkXmlHttpRequest(); + $args = array('imageType' => $parentType, 'parentId' => $parentId); + + return $this->render('includes/image-upload-list-ajax', $args); + } + + /** + * Manage how a document list will be displayed in AJAX + * + * @param int $parentId Parent id owning documents being saved + * @param string $parentType Parent Type owning documents being saved + * + * @return Response + */ + public function getDocumentListAjaxAction($parentId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.document.save'); + $this->checkXmlHttpRequest(); + $args = array('documentType' => $parentType, 'parentId' => $parentId); + + return $this->render('includes/document-upload-list-ajax', $args); + } + + /** + * Manage how an image list will be uploaded in AJAX + * + * @param int $parentId Parent id owning images being saved + * @param string $parentType Parent Type owning images being saved + * + * @return Response + */ + public function getImageFormAjaxAction($parentId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.image.save'); + $this->checkXmlHttpRequest(); + $args = array('imageType' => $parentType, 'parentId' => $parentId); + + return $this->render('includes/image-upload-form', $args); + } + + /** + * Manage how an document list will be uploaded in AJAX + * + * @param int $parentId Parent id owning documents being saved + * @param string $parentType Parent Type owning documents being saved + * + * @return Response + */ + public function getDocumentFormAjaxAction($parentId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.document.save'); + $this->checkXmlHttpRequest(); + $args = array('documentType' => $parentType, 'parentId' => $parentId); + + return $this->render('includes/document-upload-form', $args); + } + + /** + * Manage how an image is viewed + * + * @param int $imageId Parent id owning images being saved + * @param string $parentType Parent Type owning images being saved + * + * @return Response + */ + public function viewImageAction($imageId, $parentType) + { + if (null !== $response = $this->checkAuth('admin.image.view')) { + return $response; + } + try { + $fileManager = new FileManager($this->container); + $image = $fileManager->getImageModelQuery($parentType)->findPk($imageId); + $redirectUrl = $fileManager->getRedirectionUrl($parentType, $image->getParentId(), FileManager::FILE_TYPE_IMAGES); + + return $this->render('image-edit', array( + 'imageId' => $imageId, + 'imageType' => $parentType, + 'redirectUrl' => $redirectUrl, + 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_IMAGES) + )); + } catch (\Exception $e) { + $this->pageNotFound(); + } + } + + /** + * Manage how an document is viewed + * + * @param int $documentId Parent id owning images being saved + * @param string $parentType Parent Type owning images being saved + * + * @return Response + */ + public function viewDocumentAction($documentId, $parentType) + { + if (null !== $response = $this->checkAuth('admin.document.view')) { + return $response; + } + try { + $fileManager = new FileManager($this->container); + $document = $fileManager->getDocumentModelQuery($parentType)->findPk($documentId); + $redirectUrl = $fileManager->getRedirectionUrl($parentType, $document->getParentId(), FileManager::FILE_TYPE_DOCUMENTS); + + return $this->render('document-edit', array( + 'documentId' => $documentId, + 'documentType' => $parentType, + 'redirectUrl' => $redirectUrl, + 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_DOCUMENTS) + )); + } catch (\Exception $e) { + $this->pageNotFound(); + } + } + + /** + * Manage how an image is updated + * + * @param int $imageId Parent id owning images being saved + * @param string $parentType Parent Type owning images being saved + * + * @return Response + */ + public function updateImageAction($imageId, $parentType) + { + if (null !== $response = $this->checkAuth('admin.image.update')) { + return $response; + } + + $message = false; + + $fileManager = new FileManager($this->container); + $imageModification = $fileManager->getImageForm($parentType, $this->getRequest()); + + try { + $image = $fileManager->getImageModelQuery($parentType)->findPk($imageId); + $oldImage = clone $image; + if (null === $image) { + throw new \InvalidArgumentException(sprintf('%d image id does not exist', $imageId)); + } + + $form = $this->validateForm($imageModification); + + $event = $this->createImageEventInstance($parentType, $image, $form->getData()); + $event->setOldModelImage($oldImage); + + $files = $this->getRequest()->files; + $fileForm = $files->get($imageModification->getName()); + if (isset($fileForm['file'])) { + $event->setUploadedFile($fileForm['file']); + } + + $this->dispatch(TheliaEvents::IMAGE_UPDATE, $event); + + $imageUpdated = $event->getModelImage(); + + $this->adminLogAppend(sprintf('Image with Ref %s (ID %d) modified', $imageUpdated->getTitle(), $imageUpdated->getId())); + + if ($this->getRequest()->get('save_mode') == 'close') { + $this->redirectToRoute('admin.images'); + } else { + $this->redirectSuccess($imageModification); + } + + } catch (FormValidationException $e) { + $message = sprintf('Please check your input: %s', $e->getMessage()); + } catch (PropelException $e) { + $message = $e->getMessage(); + } catch (\Exception $e) { + $message = sprintf('Sorry, an error occurred: %s', $e->getMessage().' '.$e->getFile()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf('Error during image editing : %s.', $message)); + + $imageModification->setErrorMessage($message); + + $this->getParserContext() + ->addForm($imageModification) + ->setGeneralError($message); + } + + $redirectUrl = $fileManager->getRedirectionUrl($parentType, $image->getParentId(), FileManager::FILE_TYPE_IMAGES); + + return $this->render('image-edit', array( + 'imageId' => $imageId, + 'imageType' => $parentType, + 'redirectUrl' => $redirectUrl, + 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_IMAGES) + )); + } + + /** + * Manage how an document is updated + * + * @param int $documentId Parent id owning documents being saved + * @param string $parentType Parent Type owning documents being saved + * + * @return Response + */ + public function updateDocumentAction($documentId, $parentType) + { + if (null !== $response = $this->checkAuth('admin.document.update')) { + return $response; + } + + $message = false; + + $fileManager = new FileManager($this->container); + $documentModification = $fileManager->getDocumentForm($parentType, $this->getRequest()); + + try { + $document = $fileManager->getDocumentModelQuery($parentType)->findPk($documentId); + $oldDocument = clone $document; + if (null === $document) { + throw new \InvalidArgumentException(sprintf('%d document id does not exist', $documentId)); + } + + $form = $this->validateForm($documentModification); + + $event = $this->createDocumentEventInstance($parentType, $document, $form->getData()); + $event->setOldModelDocument($oldDocument); + + $files = $this->getRequest()->files; + $fileForm = $files->get($documentModification->getName()); + if (isset($fileForm['file'])) { + $event->setUploadedFile($fileForm['file']); + } + + $this->dispatch(TheliaEvents::DOCUMENT_UPDATE, $event); + + $documentUpdated = $event->getModelDocument(); + + $this->adminLogAppend(sprintf('Document with Ref %s (ID %d) modified', $documentUpdated->getTitle(), $documentUpdated->getId())); + + if ($this->getRequest()->get('save_mode') == 'close') { + $this->redirectToRoute('admin.documents'); + } else { + $this->redirectSuccess($documentModification); + } + + } catch (FormValidationException $e) { + $message = sprintf('Please check your input: %s', $e->getMessage()); + } catch (PropelException $e) { + $message = $e->getMessage(); + } catch (\Exception $e) { + $message = sprintf('Sorry, an error occurred: %s', $e->getMessage().' '.$e->getFile()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf('Error during document editing : %s.', $message)); + + $documentModification->setErrorMessage($message); + + $this->getParserContext() + ->addForm($documentModification) + ->setGeneralError($message); + } + + $redirectUrl = $fileManager->getRedirectionUrl($parentType, $document->getParentId(), FileManager::FILE_TYPE_DOCUMENTS); + + return $this->render('document-edit', array( + 'documentId' => $documentId, + 'documentType' => $parentType, + 'redirectUrl' => $redirectUrl, + 'formId' => $fileManager->getFormId($parentType, FileManager::FILE_TYPE_DOCUMENTS) + )); + } + + /** + * Manage how a image has to be deleted (AJAX) + * + * @param int $imageId Parent id owning image being deleted + * @param string $parentType Parent Type owning image being deleted + * + * @return Response + */ + public function deleteImageAction($imageId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.image.delete'); + $this->checkXmlHttpRequest(); + + $fileManager = new FileManager($this->container); + $imageModelQuery = $fileManager->getImageModelQuery($parentType); + $model = $imageModelQuery->findPk($imageId); + + if ($model == null) { + return $this->pageNotFound(); + } + + // Feed event + $imageDeleteEvent = new ImageDeleteEvent( + $model, + $parentType + ); + + // Dispatch Event to the Action + $this->dispatch( + TheliaEvents::IMAGE_DELETE, + $imageDeleteEvent + ); + + $message = $this->getTranslator() + ->trans( + 'Images deleted successfully', + array(), + 'image' + ); + + return new Response($message); + } + + /** + * Manage how a document has to be deleted (AJAX) + * + * @param int $documentId Parent id owning document being deleted + * @param string $parentType Parent Type owning document being deleted + * + * @return Response + */ + public function deleteDocumentAction($documentId, $parentType) + { + $this->checkAuth('ADMIN', 'admin.document.delete'); + $this->checkXmlHttpRequest(); + + $fileManager = new FileManager($this->container); + $documentModelQuery = $fileManager->getDocumentModelQuery($parentType); + $model = $documentModelQuery->findPk($documentId); + + if ($model == null) { + return $this->pageNotFound(); + } + + // Feed event + $documentDeleteEvent = new DocumentDeleteEvent( + $model, + $parentType + ); + + // Dispatch Event to the Action + $this->dispatch( + TheliaEvents::DOCUMENT_DELETE, + $documentDeleteEvent + ); + + $message = $this->getTranslator() + ->trans( + 'Document deleted successfully', + array(), + 'document' + ); + + return new Response($message); + } + + /** + * Log error message + * + * @param string $parentType Parent type + * @param string $action Creation|Update|Delete + * @param string $message Message to log + * @param \Exception $e Exception to log + * + * @return $this + */ + protected function logError($parentType, $action, $message, $e) + { + Tlog::getInstance()->error( + sprintf( + 'Error during ' . $parentType . ' ' . $action . ' process : %s. Exception was %s', + $message, + $e->getMessage() + ) + ); + + return $this; + } + + /** + * Check if parent type is valid or not + * + * @param string $parentType Parent type + * + * @return bool + */ + public function isParentTypeValid($parentType) + { + return (in_array($parentType, FileManager::getAvailableTypes())); + } + + /** + * Create Image Event instance + * + * @param string $parentType Parent Type owning images being saved + * @param CategoryImage|ProductImage|ContentImage|FolderImage $model Image model + * @param array $data Post data + * + * @return ImageCreateOrUpdateEvent + */ + protected function createImageEventInstance($parentType, $model, $data) + { + $imageCreateEvent = new ImageCreateOrUpdateEvent($parentType, null); + + if (isset($data['title'])) { + $model->setTitle($data['title']); + } + if (isset($data['chapo'])) { + $model->setChapo($data['chapo']); + } + if (isset($data['description'])) { + $model->setDescription($data['description']); + } + if (isset($data['file'])) { + $model->setFile($data['file']); + } + if (isset($data['postscriptum'])) { + $model->setPostscriptum($data['postscriptum']); + } + + $imageCreateEvent->setModelImage($model); + + return $imageCreateEvent; + } + + /** + * Create Document Event instance + * + * @param string $parentType Parent Type owning documents being saved + * @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $model Document model + * @param array $data Post data + * + * @return DocumentCreateOrUpdateEvent + */ + protected function createDocumentEventInstance($parentType, $model, $data) + { + $documentCreateEvent = new DocumentCreateOrUpdateEvent($parentType, null); + + if (isset($data['title'])) { + $model->setTitle($data['title']); + } + if (isset($data['chapo'])) { + $model->setChapo($data['chapo']); + } + if (isset($data['description'])) { + $model->setDescription($data['description']); + } + if (isset($data['file'])) { + $model->setFile($data['file']); + } + if (isset($data['postscriptum'])) { + $model->setPostscriptum($data['postscriptum']); + } + + $documentCreateEvent->setModelDocument($model); + + return $documentCreateEvent; + } + +} diff --git a/core/lib/Thelia/Controller/Admin/FolderController.php b/core/lib/Thelia/Controller/Admin/FolderController.php index dd2feb823..24e2659d9 100644 --- a/core/lib/Thelia/Controller/Admin/FolderController.php +++ b/core/lib/Thelia/Controller/Admin/FolderController.php @@ -22,25 +22,308 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; +use Thelia\Core\Event\Folder\FolderCreateEvent; +use Thelia\Core\Event\Folder\FolderDeleteEvent; +use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent; +use Thelia\Core\Event\Folder\FolderUpdateEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Form\FolderCreationForm; +use Thelia\Form\FolderModificationForm; +use Thelia\Model\FolderQuery; /** * Class FolderController * @package Thelia\Controller\Admin * @author Manuel Raynaud */ -class FolderController extends BaseAdminController +class FolderController extends AbstractCrudController { - public function indexAction() + + public function __construct() { - if (null !== $response = $this->checkAuth("admin.folder.view")) return $response; - return $this->render("folders", array("display_folder" => 20)); + parent::__construct( + 'folder', + 'manual', + 'folder_order', + + 'admin.folder.default', + 'admin.folder.create', + 'admin.folder.update', + 'admin.folder.delete', + + TheliaEvents::FOLDER_CREATE, + TheliaEvents::FOLDER_UPDATE, + TheliaEvents::FOLDER_DELETE, + TheliaEvents::FOLDER_TOGGLE_VISIBILITY, + TheliaEvents::FOLDER_UPDATE_POSITION + ); } - - public function updateAction($folder_id) + + /** + * Return the creation form for this object + */ + protected function getCreationForm() + { + return new FolderCreationForm($this->getRequest()); + } + + /** + * Return the update form for this object + */ + protected function getUpdateForm() + { + return new FolderModificationForm($this->getRequest()); + } + + /** + * Hydrate the update form for this object, before passing it to the update template + * + * @param \Thelia\Model\Folder $object + */ + 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->getRewrittenUrl($this->getCurrentEditionLocale()), + 'parent' => $object->getParent() + ); + + // Setup the object form + return new FolderModificationForm($this->getRequest(), "form", $data); + } + + /** + * Creates the creation event with the provided form data + * + * @param unknown $formData + */ + protected function getCreationEvent($formData) + { + $creationEvent = new FolderCreateEvent(); + + $creationEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setVisible($formData['visible']) + ->setParent($formData['parent']); + + return $creationEvent; + } + + /** + * Creates the update event with the provided form data + * + * @param unknown $formData + */ + protected function getUpdateEvent($formData) + { + $updateEvent = new FolderUpdateEvent($formData['id']); + + $updateEvent + ->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 $updateEvent; + } + + /** + * Creates the delete event with the provided form data + */ + protected function getDeleteEvent() + { + return new FolderDeleteEvent($this->getRequest()->get('folder_id'), 0); + } + + /** + * @return \Thelia\Core\Event\Folder\FolderToggleVisibilityEvent|void + */ + protected function createToggleVisibilityEvent() + { + return new FolderToggleVisibilityEvent($this->getExistingObject()); + } + + /** + * @param $positionChangeMode + * @param $positionValue + * @return UpdatePositionEvent|void + */ + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('folder_id', null), + $positionChangeMode, + $positionValue + ); + } + + /** + * Return true if the event contains the object, e.g. the action has updated the object in the event. + * + * @param \Thelia\Core\Event\Folder\FolderEvent $event + */ + protected function eventContainsObject($event) + { + return $event->hasFolder(); + } + + /** + * Get the created object from an event. + * + * @param $event \Thelia\Core\Event\Folder\FolderEvent $event + * + * @return null|\Thelia\Model\Folder + */ + protected function getObjectFromEvent($event) + { + return $event->hasFolder() ? $event->getFolder() : null; + } + + /** + * Load an existing object from the database + */ + protected function getExistingObject() + { + return FolderQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('folder_id', 0)); + } + + /** + * Returns the object label form the object event (name, title, etc.) + * + * @param unknown $object + */ + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + /** + * Returns the object ID from the object + * + * @param unknown $object + */ + protected function getObjectId($object) + { + return $object->getId(); + } + + /** + * Render the main list template + * + * @param unknown $currentOrder, if any, null otherwise. + */ + protected function renderListTemplate($currentOrder) + { + // Get content order + $content_order = $this->getListOrderFromSession('content', 'content_order', 'manual'); + + return $this->render('folders', + array( + 'folder_order' => $currentOrder, + 'content_order' => $content_order, + 'parent' => $this->getRequest()->get('parent', 0) + )); + } + + /** + * Render the edition template + */ + protected function renderEditionTemplate() + { + return $this->render('folder-edit', $this->getEditionArguments()); + } + + protected function getEditionArguments() + { + return array( + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') + ); + } + + /** + * @param \Thelia\Core\Event\Folder\FolderUpdateEvent $updateEvent + * @return Response|void + */ + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $updateEvent->getFolder()->getParent()) + ); + } + } + + /** + * Put in this method post object delete processing if required. + * + * @param \Thelia\Core\Event\Folder\FolderDeleteEvent $deleteEvent the delete event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalDeleteAction($deleteEvent) + { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $deleteEvent->getFolder()->getParent()) + ); + } + + /** + * @param $event \Thelia\Core\Event\UpdatePositionEvent + * @return null|Response + */ + protected function performAdditionalUpdatePositionAction($event) { - return $this->render("folder-edit", array( - "folder_id" => $folder_id - )); + $folder = FolderQuery::create()->findPk($event->getObjectId()); + + if ($folder != null) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $folder->getParent()) + ); + } + + return null; } -} \ No newline at end of file + + /** + * Redirect to the edition template + */ + protected function redirectToEditionTemplate() + { + $this->redirect($this->getRoute('admin.folders.update', $this->getEditionArguments())); + } + + /** + * Redirect to the list template + */ + protected function redirectToListTemplate() + { + $this->redirectToRoute( + 'admin.folders.default', + array('parent' => $this->getRequest()->get('parent', 0)) + ); + } +} diff --git a/core/lib/Thelia/Controller/Admin/MessageController.php b/core/lib/Thelia/Controller/Admin/MessageController.php index a55c9deca..176fa7de8 100644 --- a/core/lib/Thelia/Controller/Admin/MessageController.php +++ b/core/lib/Thelia/Controller/Admin/MessageController.php @@ -23,9 +23,9 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\MessageDeleteEvent; -use Thelia\Core\Event\TheliaEvents;use Thelia\Core\Event\MessageUpdateEvent; -use Thelia\Core\Event\MessageCreateEvent; +use Thelia\Core\Event\Message\MessageDeleteEvent; +use Thelia\Core\Event\TheliaEvents;use Thelia\Core\Event\Message\MessageUpdateEvent; +use Thelia\Core\Event\Message\MessageCreateEvent; use Thelia\Model\MessageQuery; use Thelia\Form\MessageModificationForm; use Thelia\Form\MessageCreationForm; diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index fe794abf9..03691c069 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -35,12 +35,11 @@ class ModuleController extends BaseAdminController if (null !== $response = $this->checkAuth("admin.module.view")) return $response; return $this->render("modules", array("display_module" => 20)); } - + public function updateAction($module_id) { - - return $this->render("module-edit", array( - "module_id" => $module_id - )); + return $this->render("module-edit", array( + "module_id" => $module_id + )); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php index b2047cc31..77df4f9b3 100644 --- a/core/lib/Thelia/Controller/Admin/OrderController.php +++ b/core/lib/Thelia/Controller/Admin/OrderController.php @@ -23,6 +23,15 @@ namespace Thelia\Controller\Admin; +use Thelia\Core\Event\Order\OrderAddressEvent; +use Thelia\Core\Event\Order\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Form\OrderUpdateAddress; +use Thelia\Model\Base\OrderAddressQuery; +use Thelia\Model\OrderQuery; +use Thelia\Model\OrderStatusQuery; +use Thelia\Tools\URL; + /** * Class OrderController * @package Thelia\Controller\Admin @@ -38,10 +47,150 @@ class OrderController extends BaseAdminController public function viewAction($order_id) { - - return $this->render("order-edit", array( - "order_id" => $order_id - )); + return $this->render("order-edit", array( + "order_id" => $order_id + )); } -} \ No newline at end of file + public function updateStatus($order_id = null) + { + if (null !== $response = $this->checkAuth("admin.order.update")) return $response; + + $message = null; + + try { + if ($order_id !== null) { + $order_id = $order_id; + } else { + $order_id = $this->getRequest()->get("order_id"); + } + + $order = OrderQuery::create()->findPk($order_id); + + $statusId = $this->getRequest()->request->get("status_id"); + $status = OrderStatusQuery::create()->findPk($statusId); + + if (null === $order) { + throw new \InvalidArgumentException("The order you want to update status does not exist"); + } + if (null === $status) { + throw new \InvalidArgumentException("The status you want to set to the order does not exist"); + } + + $event = new OrderEvent($order); + $event->setStatus($statusId); + + $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); + } catch (\Exception $e) { + $message = $e->getMessage(); + } + + $params = array(); + + if ($message) { + $params["update_status_error_message"] = $message; + } + + $browsedPage = $this->getRequest()->get("order_page"); + + if ($browsedPage) { + $params["order_page"] = $browsedPage; + $this->redirectToRoute("admin.order.list", $params); + } else { + $params["order_id"] = $order_id; + $params["tab"] = $this->getRequest()->get("tab", 'cart'); + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params))); + } + } + + public function updateDeliveryRef($order_id) + { + if (null !== $response = $this->checkAuth("admin.order.update")) return $response; + + $message = null; + + try { + $order = OrderQuery::create()->findPk($order_id); + + $deliveryRef = $this->getRequest()->get("delivery_ref"); + + if (null === $order) { + throw new \InvalidArgumentException("The order you want to update status does not exist"); + } + + $event = new OrderEvent($order); + $event->setDeliveryRef($deliveryRef); + + $this->dispatch(TheliaEvents::ORDER_UPDATE_DELIVERY_REF, $event); + } catch (\Exception $e) { + $message = $e->getMessage(); + } + + $params = array(); + + if ($message) { + $params["update_status_error_message"] = $message; + } + + $params["order_id"] = $order_id; + $params["tab"] = $this->getRequest()->get("tab", 'bill'); + + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params))); + } + + public function updateAddress($order_id) + { + if (null !== $response = $this->checkAuth("admin.order.update")) return $response; + + $message = null; + + $orderUpdateAddress = new OrderUpdateAddress($this->getRequest()); + + try { + $order = OrderQuery::create()->findPk($order_id); + + if (null === $order) { + throw new \InvalidArgumentException("The order you want to update does not exist"); + } + + $form = $this->validateForm($orderUpdateAddress, "post"); + + $orderAddress = OrderAddressQuery::create()->findPk($form->get("id")->getData()); + + if ($orderAddress->getId() !== $order->getInvoiceOrderAddressId() && $orderAddress->getId() !== $order->getDeliveryOrderAddressId()) { + throw new \InvalidArgumentException("The order address you want to update does not belong to the current order not exist"); + } + + $event = new OrderAddressEvent( + $form->get("title")->getData(), + $form->get("firstname")->getData(), + $form->get("lastname")->getData(), + $form->get("address1")->getData(), + $form->get("address2")->getData(), + $form->get("address3")->getData(), + $form->get("zipcode")->getData(), + $form->get("city")->getData(), + $form->get("country")->getData(), + $form->get("phone")->getData(), + $form->get("company")->getData() + ); + $event->setOrderAddress($orderAddress); + $event->setOrder($order); + + $this->dispatch(TheliaEvents::ORDER_UPDATE_ADDRESS, $event); + } catch (\Exception $e) { + $message = $e->getMessage(); + } + + $params = array(); + + if ($message) { + $params["update_status_error_message"] = $message; + } + + $params["order_id"] = $order_id; + $params["tab"] = $this->getRequest()->get("tab", 'bill'); + + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params))); + } +} diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 27c559442..4ff40abff 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -23,26 +23,29 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\ProductDeleteEvent; +use Thelia\Core\Event\Product\ProductAddCategoryEvent; +use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; +use Thelia\Core\Event\Product\ProductDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\ProductUpdateEvent; -use Thelia\Core\Event\ProductCreateEvent; +use Thelia\Core\Event\Product\ProductUpdateEvent; +use Thelia\Core\Event\Product\ProductCreateEvent; use Thelia\Model\ProductQuery; use Thelia\Form\ProductModificationForm; use Thelia\Form\ProductCreationForm; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Core\Event\ProductToggleVisibilityEvent; -use Thelia\Core\Event\ProductDeleteContentEvent; -use Thelia\Core\Event\ProductAddContentEvent; -use Thelia\Model\ProductAssociatedContent; +use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; +use Thelia\Core\Event\Product\ProductDeleteContentEvent; +use Thelia\Core\Event\Product\ProductAddContentEvent; use Thelia\Model\FolderQuery; use Thelia\Model\ContentQuery; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Model\ProductAssociatedContentQuery; use Thelia\Model\AccessoryQuery; use Thelia\Model\CategoryQuery; -use Thelia\Core\Event\ProductAddAccessoryEvent; -use Thelia\Core\Event\ProductDeleteAccessoryEvent; + +use Thelia\Core\Event\Product\ProductAddAccessoryEvent; +use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent; +use Thelia\Model\ProductSaleElementsQuery; /** * Manages products @@ -72,6 +75,35 @@ class ProductController extends AbstractCrudController ); } + /** + * Attributes ajax tab loading + */ + public function loadAttributesAjaxTabAction() + { + return $this->render( + 'ajax/product-attributes-tab', + array( + 'product_id' => $this->getRequest()->get('product_id', 0), + ) + ); + } + + /** + * Related information ajax tab loading + */ + public function loadRelatedAjaxTabAction() + { + return $this->render( + 'ajax/product-related-tab', + array( + 'product_id' => $this->getRequest()->get('product_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'accessory_category_id' => $this->getRequest()->get('accessory_category_id', 0) + + ) + ); + } + protected function getCreationForm() { return new ProductCreationForm($this->getRequest()); @@ -92,6 +124,10 @@ class ProductController extends AbstractCrudController ->setLocale($formData['locale']) ->setDefaultCategory($formData['default_category']) ->setVisible($formData['visible']) + ->setBasePrice($formData['price']) + ->setBaseWeight($formData['weight']) + ->setCurrencyId($formData['currency']) + ->setTaxRuleId($formData['tax_rule']) ; return $createEvent; @@ -110,8 +146,8 @@ class ProductController extends AbstractCrudController ->setPostscriptum($formData['postscriptum']) ->setVisible($formData['visible']) ->setUrl($formData['url']) - ->setParent($formData['parent']) - ; + ->setDefaultCategory($formData['default_category']) + ; return $changeEvent; } @@ -137,9 +173,15 @@ class ProductController extends AbstractCrudController protected function hydrateObjectForm($object) { + // Get the default produc sales element + $salesElement = ProductSaleElementsQuery::create()->filterByProduct($object)->filterByIsDefault(true)->findOne(); + +// $prices = $salesElement->getProductPrices(); + // Prepare the data that will hydrate the form $data = array( 'id' => $object->getId(), + 'ref' => $object->getRef(), 'locale' => $object->getLocale(), 'title' => $object->getTitle(), 'chapo' => $object->getChapo(), @@ -148,6 +190,8 @@ class ProductController extends AbstractCrudController 'visible' => $object->getVisible(), 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), 'default_category' => $object->getDefaultCategoryId() + + // A terminer pour les prix ); // Setup the object form @@ -179,15 +223,16 @@ class ProductController extends AbstractCrudController protected function getEditionArguments() { return array( - 'category_id' => $this->getCategoryId(), - 'product_id' => $this->getRequest()->get('product_id', 0), - 'folder_id' => $this->getRequest()->get('folder_id', 0), - 'accessory_category_id'=> $this->getRequest()->get('accessory_category_id', 0), + 'category_id' => $this->getCategoryId(), + 'product_id' => $this->getRequest()->get('product_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'accessory_category_id' => $this->getRequest()->get('accessory_category_id', 0), 'current_tab' => $this->getRequest()->get('current_tab', 'general') ); } - protected function getCategoryId() { + protected function getCategoryId() + { // Trouver le category_id, soit depuis la reques, souit depuis le produit courant $category_id = $this->getRequest()->get('category_id', null); @@ -298,7 +343,7 @@ class ProductController extends AbstractCrudController ; if ($list !== null) { - foreach($list as $item) { + foreach ($list as $item) { $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); } } @@ -324,8 +369,7 @@ class ProductController extends AbstractCrudController try { $this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -351,8 +395,7 @@ class ProductController extends AbstractCrudController try { $this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -361,7 +404,6 @@ class ProductController extends AbstractCrudController $this->redirectToEditionTemplate(); } - // -- Accessories management ---------------------------------------------- public function getAvailableAccessoriesAction($productId, $categoryId) @@ -380,7 +422,7 @@ class ProductController extends AbstractCrudController ; if ($list !== null) { - foreach($list as $item) { + foreach ($list as $item) { $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); } } @@ -405,8 +447,7 @@ class ProductController extends AbstractCrudController try { $this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -417,7 +458,6 @@ class ProductController extends AbstractCrudController public function deleteAccessoryAction() { - // Check current user authorization if (null !== $response = $this->checkAuth("admin.products.update")) return $response; @@ -432,8 +472,7 @@ class ProductController extends AbstractCrudController try { $this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } @@ -443,30 +482,293 @@ class ProductController extends AbstractCrudController } /** - * Update accessory position (only for objects whichsupport that) + * Update accessory position */ public function updateAccessoryPositionAction() + { + $accessory = AccessoryQuery::create()->findPk($this->getRequest()->get('accessory_id', null)); + + return $this->genericUpdatePositionAction( + $accessory, + TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION + ); + } + + /** + * Update related content position + */ + public function updateContentPositionAction() + { + $content = ProductAssociatedContentQuery::create()->findPk($this->getRequest()->get('content_id', null)); + + return $this->genericUpdatePositionAction( + $content, + TheliaEvents::PRODUCT_UPDATE_CONTENT_POSITION + ); + } + + /** + * Change product template for a given product. + * + * @param unknown $productId + */ + public function setProductTemplateAction($productId) { // Check current user authorization if (null !== $response = $this->checkAuth('admin.products.update')) return $response; - try { - $mode = $this->getRequest()->get('mode', null); + $product = ProductQuery::create()->findPk($productId); - if ($mode == 'up') - $mode = UpdatePositionEvent::POSITION_UP; - else if ($mode == 'down') - $mode = UpdatePositionEvent::POSITION_DOWN; - else - $mode = UpdatePositionEvent::POSITION_ABSOLUTE; + if ($product != null) { - $position = $this->getRequest()->get('position', null); + $template_id = intval($this->getRequest()->get('template_id', 0)); - $event = new UpdatePositionEvent($mode, $position); - - $this->dispatch(TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION, $event); + $this->dispatch( + TheliaEvents::PRODUCT_SET_TEMPLATE, + new ProductSetTemplateEvent($product, $template_id) + ); } - catch (\Exception $ex) { + + $this->redirectToEditionTemplate(); + } + + /** + * Update product attributes and features + */ + public function updateAttributesAndFeaturesAction($productId) + { + $product = ProductQuery::create()->findPk($productId); + + if ($product != null) { + + $featureTemplate = FeatureTemplateQuery::create()->filterByTemplateId($product->getTemplateId())->find(); + + if ($featureTemplate !== null) { + + // Get all features for the template attached to this product + $allFeatures = FeatureQuery::create() + ->filterByFeatureTemplate($featureTemplate) + ->find(); + + $updatedFeatures = array(); + + // Update all features values, starting with feature av. values + $featureValues = $this->getRequest()->get('feature_value', array()); + + foreach ($featureValues as $featureId => $featureValueList) { + + // Delete all features av. for this feature. + $event = new FeatureProductDeleteEvent($productId, $featureId); + + $this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event); + + // Add then all selected values + foreach ($featureValueList as $featureValue) { + $event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue); + + $this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event); + } + + $updatedFeatures[] = $featureId; + } + + // Update then features text values + $featureTextValues = $this->getRequest()->get('feature_text_value', array()); + + foreach ($featureTextValues as $featureId => $featureValue) { + + // considere empty text as empty feature value (e.g., we will delete it) + if (empty($featureValue)) continue; + + $event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue, true); + + $this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event); + + $updatedFeatures[] = $featureId; + } + + // Delete features which don't have any values + foreach ($allFeatures as $feature) { + + if (! in_array($feature->getId(), $updatedFeatures)) { + $event = new FeatureProductDeleteEvent($productId, $feature->getId()); + + $this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event); + } + } + } + } + + // 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 category/product list + $this->redirectToListTemplate(); + } + + public function addAdditionalCategoryAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $category_id = intval($this->getRequest()->request->get('additional_category_id')); + + if ($category_id > 0) { + + $event = new ProductAddCategoryEvent( + $this->getExistingObject(), + $category_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_ADD_CATEGORY, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteAdditionalCategoryAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $category_id = intval($this->getRequest()->get('additional_category_id')); + + if ($category_id > 0) { + + $event = new ProductDeleteCategoryEvent( + $this->getExistingObject(), + $category_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_REMOVE_CATEGORY, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + // -- Product combination management --------------------------------------- + + public function getAttributeValuesAction($productId, $attributeId) + { + $result = array(); + + // Get attribute for this product + $attribute = AttributeQuery::create()->findPk($attributeId); + + if ($attribute !== null) { + + $values = AttributeAvQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByAttribute($attribute) + ->find(); + ; + + if ($values !== null) { + foreach ($values as $value) { + $result[] = array('id' => $value->getId(), 'title' => $value->getTitle()); + } + } + } + + return $this->jsonResponse(json_encode($result)); + } + + public function addAttributeValueToCombinationAction($productId, $attributeAvId, $combination) + { + $result = array(); + + // Get attribute for this product + $attributeAv = AttributeAvQuery::create()->joinWithI18n($this->getCurrentEditionLocale())->findPk($attributeAvId); + + if ($attributeAv !== null) { + + $addIt = true; + + $attribute = $attributeAv->getAttribute(); + + // Check if this attribute is not already present + $combinationArray = explode(',', $combination); + + foreach ($combinationArray as $id) { + + $attrAv = AttributeAvQuery::create()->joinWithI18n($this->getCurrentEditionLocale())->findPk($id); + + if ($attrAv !== null) { + + if ($attrAv->getAttributeId() == $attribute->getId()) { + + $result['error'] = $this->getTranslator()->trans( + 'A value for attribute "%name" is already present in the combination', + array('%name' => $attribute->getTitle()) + ); + + $addIt = false; + } + + $result[] = array('id' => $attrAv->getId(), 'title' => $attrAv->getAttribute()->getTitle() . " : " . $attrAv->getTitle()); + } + } + + if ($addIt) $result[] = array('id' => $attributeAv->getId(), 'title' => $attribute->getTitle() . " : " . $attributeAv->getTitle()); + } + + return $this->jsonResponse(json_encode($result)); + } + + /** + * A a new combination to a product + */ + public function addCombinationAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $event = new ProductCreateCombinationEvent( + $this->getExistingObject(), + $this->getRequest()->get('combination_attributes', array()), + $this->getCurrentEditionCurrency()->getId() + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_ADD_COMBINATION, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + $this->redirectToEditionTemplate(); + } + + + /** + * A a new combination to a product + */ + public function deleteCombinationAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $event = new ProductDeleteCombinationEvent( + $this->getExistingObject(), + $this->getRequest()->get('product_sale_element_id',0) + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_DELETE_COMBINATION, $event); + } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php index 120a28b26..6d8d14416 100755 --- a/core/lib/Thelia/Controller/Admin/SessionController.php +++ b/core/lib/Thelia/Controller/Admin/SessionController.php @@ -31,9 +31,7 @@ use Thelia\Tools\URL; use Thelia\Tools\Redirect; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Security\Authentication\AdminTokenAuthenticator; -use Thelia\Core\Security\UserProvider\TokenProvider; use Symfony\Component\HttpFoundation\Cookie; -use Thelia\Core\Security\UserProvider\CookieTokenProvider; use Thelia\Core\Security\Exception\TokenAuthenticationException; class SessionController extends BaseAdminController @@ -59,8 +57,7 @@ class SessionController extends BaseAdminController // Render the home page return $this->render("home"); - } - catch (TokenAuthenticationException $ex) { + } catch (TokenAuthenticationException $ex) { $this->adminLogAppend("Token based authentication failed."); // Clear the cookie diff --git a/core/lib/Thelia/Controller/Admin/ShippingConfigurationController.php b/core/lib/Thelia/Controller/Admin/ShippingConfigurationController.php index 71aa0ba2f..92b73a83e 100644 --- a/core/lib/Thelia/Controller/Admin/ShippingConfigurationController.php +++ b/core/lib/Thelia/Controller/Admin/ShippingConfigurationController.php @@ -35,12 +35,11 @@ class ShippingConfigurationController extends BaseAdminController if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response; return $this->render("shipping-configuration", array("display_shipping_configuration" => 20)); } - + public function updateAction($shipping_configuration_id) { - return $this->render("shipping-configuration-edit", array( "shipping_configuration_id" => $shipping_configuration_id )); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php index ee34d11bd..0084c861b 100644 --- a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php +++ b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php @@ -35,12 +35,11 @@ class ShippingZoneController extends BaseAdminController if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response; return $this->render("shipping-zones", array("display_shipping_zone" => 20)); } - + public function updateAction($shipping_zones_id) { - - return $this->render("shipping-zones-edit", array( - "shipping_zones_id" => $shipping_zones_id - )); + return $this->render("shipping-zones-edit", array( + "shipping_zones_id" => $shipping_zones_id + )); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/TemplateController.php b/core/lib/Thelia/Controller/Admin/TemplateController.php index c9e30612c..bdeac9fd2 100644 --- a/core/lib/Thelia/Controller/Admin/TemplateController.php +++ b/core/lib/Thelia/Controller/Admin/TemplateController.php @@ -23,22 +23,19 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\TemplateDeleteEvent; +use Thelia\Core\Event\Template\TemplateDeleteEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\TemplateUpdateEvent; -use Thelia\Core\Event\TemplateCreateEvent; +use Thelia\Core\Event\Template\TemplateUpdateEvent; +use Thelia\Core\Event\Template\TemplateCreateEvent; use Thelia\Model\TemplateQuery; use Thelia\Form\TemplateModificationForm; use Thelia\Form\TemplateCreationForm; -use Thelia\Core\Event\UpdatePositionEvent; -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; +use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent; +use Thelia\Core\Event\Template\TemplateAddAttributeEvent; +use Thelia\Core\Event\Template\TemplateAddFeatureEvent; +use Thelia\Core\Event\Template\TemplateDeleteFeatureEvent; +use Thelia\Model\FeatureTemplateQuery; +use Thelia\Model\AttributeTemplateQuery; /** * Manages product templates @@ -100,7 +97,6 @@ class TemplateController extends AbstractCrudController ; // Add feature and attributes list - return $changeEvent; } @@ -197,22 +193,24 @@ class TemplateController extends AbstractCrudController return null; } - public function getAjaxFeaturesAction() { + public function getAjaxFeaturesAction() + { return $this->render( 'ajax/template-feature-list', array('template_id' => $this->getRequest()->get('template_id')) ); } - public function getAjaxAttributesAction() { + public function getAjaxAttributesAction() + { return $this->render( 'ajax/template-attribute-list', array('template_id' => $this->getRequest()->get('template_id')) ); } - public function addAttributeAction() { - + public function addAttributeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response; @@ -235,8 +233,8 @@ class TemplateController extends AbstractCrudController $this->redirectToEditionTemplate(); } - public function deleteAttributeAction() { - + public function deleteAttributeAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response; @@ -255,8 +253,23 @@ class TemplateController extends AbstractCrudController $this->redirectToEditionTemplate(); } - public function addFeatureAction() { + public function updateAttributePositionAction() + { + // Find attribute_template + $attributeTemplate = AttributeTemplateQuery::create() + ->filterByTemplateId($this->getRequest()->get('template_id', null)) + ->filterByAttributeId($this->getRequest()->get('attribute_id', null)) + ->findOne() + ; + return $this->genericUpdatePositionAction( + $attributeTemplate, + TheliaEvents::TEMPLATE_CHANGE_ATTRIBUTE_POSITION + ); + } + + public function addFeatureAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response; @@ -279,8 +292,8 @@ class TemplateController extends AbstractCrudController $this->redirectToEditionTemplate(); } - public function deleteFeatureAction() { - + public function deleteFeatureAction() + { // Check current user authorization if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response; @@ -299,4 +312,18 @@ class TemplateController extends AbstractCrudController $this->redirectToEditionTemplate(); } -} \ No newline at end of file + public function updateFeaturePositionAction() + { + // Find feature_template + $featureTemplate = FeatureTemplateQuery::create() + ->filterByTemplateId($this->getRequest()->get('template_id', null)) + ->filterByFeatureId($this->getRequest()->get('feature_id', null)) + ->findOne() + ; + + return $this->genericUpdatePositionAction( + $featureTemplate, + TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION + ); + } +} diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 8ba0cb038..51d2015ea 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -286,7 +286,7 @@ class BaseController extends ContainerAware */ protected function checkXmlHttpRequest() { - if(false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) { + if (false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) { $this->accessDenied(); } } @@ -300,6 +300,7 @@ class BaseController extends ContainerAware public function getMailer() { $mailer = $this->container->get('mailer'); + return $mailer->getSwiftMailer(); } } diff --git a/core/lib/Thelia/Controller/Front/AddressController.php b/core/lib/Thelia/Controller/Front/AddressController.php index 05e3949fa..94d0f78d7 100644 --- a/core/lib/Thelia/Controller/Front/AddressController.php +++ b/core/lib/Thelia/Controller/Front/AddressController.php @@ -22,15 +22,14 @@ /*************************************************************************************/ namespace Thelia\Controller\Front; -use Thelia\Core\Event\AddressCreateOrUpdateEvent; -use Thelia\Core\Event\AddressEvent; +use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent; +use Thelia\Core\Event\Address\AddressEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\AddressCreateForm; use Thelia\Form\AddressUpdateForm; use Thelia\Form\Exception\FormValidationException; use Thelia\Model\AddressQuery; use Thelia\Model\Customer; -use Thelia\Tools\URL; /** * Class AddressController @@ -51,10 +50,8 @@ class AddressController extends BaseFrontController $this->checkAuth(); $this->checkXmlHttpRequest(); - } - /** * Create controller. * Check if customer is logged in @@ -103,7 +100,7 @@ class AddressController extends BaseFrontController $customer = $this->getSecurityContext()->getCustomerUser(); $address = AddressQuery::create()->findPk($address_id); - if(!$address || $customer->getId() != $address->getCustomerId()) { + if (!$address || $customer->getId() != $address->getCustomerId()) { $this->redirectToRoute("home"); } @@ -117,7 +114,6 @@ class AddressController extends BaseFrontController $addressUpdate = new AddressUpdateForm($request); - try { $customer = $this->getSecurityContext()->getCustomerUser(); @@ -164,7 +160,7 @@ class AddressController extends BaseFrontController $customer = $this->getSecurityContext()->getCustomerUser(); $address = AddressQuery::create()->findPk($address_id); - if(!$address || $customer->getId() != $address->getCustomerId()) { + if (!$address || $customer->getId() != $address->getCustomerId()) { $this->redirectToRoute("home"); } diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index b8a7c6a98..fadf65795 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -24,6 +24,8 @@ namespace Thelia\Controller\Front; use Symfony\Component\Routing\Router; use Thelia\Controller\BaseController; +use Thelia\Model\AddressQuery; +use Thelia\Model\ModuleQuery; use Thelia\Tools\URL; class BaseFrontController extends BaseController @@ -53,7 +55,7 @@ class BaseFrontController extends BaseController public function checkAuth() { - if($this->getSecurityContext()->hasCustomerUser() === false) { + if ($this->getSecurityContext()->hasCustomerUser() === false) { $this->redirectToRoute("customer.login.view"); } } @@ -61,7 +63,7 @@ class BaseFrontController extends BaseController protected function checkCartNotEmpty() { $cart = $this->getSession()->getCart(); - if($cart===null || $cart->countCartItems() == 0) { + if ($cart===null || $cart->countCartItems() == 0) { $this->redirectToRoute("cart.view"); } } @@ -69,7 +71,7 @@ class BaseFrontController extends BaseController protected function checkValidDelivery() { $order = $this->getSession()->getOrder(); - if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) { + if (null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) { $this->redirectToRoute("order.delivery"); } } @@ -77,7 +79,7 @@ class BaseFrontController extends BaseController protected function checkValidInvoice() { $order = $this->getSession()->getOrder(); - if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId()) { + if (null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) { $this->redirectToRoute("order.invoice"); } } diff --git a/core/lib/Thelia/Controller/Front/CartController.php b/core/lib/Thelia/Controller/Front/CartController.php index e13ecd61b..ae116b40a 100755 --- a/core/lib/Thelia/Controller/Front/CartController.php +++ b/core/lib/Thelia/Controller/Front/CartController.php @@ -24,7 +24,7 @@ namespace Thelia\Controller\Front; use Propel\Runtime\Exception\PropelException; use Thelia\Form\Exception\FormValidationException; -use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\Cart\CartEvent; use Thelia\Core\Event\TheliaEvents; use Symfony\Component\HttpFoundation\Request; use Thelia\Form\CartAdd; @@ -102,7 +102,7 @@ class CartController extends BaseFrontController /** * use Thelia\Cart\CartTrait for searching current cart or create a new one * - * @return CartEvent + * @return \Thelia\Core\Event\Cart\CartEvent */ protected function getCartEvent() { diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 3b8c2ccff..f322d3fe1 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -22,8 +22,8 @@ /*************************************************************************************/ namespace Thelia\Controller\Front; -use Thelia\Core\Event\CustomerCreateOrUpdateEvent; -use Thelia\Core\Event\CustomerLoginEvent; +use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; +use Thelia\Core\Event\Customer\CustomerLoginEvent; use Thelia\Core\Event\LostPasswordEvent; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Exception\AuthenticationException; @@ -104,7 +104,7 @@ class CustomerController extends BaseFrontController $this->processLogin($customerCreateEvent->getCustomer()); $cart = $this->getCart($this->getRequest()); - if($cart->getCartItems()->count() > 0) { + if ($cart->getCartItems()->count() > 0) { $this->redirectToRoute("cart.view"); } else { $this->redirectSuccess($customerCreation); @@ -257,7 +257,7 @@ class CustomerController extends BaseFrontController /** * @param $data - * @return CustomerCreateOrUpdateEvent + * @return \Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent */ private function createEventInstance($data) { diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php index 53d1e070b..968597b8a 100755 --- a/core/lib/Thelia/Controller/Front/OrderController.php +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -23,8 +23,9 @@ namespace Thelia\Controller\Front; use Propel\Runtime\Exception\PropelException; +use Thelia\Exception\TheliaProcessException; use Thelia\Form\Exception\FormValidationException; -use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Symfony\Component\HttpFoundation\Request; use Thelia\Form\OrderDelivery; @@ -32,9 +33,10 @@ use Thelia\Form\OrderPayment; use Thelia\Log\Tlog; use Thelia\Model\AddressQuery; use Thelia\Model\AreaDeliveryModuleQuery; -use Thelia\Model\CountryQuery; +use Thelia\Model\Base\OrderQuery; use Thelia\Model\ModuleQuery; use Thelia\Model\Order; +use Thelia\Tools\URL; /** * Class OrderController @@ -66,7 +68,7 @@ class OrderController extends BaseFrontController /* check that the delivery address belongs to the current customer */ $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); - if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { + if ($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { throw new \Exception("Delivery address does not belong to the current customer"); } @@ -78,11 +80,8 @@ class OrderController extends BaseFrontController throw new \Exception("Delivery module cannot be use with selected delivery address"); } - /* try to get postage amount */ + /* get postage amount */ $moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace()); - if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) { - throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode())); - } $moduleInstance = $moduleReflection->newInstance(); $postage = $moduleInstance->getPostage($deliveryAddress->getCountry()); @@ -139,7 +138,7 @@ class OrderController extends BaseFrontController /* check that the invoice address belongs to the current customer */ $invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId); - if($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { + if ($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { throw new \Exception("Invoice address does not belong to the current customer"); } @@ -190,6 +189,36 @@ class OrderController extends BaseFrontController $orderEvent = $this->getOrderEvent(); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent); + + $placedOrder = $orderEvent->getPlacedOrder(); + + if (null !== $placedOrder && null !== $placedOrder->getId()) { + /* order has been placed */ + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId())))); + } else { + /* order has not been placed */ + $this->redirectToRoute("cart.view"); + } + } + + public function orderPlaced($order_id) + { + /* check if the placed order matched the customer */ + $placedOrder = OrderQuery::create()->findPk( + $this->getRequest()->attributes->get('order_id') + ); + + if (null === $placedOrder) { + throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder); + } + + $customer = $this->getSecurityContext()->getCustomerUser(); + + if (null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) { + throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder); + } + + $this->getParserContext()->set("placed_order_id", $placedOrder->getId()); } protected function getOrderEvent() diff --git a/core/lib/Thelia/Core/Event/AddressCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Address/AddressCreateOrUpdateEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/AddressCreateOrUpdateEvent.php rename to core/lib/Thelia/Core/Event/Address/AddressCreateOrUpdateEvent.php index 01e615ff6..05fc909d2 100644 --- a/core/lib/Thelia/Core/Event/AddressCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Address/AddressCreateOrUpdateEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Address; use Symfony\Component\EventDispatcher\Event; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Address; use Thelia\Model\Customer; @@ -243,8 +244,6 @@ class AddressCreateOrUpdateEvent extends ActionEvent return $this->isDefault; } - - /** * @param \Thelia\Model\Customer $customer */ diff --git a/core/lib/Thelia/Core/Event/AddressEvent.php b/core/lib/Thelia/Core/Event/Address/AddressEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/AddressEvent.php rename to core/lib/Thelia/Core/Event/Address/AddressEvent.php index 366801075..d36fd7cab 100644 --- a/core/lib/Thelia/Core/Event/AddressEvent.php +++ b/core/lib/Thelia/Core/Event/Address/AddressEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Address; use Symfony\Component\EventDispatcher\Event; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Address; /** diff --git a/core/lib/Thelia/Core/Event/AttributeAvCreateEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeAvCreateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/AttributeAvCreateEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeAvCreateEvent.php index 81d22cfb9..b0b0ee6a3 100644 --- a/core/lib/Thelia/Core/Event/AttributeAvCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeAvCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; + +use Thelia\Core\Event\Attribute\AttributeAvEvent; class AttributeAvCreateEvent extends AttributeAvEvent { diff --git a/core/lib/Thelia/Core/Event/AttributeAvDeleteEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeAvDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/AttributeAvDeleteEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeAvDeleteEvent.php index d710dc23f..515764e3d 100644 --- a/core/lib/Thelia/Core/Event/AttributeAvDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeAvDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; + +use Thelia\Core\Event\Attribute\AttributeAvEvent; class AttributeAvDeleteEvent extends AttributeAvEvent { diff --git a/core/lib/Thelia/Core/Event/AttributeAvEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeAvEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/AttributeAvEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeAvEvent.php index c6c1726bd..3dcf1e889 100644 --- a/core/lib/Thelia/Core/Event/AttributeAvEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeAvEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\AttributeAv; class AttributeAvEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/AttributeAvUpdateEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeAvUpdateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/AttributeAvUpdateEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeAvUpdateEvent.php index c76198954..318ec5817 100644 --- a/core/lib/Thelia/Core/Event/AttributeAvUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeAvUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; + +use Thelia\Core\Event\Attribute\AttributeAvCreateEvent; class AttributeAvUpdateEvent extends AttributeAvCreateEvent { diff --git a/core/lib/Thelia/Core/Event/AttributeCreateEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeCreateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/AttributeCreateEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeCreateEvent.php index 0787b34e3..155560de0 100644 --- a/core/lib/Thelia/Core/Event/AttributeCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; + +use Thelia\Core\Event\Attribute\AttributeEvent; class AttributeCreateEvent extends AttributeEvent { diff --git a/core/lib/Thelia/Core/Event/AttributeDeleteEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/AttributeDeleteEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeDeleteEvent.php index d7f359f9a..d4ee6227b 100644 --- a/core/lib/Thelia/Core/Event/AttributeDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; + +use Thelia\Core\Event\Attribute\AttributeEvent; class AttributeDeleteEvent extends AttributeEvent { diff --git a/core/lib/Thelia/Core/Event/AttributeEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/AttributeEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeEvent.php index 7ce78938c..471505270 100644 --- a/core/lib/Thelia/Core/Event/AttributeEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Attribute; class AttributeEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/AttributeUpdateEvent.php b/core/lib/Thelia/Core/Event/Attribute/AttributeUpdateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/AttributeUpdateEvent.php rename to core/lib/Thelia/Core/Event/Attribute/AttributeUpdateEvent.php index a1bf124d9..d692586e4 100644 --- a/core/lib/Thelia/Core/Event/AttributeUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Attribute/AttributeUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Attribute; + +use Thelia\Core\Event\Attribute\AttributeCreateEvent; class AttributeUpdateEvent extends AttributeCreateEvent { diff --git a/core/lib/Thelia/Core/Event/CartEvent.php b/core/lib/Thelia/Core/Event/Cart/CartEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/CartEvent.php rename to core/lib/Thelia/Core/Event/Cart/CartEvent.php index b24a5c403..4e1ed304d 100755 --- a/core/lib/Thelia/Core/Event/CartEvent.php +++ b/core/lib/Thelia/Core/Event/Cart/CartEvent.php @@ -21,9 +21,10 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Cart; use Symfony\Component\EventDispatcher\Event; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Cart; class CartEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/CartItemEvent.php b/core/lib/Thelia/Core/Event/Cart/CartItemEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CartItemEvent.php rename to core/lib/Thelia/Core/Event/Cart/CartItemEvent.php index 6718b63ff..83cbd17c0 100755 --- a/core/lib/Thelia/Core/Event/CartItemEvent.php +++ b/core/lib/Thelia/Core/Event/Cart/CartItemEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Cart; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\CartItem; class CartItemEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryAddContentEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CategoryAddContentEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryAddContentEvent.php index 3ca5b2ae5..115eae724 100644 --- a/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryAddContentEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; +use Thelia\Core\Event\Category\CategoryEvent; use Thelia\Model\Category; class CategoryAddContentEvent extends CategoryEvent diff --git a/core/lib/Thelia/Core/Event/CategoryAssociatedContentEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryAssociatedContentEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/CategoryAssociatedContentEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryAssociatedContentEvent.php index 1984a042c..6593419ef 100644 --- a/core/lib/Thelia/Core/Event/CategoryAssociatedContentEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryAssociatedContentEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; use Thelia\Model\CategoryAssociatedContent; use Thelia\Core\Event\ActionEvent; diff --git a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryCreateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CategoryCreateEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryCreateEvent.php index 41529019c..870b0beb8 100644 --- a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; + +use Thelia\Core\Event\Category\CategoryEvent; class CategoryCreateEvent extends CategoryEvent { diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryDeleteContentEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryDeleteContentEvent.php index bb28beb21..01a92a1b8 100644 --- a/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryDeleteContentEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; +use Thelia\Core\Event\Category\CategoryEvent; use Thelia\Model\Category; class CategoryDeleteContentEvent extends CategoryEvent diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CategoryDeleteEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryDeleteEvent.php index 9d77a7e87..a81d9c7ad 100644 --- a/core/lib/Thelia/Core/Event/CategoryDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; + +use Thelia\Core\Event\Category\CategoryEvent; class CategoryDeleteEvent extends CategoryEvent { diff --git a/core/lib/Thelia/Core/Event/CategoryEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/CategoryEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryEvent.php index ab5b101e5..ae0cb3b4a 100644 --- a/core/lib/Thelia/Core/Event/CategoryEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; use Thelia\Model\Category; use Thelia\Core\Event\ActionEvent; diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryToggleVisibilityEvent.php similarity index 95% rename from core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryToggleVisibilityEvent.php index f90378e38..3d580701a 100644 --- a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryToggleVisibilityEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; + +use Thelia\Core\Event\Category\CategoryEvent; class CategoryToggleVisibilityEvent extends CategoryEvent { diff --git a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php b/core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/CategoryUpdateEvent.php rename to core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php index f5f775a22..d04e8da08 100644 --- a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Category/CategoryUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Category; + +use Thelia\Core\Event\Category\CategoryCreateEvent; class CategoryUpdateEvent extends CategoryCreateEvent { diff --git a/core/lib/Thelia/Constraint/Validator/QuantityParam.php b/core/lib/Thelia/Core/Event/Condition/ConditionCreateOrUpdateEvent.php similarity index 56% rename from core/lib/Thelia/Constraint/Validator/QuantityParam.php rename to core/lib/Thelia/Core/Event/Condition/ConditionCreateOrUpdateEvent.php index ac6fcf851..58fdb10fe 100644 --- a/core/lib/Thelia/Constraint/Validator/QuantityParam.php +++ b/core/lib/Thelia/Core/Event/Condition/ConditionCreateOrUpdateEvent.php @@ -21,76 +21,86 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Validator; +namespace Thelia\Core\Event\Condition; -use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Core\Event\ActionEvent; +use Thelia\Coupon\ConditionCollection; +use Thelia\Coupon\Type\CouponInterface; /** * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM + * Date: 8/29/13 + * Time: 3:45 PM * - * Represent a Quantity + * Occurring when a Condition is created or updated * - * @package Constraint + * @package Coupon * @author Guillaume MOREL * */ -class QuantityParam extends IntegerParam +class ConditionCreateOrUpdateEvent extends ActionEvent { + /** @var ConditionCollection Array of ConditionManagerInterface */ + protected $conditions = null; + + /** @var CouponInterface Coupon model associated with this conditions */ + protected $couponModel = null; /** * Constructor * - * @param CouponAdapterInterface $adapter Provide necessary value from Thelia - * @param int $integer Integer + * @param ConditionCollection $conditions Array of ConditionManagerInterface */ - public function __construct(CouponAdapterInterface $adapter, $integer) + public function __construct(ConditionCollection $conditions) { - $this->integer = $integer; - $this->adapter = $adapter; + $this->conditions = $conditions; } /** - * Compare the current object to the passed $other. + * Get Conditions * - * Returns 0 if they are semantically equal, 1 if the other object - * is less than the current one, or -1 if its more than the current one. - * - * This method should not check for identity using ===, only for semantically equality for example - * when two different DateTime instances point to the exact same Date + TZ. - * - * @param mixed $other Object - * - * @throws \InvalidArgumentException - * @return int + * @return null|ConditionCollection Array of ConditionManagerInterface */ - public function compareTo($other) + public function getConditions() { - if (!is_integer($other) || $other < 0) { - throw new \InvalidArgumentException( - 'IntegerParam can compare only positive int' - ); - } - - return parent::compareTo($other); + return $this->conditions; } - /** - * Get I18n tooltip + * Set Conditions * - * @return string + * @param ConditionCollection $conditions Array of ConditionManagerInterface + * + * @return $this */ - public function getToolTip() + public function setConditions(ConditionCollection $conditions) { - return $this->adapter - ->getTranslator() - ->trans( - 'A positive quantity (ex: 42)', - null, - 'constraint' - ); + $this->conditions = $conditions; + + return $this; } + /** + * Set Coupon Model associated to this condition + * + * @param CouponInterface $couponModel Coupon Model + * + * @return $this + */ + public function setCouponModel($couponModel) + { + $this->couponModel = $couponModel; + + return $this; + } + + /** + * Get Coupon Model associated to this condition + * + * @return null|CouponInterface + */ + public function getCouponModel() + { + return $this->couponModel; + } } diff --git a/core/lib/Thelia/Core/Event/ConfigCreateEvent.php b/core/lib/Thelia/Core/Event/Config/ConfigCreateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/ConfigCreateEvent.php rename to core/lib/Thelia/Core/Event/Config/ConfigCreateEvent.php index 986eb31b7..86cd5c84f 100644 --- a/core/lib/Thelia/Core/Event/ConfigCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Config/ConfigCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Config; + +use Thelia\Core\Event\Config\ConfigEvent; class ConfigCreateEvent extends ConfigEvent { diff --git a/core/lib/Thelia/Core/Event/ConfigDeleteEvent.php b/core/lib/Thelia/Core/Event/Config/ConfigDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/ConfigDeleteEvent.php rename to core/lib/Thelia/Core/Event/Config/ConfigDeleteEvent.php index 87ae50c38..f225e49b5 100644 --- a/core/lib/Thelia/Core/Event/ConfigDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Config/ConfigDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Config; + +use Thelia\Core\Event\Config\ConfigEvent; class ConfigDeleteEvent extends ConfigEvent { diff --git a/core/lib/Thelia/Core/Event/ConfigEvent.php b/core/lib/Thelia/Core/Event/Config/ConfigEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/ConfigEvent.php rename to core/lib/Thelia/Core/Event/Config/ConfigEvent.php index 646b43856..d2dab3f87 100644 --- a/core/lib/Thelia/Core/Event/ConfigEvent.php +++ b/core/lib/Thelia/Core/Event/Config/ConfigEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Config; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Config; class ConfigEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/ConfigUpdateEvent.php b/core/lib/Thelia/Core/Event/Config/ConfigUpdateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/ConfigUpdateEvent.php rename to core/lib/Thelia/Core/Event/Config/ConfigUpdateEvent.php index b3d5955c4..f37f6ab55 100644 --- a/core/lib/Thelia/Core/Event/ConfigUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Config/ConfigUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Config; + +use Thelia\Core\Event\Config\ConfigCreateEvent; class ConfigUpdateEvent extends ConfigCreateEvent { diff --git a/core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php b/core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php new file mode 100644 index 000000000..a1d1d44e1 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php @@ -0,0 +1,66 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; +use Thelia\Model\Content; + + +/** + * Class ContentAddFolderEvent + * @package Thelia\Core\Event\Content + * @author Manuel Raynaud + */ +class ContentAddFolderEvent extends ContentEvent +{ + + /** + * @var int folder id + */ + protected $folderId; + + public function __construct(Content $content, $folderId) + { + $this->folderId = $folderId; + + parent::__construct($content); + } + + /** + * @param int $folderId + */ + public function setFolderId($folderId) + { + $this->folderId = $folderId; + } + + /** + * @return int + */ + public function getFolderId() + { + return $this->folderId; + } + + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php b/core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php new file mode 100644 index 000000000..7763fd359 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php @@ -0,0 +1,118 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; + +/** + * Class ContentCreateEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud + */ +class ContentCreateEvent extends ContentEvent +{ + protected $title; + protected $default_folder; + protected $locale; + protected $visible; + + /** + * @param mixed $locale + * + * @return $this + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + /** + * @return mixed + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @param mixed $default_folder + * + * @return $this + */ + public function setDefaultFolder($default_folder) + { + $this->default_folder = $default_folder; + + return $this; + } + + /** + * @return mixed + */ + public function getDefaultFolder() + { + return $this->default_folder; + } + + /** + * @param mixed $visible + * + * @return $this + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * @return mixed + */ + public function getVisible() + { + return $this->visible; + } + + /** + * @param mixed $title + * + * @return $this + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + +} diff --git a/core/lib/Thelia/Constraint/Validator/RuleParameterAbstract.php b/core/lib/Thelia/Core/Event/Content/ContentDeleteEvent.php similarity index 53% rename from core/lib/Thelia/Constraint/Validator/RuleParameterAbstract.php rename to core/lib/Thelia/Core/Event/Content/ContentDeleteEvent.php index 2be4c581f..8ad5b1c6f 100644 --- a/core/lib/Thelia/Constraint/Validator/RuleParameterAbstract.php +++ b/core/lib/Thelia/Core/Event/Content/ContentDeleteEvent.php @@ -1,67 +1,72 @@ . */ -/* */ -/**********************************************************************************/ +/*************************************************************************************/ +/* */ +/* 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 . */ +/* */ +/*************************************************************************************/ -namespace Thelia\Constraint\Validator; - -use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Exception\NotImplementedException; +namespace Thelia\Core\Event\Content; /** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Get a Param value - * - * @package Constraint - * @author Guillaume MOREL - * + * Class ContentDeleteEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud */ -abstract class RuleParameterAbstract implements ComparableInterface +class ContentDeleteEvent extends ContentEvent { - /** @var Translator Service Translator */ - protected $translator = null; + protected $content_id; + + protected $folder_id; + + public function __construct($content_id) + { + $this->content_id = $content_id; + } /** - * Get Parameter value to test against + * @param mixed $content_id * + * @return $this + */ + public function setContentId($content_id) + { + $this->content_id = $content_id; + + return $this; + } + + /** * @return mixed */ - public function getValue() + public function getContentId() { - return new NotImplementedException(); + return $this->content_id; } - /** - * Get I18n tooltip - * - * @return string - */ - public function getToolTip() + public function setDefaultFolderId($folderid) { - return new NotImplementedException(); + $this->folder_id = $folderid; } + public function getDefaultFolderId() + { + return $this->folder_id; + } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Content/ContentEvent.php b/core/lib/Thelia/Core/Event/Content/ContentEvent.php new file mode 100644 index 000000000..aebda8d28 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentEvent.php @@ -0,0 +1,72 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Content; + +/** + * Class ContentEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud + */ +class ContentEvent extends ActionEvent +{ + /** + * @var \Thelia\Model\Content + */ + protected $content; + + public function __construct(Content $content = null) + { + $this->content = $content; + } + + /** + * @param \Thelia\Model\Content $content + */ + public function setContent(Content $content) + { + $this->content = $content; + + return $this; + } + + /** + * @return \Thelia\Model\Content + */ + public function getContent() + { + return $this->content; + } + + /** + * check if content exists + * + * @return bool + */ + public function hasContent() + { + return null !== $this->content; + } +} diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountForCategoryY.php b/core/lib/Thelia/Core/Event/Content/ContentRemoveFolderEvent.php similarity index 65% rename from core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountForCategoryY.php rename to core/lib/Thelia/Core/Event/Content/ContentRemoveFolderEvent.php index 0f9f7f10b..195f4f3b0 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountForCategoryY.php +++ b/core/lib/Thelia/Core/Event/Content/ContentRemoveFolderEvent.php @@ -1,38 +1,34 @@ . */ -/* */ -/**********************************************************************************/ +/*************************************************************************************/ +/* */ +/* 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 . */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; -namespace Thelia\Constraint\Rule; /** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * @package Constraint - * @author Guillaume MOREL - * + * Class ContentRemoveFolderEvent + * @package Thelia\Core\Event\Content + * @author Manuel Raynaud */ -class AvailableForTotalAmountForCategoryY extends AvailableForTotalAmount +class ContentRemoveFolderEvent extends ContentAddFolderEvent { - } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Content/ContentToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/Content/ContentToggleVisibilityEvent.php new file mode 100644 index 000000000..b2b7e46e9 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentToggleVisibilityEvent.php @@ -0,0 +1,34 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; + +/** + * Class ContentToggleVisibilityEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud + */ +class ContentToggleVisibilityEvent extends ContentEvent +{ + +} diff --git a/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php b/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php new file mode 100644 index 000000000..fb5bdfb5e --- /dev/null +++ b/core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php @@ -0,0 +1,146 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Content; + +/** + * Class ContentUpdateEvent + * @package Thelia\Core\Event\Content + * @author manuel raynaud + */ +class ContentUpdateEvent extends ContentCreateEvent +{ + protected $content_id; + + protected $chapo; + protected $description; + protected $postscriptum; + + protected $url; + + public function __construct($content_id) + { + $this->content_id = $content_id; + } + + /** + * @param mixed $chapo + * + * @return $this + */ + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + /** + * @return mixed + */ + public function getChapo() + { + return $this->chapo; + } + + /** + * @param mixed $content_id + * + * @return $this + */ + public function setContentId($content_id) + { + $this->content_id = $content_id; + + return $this; + } + + /** + * @return mixed + */ + public function getContentId() + { + return $this->content_id; + } + + /** + * @param mixed $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param mixed $postscriptum + * + * @return $this + */ + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } + + /** + * @return mixed + */ + public function getPostscriptum() + { + return $this->postscriptum; + } + + /** + * @param mixed $url + * + * @return $this + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + +} diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php index df5cef7a9..ace8cb0b7 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponConsumeEvent.php @@ -23,8 +23,6 @@ namespace Thelia\Core\Event\Coupon; use Thelia\Core\Event\ActionEvent; -use Thelia\Coupon\CouponRuleCollection; -use Thelia\Model\Coupon; /** * Created by JetBrains PhpStorm. @@ -56,7 +54,7 @@ class CouponConsumeEvent extends ActionEvent * @param bool $isValid If Coupon is valid or * if Customer meets coupon conditions */ - function __construct($code, $discount = null, $isValid = null) + public function __construct($code, $discount = null, $isValid = null) { $this->code = $code; $this->discount = $discount; @@ -136,7 +134,4 @@ class CouponConsumeEvent extends ActionEvent return $this->isValid; } - - - } diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php index 2e004b818..3dfca3d4a 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Event\Coupon; use Thelia\Core\Event\ActionEvent; -use Thelia\Coupon\CouponRuleCollection; +use Thelia\Coupon\ConditionCollection; use Thelia\Model\Coupon; /** @@ -39,8 +39,8 @@ use Thelia\Model\Coupon; */ class CouponCreateOrUpdateEvent extends ActionEvent { - /** @var CouponRuleCollection Array of CouponRuleInterface */ - protected $rules = null; + /** @var ConditionCollection Array of ConditionManagerInterface */ + protected $conditions = null; /** @var string Coupon code (ex: XMAS) */ protected $code = null; @@ -78,8 +78,8 @@ class CouponCreateOrUpdateEvent extends ActionEvent /** @var Coupon Coupon model */ protected $coupon = null; - /** @var string Coupon effect */ - protected $effect; + /** @var string Coupon type */ + protected $type; /** @var string Language code ISO (ex: fr_FR) */ protected $locale = null; @@ -87,37 +87,24 @@ class CouponCreateOrUpdateEvent extends ActionEvent /** * Constructor * - * @param string $code Coupon Code - * @param string $title Coupon title - * @param float $amount Amount removed from the Total Checkout - * @param string $effect Coupon effect - * @param string $shortDescription Coupon short description - * @param string $description Coupon description - * @param boolean $isEnabled Enable/Disable - * @param \DateTime $expirationDate Coupon expiration date - * @param boolean $isAvailableOnSpecialOffers Is available on special offers - * @param boolean $isCumulative Is cumulative - * @param boolean $isRemovingPostage Is removing Postage - * @param int $maxUsage Coupon quantity - * @param CouponRuleCollection $rules CouponRuleInterface to add - * @param string $locale Coupon Language code ISO (ex: fr_FR) + * @param string $code Coupon Code + * @param string $title Coupon title + * @param float $amount Amount removed from the Total Checkout + * @param string $type Coupon type + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param bool $isEnabled Enable/Disable + * @param \DateTime $expirationDate Coupon expiration date + * @param boolean $isAvailableOnSpecialOffers Is available on special offers + * @param boolean $isCumulative Is cumulative + * @param boolean $isRemovingPostage Is removing Postage + * @param int $maxUsage Coupon quantity + * @param string $locale Coupon Language code ISO (ex: fr_FR) */ public function __construct( - $code, - $title, - $amount, - $effect, - $shortDescription, - $description, - $isEnabled, - \DateTime $expirationDate, - $isAvailableOnSpecialOffers, - $isCumulative, - $isRemovingPostage, - $maxUsage, - $rules, - $locale - ) { + $code, $title, $amount, $type, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale + ) + { $this->amount = $amount; $this->code = $code; $this->description = $description; @@ -127,10 +114,9 @@ class CouponCreateOrUpdateEvent extends ActionEvent $this->isEnabled = $isEnabled; $this->isRemovingPostage = $isRemovingPostage; $this->maxUsage = $maxUsage; - $this->rules = $rules; $this->shortDescription = $shortDescription; $this->title = $title; - $this->effect = $effect; + $this->type = $type; $this->locale = $locale; } @@ -206,22 +192,6 @@ class CouponCreateOrUpdateEvent extends ActionEvent return $this->amount; } - /** - * Return condition to validate the Coupon or not - * - * @return CouponRuleCollection - */ - public function getRules() - { - if ($this->rules === null || !is_object($this->rules)) { - $rules = $this->rules; - } else { - $rules = clone $this->rules; - } - - return $rules; - } - /** * Return Coupon expiration date * @@ -264,13 +234,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent } /** - * Get Coupon effect + * Get Coupon type (effect) * * @return string */ - public function getEffect() + public function getType() { - return $this->effect; + return $this->type; } /** @@ -307,4 +277,28 @@ class CouponCreateOrUpdateEvent extends ActionEvent return $this->coupon; } + /** + * Get Rules + * + * @return null|ConditionCollection Array of ConditionManagerInterface + */ + public function getConditions() + { + return $this->conditions; + } + + /** + * set Rules + * + * @param ConditionCollection $rules Array of ConditionManagerInterface + * + * @return $this + */ + public function setConditions(ConditionCollection $rules) + { + $this->conditions = $rules; + + return $this; + } + } diff --git a/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php b/core/lib/Thelia/Core/Event/Currency/CurrencyCreateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/CurrencyCreateEvent.php rename to core/lib/Thelia/Core/Event/Currency/CurrencyCreateEvent.php index fe2cf078c..45f5a1bbe 100644 --- a/core/lib/Thelia/Core/Event/CurrencyCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Currency/CurrencyCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Currency; + +use Thelia\Core\Event\Currency\CurrencyEvent; class CurrencyCreateEvent extends CurrencyEvent { diff --git a/core/lib/Thelia/Core/Event/CurrencyDeleteEvent.php b/core/lib/Thelia/Core/Event/Currency/CurrencyDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CurrencyDeleteEvent.php rename to core/lib/Thelia/Core/Event/Currency/CurrencyDeleteEvent.php index 706b77f9d..0845d4b9a 100644 --- a/core/lib/Thelia/Core/Event/CurrencyDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Currency/CurrencyDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Currency; + +use Thelia\Core\Event\Currency\CurrencyEvent; class CurrencyDeleteEvent extends CurrencyEvent { diff --git a/core/lib/Thelia/Core/Event/CurrencyEvent.php b/core/lib/Thelia/Core/Event/Currency/CurrencyEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CurrencyEvent.php rename to core/lib/Thelia/Core/Event/Currency/CurrencyEvent.php index cdc0b854c..47f91b81d 100644 --- a/core/lib/Thelia/Core/Event/CurrencyEvent.php +++ b/core/lib/Thelia/Core/Event/Currency/CurrencyEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Currency; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Currency; class CurrencyEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/CurrencyUpdateEvent.php b/core/lib/Thelia/Core/Event/Currency/CurrencyUpdateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CurrencyUpdateEvent.php rename to core/lib/Thelia/Core/Event/Currency/CurrencyUpdateEvent.php index 58f8b0af4..2d9e6e72b 100644 --- a/core/lib/Thelia/Core/Event/CurrencyUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Currency/CurrencyUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Currency; + +use Thelia\Core\Event\Currency\CurrencyCreateEvent; class CurrencyUpdateEvent extends CurrencyCreateEvent { diff --git a/core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Customer/CustomerCreateOrUpdateEvent.php similarity index 95% rename from core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php rename to core/lib/Thelia/Core/Event/Customer/CustomerCreateOrUpdateEvent.php index d3ae6f62d..2c59c2899 100755 --- a/core/lib/Thelia/Core/Event/CustomerCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Customer/CustomerCreateOrUpdateEvent.php @@ -20,9 +20,10 @@ /* along with this program. If not, see . */ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Customer; use Symfony\Component\EventDispatcher\Event; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Customer; /** @@ -58,7 +59,7 @@ class CustomerCreateOrUpdateEvent extends ActionEvent protected $customer; /** - * @param int $title the title customer id + * @param int $title the title customer id * @param string $firstname * @param string $lastname * @param string $address1 @@ -68,13 +69,13 @@ class CustomerCreateOrUpdateEvent extends ActionEvent * @param string $cellphone * @param string $zipcode * @param string $city - * @param int $country the country id + * @param int $country the country id * @param string $email * @param string $password plain password, don't put hash password, it will hashes again * @param $lang - * @param int $reseller if customer is a reseller - * @param int $sponsor customer's id sponsor - * @param float $discount + * @param int $reseller if customer is a reseller + * @param int $sponsor customer's id sponsor + * @param float $discount * @param string $company */ public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount, $company) diff --git a/core/lib/Thelia/Core/Event/CustomerEvent.php b/core/lib/Thelia/Core/Event/Customer/CustomerEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/CustomerEvent.php rename to core/lib/Thelia/Core/Event/Customer/CustomerEvent.php index 191b67e78..f11bb7f2d 100755 --- a/core/lib/Thelia/Core/Event/CustomerEvent.php +++ b/core/lib/Thelia/Core/Event/Customer/CustomerEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Customer; use Thelia\Model\Customer; use Thelia\Core\Event\ActionEvent; diff --git a/core/lib/Thelia/Core/Event/CustomerLoginEvent.php b/core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/CustomerLoginEvent.php rename to core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php index e43968845..56c29bf6c 100755 --- a/core/lib/Thelia/Core/Event/CustomerLoginEvent.php +++ b/core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Customer; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Customer; class CustomerLoginEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/Document/DocumentCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Document/DocumentCreateOrUpdateEvent.php new file mode 100755 index 000000000..74deeacc1 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Document/DocumentCreateOrUpdateEvent.php @@ -0,0 +1,217 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Document; +use Symfony\Component\HttpFoundation\File\UploadedFile; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\CategoryDocument; +use Thelia\Model\ContentDocument; +use Thelia\Model\FolderDocument; +use Thelia\Model\ProductDocument; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Occurring when a Document is saved + * + * @package Document + * @author Guillaume MOREL + * + */ +class DocumentCreateOrUpdateEvent extends ActionEvent +{ + + /** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument model to save */ + protected $modelDocument = array(); + + /** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument model to save */ + protected $oldModelDocument = array(); + + /** @var UploadedFile Document file to save */ + protected $uploadedFile = null; + + /** @var int Document parent id */ + protected $parentId = null; + + /** @var string Document type */ + protected $documentType = null; + + /** @var string Parent name */ + protected $parentName = null; + + /** + * Constructor + * + * @param string $documentType Document type + * ex : FileManager::TYPE_CATEGORY + * @param int $parentId Document parent id + */ + public function __construct($documentType, $parentId) + { + $this->documentType = $documentType; + $this->parentId = $parentId; + } + + /** + * Set Document to save + * + * @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $document Document to save + * + * @return $this + */ + public function setModelDocument($document) + { + $this->modelDocument = $document; + + return $this; + } + + /** + * Get Document being saved + * + * @return CategoryDocument|ProductDocument|ContentDocument|FolderDocument + */ + public function getModelDocument() + { + return $this->modelDocument; + } + + /** + * Set document type + * + * @param string $documentType Document type + * + * @return $this + */ + public function setDocumentType($documentType) + { + $this->documentType = $documentType; + + return $this; + } + + /** + * Get document type + * + * @return string + */ + public function getDocumentType() + { + return $this->documentType; + } + + /** + * Set Document parent id + * + * @param int $parentId Document parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get Document parent id + * + * @return int + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set uploaded file + * + * @param UploadedFile $uploadedFile File being uploaded + * + * @return $this + */ + public function setUploadedFile($uploadedFile) + { + $this->uploadedFile = $uploadedFile; + + return $this; + } + + /** + * Get uploaded file + * + * @return UploadedFile + */ + public function getUploadedFile() + { + return $this->uploadedFile; + } + + /** + * Set parent name + * + * @param string $parentName Parent name + * + * @return $this + */ + public function setParentName($parentName) + { + $this->parentName = $parentName; + + return $this; + } + + /** + * Get parent name + * + * @return string + */ + public function getParentName() + { + return $this->parentName; + } + + /** + * Set old model value + * + * @param CategoryDocument|ContentDocument|FolderDocument|ProductDocument $oldModelDocument + */ + public function setOldModelDocument($oldModelDocument) + { + $this->oldModelDocument = $oldModelDocument; + } + + /** + * Get old model value + * + * @return CategoryDocument|ContentDocument|FolderDocument|ProductDocument + */ + public function getOldModelDocument() + { + return $this->oldModelDocument; + } + +} diff --git a/core/lib/Thelia/Core/Event/Document/DocumentDeleteEvent.php b/core/lib/Thelia/Core/Event/Document/DocumentDeleteEvent.php new file mode 100755 index 000000000..28a51a208 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Document/DocumentDeleteEvent.php @@ -0,0 +1,112 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Document; + +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\CategoryDocument; +use Thelia\Model\ContentDocument; +use Thelia\Model\FolderDocument; +use Thelia\Model\ProductDocument; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Occurring when a Document is about to be deleted + * + * @package Document + * @author Guillaume MOREL + * + */ +class DocumentDeleteEvent extends ActionEvent +{ + /** @var string Document type */ + protected $documentType = null; + + /** @var CategoryDocument|ProductDocument|ContentDocument|FolderDocument Document about to be deleted */ + protected $documentToDelete = null; + + /** + * Constructor + * + * @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted + * @param string $documentType Document type + * ex : FileManager::TYPE_CATEGORY + */ + public function __construct($documentToDelete, $documentType) + { + $this->documentToDelete = $documentToDelete; + $this->documentType = $documentType; + } + + /** + * Set picture type + * + * @param string $documentType Document type + * + * @return $this + */ + public function setDocumentType($documentType) + { + $this->documentType = $documentType; + + return $this; + } + + /** + * Get picture type + * + * @return string + */ + public function getDocumentType() + { + return $this->documentType; + } + + /** + * Set Document about to be deleted + * + * @param CategoryDocument|ProductDocument|ContentDocument|FolderDocument $documentToDelete Document about to be deleted + * + * @return $this + */ + public function setDocumentToDelete($documentToDelete) + { + $this->documentToDelete = $documentToDelete; + + return $this; + } + + /** + * Get Document about to be deleted + * + * @return CategoryDocument|ProductDocument|ContentDocument|FolderDocument + */ + public function getDocumentToDelete() + { + return $this->documentToDelete; + } + +} diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedPeriod.php b/core/lib/Thelia/Core/Event/Document/DocumentEvent.php similarity index 50% rename from core/lib/Thelia/Constraint/Rule/AvailableForRepeatedPeriod.php rename to core/lib/Thelia/Core/Event/Document/DocumentEvent.php index f5bf9bafc..dd3fe86b1 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForRepeatedPeriod.php +++ b/core/lib/Thelia/Core/Event/Document/DocumentEvent.php @@ -1,73 +1,85 @@ . */ -/* */ -/**********************************************************************************/ +/*************************************************************************************/ +/* */ +/* 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 . */ +/* */ +/*************************************************************************************/ -namespace Thelia\Constraint\Rule; - -use Thelia\Coupon\CouponAdapterInterface; +namespace Thelia\Core\Event\Document; +use Thelia\Core\Event\CachedFileEvent; /** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * @package Constraint - * @author Guillaume MOREL + * Class DocumentEvent * + * @package Thelia\Core\Event */ -class AvailableForRepeatedPeriod extends AvailableForPeriod +class DocumentEvent extends CachedFileEvent { + protected $documentPath; + protected $documentUrl; /** - * Generate current Rule param to be validated from adapter + * Get Document path * - * @param CouponAdapterInterface $adapter allowing to gather - * all necessary Thelia variables + * @return string The document file path + */ + public function getDocumentPath() + { + return $this->documentPath; + } + + /** + * Set Document path + * + * @param string $documentPath the document file path * - * @throws \Symfony\Component\Intl\Exception\NotImplementedException * @return $this */ - public function setParametersToValidate(CouponAdapterInterface $adapter) + public function setDocumentPath($documentPath) { - // @todo implement + $this->documentPath = $documentPath; + + return $this; } /** - * Check if backoffice inputs are relevant or not + * Get Document URL * - * @return bool + * @return string The document URL */ - public function checkBackOfficeInput() + public function getDocumentUrl() { - // TODO: Implement checkBackOfficeInput() method. + return $this->documentUrl; } /** - * Check if Checkout inputs are relevant or not + * Set Document URL * - * @return bool + * @param string $documentUrl the document URL + * + * @return $this */ - public function checkCheckoutInput() + public function setDocumentUrl($documentUrl) { - // TODO: Implement checkCheckoutInput() method. + $this->documentUrl = $documentUrl; + + return $this; } -} \ No newline at end of file + +} diff --git a/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureAvCreateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureAvCreateEvent.php index 2c8fb228e..f465d92d3 100644 --- a/core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureAvCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; + +use Thelia\Core\Event\Feature\FeatureAvEvent; class FeatureAvCreateEvent extends FeatureAvEvent { diff --git a/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureAvDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureAvDeleteEvent.php index aa0a3c729..85e97f890 100644 --- a/core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureAvDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; + +use Thelia\Core\Event\Feature\FeatureAvEvent; class FeatureAvDeleteEvent extends FeatureAvEvent { diff --git a/core/lib/Thelia/Core/Event/FeatureAvEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureAvEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/FeatureAvEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureAvEvent.php index 225acaf11..42011bfe3 100644 --- a/core/lib/Thelia/Core/Event/FeatureAvEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureAvEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\FeatureAv; class FeatureAvEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureAvUpdateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureAvUpdateEvent.php index 5db9604c2..cd9d375aa 100644 --- a/core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureAvUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; + +use Thelia\Core\Event\Feature\FeatureAvCreateEvent; class FeatureAvUpdateEvent extends FeatureAvCreateEvent { diff --git a/core/lib/Thelia/Core/Event/FeatureCreateEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureCreateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/FeatureCreateEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureCreateEvent.php index 574433084..34f49b541 100644 --- a/core/lib/Thelia/Core/Event/FeatureCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; + +use Thelia\Core\Event\Feature\FeatureEvent; class FeatureCreateEvent extends FeatureEvent { diff --git a/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/FeatureDeleteEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureDeleteEvent.php index 1eca57982..5d53bf4bd 100644 --- a/core/lib/Thelia/Core/Event/FeatureDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; + +use Thelia\Core\Event\Feature\FeatureEvent; class FeatureDeleteEvent extends FeatureEvent { diff --git a/core/lib/Thelia/Core/Event/FeatureEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/FeatureEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureEvent.php index f1510ac63..7b597acaf 100644 --- a/core/lib/Thelia/Core/Event/FeatureEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Feature; class FeatureEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php b/core/lib/Thelia/Core/Event/Feature/FeatureUpdateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/FeatureUpdateEvent.php rename to core/lib/Thelia/Core/Event/Feature/FeatureUpdateEvent.php index 6bee33ebb..55c6cd651 100644 --- a/core/lib/Thelia/Core/Event/FeatureUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Feature/FeatureUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Feature; + +use Thelia\Core\Event\Feature\FeatureCreateEvent; class FeatureUpdateEvent extends FeatureCreateEvent { diff --git a/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductDeleteEvent.php b/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductDeleteEvent.php new file mode 100644 index 000000000..73cb88013 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductDeleteEvent.php @@ -0,0 +1,62 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\FeatureProduct; +use Thelia\Core\Event\FeatureProduct\FeatureProductEvent; +use Thelia\Model\FeatureProduct; + +class FeatureProductDeleteEvent extends FeatureProductEvent +{ + protected $product_id; + protected $feature_id; + + public function __construct($product_id, $feature_id) + { + $this->product_id = $product_id; + $this->feature_id = $feature_id; + } + + public function getProductId() + { + return $this->product_id; + } + + public function setProductId($product_id) + { + $this->product_id = $product_id; + + return $this; + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductEvent.php b/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductEvent.php new file mode 100644 index 000000000..aef4b25f5 --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductEvent.php @@ -0,0 +1,53 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\FeatureProduct; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\FeatureProduct; + +class FeatureProductEvent extends ActionEvent +{ + protected $featureProduct = null; + + public function __construct(FeatureProduct $featureProduct = null) + { + $this->featureProduct = $featureProduct; + } + + public function hasFeatureProduct() + { + return ! is_null($this->featureProduct); + } + + public function getFeatureProduct() + { + return $this->featureProduct; + } + + public function setFeatureProduct($featureProduct) + { + $this->featureProduct = $featureProduct; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductUpdateEvent.php b/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductUpdateEvent.php new file mode 100644 index 000000000..8cb90dfdd --- /dev/null +++ b/core/lib/Thelia/Core/Event/FeatureProduct/FeatureProductUpdateEvent.php @@ -0,0 +1,90 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\FeatureProduct; +use Thelia\Core\Event\FeatureProduct\FeatureProductEvent; +use Thelia\Model\FeatureProduct; + +class FeatureProductUpdateEvent extends FeatureProductEvent +{ + protected $product_id; + protected $feature_id; + protected $feature_value; + protected $is_text_value; + + public function __construct($product_id, $feature_id, $feature_value, $is_text_value = false) + { + $this->product_id = $product_id; + $this->feature_id = $feature_id; + $this->feature_value = $feature_value; + $this->is_text_value = $is_text_value; + } + + public function getProductId() + { + return $this->product_id; + } + + public function setProductId($product_id) + { + $this->product_id = $product_id; + + return $this; + } + + public function getFeatureId() + { + return $this->feature_id; + } + + public function setFeatureId($feature_id) + { + $this->feature_id = $feature_id; + + return $this; + } + + public function getFeatureValue() + { + return $this->feature_value; + } + + public function setFeatureValue($feature_value) + { + $this->feature_value = $feature_value; + + return $this; + } + + public function getIsTextValue() + { + return $this->is_text_value; + } + + public function setIsTextValue($is_text_value) + { + $this->is_text_value = $is_text_value; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/Folder/FolderCreateEvent.php b/core/lib/Thelia/Core/Event/Folder/FolderCreateEvent.php new file mode 100644 index 000000000..162d6c896 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Folder/FolderCreateEvent.php @@ -0,0 +1,120 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Folder; +use Thelia\Core\Event\Folder\FolderEvent; + +/** + * Class FolderCreateEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderCreateEvent extends FolderEvent +{ + protected $title; + protected $parent; + protected $locale; + protected $visible; + + /** + * @param mixed $locale + * + * @return $this + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + /** + * @return mixed + */ + public function getLocale() + { + return $this->locale; + } + + /** + * @param mixed $parent + * + * + * @return $this + */ + public function setParent($parent) + { + $this->parent = $parent; + + return $this; + } + + /** + * @return mixed + */ + public function getParent() + { + return $this->parent; + } + + /** + * @param mixed $title + * + * @return $this + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param mixed $visible + * + * @return $this + */ + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } + + /** + * @return mixed + */ + public function getVisible() + { + return $this->visible; + } + +} diff --git a/core/lib/Thelia/Core/Event/DocumentEvent.php b/core/lib/Thelia/Core/Event/Folder/FolderDeleteEvent.php similarity index 73% rename from core/lib/Thelia/Core/Event/DocumentEvent.php rename to core/lib/Thelia/Core/Event/Folder/FolderDeleteEvent.php index f58d51083..4dd251179 100644 --- a/core/lib/Thelia/Core/Event/DocumentEvent.php +++ b/core/lib/Thelia/Core/Event/Folder/FolderDeleteEvent.php @@ -21,47 +21,43 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Folder; +use Thelia\Core\Event\Folder\FolderEvent; -class DocumentEvent extends CachedFileEvent +/** + * Class FolderDeleteEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderDeleteEvent extends FolderEvent { - protected $document_path; - protected $document_url; + /** + * @var int folder id + */ + protected $folder_id; /** - * @return the document file path + * @param int $folder_id */ - public function getDocumentPath() + public function __construct($folder_id) { - return $this->document_path; + $this->folder_id = $folder_id; } /** - * @param string $document_path the document file path + * @param int $folder_id */ - public function setDocumentPath($document_path) + public function setFolderId($folder_id) { - $this->document_path = $document_path; - - return $this; + $this->folder_id = $folder_id; } /** - * @return the document URL + * @return int */ - public function getDocumentUrl() + public function getFolderId() { - return $this->document_url; - } - - /** - * @param string $document_url the document URL - */ - public function setDocumentUrl($document_url) - { - $this->document_url = $document_url; - - return $this; + return $this->folder_id; } } diff --git a/core/lib/Thelia/Core/Event/Folder/FolderEvent.php b/core/lib/Thelia/Core/Event/Folder/FolderEvent.php new file mode 100644 index 000000000..62eaddf39 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Folder/FolderEvent.php @@ -0,0 +1,73 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Folder; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Folder; + +/** + * Class FolderEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderEvent extends ActionEvent +{ + /** + * @var \Thelia\Model\Folder + */ + protected $folder; + + public function __construct(Folder $folder = null) + { + $this->folder = $folder; + } + + /** + * @param \Thelia\Model\Folder $folder + */ + public function setFolder(Folder $folder) + { + $this->folder = $folder; + + return $this; + } + + /** + * @return \Thelia\Model\Folder + */ + public function getFolder() + { + return $this->folder; + } + + /** + * test if a folder object exists + * + * @return bool + */ + public function hasFolder() + { + return null !== $this->folder; + } + +} diff --git a/core/lib/Thelia/Core/Event/Folder/FolderToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/Folder/FolderToggleVisibilityEvent.php new file mode 100644 index 000000000..d6bf24297 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Folder/FolderToggleVisibilityEvent.php @@ -0,0 +1,34 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Folder; +use Thelia\Core\Event\Folder\FolderEvent; + +/** + * Class FolderToggleVisibilityEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderToggleVisibilityEvent extends FolderEvent +{ +} diff --git a/core/lib/Thelia/Core/Event/Folder/FolderUpdateEvent.php b/core/lib/Thelia/Core/Event/Folder/FolderUpdateEvent.php new file mode 100644 index 000000000..bb4234d6c --- /dev/null +++ b/core/lib/Thelia/Core/Event/Folder/FolderUpdateEvent.php @@ -0,0 +1,137 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Folder; +use Thelia\Core\Event\Folder\FolderCreateEvent; + +/** + * Class FolderUpdateEvent + * @package Thelia\Core\Event + * @author Manuel Raynaud + */ +class FolderUpdateEvent extends FolderCreateEvent +{ + protected $folder_id; + + protected $chapo; + protected $description; + protected $postscriptum; + + protected $url; + + public function __construct($folder_id) + { + $this->folder_id = $folder_id; + } + + /** + * @param mixed $chapo + */ + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + /** + * @return mixed + */ + public function getChapo() + { + return $this->chapo; + } + + /** + * @param mixed $description + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param mixed $folder_id + */ + public function setFolderId($folder_id) + { + $this->folder_id = $folder_id; + + return $this; + } + + /** + * @return mixed + */ + public function getFolderId() + { + return $this->folder_id; + } + + /** + * @param mixed $postscriptum + */ + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } + + /** + * @return mixed + */ + public function getPostscriptum() + { + return $this->postscriptum; + } + + /** + * @param mixed $url + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + +} diff --git a/core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php b/core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php index 7ee22cddd..95604ceb5 100644 --- a/core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php +++ b/core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php @@ -23,14 +23,13 @@ namespace Thelia\Core\Event; - /** * Class GenerateRewrittenUrlEvent * @package Thelia\Core\Event * @author Manuel Raynaud */ -class GenerateRewrittenUrlEvent extends ActionEvent { - +class GenerateRewrittenUrlEvent extends ActionEvent +{ protected $object; protected $locale; @@ -57,4 +56,4 @@ class GenerateRewrittenUrlEvent extends ActionEvent { return $this->url; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Image/ImageCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Image/ImageCreateOrUpdateEvent.php new file mode 100755 index 000000000..ea870dd14 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Image/ImageCreateOrUpdateEvent.php @@ -0,0 +1,213 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Image; +use Symfony\Component\HttpFoundation\File\UploadedFile; +use Thelia\Core\Event\ActionEvent; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Occurring when an Image is saved + * + * @package Image + * @author Guillaume MOREL + * + */ +class ImageCreateOrUpdateEvent extends ActionEvent +{ + + /** @var \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage model to save */ + protected $modelImage = array(); + + /** @var \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage model to save */ + protected $oldModelImage = array(); + + /** @var UploadedFile Image file to save */ + protected $uploadedFile = null; + + /** @var int Image parent id */ + protected $parentId = null; + + /** @var string Image type */ + protected $imageType = null; + + /** @var string Parent name */ + protected $parentName = null; + + /** + * Constructor + * + * @param string $imageType Image type + * ex : FileManager::TYPE_CATEGORY + * @param int $parentId Image parent id + */ + public function __construct($imageType, $parentId) + { + $this->imageType = $imageType; + $this->parentId = $parentId; + } + + /** + * Set Image to save + * + * @param $image \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage + * + * @return $this + */ + public function setModelImage($image) + { + $this->modelImage = $image; + + return $this; + } + + /** + * Get Image being saved + * + * @return \Thelia\Model\CategoryImage|\Thelia\Model\ProductImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage + */ + public function getModelImage() + { + return $this->modelImage; + } + + /** + * Set picture type + * + * @param string $imageType Image type + * + * @return $this + */ + public function setImageType($imageType) + { + $this->imageType = $imageType; + + return $this; + } + + /** + * Get picture type + * + * @return string + */ + public function getImageType() + { + return $this->imageType; + } + + /** + * Set Image parent id + * + * @param int $parentId Image parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + + return $this; + } + + /** + * Get Image parent id + * + * @return int + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set uploaded file + * + * @param UploadedFile $uploadedFile File being uploaded + * + * @return $this + */ + public function setUploadedFile($uploadedFile) + { + $this->uploadedFile = $uploadedFile; + + return $this; + } + + /** + * Get uploaded file + * + * @return UploadedFile + */ + public function getUploadedFile() + { + return $this->uploadedFile; + } + + /** + * Set parent name + * + * @param string $parentName Parent name + * + * @return $this + */ + public function setParentName($parentName) + { + $this->parentName = $parentName; + + return $this; + } + + /** + * Get parent name + * + * @return string + */ + public function getParentName() + { + return $this->parentName; + } + + /** + * Set old model value + * + * @param \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage $oldModelImage + */ + public function setOldModelImage($oldModelImage) + { + $this->oldModelImage = $oldModelImage; + } + + /** + * Get old model value + * + * @return \Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage + */ + public function getOldModelImage() + { + return $this->oldModelImage; + } + +} diff --git a/core/lib/Thelia/Core/Event/Image/ImageDeleteEvent.php b/core/lib/Thelia/Core/Event/Image/ImageDeleteEvent.php new file mode 100755 index 000000000..d3ba94374 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Image/ImageDeleteEvent.php @@ -0,0 +1,112 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Image; + +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\CategoryImage; +use Thelia\Model\ContentImage; +use Thelia\Model\FolderImage; +use Thelia\Model\ProductImage; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Occurring when a Image is about to be deleted + * + * @package Image + * @author Guillaume MOREL + * + */ +class ImageDeleteEvent extends ActionEvent +{ + /** @var string Image type */ + protected $imageType = null; + + /** @var CategoryImage|ProductImage|ContentImage|FolderImage Image about to be deleted */ + protected $imageToDelete = null; + + /** + * Constructor + * + * @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted + * @param string $imageType Image type + * ex : FileManager::TYPE_CATEGORY + */ + public function __construct($imageToDelete, $imageType) + { + $this->imageToDelete = $imageToDelete; + $this->imageType = $imageType; + } + + /** + * Set picture type + * + * @param string $imageType Image type + * + * @return $this + */ + public function setImageType($imageType) + { + $this->imageType = $imageType; + + return $this; + } + + /** + * Get picture type + * + * @return string + */ + public function getImageType() + { + return $this->imageType; + } + + /** + * Set Image about to be deleted + * + * @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted + * + * @return $this + */ + public function setImageToDelete($imageToDelete) + { + $this->imageToDelete = $imageToDelete; + + return $this; + } + + /** + * Get Image about to be deleted + * + * @return CategoryImage|ProductImage|ContentImage|FolderImage + */ + public function getImageToDelete() + { + return $this->imageToDelete; + } + +} diff --git a/core/lib/Thelia/Core/Event/ImageEvent.php b/core/lib/Thelia/Core/Event/Image/ImageEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ImageEvent.php rename to core/lib/Thelia/Core/Event/Image/ImageEvent.php index 462fa012d..2fce2466c 100755 --- a/core/lib/Thelia/Core/Event/ImageEvent.php +++ b/core/lib/Thelia/Core/Event/Image/ImageEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Image; + +use Thelia\Core\Event\CachedFileEvent; class ImageEvent extends CachedFileEvent { diff --git a/core/lib/Thelia/Core/Event/LostPasswordEvent.php b/core/lib/Thelia/Core/Event/LostPasswordEvent.php index fe1f9dc5f..78d786b2d 100644 --- a/core/lib/Thelia/Core/Event/LostPasswordEvent.php +++ b/core/lib/Thelia/Core/Event/LostPasswordEvent.php @@ -23,14 +23,13 @@ namespace Thelia\Core\Event; - /** * Class LostPasswordEvent * @package Thelia\Core\Event * @author Manuel Raynaud */ -class LostPasswordEvent extends ActionEvent { - +class LostPasswordEvent extends ActionEvent +{ protected $email; public function __construct($email) @@ -46,6 +45,4 @@ class LostPasswordEvent extends ActionEvent { return $this->email; } - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/MailTransporterEvent.php b/core/lib/Thelia/Core/Event/MailTransporterEvent.php index d47ac693f..5a133158e 100644 --- a/core/lib/Thelia/Core/Event/MailTransporterEvent.php +++ b/core/lib/Thelia/Core/Event/MailTransporterEvent.php @@ -23,13 +23,13 @@ namespace Thelia\Core\Event; - /** * Class MailTransporterEvent * @package Thelia\Core\Event * @author Manuel Raynaud */ -class MailTransporterEvent extends ActionEvent { +class MailTransporterEvent extends ActionEvent +{ /** * @var \Swift_Transport */ @@ -49,4 +49,4 @@ class MailTransporterEvent extends ActionEvent { { return null !== $this->transporter; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/MessageCreateEvent.php b/core/lib/Thelia/Core/Event/Message/MessageCreateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/MessageCreateEvent.php rename to core/lib/Thelia/Core/Event/Message/MessageCreateEvent.php index 172af5f61..fc20c2c81 100644 --- a/core/lib/Thelia/Core/Event/MessageCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Message/MessageCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Message; + +use Thelia\Core\Event\Message\MessageEvent; class MessageCreateEvent extends MessageEvent { diff --git a/core/lib/Thelia/Core/Event/MessageDeleteEvent.php b/core/lib/Thelia/Core/Event/Message/MessageDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/MessageDeleteEvent.php rename to core/lib/Thelia/Core/Event/Message/MessageDeleteEvent.php index 241c68463..a40b19a27 100644 --- a/core/lib/Thelia/Core/Event/MessageDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Message/MessageDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Message; + +use Thelia\Core\Event\Message\MessageEvent; class MessageDeleteEvent extends MessageEvent { diff --git a/core/lib/Thelia/Core/Event/MessageEvent.php b/core/lib/Thelia/Core/Event/Message/MessageEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/MessageEvent.php rename to core/lib/Thelia/Core/Event/Message/MessageEvent.php index c0efcf39f..82086ed05 100644 --- a/core/lib/Thelia/Core/Event/MessageEvent.php +++ b/core/lib/Thelia/Core/Event/Message/MessageEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Message; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Message; class MessageEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/MessageUpdateEvent.php b/core/lib/Thelia/Core/Event/Message/MessageUpdateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/MessageUpdateEvent.php rename to core/lib/Thelia/Core/Event/Message/MessageUpdateEvent.php index 8c9e2e740..858a668b8 100644 --- a/core/lib/Thelia/Core/Event/MessageUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Message/MessageUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Message; + +use Thelia\Core\Event\Message\MessageCreateEvent; class MessageUpdateEvent extends MessageCreateEvent { diff --git a/core/lib/Thelia/Core/Event/Order/OrderAddressEvent.php b/core/lib/Thelia/Core/Event/Order/OrderAddressEvent.php new file mode 100755 index 000000000..92c101dd6 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Order/OrderAddressEvent.php @@ -0,0 +1,231 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Order; + +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Order; +use Thelia\Model\OrderAddress; + +class OrderAddressEvent extends ActionEvent +{ + /** + * @var int title id + */ + protected $title; + + /** + * @var string|null company name + */ + protected $company; + + /** + * @var string first name + */ + protected $firstname; + + /** + * @var string last name + */ + protected $lastname; + + /** + * @var string address + */ + protected $address1; + + /** + * @var string address line 2 + */ + protected $address2; + + /** + * @var string address line 3 + */ + protected $address3; + + /** + * @var string zipcode + */ + protected $zipcode; + + /** + * @var string city + */ + protected $city; + + /** + * @var int country id + */ + protected $country; + + /** + * @var string phone + */ + protected $phone; + + /** + * @var \Thelia\Model\OrderAddress + */ + protected $orderAddress; + + /** + * @var \Thelia\Model\Order + */ + protected $order; + + public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $phone, $company) + { + $this->address1 = $address1; + $this->address2 = $address2; + $this->address3 = $address3; + $this->city = $city; + $this->company = $company; + $this->country = $country; + $this->firstname = $firstname; + $this->lastname = $lastname; + $this->phone = $phone; + $this->title = $title; + $this->zipcode = $zipcode; + } + + /** + * @return string + */ + public function getAddress1() + { + return $this->address1; + } + + /** + * @return string + */ + public function getAddress2() + { + return $this->address2; + } + + /** + * @return string + */ + public function getAddress3() + { + return $this->address3; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @return null|string + */ + public function getCompany() + { + return $this->company; + } + + /** + * @return int + */ + public function getCountry() + { + return $this->country; + } + + /** + * @return string + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * @return string + */ + public function getLastname() + { + return $this->lastname; + } + + /** + * @return string + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @return int + */ + public function getTitle() + { + return $this->title; + } + + /** + * @return string + */ + public function getZipcode() + { + return $this->zipcode; + } + + /** + * @param \Thelia\Model\OrderAddress $orderAddress + */ + public function setOrderAddress(OrderAddress $orderAddress) + { + $this->orderAddress = $orderAddress; + } + + /** + * @param \Thelia\Model\Order $order + */ + public function setOrder(Order $order) + { + $this->order = $order; + } + + /** + * @return \Thelia\Model\OrderAddress + */ + public function getOrderAddress() + { + return $this->orderAddress; + } + + /** + * @return \Thelia\Model\Order + */ + public function getOrder() + { + return $this->order; + } +} diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/Order/OrderEvent.php similarity index 81% rename from core/lib/Thelia/Core/Event/OrderEvent.php rename to core/lib/Thelia/Core/Event/Order/OrderEvent.php index a156b753f..7463bd176 100755 --- a/core/lib/Thelia/Core/Event/OrderEvent.php +++ b/core/lib/Thelia/Core/Event/Order/OrderEvent.php @@ -21,19 +21,23 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Order; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Order; class OrderEvent extends ActionEvent { protected $order = null; + protected $placedOrder = null; protected $invoiceAddress = null; protected $deliveryAddress = null; protected $deliveryModule = null; protected $paymentModule = null; protected $postage = null; protected $ref = null; + protected $status = null; + protected $deliveryRef = null; /** * @param Order $order @@ -51,6 +55,14 @@ class OrderEvent extends ActionEvent $this->order = $order; } + /** + * @param Order $order + */ + public function setPlacedOrder(Order $order) + { + $this->placedOrder = $order; + } + /** * @param $address */ @@ -99,6 +111,22 @@ class OrderEvent extends ActionEvent $this->ref = $ref; } + /** + * @param $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @param $deliveryRef + */ + public function setDeliveryRef($deliveryRef) + { + $this->deliveryRef = $deliveryRef; + } + /** * @return null|Order */ @@ -107,6 +135,14 @@ class OrderEvent extends ActionEvent return $this->order; } + /** + * @return null|Order + */ + public function getPlacedOrder() + { + return $this->placedOrder; + } + /** * @return null|int */ @@ -154,4 +190,20 @@ class OrderEvent extends ActionEvent { return $this->ref; } + + /** + * @return null|int + */ + public function getStatus() + { + return $this->status; + } + + /** + * @return null|string + */ + public function getDeliveryRef() + { + return $this->deliveryRef; + } } diff --git a/core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php b/core/lib/Thelia/Core/Event/Product/ProductAddAccessoryEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductAddAccessoryEvent.php index d3f2ba19b..d32988b84 100644 --- a/core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductAddAccessoryEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; use Thelia\Model\Product; diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForPeriod.php b/core/lib/Thelia/Core/Event/Product/ProductAddCategoryEvent.php similarity index 56% rename from core/lib/Thelia/Constraint/Rule/AvailableForPeriod.php rename to core/lib/Thelia/Core/Event/Product/ProductAddCategoryEvent.php index 30679a973..de11b34cb 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForPeriod.php +++ b/core/lib/Thelia/Core/Event/Product/ProductAddCategoryEvent.php @@ -1,57 +1,48 @@ . */ -/* */ -/**********************************************************************************/ +/*************************************************************************************/ +/* */ +/* 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 . */ +/* */ +/*************************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Core\Event\Product; -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class AvailableForPeriod extends CouponRuleAbstract +use Thelia\Model\Product; + +class ProductAddCategoryEvent extends ProductEvent { + protected $category_id; - /** - * Check if backoffice inputs are relevant or not - * - * @return bool - */ - public function checkBackOfficeInput() + public function __construct(Product $product, $category_id) { - // TODO: Implement checkBackOfficeInput() method. + parent::__construct($product); + + $this->category_id = $category_id; } - /** - * Check if Checkout inputs are relevant or not - * - * @return bool - */ - public function checkCheckoutInput() + public function getCategoryId() { - // TODO: Implement checkCheckoutInput() method. + return $this->category_id; } -} \ No newline at end of file + + public function setCategoryId($category_id) + { + $this->category_id = $category_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductAddContentEvent.php b/core/lib/Thelia/Core/Event/Product/ProductAddContentEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ProductAddContentEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductAddContentEvent.php index 8cd648753..960dbfdf6 100644 --- a/core/lib/Thelia/Core/Event/ProductAddContentEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductAddContentEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; use Thelia\Model\Product; diff --git a/core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php b/core/lib/Thelia/Core/Event/Product/ProductAssociatedContentEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductAssociatedContentEvent.php index ba41b5ede..5cdb7c8e1 100644 --- a/core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductAssociatedContentEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; use Thelia\Model\ProductAssociatedContent; use Thelia\Core\Event\ActionEvent; diff --git a/core/lib/Thelia/Core/Event/Product/ProductCreateCombinationEvent.php b/core/lib/Thelia/Core/Event/Product/ProductCreateCombinationEvent.php new file mode 100644 index 000000000..1af473aeb --- /dev/null +++ b/core/lib/Thelia/Core/Event/Product/ProductCreateCombinationEvent.php @@ -0,0 +1,65 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Product; + +use Thelia\Model\Product; + +class ProductCreateCombinationEvent extends ProductEvent +{ + protected $attribute_av_list; + protected $currency_id; + + public function __construct(Product $product, $attribute_av_list, $currency_id) + { + parent::__construct($product); + + $this->attribute_av_list = $attribute_av_list; + $this->currency_id = $currency_id; + } + + public function getAttributeAvList() + { + return $this->attribute_av_list; + } + + public function setAttributeAvList($attribute_av_list) + { + $this->attribute_av_list = $attribute_av_list; + + return $this; + } + + public function getCurrencyId() + { + return $this->currency_id; + } + + public function setCurrencyId($currency_id) + { + $this->currency_id = $currency_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/ProductCreateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductCreateEvent.php similarity index 75% rename from core/lib/Thelia/Core/Event/ProductCreateEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductCreateEvent.php index d2d30a11a..a9f6bbea1 100644 --- a/core/lib/Thelia/Core/Event/ProductCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductCreateEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; + class ProductCreateEvent extends ProductEvent { @@ -31,6 +32,11 @@ class ProductCreateEvent extends ProductEvent protected $default_category; protected $visible; + protected $basePrice; + protected $baseWeight; + protected $taxRuleId; + protected $currencyId; + public function getRef() { return $this->ref; @@ -39,6 +45,7 @@ class ProductCreateEvent extends ProductEvent public function setRef($ref) { $this->ref = $ref; + return $this; } @@ -50,6 +57,7 @@ class ProductCreateEvent extends ProductEvent public function setTitle($title) { $this->title = $title; + return $this; } @@ -61,6 +69,7 @@ class ProductCreateEvent extends ProductEvent public function setLocale($locale) { $this->locale = $locale; + return $this; } @@ -72,6 +81,7 @@ class ProductCreateEvent extends ProductEvent public function setDefaultCategory($default_category) { $this->default_category = $default_category; + return $this; } @@ -83,6 +93,55 @@ class ProductCreateEvent extends ProductEvent public function setVisible($visible) { $this->visible = $visible; + + return $this; + } + + public function getBasePrice() + { + return $this->basePrice; + } + + public function setBasePrice($basePrice) + { + $this->basePrice = $basePrice; + + return $this; + } + + public function getBaseWeight() + { + return $this->baseWeight; + } + + public function setBaseWeight($baseWeight) + { + $this->baseWeight = $baseWeight; + + return $this; + } + + public function getTaxRuleId() + { + return $this->taxRuleId; + } + + public function setTaxRuleId($taxRuleId) + { + $this->taxRuleId = $taxRuleId; + + return $this; + } + + public function getCurrencyId() + { + return $this->currencyId; + } + + public function setCurrencyId($currencyId) + { + $this->currencyId = $currencyId; + return $this; } } diff --git a/core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php b/core/lib/Thelia/Core/Event/Product/ProductDeleteAccessoryEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductDeleteAccessoryEvent.php index 9644cdacc..0cfd979c2 100644 --- a/core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductDeleteAccessoryEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; use Thelia\Model\Product; diff --git a/core/lib/Thelia/Core/Event/Product/ProductDeleteCategoryEvent.php b/core/lib/Thelia/Core/Event/Product/ProductDeleteCategoryEvent.php new file mode 100644 index 000000000..e83cd087b --- /dev/null +++ b/core/lib/Thelia/Core/Event/Product/ProductDeleteCategoryEvent.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Product; + +use Thelia\Model\Product; + +class ProductDeleteCategoryEvent extends ProductEvent +{ + protected $category_id; + + public function __construct(Product $product, $category_id) + { + parent::__construct($product); + + $this->category_id = $category_id; + } + + public function getCategoryId() + { + return $this->category_id; + } + + public function setCategoryId($category_id) + { + $this->category_id = $category_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForLocationX.php b/core/lib/Thelia/Core/Event/Product/ProductDeleteCombinationEvent.php similarity index 55% rename from core/lib/Thelia/Constraint/Rule/AvailableForLocationX.php rename to core/lib/Thelia/Core/Event/Product/ProductDeleteCombinationEvent.php index 5c3ec494c..a4e926ee6 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForLocationX.php +++ b/core/lib/Thelia/Core/Event/Product/ProductDeleteCombinationEvent.php @@ -1,59 +1,48 @@ . */ -/* */ -/**********************************************************************************/ +/*************************************************************************************/ +/* */ +/* 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 . */ +/* */ +/*************************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Core\Event\Product; -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class AvailableForLocationX extends CouponRuleAbstract +use Thelia\Model\Product; + +class ProductDeleteCombinationEvent extends ProductEvent { + protected $product_sale_element_id; - /** - * Check if backoffice inputs are relevant or not - * - * @return bool - */ - public function checkBackOfficeInput() + public function __construct(Product $product, $product_sale_element_id) { - // TODO: Implement checkBackOfficeInput() method. + parent::__construct($product); + + $this->product_sale_element_id = $product_sale_element_id; } - /** - * Check if Checkout inputs are relevant or not - * - * @return bool - */ - public function checkCheckoutInput() + public function getProductSaleElementId() { - // TODO: Implement checkCheckoutInput() method. + return $this->product_sale_element_id; } - -} \ No newline at end of file + public function setProductSaleElementId($product_sale_element_id) + { + $this->product_sale_element_id = $product_sale_element_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php b/core/lib/Thelia/Core/Event/Product/ProductDeleteContentEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductDeleteContentEvent.php index f3cdbda1f..6f09411cb 100644 --- a/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductDeleteContentEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; use Thelia\Model\Product; diff --git a/core/lib/Thelia/Core/Event/ProductDeleteEvent.php b/core/lib/Thelia/Core/Event/Product/ProductDeleteEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ProductDeleteEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductDeleteEvent.php index 43273887c..108ceb781 100644 --- a/core/lib/Thelia/Core/Event/ProductDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductDeleteEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; + class ProductDeleteEvent extends ProductEvent { diff --git a/core/lib/Thelia/Core/Event/ProductEvent.php b/core/lib/Thelia/Core/Event/Product/ProductEvent.php similarity index 98% rename from core/lib/Thelia/Core/Event/ProductEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductEvent.php index 6decd8101..11359c616 100644 --- a/core/lib/Thelia/Core/Event/ProductEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductEvent.php @@ -21,7 +21,7 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; use Thelia\Model\Product; use Thelia\Core\Event\ActionEvent; diff --git a/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php new file mode 100644 index 000000000..1847ca48f --- /dev/null +++ b/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Product; + +use Thelia\Model\Product; + +class ProductSetTemplateEvent extends ProductEvent +{ + public $template_id = null; + + public function __construct(Product $product = null, $template_id) + { + parent::__construct($product); + + $this->template_id = $template_id; + } + + public function getTemplateId() + { + return $this->template_id; + } + + public function setTemplateId($template_id) + { + $this->template_id = $template_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/Product/ProductToggleVisibilityEvent.php similarity index 95% rename from core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductToggleVisibilityEvent.php index 732cfac76..c6a35a660 100644 --- a/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductToggleVisibilityEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; + +use Thelia\Core\Event\Product\ProductEvent; class ProductToggleVisibilityEvent extends ProductEvent { diff --git a/core/lib/Thelia/Core/Event/ProductUpdateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php similarity index 97% rename from core/lib/Thelia/Core/Event/ProductUpdateEvent.php rename to core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php index 8ade33c74..535f04462 100644 --- a/core/lib/Thelia/Core/Event/ProductUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Product; + +use Thelia\Core\Event\Product\ProductCreateEvent; class ProductUpdateEvent extends ProductCreateEvent { diff --git a/core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateAddAttributeEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateAddAttributeEvent.php index 6adebf080..f73aba820 100644 --- a/core/lib/Thelia/Core/Event/TemplateAddAttributeEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateAddAttributeEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; +use Thelia\Core\Event\Template\TemplateEvent; use Thelia\Model\Template; class TemplateAddAttributeEvent extends TemplateEvent { diff --git a/core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateAddFeatureEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateAddFeatureEvent.php index ccfecb95a..c718ea78e 100644 --- a/core/lib/Thelia/Core/Event/TemplateAddFeatureEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateAddFeatureEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; +use Thelia\Core\Event\Template\TemplateEvent; use Thelia\Model\Template; class TemplateAddFeatureEvent extends TemplateEvent { diff --git a/core/lib/Thelia/Core/Event/TemplateCreateEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateCreateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateCreateEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateCreateEvent.php index b966ce09b..e8b1cfb1a 100644 --- a/core/lib/Thelia/Core/Event/TemplateCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateCreateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; + +use Thelia\Core\Event\Template\TemplateEvent; class TemplateCreateEvent extends TemplateEvent { diff --git a/core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateDeleteAttributeEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateDeleteAttributeEvent.php index 3df83422d..f3381678a 100644 --- a/core/lib/Thelia/Core/Event/TemplateDeleteAttributeEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateDeleteAttributeEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; +use Thelia\Core\Event\Template\TemplateEvent; use Thelia\Model\Template; class TemplateDeleteAttributeEvent extends TemplateEvent diff --git a/core/lib/Thelia/Core/Event/TemplateDeleteEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateDeleteEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateDeleteEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateDeleteEvent.php index de504cc98..cda8c9eea 100644 --- a/core/lib/Thelia/Core/Event/TemplateDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateDeleteEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; + +use Thelia\Core\Event\Template\TemplateEvent; class TemplateDeleteEvent extends TemplateEvent { diff --git a/core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateDeleteFeatureEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateDeleteFeatureEvent.php index 83f73d923..a2d795402 100644 --- a/core/lib/Thelia/Core/Event/TemplateDeleteFeatureEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateDeleteFeatureEvent.php @@ -21,8 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; +use Thelia\Core\Event\Template\TemplateEvent; use Thelia\Model\Template; class TemplateDeleteFeatureEvent extends TemplateEvent diff --git a/core/lib/Thelia/Core/Event/TemplateEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateEvent.php index 96945189e..1010cfc31 100644 --- a/core/lib/Thelia/Core/Event/TemplateEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateEvent.php @@ -21,7 +21,8 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Template; class TemplateEvent extends ActionEvent diff --git a/core/lib/Thelia/Core/Event/TemplateUpdateEvent.php b/core/lib/Thelia/Core/Event/Template/TemplateUpdateEvent.php similarity index 96% rename from core/lib/Thelia/Core/Event/TemplateUpdateEvent.php rename to core/lib/Thelia/Core/Event/Template/TemplateUpdateEvent.php index bae8ec7da..aaf39708f 100644 --- a/core/lib/Thelia/Core/Event/TemplateUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Template/TemplateUpdateEvent.php @@ -21,7 +21,9 @@ /* */ /*************************************************************************************/ -namespace Thelia\Core\Event; +namespace Thelia\Core\Event\Template; + +use Thelia\Core\Event\Template\TemplateCreateEvent; class TemplateUpdateEvent extends TemplateCreateEvent { @@ -55,6 +57,7 @@ class TemplateUpdateEvent extends TemplateCreateEvent public function setFeatureList($feature_list) { $this->feature_list = $feature_list; + return $this; } @@ -66,6 +69,7 @@ class TemplateUpdateEvent extends TemplateCreateEvent public function setAttributeList($attribute_list) { $this->attribute_list = $attribute_list; + return $this; } } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 75f5314f0..29f45dd6d 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -165,13 +165,54 @@ final class TheliaEvents const BEFORE_UPDATECATEGORY = "action.before_updateCategory"; const AFTER_UPDATECATEGORY = "action.after_updateCategory"; + // -- folder management ----------------------------------------------- + + const FOLDER_CREATE = "action.createFolder"; + const FOLDER_UPDATE = "action.updateFolder"; + const FOLDER_DELETE = "action.deleteFolder"; + const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility"; + const FOLDER_UPDATE_POSITION = "action.updateFolderPosition"; + +// const FOLDER_ADD_CONTENT = "action.categoryAddContent"; +// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent"; + + const BEFORE_CREATEFOLDER = "action.before_createFolder"; + const AFTER_CREATEFOLDER = "action.after_createFolder"; + + const BEFORE_DELETEFOLDER = "action.before_deleteFolder"; + const AFTER_DELETEFOLDER = "action.after_deleteFolder"; + + const BEFORE_UPDATEFOLDER = "action.before_updateFolder"; + const AFTER_UPDATEFOLDER = "action.after_updateFolder"; + + // -- content management ----------------------------------------------- + + const CONTENT_CREATE = "action.createContent"; + const CONTENT_UPDATE = "action.updateContent"; + const CONTENT_DELETE = "action.deleteContent"; + const CONTENT_TOGGLE_VISIBILITY = "action.toggleContentVisibility"; + const CONTENT_UPDATE_POSITION = "action.updateContentPosition"; + + const CONTENT_ADD_FOLDER = "action.contentAddFolder"; + const CONTENT_REMOVE_FOLDER = "action.contentRemoveFolder"; + + + const BEFORE_CREATECONTENT = "action.before_createContent"; + const AFTER_CREATECONTENT = "action.after_createContent"; + + const BEFORE_DELETECONTENT = "action.before_deleteContent"; + const AFTER_DELETECONTENT = "action.after_deleteContent"; + + const BEFORE_UPDATECONTENT = "action.before_updateContent"; + const AFTER_UPDATECONTENT = "action.after_updateContent"; + // -- Categories Associated Content ---------------------------------------- const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent"; const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent"; - const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContenty"; - const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory"; + const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContent"; + const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteCategoryAssociatedContent"; const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent"; const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent"; @@ -184,12 +225,24 @@ final class TheliaEvents const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility"; const PRODUCT_UPDATE_POSITION = "action.updateProductPosition"; - const PRODUCT_ADD_CONTENT = "action.productAddContent"; - const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; + const PRODUCT_ADD_CONTENT = "action.productAddContent"; + const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; + const PRODUCT_UPDATE_CONTENT_POSITION = "action.updateProductContentPosition"; - const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory"; - const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory"; - const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition"; + const PRODUCT_ADD_COMBINATION = "action.productAddCombination"; + const PRODUCT_DELETE_COMBINATION = "action.productDeleteCombination"; + + const PRODUCT_SET_TEMPLATE = "action.productSetTemplate"; + + const PRODUCT_ADD_ACCESSORY = "action.productAddProductAccessory"; + const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveProductAccessory"; + const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductAccessoryPosition"; + + const PRODUCT_FEATURE_UPDATE_VALUE = "action.updateProductFeatureValue"; + const PRODUCT_FEATURE_DELETE_VALUE = "action.deleteProductFeatureValue"; + + const PRODUCT_ADD_CATEGORY = "action.addProductCategory"; + const PRODUCT_REMOVE_CATEGORY = "action.deleteProductCategory"; const BEFORE_CREATEPRODUCT = "action.before_createproduct"; const AFTER_CREATEPRODUCT = "action.after_createproduct"; @@ -211,17 +264,28 @@ final class TheliaEvents const BEFORE_UPDATEACCESSORY = "action.before_updateAccessory"; const AFTER_UPDATEACCESSORY = "action.after_updateAccessory"; - // -- Product Associated Content -------------------------------------------------- + // -- Product Associated Content ------------------------------------------- const BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.before_createProductAssociatedContent"; const AFTER_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.after_createProductAssociatedContent"; - const BEFORE_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.before_deleteProductAssociatedContenty"; - const AFTER_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory"; + const BEFORE_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.before_deleteProductAssociatedContent"; + const AFTER_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.after_deleteProductAssociatedContent"; const BEFORE_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.before_updateProductAssociatedContent"; const AFTER_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.after_updateProductAssociatedContent"; + // -- Feature product ------------------------------------------------------ + + const BEFORE_CREATEFEATURE_PRODUCT = "action.before_createFeatureProduct"; + const AFTER_CREATEFEATURE_PRODUCT = "action.after_createFeatureProduct"; + + const BEFORE_DELETEFEATURE_PRODUCT = "action.before_deleteFeatureProduct"; + const AFTER_DELETEFEATURE_PRODUCT = "action.after_deleteFeatureProduct"; + + const BEFORE_UPDATEFEATURE_PRODUCT = "action.before_updateFeatureProduct"; + const AFTER_UPDATEFEATURE_PRODUCT = "action.after_updateFeatureProduct"; + /** * sent when a new existing cat id duplicated. This append when current customer is different from current cart */ @@ -257,7 +321,16 @@ final class TheliaEvents const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress"; const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule"; const ORDER_PAY = "action.order.pay"; - const ORDER_SET_REFERENCE = "action.order.setReference"; + const ORDER_BEFORE_CREATE = "action.order.beforeCreate"; + const ORDER_AFTER_CREATE = "action.order.afterCreate"; + const ORDER_BEFORE_PAYMENT = "action.order.beforePayment"; + + const ORDER_UPDATE_STATUS = "action.order.updateStatus"; + const ORDER_UPDATE_DELIVERY_REF = "action.order.updateDeliveryRef"; + const ORDER_UPDATE_ADDRESS = "action.order.updateAddress"; + + const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate"; + const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate"; /** * Sent on image processing @@ -269,11 +342,46 @@ final class TheliaEvents */ const DOCUMENT_PROCESS = "action.processDocument"; + /** + * Sent on image cache clear request + */ + const DOCUMENT_CLEAR_CACHE = "action.clearDocumentCache"; + + /** + * Save given documents + */ + const DOCUMENT_SAVE = "action.saveDocument"; + + /** + * Save given documents + */ + const DOCUMENT_UPDATE = "action.updateDocument"; + + /** + * Delete given document + */ + const DOCUMENT_DELETE = "action.deleteDocument"; + /** * Sent on image cache clear request */ const IMAGE_CLEAR_CACHE = "action.clearImageCache"; + /** + * Save given images + */ + const IMAGE_SAVE = "action.saveImages"; + + /** + * Save given images + */ + const IMAGE_UPDATE = "action.updateImages"; + + /** + * Delete given image + */ + const IMAGE_DELETE = "action.deleteImage"; + /** * Sent when creating a Coupon */ @@ -320,19 +428,19 @@ final class TheliaEvents const AFTER_CONSUME_COUPON = "action.after_consume_coupon"; /** - * Sent when attempting to update Coupon Rule + * Sent when attempting to update Coupon Condition */ - const COUPON_RULE_UPDATE = "action.update_coupon_rule"; + const COUPON_CONDITION_UPDATE = "action.update_coupon_condition"; /** - * Sent just before an attempt to update a Coupon Rule + * Sent just before an attempt to update a Coupon Condition */ - const BEFORE_COUPON_RULE_UPDATE = "action.before_update_coupon_rule"; + const BEFORE_COUPON_CONDITION_UPDATE = "action.before_update_coupon_condition"; /** - * Sent just after an attempt to update a Coupon Rule + * Sent just after an attempt to update a Coupon Condition */ - const AFTER_COUPON_RULE_UPDATE = "action.after_update_coupon_rule"; + const AFTER_COUPON_CONDITION_UPDATE = "action.after_update_coupon_condition"; // -- Configuration management --------------------------------------------- @@ -384,6 +492,7 @@ final class TheliaEvents const AFTER_DELETECURRENCY = "action.after_deleteCurrency"; const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency'; + // -- Product templates management ----------------------------------------- const TEMPLATE_CREATE = "action.createTemplate"; @@ -396,6 +505,9 @@ final class TheliaEvents const TEMPLATE_ADD_FEATURE = "action.templateAddFeature"; const TEMPLATE_DELETE_FEATURE = "action.templateDeleteFeature"; + const TEMPLATE_CHANGE_FEATURE_POSITION = "action.templateChangeAttributePosition"; + const TEMPLATE_CHANGE_ATTRIBUTE_POSITION = "action.templateChangeFeaturePosition"; + const BEFORE_CREATETEMPLATE = "action.before_createTemplate"; const AFTER_CREATETEMPLATE = "action.after_createTemplate"; @@ -459,7 +571,6 @@ 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"; diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 9de281dbe..aefc0cf90 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -79,10 +79,20 @@ class ViewListener implements EventSubscriberInterface $content = $parser->getContent(); if ($content instanceof Response) { - $event->setResponse($content); + $response = $content;$event->setResponse($content); } else { - $event->setResponse(new Response($content, $parser->getStatus() ?: 200)); + $response = new Response($content, $parser->getStatus() ?: 200); } + + $response->setCache(array( + 'last_modified' => new \DateTime(), + 'max_age' => 600, + 's_maxage' => 600, + 'private' => false, + 'public' => true, + )); + + $event->setResponse($response); } catch (ResourceNotFoundException $e) { $event->setResponse(new Response($e->getMessage(), 404)); } catch (AuthenticationException $ex) { @@ -90,7 +100,7 @@ class ViewListener implements EventSubscriberInterface // Redirect to the login template Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate())); } catch (OrderException $e) { - switch($e->getCode()) { + switch ($e->getCode()) { case OrderException::CART_EMPTY: // Redirect to the cart template Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL)); diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index 8a0952ff4..09b932a98 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -51,10 +51,10 @@ class Session extends BaseSession public function getLang($forceDefault = true) { $lang = $this->get("thelia.current.lang"); - if(null === $lang && $forceDefault) - { + if (null === $lang && $forceDefault) { $lang = Lang::getDefaultLanguage(); } + return $lang; } @@ -65,23 +65,6 @@ class Session extends BaseSession return $this; } - public function getAdminEditionLang() - { - $lang = $this->get('thelia.admin.edition.lang'); - - if (null === $lang) { - $lang = Lang::getDefaultLanguage(); - } - return $lang; - } - - public function setAdminEditionLang($langId) - { - $this->set('thelia.admin.edition.lang', $langId); - - return $this; - } - public function setCurrency(Currency $currency) { $this->set("thelia.current.currency", $currency); @@ -91,13 +74,51 @@ class Session extends BaseSession { $currency = $this->get("thelia.current.currency"); - if(null === $currency && $forceDefault) - { + if (null === $currency && $forceDefault) { $currency = Currency::getDefaultCurrency(); } + return $currency; } + // -- Admin lang and currency ---------------------------------------------- + + public function getAdminEditionCurrency() + { + $currency = $this->get('thelia.admin.edition.currency', null); + + if (null === $currency) { + $currency = Currency::getDefaultCurrency(); + } + + return $currency; + } + + public function setAdminEditionCurrency($currencyId) + { + $this->set('thelia.admin.edition.currency', $currencyId); + + return $this; + } + + public function getAdminEditionLang() + { + $lang = $this->get('thelia.admin.edition.lang'); + + if (null === $lang) { + $lang = Lang::getDefaultLanguage(); + } + + return $lang; + } + + public function setAdminEditionLang($lang) + { + $this->set('thelia.admin.edition.lang', $lang); + + return $this; + } + // -- Customer user -------------------------------------------------------- public function setCustomerUser(UserInterface $user) @@ -167,7 +188,7 @@ class Session extends BaseSession $cart = null; if ($cart_id) { $cart = CartQuery::create()->findPk($cart_id); - if($cart) { + if ($cart) { try { $this->verifyValidCart($cart); } catch (InvalidCartException $e) { @@ -210,7 +231,6 @@ class Session extends BaseSession // -- Order ------------------------------------------------------------------ - public function setOrder(Order $order) { $this->set("thelia.order", $order); @@ -226,7 +246,6 @@ class Session extends BaseSession return $this->get("thelia.order"); } - /** * Set consumed coupons by the Customer * diff --git a/core/lib/Thelia/Core/HttpKernel/Exception/NotFountHttpException.php b/core/lib/Thelia/Core/HttpKernel/Exception/NotFountHttpException.php index a52f0eb86..41ca0bdc1 100644 --- a/core/lib/Thelia/Core/HttpKernel/Exception/NotFountHttpException.php +++ b/core/lib/Thelia/Core/HttpKernel/Exception/NotFountHttpException.php @@ -20,15 +20,15 @@ /* along with this program. If not, see . */ /* */ /*************************************************************************************/ -namespace Thelia\Core\HttpKernel\Exceptions; +namespace Thelia\Core\HttpKernel\Exception; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException as BaseNotFountHttpException; /** * Class NotFountHttpException * @author Manuel Raynaud */ -class NotFountHttpException extends BaseNotFountHttpException { - +class NotFountHttpException extends BaseNotFountHttpException +{ protected $adminContext = false; public function __construct($message = null, \Exception $previous = null, $code = 0, $adminContext = false) @@ -43,4 +43,4 @@ class NotFountHttpException extends BaseNotFountHttpException { return $this->adminContext === true; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php index 1c8c11c73..e00ae4375 100644 --- a/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Security\Authentication; use Thelia\Core\Security\Authentication\AuthenticatorInterface; -use Thelia\Core\Security\UserProvider\UserProviderInterface; use Thelia\Core\Security\UserProvider\TokenUserProvider; use Thelia\Core\Security\Exception\TokenAuthenticationException; @@ -51,7 +50,6 @@ class TokenAuthenticator implements AuthenticatorInterface $user = $this->userProvider->getUser($keyData); if ($user === null) throw new TokenAuthenticationException("No user matches the provided token"); - return $user; } } diff --git a/core/lib/Thelia/Core/Security/Token/TokenProvider.php b/core/lib/Thelia/Core/Security/Token/TokenProvider.php index e50b60602..32c5b7d6c 100644 --- a/core/lib/Thelia/Core/Security/Token/TokenProvider.php +++ b/core/lib/Thelia/Core/Security/Token/TokenProvider.php @@ -6,8 +6,8 @@ use Thelia\Core\Security\User\UserInterface; class TokenProvider { - public function encodeKey(UserInterface $user) { - + public function encodeKey(UserInterface $user) + { // Always set a new token in the user environment $user->setToken(uniqid()); @@ -15,7 +15,8 @@ class TokenProvider array($user->getUsername(), $user->getToken(), $user->getSerial()))); } - public function decodeKey($key) { + public function decodeKey($key) + { $data = unserialize(base64_decode($key)); return array( diff --git a/core/lib/Thelia/Core/Security/User/UserInterface.php b/core/lib/Thelia/Core/Security/User/UserInterface.php index cdff4d44e..113909a41 100755 --- a/core/lib/Thelia/Core/Security/User/UserInterface.php +++ b/core/lib/Thelia/Core/Security/User/UserInterface.php @@ -68,4 +68,4 @@ interface UserInterface * Set a serial number int the user data (used by remember me authnetication system) */ public function setSerial($serial); -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Security/UserProvider/AdminTokenUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/AdminTokenUserProvider.php index 4567176e5..ca36fc29a 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/AdminTokenUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/AdminTokenUserProvider.php @@ -23,13 +23,12 @@ namespace Thelia\Core\Security\UserProvider; -use Thelia\Model\Admin; use Thelia\Model\AdminQuery; class AdminTokenUserProvider extends TokenUserProvider { - public function getUser($dataArray) { - + public function getUser($dataArray) + { return AdminQuery::create() ->filterByLogin($dataArray['username']) ->filterByRememberMeSerial($dataArray['serial']) diff --git a/core/lib/Thelia/Core/Security/UserProvider/CustomerTokenUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/CustomerTokenUserProvider.php index 421d48dd4..e0ea58b84 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/CustomerTokenUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/CustomerTokenUserProvider.php @@ -23,17 +23,16 @@ namespace Thelia\Core\Security\UserProvider; -use Thelia\Action\Customer; use Thelia\Model\CustomerQuery; class CustomerTokenUserProvider extends TokenUserProvider { - public function getUser($dataArray) { - + public function getUser($dataArray) + { return CustomerQuery::create() ->filterByEmail($dataArray['username']) ->filterByRememberMeSerial($dataArray['serial']) ->filterByRememberMeToken($dataArray['token']) ->findOne(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php index 21db28cab..ccc15c3c7 100755 --- a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php @@ -35,4 +35,4 @@ class CustomerUserProvider implements UserProviderInterface return $customer; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Security/UserProvider/TokenUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/TokenUserProvider.php index 6c46bcbbb..e58a2e123 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/TokenUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/TokenUserProvider.php @@ -23,10 +23,9 @@ namespace Thelia\Core\Security\UserProvider; -use Thelia\Core\Security\User\UserInterface; use Thelia\Core\Security\Token\TokenProvider; abstract class TokenUserProvider extends TokenProvider implements UserProviderInterface { - public abstract function getUser($key); + abstract public function getUser($key); } diff --git a/core/lib/Thelia/Core/Template/Loop/Accessory.php b/core/lib/Thelia/Core/Template/Loop/Accessory.php index 6dc269b62..6b15a6715 100755 --- a/core/lib/Thelia/Core/Template/Loop/Accessory.php +++ b/core/lib/Thelia/Core/Template/Loop/Accessory.php @@ -74,6 +74,7 @@ class Accessory extends Product $search = AccessoryQuery::create(); $product = $this->getProduct(); + $search->filterByProductId($product, Criteria::IN); $order = $this->getOrder(); @@ -93,10 +94,16 @@ class Accessory extends Product $accessories = $this->search($search); $accessoryIdList = array(0); - $accessoryPosition = array(); + $accessoryPosition = $accessoryId = array(); + foreach ($accessories as $accessory) { - array_push($accessoryIdList, $accessory->getAccessory()); - $accessoryPosition[$accessory->getAccessory()] = $accessory->getPosition(); + + $accessoryProductId = $accessory->getAccessory(); + + array_push($accessoryIdList, $accessoryProductId); + + $accessoryPosition[$accessoryProductId] = $accessory->getPosition(); + $accessoryId[$accessoryProductId] = $accessory->getId(); } $receivedIdList = $this->getId(); @@ -110,13 +117,16 @@ class Accessory extends Product $loopResult = parent::exec($pagination); - foreach($loopResult as $loopResultRow) { + foreach ($loopResult as $loopResultRow) { + + $accessoryProductId = $loopResultRow->get('ID'); + $loopResultRow - ->set("POSITION" , $accessoryPosition[$loopResultRow->get('ID')]) - ; + ->set("ID" , $accessoryId[$accessoryProductId]) + ->set("POSITION", $accessoryPosition[$accessoryProductId]) + ; } return $loopResult; } - } diff --git a/core/lib/Thelia/Core/Template/Loop/Address.php b/core/lib/Thelia/Core/Template/Loop/Address.php index 9ca4352e9..5fe20b0e4 100755 --- a/core/lib/Thelia/Core/Template/Loop/Address.php +++ b/core/lib/Thelia/Core/Template/Loop/Address.php @@ -112,7 +112,7 @@ class Address extends BaseLoop if ($default === true) { $search->filterByIsDefault(1, Criteria::EQUAL); - } else if($default === false) { + } elseif ($default === false) { $search->filterByIsDefault(0, Criteria::EQUAL); } diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php index 418a76220..a9efad7ae 100755 --- a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php +++ b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php @@ -60,10 +60,10 @@ class Argument { $x = $value === null; - if($value === null) { + if ($value === null) { $this->value = null; } else { - if(false === $value) { + if (false === $value) { /* (string) $value = "" */ $this->value = 0; } else { diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 20fe5cb1e..6fc41fc9b 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -135,8 +135,17 @@ class AssociatedContent extends Content $associatedContents = $this->search($search); $associatedContentIdList = array(0); + + $contentIdList = array(0); + $contentPosition = $contentId = array(); + foreach ($associatedContents as $associatedContent) { - array_push($associatedContentIdList, $associatedContent->getContentId()); + + $associatedContentId = $associatedContent->getContentId(); + + array_push($associatedContentIdList, $associatedContentId); + $contentPosition[$associatedContentId] = $associatedContent->getPosition(); + $contentId[$associatedContentId] = $associatedContent->getId(); } $receivedIdList = $this->getId(); @@ -148,7 +157,18 @@ class AssociatedContent extends Content $this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $associatedContentIdList)) ); } - return parent::exec($pagination); - } + $loopResult = parent::exec($pagination); + foreach ($loopResult as $loopResultRow) { + + $relatedContentId = $loopResultRow->get('ID'); + + $loopResultRow + ->set("ID" , $contentId[$relatedContentId]) + ->set("POSITION", $contentPosition[$relatedContentId]) + ; + } + + return $loopResult; + } } diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index e2ea7cf0f..daad80979 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -31,17 +31,13 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Base\CategoryQuery; -use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\AttributeQuery; -use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Type\TypeCollection; use Thelia\Type; -use Thelia\Type\BooleanOrBothType; use Thelia\Model\ProductQuery; use Thelia\Model\TemplateQuery; use Thelia\Model\AttributeTemplateQuery; - +use Thelia\Model\Map\AttributeTemplateTableMap; /** * * Attribute loop @@ -106,33 +102,49 @@ class Attribute extends BaseI18nLoop $product = $this->getProduct(); $template = $this->getTemplate(); - - if (null !== $product) { - // Find the template assigned to the product. - $productObj = ProductQuery::create()->findPk($product); - - // Ignore if the product cannot be found. - if ($productObj !== null) - $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('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 - ); + $use_attribute_pos = true; + + if (null !== $product) { + // Find all template assigned to the products. + $products = ProductQuery::create()->findById($product); + + // Ignore if the product cannot be found. + if ($products !== null) { + + // Create template array + if ($template == null) $template = array(); + + foreach ($products as $product) { + $tpl_id = $product->getTemplateId(); + + if (! is_null($tpl_id)) $template[] = $tpl_id; + } + } + } + + if (! empty($template)) { + + // Join with feature_template table to get position + $search + ->withColumn(AttributeTemplateTableMap::POSITION, 'position') + ->filterByTemplate(TemplateQuery::create()->findById($template), Criteria::IN) + ; + + $use_attribute_pos = false; + } elseif (null !== $exclude_template) { + + // Join with attribute_template table to get position + $exclude_attributes = AttributeTemplateQuery::create()->filterByTemplateId($exclude_template)->select('attribute_id')->find(); + + $search + ->joinAttributeTemplate(null, Criteria::LEFT_JOIN) + ->withColumn(AttributeTemplateTableMap::POSITION, 'position') + ->filterById($exclude_attributes, Criteria::NOT_IN) + ; + + $use_attribute_pos = false; } $orders = $this->getOrder(); @@ -152,10 +164,16 @@ class Attribute extends BaseI18nLoop $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": - $search->orderByPosition(Criteria::ASC); + if ($use_attribute_pos) + $search->orderByPosition(Criteria::ASC); + else + $search->addAscendingOrderByColumn(AttributeTemplateTableMap::POSITION); break; case "manual_reverse": - $search->orderByPosition(Criteria::DESC); + if ($use_attribute_pos) + $search->orderByPosition(Criteria::DESC); + else + $search->addDescendingOrderByColumn(AttributeTemplateTableMap::POSITION); break; } } @@ -174,7 +192,8 @@ class Attribute extends BaseI18nLoop ->set("CHAPO", $attribute->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $attribute->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $attribute->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("POSITION", $attribute->getPosition()); + ->set("POSITION", $use_attribute_pos ? $attribute->getPosition() : $attribute->getVirtualColumn('position')) + ; $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 16c108135..5c08b2896 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -81,6 +81,8 @@ class Cart extends BaseLoop return $result; } + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic; + foreach ($cartItems as $cartItem) { $product = $cartItem->getProduct(); $productSaleElement = $cartItem->getProductSaleElements(); @@ -97,12 +99,8 @@ class Cart extends BaseLoop ->set("STOCK", $productSaleElement->getQuantity()) ->set("PRICE", $cartItem->getPrice()) ->set("PROMO_PRICE", $cartItem->getPromoPrice()) - ->set("TAXED_PRICE", $cartItem->getTaxedPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - )) - ->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - )) + ->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry)) + ->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry)) ->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0); $result->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index bd1c32de2..9c9ddab7d 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -35,6 +35,7 @@ use Thelia\Model\CategoryQuery; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; +use Thelia\Model\ProductQuery; /** * @@ -73,6 +74,8 @@ class Category extends BaseI18nLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntTypeArgument('parent'), + Argument::createIntTypeArgument('product'), + Argument::createIntTypeArgument('exclude_product'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('not_empty', 0), Argument::createBooleanOrBothTypeArgument('visible', 1), @@ -128,6 +131,22 @@ class Category extends BaseI18nLoop if ($this->getVisible() != BooleanOrBothType::ANY) $search->filterByVisible($this->getVisible() ? 1 : 0); + $product = $this->getProduct(); + + if ($product != null) { + $obj = ProductQuery::create()->findPk($product); + + if ($obj != null) $search->filterByProduct($obj, Criteria::IN); + } + + $exclude_product = $this->getExclude_product(); + + if ($exclude_product != null) { + $obj = ProductQuery::create()->findPk($exclude_product); + + if ($obj != null) $search->filterByProduct($obj, Criteria::NOT_IN); + } + $orders = $this->getOrder(); foreach ($orders as $order) { @@ -206,7 +225,8 @@ class Category extends BaseI18nLoop ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT", $category->getParent()) ->set("URL", $category->getUrl($locale)) - ->set("PRODUCT_COUNT", $category->countChild()) + ->set("PRODUCT_COUNT", $category->countAllProducts()) + ->set("CHILD_COUNT", $category->countChild()) ->set("VISIBLE", $category->getVisible() ? "1" : "0") ->set("POSITION", $category->getPosition()) diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php index 712767954..009e2204f 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php @@ -59,7 +59,7 @@ class CategoryTree extends BaseI18nLoop } // changement de rubrique - protected function buildCategoryTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult) + protected function buildCategoryTree($parent, $visible, $level, $previousLevel, $max_level, $exclude, LoopResult &$loopResult) { if ($level > $max_level) return; @@ -87,11 +87,12 @@ class CategoryTree extends BaseI18nLoop ->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE')) ->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale)) ->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level) + ->set('CHILD_COUNT', $result->countChild())->set('PREV_LEVEL', $previousLevel) ; $loopResult->addRow($loopResultRow); - $this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult); + $this->buildCategoryTree($result->getId(), $visible, 1 + $level, $level, $max_level, $exclude, $loopResult); } } @@ -109,7 +110,7 @@ class CategoryTree extends BaseI18nLoop $loopResult = new LoopResult(); - $this->buildCategoryTree($id, $visible, 0, $depth, $exclude, $loopResult); + $this->buildCategoryTree($id, $visible, 0, 0, $depth, $exclude, $loopResult); return $loopResult; } diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index a29cb2e60..ce966bf5c 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -234,7 +234,9 @@ class Content extends BaseI18nLoop ->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("POSITION", $content->getPosition()) + ->set("DEFAULT_FOLDER", $content->getDefaultFolderId()) ->set("URL", $content->getUrl($locale)) + ->set("VISIBLE", $content->getVisible()) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 4e8ca3e71..61e3b2762 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -25,21 +25,18 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Util\PropelModelPager; -use Thelia\Constraint\ConstraintFactory; -use Thelia\Constraint\Rule\CouponRuleInterface; +use Thelia\Condition\ConditionFactory; +use Thelia\Condition\ConditionManagerInterface; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; - -use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; - +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Coupon\Type\CouponInterface; -use Thelia\Model\CouponQuery; use Thelia\Model\Coupon as MCoupon; +use Thelia\Model\CouponQuery; use Thelia\Type; -use Thelia\Type\BooleanOrBothType; /** * Created by JetBrains PhpStorm. @@ -63,14 +60,14 @@ class Coupon extends BaseI18nLoop { return new ArgumentCollection( Argument::createIntListTypeArgument('id'), - Argument::createBooleanOrBothTypeArgument('is_enabled', 1) + Argument::createBooleanOrBothTypeArgument('is_enabled') ); } /** * Execute Loop * - * @param PropelModelPager $pagination + * @param PropelModelPager $pagination Pagination manager * * @return \Thelia\Core\Template\Element\LoopResult */ @@ -88,16 +85,16 @@ class Coupon extends BaseI18nLoop $search->filterById($id, Criteria::IN); } - if ($isEnabled != BooleanOrBothType::ANY) { - $search->filterByIsEnabled($isEnabled ? 1 : 0); + if (isset($isEnabled)) { + $search->filterByIsEnabled($isEnabled ? true : false); } // Perform search $coupons = $this->search($search, $pagination); $loopResult = new LoopResult(); - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $this->container->get('thelia.constraint.factory'); + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $this->container->get('thelia.condition.factory'); /** @var Request $request */ $request = $this->container->get('request'); @@ -107,8 +104,8 @@ class Coupon extends BaseI18nLoop /** @var MCoupon $coupon */ foreach ($coupons as $coupon) { $loopResultRow = new LoopResultRow(); - $rules = $constraintFactory->unserializeCouponRuleCollection( - $coupon->getSerializedRules() + $conditions = $conditionFactory->unserializeConditionCollection( + $coupon->getSerializedConditions() ); /** @var CouponInterface $couponManager */ @@ -132,10 +129,10 @@ class Coupon extends BaseI18nLoop $datediff = $coupon->getExpirationDate()->getTimestamp() - $now; $daysLeftBeforeExpiration = floor($datediff/(60*60*24)); - $cleanedRules = array(); - /** @var CouponRuleInterface $rule */ - foreach ($rules->getRules() as $rule) { - $cleanedRules[] = $rule->getToolTip(); + $cleanedConditions = array(); + /** @var ConditionManagerInterface $condition */ + foreach ($conditions->getConditions() as $condition) { + $cleanedConditions[] = $condition->getToolTip(); } $loopResultRow->set("ID", $coupon->getId()) ->set("IS_TRANSLATED", $coupon->getVirtualColumn('IS_TRANSLATED')) @@ -151,7 +148,7 @@ class Coupon extends BaseI18nLoop ->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $coupon->getIsAvailableOnSpecialOffers()) ->set("IS_ENABLED", $coupon->getIsEnabled()) ->set("AMOUNT", $coupon->getAmount()) - ->set("APPLICATION_CONDITIONS", $cleanedRules) + ->set("APPLICATION_CONDITIONS", $cleanedConditions) ->set("TOOLTIP", $couponManager->getToolTip()) ->set("DAY_LEFT_BEFORE_EXPIRATION", $daysLeftBeforeExpiration) ->set("SERVICE_ID", $couponManager->getServiceId()); diff --git a/core/lib/Thelia/Core/Template/Loop/Customer.php b/core/lib/Thelia/Core/Template/Loop/Customer.php index e0ce92c76..e811606c0 100755 --- a/core/lib/Thelia/Core/Template/Loop/Customer.php +++ b/core/lib/Thelia/Core/Template/Loop/Customer.php @@ -63,7 +63,6 @@ class Customer extends BaseLoop ) ), Argument::createBooleanTypeArgument('reseller'), - Argument::createBooleanTypeArgument('last_order'), Argument::createIntTypeArgument('sponsor') ); } @@ -130,20 +129,6 @@ class Customer extends BaseLoop $loopResultRow->set("SPONSOR", $customer->getSponsor()); $loopResultRow->set("DISCOUNT", $customer->getDiscount()); - $lastOrderDate = ""; - $lastOrderAmount = ""; - - if ($this->getLastOrder()) { - $order = $customer->getOrders()->getFirst(); - if ($order) { - $lastOrderDate = $order->getCreatedAt(); - $lastOrderAmount = $order->getTotalAmount(); - } - } - - $loopResultRow->set("LASTORDER_DATE", $lastOrderDate); - $loopResultRow->set("LASTORDER_AMOUNT", $lastOrderAmount); - $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php index 5d33d398d..3a0c5cb31 100644 --- a/core/lib/Thelia/Core/Template/Loop/Delivery.php +++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php @@ -57,9 +57,9 @@ class Delivery extends BaseSpecificModule $search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL); $countryId = $this->getCountry(); - if(null !== $countryId) { + if (null !== $countryId) { $country = CountryQuery::create()->findPk($countryId); - if(null === $country) { + if (null === $country) { throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop'); } } else { diff --git a/core/lib/Thelia/Core/Template/Loop/Document.php b/core/lib/Thelia/Core/Template/Loop/Document.php index 0e7e979c9..9f99a6fa4 100644 --- a/core/lib/Thelia/Core/Template/Loop/Document.php +++ b/core/lib/Thelia/Core/Template/Loop/Document.php @@ -24,7 +24,7 @@ namespace Thelia\Core\Template\Loop; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Core\Event\DocumentEvent; +use Thelia\Core\Event\Document\DocumentEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Type\TypeCollection; @@ -251,9 +251,9 @@ class Document extends BaseI18nLoop $loopResultRow ->set("ID" , $result->getId()) - ->set("LOCALE" ,$locale) + ->set("LOCALE" , $locale) ->set("DOCUMENT_URL" , $event->getFileUrl()) - ->set("DOCUMENT_PATH" , $event->getCacheFilepath()) + ->set("DOCUMENT_PATH" , $event->getDocumentPath()) ->set("ORIGINAL_DOCUMENT_PATH", $source_filepath) ->set("TITLE" , $result->getVirtualColumn('i18n_TITLE')) ->set("CHAPO" , $result->getVirtualColumn('i18n_CHAPO')) @@ -265,8 +265,7 @@ class Document extends BaseI18nLoop ; $loopResult->addRow($loopResultRow); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Ignore the result and log an error Tlog::getInstance()->addError("Failed to process document in document loop: ", $this->args); } diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index 380333e38..89b338b0f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -31,16 +31,15 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\CategoryQuery; use Thelia\Model\FeatureI18nQuery; -use Thelia\Model\ProductCategoryQuery; use Thelia\Model\FeatureQuery; -use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Model\ProductQuery; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; use Thelia\Model\FeatureTemplateQuery; +use Thelia\Model\TemplateQuery; +use Thelia\Model\Map\FeatureTemplateTableMap; /** * @@ -70,7 +69,7 @@ class Feature extends BaseI18nLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual_reverse')) + new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha-reverse', 'manual', 'manual_reverse')) ), 'manual' ), @@ -108,45 +107,61 @@ class Feature extends BaseI18nLoop $product = $this->getProduct(); $template = $this->getTemplate(); - - if (null !== $product) { - // Find the template assigned to the product. - $productObj = ProductQuery::create()->findPk($product); - - // 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 - ); - } - $exclude_template = $this->getExcludeTemplate(); - // If we have to filter by template, find all features assigned to this template, and filter by found IDs + $use_feature_pos = true; + + if (null !== $product) { + // Find all template assigned to the products. + $products = ProductQuery::create()->findById($product); + + // Ignore if the product cannot be found. + if ($products !== null) { + + // Create template array + if ($template == null) $template = array(); + + foreach ($products as $product) { + $tpl_id = $product->getTemplateId(); + + if (! is_null($tpl_id)) $template[] = $tpl_id; + } + } + } + + if (! empty($template)) { + + // Join with feature_template table to get position + $search + ->withColumn(FeatureTemplateTableMap::POSITION, 'position') + ->filterByTemplate(TemplateQuery::create()->findById($template), Criteria::IN) + ; + + $use_feature_pos = false; + } + 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 - ); + $exclude_features = FeatureTemplateQuery::create()->filterByTemplateId($exclude_template)->select('feature_id')->find(); + + $search + ->joinFeatureTemplate(null, Criteria::LEFT_JOIN) + ->withColumn(FeatureTemplateTableMap::POSITION, 'position') + ->filterById($exclude_features, Criteria::NOT_IN) + ; + + $use_feature_pos = false; } $title = $this->getTitle(); if (null !== $title) { - //find all feture that match exactly this title and find with all locales. + //find all feature that match exactly this title and find with all locales. $features = FeatureI18nQuery::create() ->filterByTitle($title, Criteria::LIKE) ->select('id') ->find(); - if($features) { + if ($features) { $search->filterById( $features, Criteria::IN @@ -158,6 +173,12 @@ class Feature extends BaseI18nLoop foreach ($orders as $order) { switch ($order) { + case "id": + $search->orderById(Criteria::ASC); + break; + case "id_reverse": + $search->orderById(Criteria::DESC); + break; case "alpha": $search->addAscendingOrderByColumn('i18n_TITLE'); break; @@ -165,12 +186,19 @@ class Feature extends BaseI18nLoop $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": - $search->orderByPosition(Criteria::ASC); + if ($use_feature_pos) + $search->orderByPosition(Criteria::ASC); + else + $search->addAscendingOrderByColumn(FeatureTemplateTableMap::POSITION); break; case "manual_reverse": - $search->orderByPosition(Criteria::DESC); + if ($use_feature_pos) + $search->orderByPosition(Criteria::DESC); + else + $search->addDescendingOrderByColumn(FeatureTemplateTableMap::POSITION); break; } + } /* perform search */ @@ -187,7 +215,8 @@ class Feature extends BaseI18nLoop ->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO')) ->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION')) ->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("POSITION", $feature->getPosition()); + ->set("POSITION", $use_feature_pos ? $feature->getPosition() : $feature->getVirtualColumn('position')) + ; $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php index 30a8dcf27..8ae8b0f4f 100755 --- a/core/lib/Thelia/Core/Template/Loop/FeatureValue.php +++ b/core/lib/Thelia/Core/Template/Loop/FeatureValue.php @@ -59,7 +59,7 @@ class FeatureValue extends BaseI18nLoop Argument::createIntTypeArgument('product', null, true), Argument::createIntListTypeArgument('feature_availability'), Argument::createBooleanTypeArgument('exclude_feature_availability', 0), - Argument::createBooleanTypeArgument('exclude_personal_values', 0), + Argument::createBooleanTypeArgument('exclude_free_text', 0), new Argument( 'order', new TypeCollection( @@ -79,7 +79,7 @@ class FeatureValue extends BaseI18nLoop { $search = FeatureProductQuery::create(); - /* manage featureAv translations */ + // manage featureAv translations $locale = $this->configureI18nProcessing( $search, array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), @@ -103,13 +103,9 @@ class FeatureValue extends BaseI18nLoop } $excludeFeatureAvailability = $this->getExclude_feature_availability(); - if ($excludeFeatureAvailability == true) { - $search->filterByFeatureAvId(null, Criteria::NULL); - } - $excludeDefaultValues = $this->getExclude_personal_values(); - if ($excludeDefaultValues == true) { - $search->filterByByDefault(null, Criteria::NULL); + if ($excludeFeatureAvailability == true) { + $search->filterByFeatureAvId(null, Criteria::ISNULL); } $orders = $this->getOrder(); @@ -136,17 +132,26 @@ class FeatureValue extends BaseI18nLoop $loopResult = new LoopResult($featureValues); foreach ($featureValues as $featureValue) { + $loopResultRow = new LoopResultRow($loopResult, $featureValue, $this->versionable, $this->timestampable, $this->countable); - $loopResultRow->set("ID", $featureValue->getId()); $loopResultRow - ->set("LOCALE",$locale) - ->set("PERSONAL_VALUE", $featureValue->getByDefault()) - ->set("TITLE",$featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE')) - ->set("CHAPO", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_CHAPO')) - ->set("DESCRIPTION", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')) - ->set("POSITION", $featureValue->getPosition()); + ->set("ID" , $featureValue->getId()) + ->set("PRODUCT" , $featureValue->getProductId()) + ->set("FEATURE_AV_ID" , $featureValue->getFeatureAvId()) + ->set("FREE_TEXT_VALUE" , $featureValue->getFreeTextValue()) + + ->set("IS_FREE_TEXT" , is_null($featureValue->getFeatureAvId()) ? 1 : 0) + ->set("IS_FEATURE_AV" , is_null($featureValue->getFeatureAvId()) ? 0 : 1) + + ->set("LOCALE" , $locale) + ->set("TITLE" , $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE')) + ->set("CHAPO" , $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_CHAPO')) + ->set("DESCRIPTION" , $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')) + + ->set("POSITION" , $featureValue->getPosition()) + ; $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index cfd54db4f..04ba737fa 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -31,6 +31,7 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\ContentQuery; use Thelia\Model\FolderQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -55,6 +56,7 @@ class Folder extends BaseI18nLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntTypeArgument('parent'), + Argument::createIntTypeArgument('content'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('not_empty', 0), Argument::createBooleanOrBothTypeArgument('visible', 1), @@ -107,6 +109,16 @@ class Folder extends BaseI18nLoop $search->filterById($exclude, Criteria::NOT_IN); } + $content = $this->getContent(); + + if (null !== $content) { + $obj = ContentQuery::create()->findPk($content); + + if($obj) { + $search->filterByContent($obj, Criteria::IN); + } + } + $visible = $this->getVisible(); if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); @@ -162,7 +174,8 @@ class Folder extends BaseI18nLoop ->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("PARENT", $folder->getParent()) ->set("URL", $folder->getUrl($locale)) - ->set("CONTENT_COUNT", $folder->countChild()) + ->set("CHILD_COUNT", $folder->countChild()) + ->set("CONTENT_COUNT", $folder->countAllContents()) ->set("VISIBLE", $folder->getVisible() ? "1" : "0") ->set("POSITION", $folder->getPosition()) ; diff --git a/core/lib/Thelia/Core/Template/Loop/FolderPath.php b/core/lib/Thelia/Core/Template/Loop/FolderPath.php new file mode 100644 index 000000000..272b9fbbb --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/FolderPath.php @@ -0,0 +1,160 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Model\FolderQuery; +use Thelia\Type\BooleanOrBothType; + + +/** + * Class FolderPath + * @package Thelia\Core\Template\Loop + * @author Manuel Raynaud + */ +class FolderPath extends BaseI18nLoop +{ + + /** + * + * define all args used in your loop + * + * + * example : + * + * public function getArgDefinitions() + * { + * return new ArgumentCollection( + * Argument::createIntListTypeArgument('id'), + * new Argument( + * 'ref', + * new TypeCollection( + * new Type\AlphaNumStringListType() + * ) + * ), + * Argument::createIntListTypeArgument('category'), + * Argument::createBooleanTypeArgument('new'), + * Argument::createBooleanTypeArgument('promo'), + * Argument::createFloatTypeArgument('min_price'), + * Argument::createFloatTypeArgument('max_price'), + * Argument::createIntTypeArgument('min_stock'), + * Argument::createFloatTypeArgument('min_weight'), + * Argument::createFloatTypeArgument('max_weight'), + * Argument::createBooleanTypeArgument('current'), + * + * ); + * } + * + * @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('folder', null, true), + Argument::createIntTypeArgument('depth'), + Argument::createIntTypeArgument('level'), + Argument::createBooleanOrBothTypeArgument('visible', true, false) + ); + } + + /** + * + * this function have to be implement in your own loop class. + * + * All loops parameters can be accessible via getter. + * + * for example, ref parameter is accessible through getRef method + * + * @param $pagination + * + * @return mixed + */ + public function exec(&$pagination) + { + $id = $this->getFolder(); + $visible = $this->getVisible(); + + $search = FolderQuery::create(); + + $locale = $this->configureI18nProcessing($search, array('TITLE')); + + $search->filterById($id); + if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); + + $results = array(); + + $ids = array(); + + do { + $folder = $search->findOne(); + + if ($folder != null) { + + $loopResultRow = new LoopResultRow(); + + $loopResultRow + ->set("TITLE",$folder->getVirtualColumn('i18n_TITLE')) + ->set("URL", $folder->getUrl($locale)) + ->set("ID", $folder->getId()) + ->set("LOCALE",$locale) + ; + + $results[] = $loopResultRow; + + $parent = $folder->getParent(); + + if ($parent > 0) { + + // Prevent circular refererences + if (in_array($parent, $ids)) { + throw new \LogicException(sprintf("Circular reference detected in folder ID=%d hierarchy (folder ID=%d appears more than one times in path)", $id, $parent)); + } + + $ids[] = $parent; + + $search = FolderQuery::create(); + + $this->configureI18nProcessing($search, array('TITLE')); + + $search->filterById($parent); + if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); + } + } + } while ($folder != null && $parent > 0); + + // Reverse list and build the final result + $results = array_reverse($results); + + $loopResult = new LoopResult(); + + foreach($results as $result) $loopResult->addRow($result); + + return $loopResult; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index a62f23702..b20b161a3 100755 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -24,7 +24,7 @@ namespace Thelia\Core\Template\Loop; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Core\Event\ImageEvent; +use Thelia\Core\Event\Image\ImageEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Type\TypeCollection; @@ -318,8 +318,7 @@ class Image extends BaseI18nLoop ; $loopResult->addRow($loopResultRow); - } - catch (\Exception $ex) { + } catch (\Exception $ex) { // Ignore the result and log an error Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args); } diff --git a/core/lib/Thelia/Core/Template/Loop/Module.php b/core/lib/Thelia/Core/Template/Loop/Module.php new file mode 100755 index 000000000..d780658c0 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Module.php @@ -0,0 +1,137 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\ModuleQuery; + +use Thelia\Module\BaseModule; +use Thelia\Type; + +/** + * + * Module loop + * + * + * Class Module + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Module extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'module_type', + new Type\TypeCollection( + new Type\EnumListType(array( + BaseModule::CLASSIC_MODULE_TYPE, + BaseModule::DELIVERY_MODULE_TYPE, + BaseModule::PAYMENT_MODULE_TYPE, + )) + ) + ), + Argument::createIntListTypeArgument('exclude'), + Argument::createBooleanOrBothTypeArgument('active', Type\BooleanOrBothType::ANY) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = ModuleQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $moduleType = $this->getModule_type(); + + if (null !== $moduleType) { + $search->filterByType($moduleType, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $active = $this->getActive(); + + if ($active !== Type\BooleanOrBothType::ANY) { + $search->filterByActivate($active ? 1 : 0, Criteria::EQUAL); + } + + $search->orderByPosition(); + + /* perform search */ + $modules = $this->search($search, $pagination); + + $loopResult = new LoopResult($modules); + + foreach ($modules as $module) { + $loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $module->getId()) + ->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("TITLE",$module->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $module->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("CODE", $module->getCode()) + ->set("TYPE", $module->getType()) + ->set("ACTIVE", $module->getActivate()) + ->set("CLASS", $module->getFullNamespace()) + ->set("POSITION", $module->getPosition()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index fd11d8d4c..5b1e97cc1 100755 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -23,12 +23,16 @@ namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; - +use Thelia\Model\OrderQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; /** * * @package Thelia\Core\Template\Loop @@ -37,19 +41,120 @@ use Thelia\Core\Template\Loop\Argument\Argument; */ class Order extends BaseLoop { + public $countable = true; + public $timestampable = true; + public $versionable = false; + public function getArgDefinitions() { - return new ArgumentCollection(); + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'customer', + new TypeCollection( + new Type\IntType(), + new Type\EnumType(array('current', '*')) + ), + 'current' + ), + new Argument( + 'status', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('*')) + ) + ), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('create-date', 'create-date-reverse')) + ), + 'create-date-reverse' + ) + ); } /** + * @param $pagination * - * - * @return \Thelia\Core\Template\Element\LoopResult + * @return LoopResult */ public function exec(&$pagination) { - // TODO : a coder ! - return new LoopResult(); + $search = OrderQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $customer = $this->getCustomer(); + + if ($customer === 'current') { + $currentCustomer = $this->securityContext->getCustomerUser(); + if ($currentCustomer === null) { + return new LoopResult(); + } else { + $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL); + } + } elseif ($customer !== '*') { + $search->filterByCustomerId($customer, Criteria::EQUAL); + } + + $status = $this->getStatus(); + + if (null !== $status && $status != '*') { + $search->filterByStatusId($status, Criteria::IN); + } + + $orderers = $this->getOrder(); + + foreach ($orderers as $orderer) { + switch ($orderer) { + case "create-date": + $search->orderByCreatedAt(Criteria::ASC); + break; + case "create-date-reverse": + $search->orderByCreatedAt(Criteria::DESC); + break; + } + } + + $orders = $this->search($search, $pagination); + + $loopResult = new LoopResult($orders); + + foreach ($orders as $order) { + $tax = 0; + $amount = $order->getTotalAmount($tax); + $loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow + ->set("ID", $order->getId()) + ->set("REF", $order->getRef()) + ->set("CUSTOMER", $order->getCustomerId()) + ->set("DELIVERY_ADDRESS", $order->getDeliveryOrderAddressId()) + ->set("INVOICE_ADDRESS", $order->getInvoiceOrderAddressId()) + ->set("INVOICE_DATE", $order->getInvoiceDate()) + ->set("CURRENCY", $order->getCurrencyId()) + ->set("CURRENCY_RATE", $order->getCurrencyRate()) + ->set("TRANSACTION_REF", $order->getTransactionRef()) + ->set("DELIVERY_REF", $order->getDeliveryRef()) + ->set("INVOICE_REF", $order->getInvoiceRef()) + ->set("POSTAGE", $order->getPostage()) + ->set("PAYMENT_MODULE", $order->getPaymentModuleId()) + ->set("DELIVERY_MODULE", $order->getDeliveryModuleId()) + ->set("STATUS", $order->getStatusId()) + ->set("LANG", $order->getLangId()) + ->set("POSTAGE", $order->getPostage()) + ->set("TOTAL_TAX", $tax) + ->set("TOTAL_AMOUNT", $amount - $tax) + ->set("TOTAL_TAXED_AMOUNT", $amount) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; } } diff --git a/core/lib/Thelia/Core/Template/Loop/OrderAddress.php b/core/lib/Thelia/Core/Template/Loop/OrderAddress.php new file mode 100755 index 000000000..38dcb0239 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/OrderAddress.php @@ -0,0 +1,98 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\OrderAddressQuery; + +/** + * + * OrderAddress loop + * + * + * Class OrderAddress + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class OrderAddress extends BaseLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('id', null, true) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = OrderAddressQuery::create(); + + $id = $this->getId(); + + $search->filterById($id, Criteria::IN); + + $orderAddresses = $this->search($search, $pagination); + + $loopResult = new LoopResult($orderAddresses); + + foreach ($orderAddresses as $orderAddress) { + $loopResultRow = new LoopResultRow($loopResult, $orderAddress, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow + ->set("ID", $orderAddress->getId()) + ->set("TITLE", $orderAddress->getCustomerTitleId()) + ->set("COMPANY", $orderAddress->getCompany()) + ->set("FIRSTNAME", $orderAddress->getFirstname()) + ->set("LASTNAME", $orderAddress->getLastname()) + ->set("ADDRESS1", $orderAddress->getAddress1()) + ->set("ADDRESS2", $orderAddress->getAddress2()) + ->set("ADDRESS3", $orderAddress->getAddress3()) + ->set("ZIPCODE", $orderAddress->getZipcode()) + ->set("CITY", $orderAddress->getCity()) + ->set("COUNTRY", $orderAddress->getCountryId()) + ->set("PHONE", $orderAddress->getPhone()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/OrderProduct.php b/core/lib/Thelia/Core/Template/Loop/OrderProduct.php new file mode 100755 index 000000000..ab1fa2ab1 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/OrderProduct.php @@ -0,0 +1,118 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\Base\OrderProductQuery; + +/** + * + * OrderProduct loop + * + * Class OrderProduct + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class OrderProduct extends BaseLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('order', null, true) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + * @throws \InvalidArgumentException + */ + public function exec(&$pagination) + { + $search = OrderProductQuery::create(); + + $search->joinOrderProductTax('opt', Criteria::LEFT_JOIN) + ->withColumn('SUM(`opt`.AMOUNT)', 'TOTAL_TAX') + ->withColumn('SUM(`opt`.PROMO_AMOUNT)', 'TOTAL_PROMO_TAX') + ->groupById(); + + $order = $this->getOrder(); + + $search->filterByOrderId($order, Criteria::EQUAL); + + $search->orderById(Criteria::ASC); + + $products = $this->search($search, $pagination); + + $loopResult = new LoopResult($products); + + foreach ($products as $product) { + $loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable); + + $price = $product->getPrice(); + $taxedPrice = $price + round($product->getVirtualColumn('TOTAL_TAX'), 2); + $promoPrice = $product->getPromoPrice(); + $taxedPromoPrice = $promoPrice + round($product->getVirtualColumn('TOTAL_PROMO_TAX'), 2); + + $loopResultRow->set("ID", $product->getId()) + ->set("REF", $product->getProductRef()) + ->set("PRODUCT_SALE_ELEMENTS_REF", $product->getProductSaleElementsRef()) + ->set("WAS_NEW", $product->getWasNew() === 1 ? 1 : 0) + ->set("WAS_IN_PROMO", $product->getWasInPromo() === 1 ? 1 : 0) + ->set("WEIGHT", $product->getWeight()) + ->set("TITLE", $product->getTitle()) + ->set("CHAPO", $product->getChapo()) + ->set("DESCRIPTION", $product->getDescription()) + ->set("POSTSCRIPTUM", $product->getPostscriptum()) + ->set("QUANTITY", $product->getQuantity()) + ->set("PRICE", $price) + ->set("PRICE_TAX", $taxedPrice - $price) + ->set("TAXED_PRICE", $taxedPrice) + ->set("PROMO_PRICE", $promoPrice) + ->set("PROMO_PRICE_TAX", $taxedPromoPrice - $promoPrice) + ->set("TAXED_PROMO_PRICE", $taxedPromoPrice) + ->set("TAX_RULE_TITLE", $product->getTaxRuleTitle()) + ->set("TAX_RULE_DESCRIPTION", $product->getTaxRuledescription()) + ->set("PARENT", $product->getParent()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php new file mode 100755 index 000000000..623d0bae5 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php @@ -0,0 +1,117 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\Base\OrderProductAttributeCombinationQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * OrderProductOrderProductAttributeCombination loop + * + * Class OrderProductAttributeCombination + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class OrderProductAttributeCombination extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('order_product', null, true), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('alpha', 'alpha_reverse')) + ), + 'alpha' + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = OrderProductAttributeCombinationQuery::create(); + + $orderProduct = $this->getOrder_product(); + + $search->filterByOrderProductId($orderProduct, Criteria::EQUAL); + + $orders = $this->getOrder(); + + foreach ($orders as $order) { + switch ($order) { + case "alpha": + $search->orderByAttributeTitle(Criteria::ASC); + break; + case "alpha_reverse": + $search->orderByAttributeTitle(Criteria::DESC); + break; + } + } + + $attributeCombinations = $this->search($search, $pagination); + + $loopResult = new LoopResult($attributeCombinations); + + foreach ($attributeCombinations as $attributeCombination) { + $loopResultRow = new LoopResultRow($loopResult, $attributeCombination, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("LOCALE",$locale) + ->set("ATTRIBUTE_TITLE", $attributeCombination->getAttributeTitle()) + ->set("ATTRIBUTE_CHAPO", $attributeCombination->getAttributeChapo()) + ->set("ATTRIBUTE_DESCRIPTION", $attributeCombination->getAttributeDescription()) + ->set("ATTRIBUTE_POSTSCRIPTUM", $attributeCombination->getAttributePostscriptum()) + ->set("ATTRIBUTE_AVAILABILITY_TITLE", $attributeCombination->getAttributeAvTitle()) + ->set("ATTRIBUTE_AVAILABILITY_CHAPO", $attributeCombination->getAttributeAvChapo()) + ->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $attributeCombination->getAttributeAvDescription()) + ->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $attributeCombination->getAttributeAvPostscriptum()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/OrderStatus.php b/core/lib/Thelia/Core/Template/Loop/OrderStatus.php index 7f0e97c4f..0f0d144c4 100755 --- a/core/lib/Thelia/Core/Template/Loop/OrderStatus.php +++ b/core/lib/Thelia/Core/Template/Loop/OrderStatus.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -23,33 +23,77 @@ namespace Thelia\Core\Template\Loop; -use Thelia\Core\Template\Element\BaseLoop; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\OrderStatusQuery; + /** * - * @package Thelia\Core\Template\Loop + * OrderStatus loop * - * @author Franck Allimant + * + * Class OrderStatus + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix */ -class OrderStatus extends BaseLoop +class OrderStatus extends BaseI18nLoop { - public function getArgDefinitions() + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() { - return new ArgumentCollection(); + return new ArgumentCollection( + Argument::createIntListTypeArgument('id') + ); } /** - * + * @param $pagination * * @return \Thelia\Core\Template\Element\LoopResult */ public function exec(&$pagination) { - // TODO : a coder ! - return new LoopResult(); + $search = OrderStatusQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + /* perform search */ + $orderStatusList = $this->search($search, $pagination); + + $loopResult = new LoopResult($orderStatusList); + + foreach ($orderStatusList as $orderStatus) { + $loopResultRow = new LoopResultRow($loopResult, $orderStatus, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $orderStatus->getId()) + ->set("IS_TRANSLATED",$orderStatus->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("CODE", $orderStatus->getCode()) + ->set("TITLE", $orderStatus->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $orderStatus->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $orderStatus->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $orderStatus->getVirtualColumn('i18n_POSTSCRIPTUM')) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; } } diff --git a/core/lib/Thelia/Core/Template/Loop/Payment.php b/core/lib/Thelia/Core/Template/Loop/Payment.php index 542ffb590..ca0aaa18f 100644 --- a/core/lib/Thelia/Core/Template/Loop/Payment.php +++ b/core/lib/Thelia/Core/Template/Loop/Payment.php @@ -25,7 +25,6 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; -use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Module\BaseModule; /** diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 9deade5cc..f0bb95249 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -138,9 +138,9 @@ class Product extends BaseI18nLoop public function exec(&$pagination) { $currencyId = $this->getCurrency(); - if(null !== $currencyId) { + if (null !== $currencyId) { $currency = CurrencyQuery::create()->findOneById($currencyId); - if(null === $currency) { + if (null === $currency) { throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); } } else { @@ -610,7 +610,7 @@ class Product extends BaseI18nLoop $taxedPrice = $product->getTaxedPrice( $taxCountry ); - } catch(TaxEngineException $e) { + } catch (TaxEngineException $e) { $taxedPrice = null; } @@ -650,6 +650,7 @@ class Product extends BaseI18nLoop ->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new')) ->set("POSITION" , $product->getPosition()) ->set("VISIBLE" , $product->getVisible() ? "1" : "0") + ->set("TEMPLATE" , $product->getTemplateId()) ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) ->set("HAS_NEXT" , $next != null ? 1 : 0) ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index 8fb044556..aa71d2b3c 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -158,7 +158,7 @@ class ProductSaleElements extends BaseLoop $taxedPrice = $PSEValue->getTaxedPrice( $taxCountry ); - } catch(TaxEngineException $e) { + } catch (TaxEngineException $e) { $taxedPrice = null; } $promoPrice = $PSEValue->getPromoPrice(); @@ -166,21 +166,23 @@ class ProductSaleElements extends BaseLoop $taxedPromoPrice = $PSEValue->getTaxedPromoPrice( $taxCountry ); - } catch(TaxEngineException $e) { + } catch (TaxEngineException $e) { $taxedPromoPrice = null; } - $loopResultRow->set("ID", $PSEValue->getId()) - ->set("QUANTITY", $PSEValue->getQuantity()) - ->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0) - ->set("IS_NEW", $PSEValue->getNewness() === 1 ? 1 : 0) - ->set("WEIGHT", $PSEValue->getWeight()) - ->set("PRICE", $price) - ->set("PRICE_TAX", $taxedPrice - $price) - ->set("TAXED_PRICE", $taxedPrice) - ->set("PROMO_PRICE", $promoPrice) - ->set("PROMO_PRICE_TAX", $taxedPromoPrice - $promoPrice) - ->set("TAXED_PROMO_PRICE", $taxedPromoPrice); + $loopResultRow + ->set("ID" , $PSEValue->getId()) + ->set("QUANTITY" , $PSEValue->getQuantity()) + ->set("IS_PROMO" , $PSEValue->getPromo() === 1 ? 1 : 0) + ->set("IS_NEW" , $PSEValue->getNewness() === 1 ? 1 : 0) + ->set("IS_DEFAULT" , $PSEValue->getIsDefault() === 1 ? 1 : 0) + ->set("WEIGHT" , $PSEValue->getWeight()) + ->set("PRICE" , $price) + ->set("PRICE_TAX" , $taxedPrice - $price) + ->set("TAXED_PRICE" , $taxedPrice) + ->set("PROMO_PRICE" , $promoPrice) + ->set("PROMO_PRICE_TAX" , $taxedPromoPrice - $promoPrice) + ->set("TAXED_PROMO_PRICE" , $taxedPromoPrice); $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/TaxRule.php b/core/lib/Thelia/Core/Template/Loop/TaxRule.php index 5851f631d..e1c30d177 100644 --- a/core/lib/Thelia/Core/Template/Loop/TaxRule.php +++ b/core/lib/Thelia/Core/Template/Loop/TaxRule.php @@ -132,4 +132,4 @@ class TaxRule extends BaseI18nLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Template.php b/core/lib/Thelia/Core/Template/Loop/Template.php index db8bca7ee..9eaa3ea4f 100644 --- a/core/lib/Thelia/Core/Template/Loop/Template.php +++ b/core/lib/Thelia/Core/Template/Loop/Template.php @@ -31,13 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Model\Base\CategoryQuery; -use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\TemplateQuery; -use Thelia\Model\Map\ProductCategoryTableMap; -use Thelia\Type\TypeCollection; use Thelia\Type; -use Thelia\Type\BooleanOrBothType; /** * @@ -111,4 +106,4 @@ class Template extends BaseI18nLoop return $loopResult; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index fe203e7b8..315adf37e 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -56,6 +56,8 @@ class DataAccessFunctions extends AbstractSmartyPlugin protected $request; protected $dispatcher; + private static $dataAccessCache = array(); + public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher) { $this->securityContext = $securityContext; @@ -160,9 +162,14 @@ class DataAccessFunctions extends AbstractSmartyPlugin public function countryDataAccess($params, $smarty) { - $defaultCountry = CountryQuery::create()->findOneByByDefault(1); + if (array_key_exists('defaultCountry', self::$dataAccessCache)) { + $defaultCountry = self::$dataAccessCache['defaultCountry']; + } else { + $defaultCountry = CountryQuery::create()->findOneByByDefault(1); + self::$dataAccessCache['defaultCountry'] = $defaultCountry; + } - switch($params["attr"]) { + switch ($params["attr"]) { case "default": return $defaultCountry->getId(); } @@ -170,9 +177,16 @@ class DataAccessFunctions extends AbstractSmartyPlugin public function cartDataAccess($params, $smarty) { + if (array_key_exists('currentCountry', self::$dataAccessCache)) { + $currentCountry = self::$dataAccessCache['currentCountry']; + } else { + $currentCountry = CountryQuery::create()->findOneById(64); // @TODO : make it magic + self::$dataAccessCache['currentCountry'] = $currentCountry; + } + $cart = $this->getCart($this->request); $result = ""; - switch($params["attr"]) { + switch ($params["attr"]) { case "count_item": $result = $cart->getCartItems()->count(); break; @@ -180,9 +194,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin $result = $cart->getTotalAmount(); break; case "total_taxed_price": - $result = $cart->getTaxedAmount( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - ); + $result = $cart->getTaxedAmount($currentCountry); break; } @@ -193,7 +205,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin { $order = $this->request->getSession()->getOrder(); $attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr')); - switch($attribute) { + switch ($attribute) { case 'postage': return $order->getPostage(); case 'delivery_address': @@ -234,24 +246,30 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ protected function dataAccessWithI18n($objectLabel, $params, ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID') { - $lang = $this->getNormalizedParam($params, array('lang')); - if ($lang === null) { - $lang = $this->request->getSession()->getLang()->getId(); + if (array_key_exists('data_' . $objectLabel, self::$dataAccessCache)) { + $data = self::$dataAccessCache['data_' . $objectLabel]; + } else { + $lang = $this->getNormalizedParam($params, array('lang')); + if ($lang === null) { + $lang = $this->request->getSession()->getLang()->getId(); + } + + ModelCriteriaTools::getI18n( + false, + $lang, + $search, + $this->request->getSession()->getLang()->getLocale(), + $columns, + $foreignTable, + $foreignKey, + true + ); + + $data = $search->findOne(); + + self::$dataAccessCache['data_' . $objectLabel] = $data; } - ModelCriteriaTools::getI18n( - false, - $lang, - $search, - $this->request->getSession()->getLang()->getLocale(), - $columns, - $foreignTable, - $foreignKey, - true - ); - - $data = $search->findOne(); - $noGetterData = array(); foreach ($columns as $column) { $noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column); @@ -314,7 +332,6 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ public function getPluginDescriptors() { - return array( new SmartyPluginDescriptor('function', 'admin', $this, 'adminDataAccess'), new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess'), diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/FlashMessage.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/FlashMessage.php new file mode 100755 index 000000000..61a68fdc7 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/FlashMessage.php @@ -0,0 +1,99 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Core\Template\Smarty\Plugins; + +use Symfony\Component\HttpFoundation\Request; +use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; +use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Plugin for smarty defining blocks allowing to get flash message + * A flash message is a variable, array, object stored in session under the flashMessage key + * ex $SESSION['flashMessage']['myKey'] + * + * blocks : + * - {flashMessage key="myKey"} ... {/flashMessage} + * + * Class Form + * + * @package Thelia\Core\Template\Smarty\Plugins + * @author Guillaume MOREL + */ +class FlashMessage extends AbstractSmartyPlugin +{ + + /** @var Request Request service */ + protected $request; + + /** + * Constructor + * + * @param Request $request Request service + */ + public function __construct(Request $request) + { + $this->request = $request; + } + + /** + * Get FlashMessage + * And clean session from this key + * + * @param array $params Block parameters + * @param mixed $content Block content + * @param \Smarty_Internal_Template $template Template + * @param bool $repeat Control how many times + * the block is displayed + * + * @return mixed + */ + public function getFlashMessage($params, $content, \Smarty_Internal_Template $template, &$repeat) + { + if ($repeat) { + $key = $params['key']; + $flashBag = $this->request->getSession()->get('flashMessage'); + $template->assign('value', $flashBag[$key]); + + // Reset flash message (can be read once) + unset($flashBag[$key]); + $this->request->getSession()->set('flashMessage', $flashBag); + } else { + return $content; + } + } + + /** + * @return array an array of SmartyPluginDescriptor + */ + public function getPluginDescriptors() + { + return array( + new SmartyPluginDescriptor("block", "flashMessage", $this, "getFlashMessage") + ); + } + +} diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 4c953be3c..e7613bbac 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -168,8 +168,7 @@ $val = $value[$key]; $this->assignFieldValues($template, $name, $val, $formFieldView->vars); } } -} -else { +} else { $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVars["value"], $formFieldView->vars); } */ @@ -204,7 +203,7 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar { $instance = $this->getInstanceFromParams($params); - $formView = $instance->getForm(); + $formView = $instance->getView(); if ($formView->vars["multipart"]) { return sprintf('%s="%s"',"enctype", "multipart/form-data"); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index 1492f45cd..b6e31aef0 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -46,9 +46,9 @@ class Security extends AbstractSmartyPlugin /** * Process security check function * - * @param array $params - * @param unknown $smarty - * @return string no text is returned. + * @param array $params + * @param unknown $smarty + * @return string no text is returned. * @throws \Thelia\Core\Security\Exception\AuthenticationException */ public function checkAuthFunction($params, &$smarty) @@ -79,7 +79,7 @@ class Security extends AbstractSmartyPlugin public function checkCartNotEmptyFunction($params, &$smarty) { $cart = $this->request->getSession()->getCart(); - if($cart===null || $cart->countCartItems() == 0) { + if ($cart===null || $cart->countCartItems() == 0) { throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY, array('empty' => 1)); } @@ -90,11 +90,11 @@ class Security extends AbstractSmartyPlugin { $order = $this->request->getSession()->getOrder(); /* Does address and module still exists ? We assume address owner can't change neither module type */ - if($order !== null) { + if ($order !== null) { $checkAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress); $checkModule = ModuleQuery::create()->findPk($order->getDeliveryModuleId()); } - if(null === $order || null == $checkAddress || null === $checkModule) { + if (null === $order || null == $checkAddress || null === $checkModule) { throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1)); } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index bd2c10513..a076c808a 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -247,6 +247,7 @@ class TheliaLoop extends AbstractSmartyPlugin // Find pagination $pagination = self::getPagination($loopName); if ($pagination === null) { // loop gas no result + return ''; } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php new file mode 100755 index 000000000..cc42a6b21 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Smarty\Plugins; + +use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; +use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; + +class Type extends AbstractSmartyPlugin +{ + public function assertTypeModifier($value, $option) + { + $typeClass = "\\Thelia\\Type\\$option"; + if (!class_exists($typeClass)) { + throw new \InvalidArgumentException(sprintf("Invalid type name `%s` in `assertType` modifier", $option)); + } + + $typeInstance = new $typeClass(); + if (!$typeInstance->isValid($value)) { + return ''; + } + + return $value; + } + + /** + * Define the various smarty plugins handled by this class + * + * @return an array of smarty plugin descriptors + */ + public function getPluginDescriptors() + { + return array( + new SmartyPluginDescriptor('modifier', 'assertType', $this, 'assertTypeModifier'), + ); + } +} diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php index aa96a0014..d8227092f 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/UrlGenerator.php @@ -48,17 +48,16 @@ class UrlGenerator extends AbstractSmartyPlugin public function generateUrlFunction($params, &$smarty) { // the path to process - $path = $this->getParam($params, 'path', null); - $file = $this->getParam($params, 'file', null); + $path = $this->getParam($params, 'path', null); + $file = $this->getParam($params, 'file', null); // Do not invoke index.php in URL (get a static file in web space + $noamp = $this->getParam($params, 'noamp', null); // Do not change & in & if ($file !== null) { $path = $file; $mode = URL::PATH_TO_FILE; - } - else if ($path !== null) { + } elseif ($path !== null) { $mode = URL::WITH_INDEX_PAGE; - } - else { + } else { throw \InvalidArgumentException(Translator::getInstance()->trans("Please specify either 'path' or 'file' parameter in {url} function.")); } @@ -66,12 +65,13 @@ class UrlGenerator extends AbstractSmartyPlugin $url = URL::getInstance()->absoluteUrl( $path, - $this->getArgsFromParam($params, array('path', 'file', 'target')), + $this->getArgsFromParam($params, array('noamp', 'path', 'file', 'target')), $mode ); - if ($target != null) $url .= '#'.$target; + if ($noamp == null) $url = str_replace('&', '&', $url); + if ($target != null) $url .= '#'.$target; return $url; } @@ -186,7 +186,8 @@ class UrlGenerator extends AbstractSmartyPlugin protected function getCurrentUrl() { - return URL::getInstance()->retrieveCurrent($this->request)->toString(); + //return URL::getInstance()->retrieveCurrent($this->request)->toString(); + return $this->request->getUri(); } protected function getReturnToUrl() diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index d76dd8dfa..868f1570c 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -70,14 +70,8 @@ class SmartyParser extends Smarty implements ParserInterface $this->error_reporting = E_ALL ^ E_NOTICE; // Si on n'est pas en mode debug, activer le cache, avec une lifetime de 15mn, et en vérifiant que les templates sources n'ont pas été modifiés. - if ($debug === false) { - $this->caching = Smarty::CACHING_LIFETIME_CURRENT; - $this->cache_lifetime = 300; - $this->compile_check = true; - } else { - $this->caching = Smarty::CACHING_OFF; - $this->force_compile = true; - } + $this->caching = Smarty::CACHING_OFF; + $this->force_compile = true; // The default HTTP status $this->status = 200; @@ -105,6 +99,10 @@ class SmartyParser extends Smarty implements ParserInterface $this->template = $template_path_from_template_base; $this->setTemplateDir(THELIA_TEMPLATE_DIR.$this->template); + + $config_dir = THELIA_TEMPLATE_DIR.$this->template.'/configs'; + + $this->setConfigDir($config_dir); } public function getTemplate() diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index dbfe48e17..199a0bb0b 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -87,7 +87,6 @@ class Thelia extends Kernel $con->useDebug(true); } - } /** diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index c3ed552c0..07dc15eed 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -32,7 +32,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Session; -use Thelia\Core\Event\CurrencyEvent; +use Thelia\Core\Event\Currency\CurrencyEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model; @@ -148,7 +148,7 @@ class TheliaHttpKernel extends HttpKernel $currency = null; if ($request->query->has("currency")) { $currency = Model\CurrencyQuery::create()->findOneByCode($request->query->get("currency")); - if($currency) { + if ($currency) { $this->container->get("event_dispatcher")->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyEvent($currency)); } } else { diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/AdapterInterface.php similarity index 91% rename from core/lib/Thelia/Coupon/CouponAdapterInterface.php rename to core/lib/Thelia/Coupon/AdapterInterface.php index b2c168186..37979b44f 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/AdapterInterface.php @@ -27,6 +27,8 @@ use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface; +use Thelia\Condition\ConditionEvaluator; +use Thelia\Core\HttpFoundation\Request; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon; @@ -35,13 +37,13 @@ use Thelia\Model\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Allow a CouponManager class to be fed with relevant Thelia data + * Allow to assist in getting relevant data on the current application state * * @package Coupon * @author Guillaume MOREL * */ -interface CouponAdapterInterface +interface AdapterInterface { /** @@ -163,10 +165,17 @@ interface CouponAdapterInterface public function getRequest(); /** - * Return Constraint Validator + * Return Condition Evaluator * - * @return ConstraintValidator + * @return ConditionEvaluator */ - public function getConstraintValidator(); + public function getConditionEvaluator(); + + /** + * Return all available currencies + * + * @return array of Currency + */ + public function getAvailableCurrencies(); } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/BaseAdapter.php similarity index 93% rename from core/lib/Thelia/Coupon/CouponBaseAdapter.php rename to core/lib/Thelia/Coupon/BaseAdapter.php index 046b4ac81..883758ce1 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/BaseAdapter.php @@ -27,26 +27,27 @@ use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface; -use Thelia\Constraint\ConstraintValidator; use Thelia\Core\HttpFoundation\Request; -use Thelia\Core\Security\SecurityContext; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; use Thelia\Cart\CartTrait; use Thelia\Model\Currency; +use Thelia\Model\CurrencyQuery; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * + * Allow to assist in getting relevant data on the current application state + * * @package Coupon * @author Guillaume MOREL * @todo implements * */ -class CouponBaseAdapter implements CouponAdapterInterface +class BaseAdapter implements AdapterInterface { use CartTrait { CartTrait::getCart as getCartFromTrait; @@ -260,11 +261,24 @@ class CouponBaseAdapter implements CouponAdapterInterface /** * Return Constraint Validator * - * @return ConstraintValidator + * @return ConditionValidator */ - public function getConstraintValidator() + public function getConditionEvaluator() { - return $this->container->get('thelia.constraint.validator'); + return $this->container->get('thelia.condition.validator'); + } + + + /** + * Return all available currencies + * + * @return array of Currency + */ + public function getAvailableCurrencies() + { + $currencies = CurrencyQuery::create(); + + return $currencies->find(); } /** diff --git a/core/lib/Thelia/Coupon/CouponRuleCollection.php b/core/lib/Thelia/Coupon/ConditionCollection.php similarity index 72% rename from core/lib/Thelia/Coupon/CouponRuleCollection.php rename to core/lib/Thelia/Coupon/ConditionCollection.php index 29bf170e9..21e694aef 100644 --- a/core/lib/Thelia/Coupon/CouponRuleCollection.php +++ b/core/lib/Thelia/Coupon/ConditionCollection.php @@ -24,6 +24,7 @@ namespace Thelia\Coupon; use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Condition\ConditionManagerInterface; use Thelia\Constraint\Rule\CouponRuleInterface; use Thelia\Constraint\Rule\SerializableRule; @@ -32,70 +33,62 @@ use Thelia\Constraint\Rule\SerializableRule; * Date: 8/19/13 * Time: 3:24 PM * - * Manage a set of CouponRuleInterface + * Manage a set of ConditionManagerInterface * - * @package Coupon + * @package Condition * @author Guillaume MOREL * */ -class CouponRuleCollection +class ConditionCollection { - /** @var array Array of CouponRuleInterface */ - protected $rules = array(); + /** @var array Array of ConditionManagerInterface */ + protected $conditions = array(); /** - * Constructor + * Get Conditions + * + * @return array Array of ConditionManagerInterface */ - function __construct() + public function getConditions() { - + return $this->conditions; } /** - * Get Rules + * Add a ConditionManagerInterface to the Collection * - * @return array Array of CouponRuleInterface - */ - public function getRules() - { - return $this->rules; - } - - /** - * Add a CouponRuleInterface to the Collection - * - * @param CouponRuleInterface $rule Rule + * @param ConditionManagerInterface $condition Condition * * @return $this */ - public function add(CouponRuleInterface $rule) + public function add(ConditionManagerInterface $condition) { - $this->rules[] = $rule; + $this->conditions[] = $condition; return $this; } /** - * Check if there is at least one rule in the collection + * Check if there is at least one condition in the collection * * @return bool */ public function isEmpty() { - return (empty($this->rules)); + return (empty($this->conditions)); } /** - * Allow to compare 2 set of rules + * Allow to compare 2 set of conditions * * @return string Jsoned data */ public function __toString() { $arrayToSerialize = array(); - /** @var CouponRuleInterface $rule */ - foreach ($this->getRules() as $rule) { - $arrayToSerialize[] = $rule->getSerializableRule(); + /** @var ConditionManagerInterface $condition */ + foreach ($this->getConditions() as $condition) { + $arrayToSerialize[] = $condition->getSerializableCondition(); } return json_encode($arrayToSerialize); diff --git a/core/lib/Thelia/Coupon/CouponFactory.php b/core/lib/Thelia/Coupon/CouponFactory.php index 2f0c799a8..102d1a74c 100644 --- a/core/lib/Thelia/Coupon/CouponFactory.php +++ b/core/lib/Thelia/Coupon/CouponFactory.php @@ -25,13 +25,11 @@ namespace Thelia\Coupon; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Translation\Exception\NotFoundResourceException; -use Thelia\Constraint\ConstraintFactory; -use Thelia\Constraint\Rule\CouponRuleInterface; +use Thelia\Condition\ConditionFactory; use Thelia\Coupon\Type\CouponInterface; use Thelia\Exception\CouponExpiredException; -use Thelia\Exception\InvalidRuleException; +use Thelia\Exception\InvalidConditionException; use Thelia\Model\Coupon; -use Symfony\Component\Serializer\Encoder\JsonEncoder; /** * Created by JetBrains PhpStorm. @@ -49,7 +47,7 @@ class CouponFactory /** @var ContainerInterface Service Container */ protected $container = null; - /** @var CouponAdapterInterface Provide necessary value from Thelia*/ + /** @var AdapterInterface Provide necessary value from Thelia*/ protected $adapter; /** @@ -57,7 +55,7 @@ class CouponFactory * * @param ContainerInterface $container Service container */ - function __construct(ContainerInterface $container) + public function __construct(ContainerInterface $container) { $this->container = $container; $this->adapter = $container->get('thelia.adapter'); @@ -69,6 +67,7 @@ class CouponFactory * @param string $couponCode Coupon code ex: XMAS * * @throws \Thelia\Exception\CouponExpiredException + * @throws \Thelia\Exception\InvalidConditionException * @throws \Symfony\Component\Translation\Exception\NotFoundResourceException * @return CouponInterface ready to be processed */ @@ -87,9 +86,9 @@ class CouponFactory } /** @var CouponInterface $couponInterface */ - $couponInterface = $this->buildCouponInterfacFromModel($couponModel); - if ($couponInterface->getRules()->isEmpty()) { - throw new InvalidRuleException( + $couponInterface = $this->buildCouponInterfaceFromModel($couponModel); + if ($couponInterface->getConditions()->isEmpty()) { + throw new InvalidConditionException( get_class($couponInterface) ); } @@ -104,7 +103,7 @@ class CouponFactory * * @return CouponInterface ready to use CouponInterface object instance */ - protected function buildCouponInterfacFromModel(Coupon $model) + protected function buildCouponInterfaceFromModel(Coupon $model) { $isCumulative = ($model->getIsCumulative() == 1 ? true : false); $isRemovingPostage = ($model->getIsRemovingPostage() == 1 ? true : false); @@ -130,13 +129,13 @@ class CouponFactory $model->getExpirationDate() ); - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $this->container->get('thelia.constraint.factory'); - $rules = $constraintFactory->unserializeCouponRuleCollection( - $model->getSerializedRules() + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $this->container->get('thelia.condition.factory'); + $conditions = $conditionFactory->unserializeConditionCollection( + $model->getSerializedConditions() ); - $couponManager->setRules($rules); + $couponManager->setConditions($conditions); return $couponManager; } diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index d8575c3e6..c4ba661be 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -24,7 +24,7 @@ namespace Thelia\Coupon; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\Constraint\Rule\CouponRuleInterface; +use Thelia\Condition\ConditionManagerInterface; use Thelia\Coupon\Type\CouponInterface; /** @@ -40,7 +40,7 @@ use Thelia\Coupon\Type\CouponInterface; */ class CouponManager { - /** @var CouponAdapterInterface Provides necessary value from Thelia */ + /** @var AdapterInterface Provides necessary value from Thelia */ protected $adapter = null; /** @var ContainerInterface Service Container */ @@ -52,15 +52,15 @@ class CouponManager /** @var array Available Coupons (Services) */ protected $availableCoupons = array(); - /** @var array Available Rules (Services) */ - protected $availableRules = array(); + /** @var array Available Conditions (Services) */ + protected $availableConditions = array(); /** * Constructor * * @param ContainerInterface $container Service container */ - function __construct(ContainerInterface $container) + public function __construct(ContainerInterface $container) { $this->container = $container; $this->adapter = $container->get('thelia.adapter'); @@ -191,29 +191,29 @@ class CouponManager } /** - * Build a CouponRuleInterface from data coming from a form + * Build a ConditionManagerInterface from data coming from a form * - * @param string $ruleServiceId Rule service id you want to instantiate - * @param array $operators Rule Operator set by the Admin - * @param array $values Rule Values set by the Admin + * @param string $conditionServiceId Condition service id you want to instantiate + * @param array $operators Condition Operator set by the Admin + * @param array $values Condition Values set by the Admin * - * @return CouponRuleInterface + * @return ConditionManagerInterface */ - public function buildRuleFromForm($ruleServiceId, array $operators, array $values) + public function buildRuleFromForm($conditionServiceId, array $operators, array $values) { - $rule = false; + $condition = false; try { - if ($this->container->has($ruleServiceId)) { - /** @var CouponRuleInterface $rule */ - $rule = $this->container->get($ruleServiceId); - $rule->populateFromForm($operators, $values); + if ($this->container->has($conditionServiceId)) { + /** @var ConditionManagerInterface $condition */ + $condition = $this->container->get($conditionServiceId); + $condition->populateFromForm($operators, $values); } } catch (\InvalidArgumentException $e) { } - return $rule; + return $condition; } /** @@ -239,11 +239,11 @@ class CouponManager /** * Add an available ConstraintManager (Services) * - * @param CouponRuleInterface $rule CouponRuleInterface + * @param ConditionManagerInterface $condition ConditionManagerInterface */ - public function addAvailableRule(CouponRuleInterface $rule) + public function addAvailableRule(ConditionManagerInterface $condition) { - $this->availableRules[] = $rule; + $this->availableConditions[] = $condition; } /** @@ -251,8 +251,8 @@ class CouponManager * * @return array */ - public function getAvailableRules() + public function getAvailableConditions() { - return $this->availableRules; + return $this->availableConditions; } } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/RuleOrganizer.php b/core/lib/Thelia/Coupon/RuleOrganizer.php index 4c16ea1ff..ee840bfbc 100644 --- a/core/lib/Thelia/Coupon/RuleOrganizer.php +++ b/core/lib/Thelia/Coupon/RuleOrganizer.php @@ -30,20 +30,20 @@ namespace Thelia\Coupon; * * Manage how Coupons could interact with a Checkout * - * @package Coupon + * @package Condition * @author Guillaume MOREL * */ class RuleOrganizer implements RuleOrganizerInterface { /** - * Organize CouponRuleInterface + * Organize ConditionManagerInterface * - * @param array $rules Array of CouponRuleInterface + * @param array $conditions Array of ConditionManagerInterface * - * @return array Array of CouponRuleInterface sorted + * @return array Array of ConditionManagerInterface sorted */ - public function organize(array $rules) + public function organize(array $conditions) { // TODO: Implement organize() method. } diff --git a/core/lib/Thelia/Coupon/RuleOrganizerInterface.php b/core/lib/Thelia/Coupon/RuleOrganizerInterface.php index b8b222028..93dd12ee9 100644 --- a/core/lib/Thelia/Coupon/RuleOrganizerInterface.php +++ b/core/lib/Thelia/Coupon/RuleOrganizerInterface.php @@ -28,20 +28,20 @@ namespace Thelia\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Manage how Coupons could interact with a Checkout + * Manage how Condition could interact with a Checkout * - * @package Coupon + * @package Condition * @author Guillaume MOREL * */ interface RuleOrganizerInterface { /** - * Organize CouponRuleInterface + * Organize ConditionManagerInterface * - * @param array $rules Array of CouponRuleInterface + * @param array $conditions Array of ConditionManagerInterface * - * @return array Array of CouponRuleInterface sorted + * @return array Array of ConditionManagerInterface sorted */ - public function organize(array $rules); + public function organize(array $conditions); } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index 45e1427f1..f3aa392bc 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -24,13 +24,12 @@ namespace Thelia\Coupon\Type; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Constraint\ConstraintManager; -use Thelia\Constraint\ConstraintValidator; +use Thelia\Condition\ConditionEvaluator; use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\CouponRuleCollection; +use Thelia\Coupon\AdapterInterface; +use Thelia\Coupon\ConditionCollection; use Thelia\Coupon\RuleOrganizerInterface; -use Thelia\Exception\InvalidRuleException; +use Thelia\Exception\InvalidConditionException; /** * Created by JetBrains PhpStorm. @@ -45,7 +44,7 @@ use Thelia\Exception\InvalidRuleException; */ abstract class CouponAbstract implements CouponInterface { - /** @var CouponAdapterInterface Provide necessary value from Thelia */ + /** @var AdapterInterface Provide necessary value from Thelia */ protected $adapter = null; /** @var Translator Service Translator */ @@ -54,12 +53,11 @@ abstract class CouponAbstract implements CouponInterface /** @var RuleOrganizerInterface */ protected $organizer = null; - /** @var CouponRuleCollection Array of CouponRuleInterface */ - protected $rules = null; - - /** @var ConstraintValidator Constraint validator */ - protected $constraintValidator = null; + /** @var ConditionCollection Array of ConditionManagerInterface */ + protected $conditions = null; + /** @var ConditionEvaluator Condition validator */ + protected $conditionEvaluator = null; /** @var string Service Id */ @@ -106,19 +104,19 @@ abstract class CouponAbstract implements CouponInterface /** * Constructor * - * @param CouponAdapterInterface $adapter Service adapter + * @param AdapterInterface $adapter Service adapter */ - function __construct(CouponAdapterInterface $adapter) + public function __construct(AdapterInterface $adapter) { $this->adapter = $adapter; $this->translator = $adapter->getTranslator(); - $this->constraintValidator = $adapter->getConstraintValidator(); + $this->conditionEvaluator = $adapter->getConditionEvaluator(); } /** - * Set Rule Organizer + * Set Condition Organizer * - * @param RuleOrganizerInterface $organizer Manage Rule groups (&& and ||) + * @param RuleOrganizerInterface $organizer Manage Condition groups (&& and ||) * * @return $this */ @@ -205,25 +203,25 @@ abstract class CouponAbstract implements CouponInterface /** * Return condition to validate the Coupon or not * - * @return CouponRuleCollection + * @return ConditionCollection */ - public function getRules() + public function getConditions() { - return clone $this->rules; + return clone $this->conditions; } /** - * Replace the existing Rules by those given in parameter - * If one Rule is badly implemented, no Rule will be added + * Replace the existing Conditions by those given in parameter + * If one Condition is badly implemented, no Condition will be added * - * @param CouponRuleCollection $rules CouponRuleInterface to add + * @param ConditionCollection $conditions ConditionManagerInterface to add * * @return $this - * @throws \Thelia\Exception\InvalidRuleException + * @throws \Thelia\Exception\InvalidConditionException */ - public function setRules(CouponRuleCollection $rules) + public function setConditions(ConditionCollection $conditions) { - $this->rules = $rules; + $this->conditions = $conditions; return $this; } @@ -249,7 +247,6 @@ abstract class CouponAbstract implements CouponInterface return $this->isAvailableOnSpecialOffers; } - /** * Check if Coupon has been disabled by admin * @@ -300,14 +297,14 @@ abstract class CouponAbstract implements CouponInterface /** - * Check if the current Coupon is matching its conditions (Rules) - * Thelia variables are given by the CouponAdapterInterface + * Check if the current state of the application is matching this Coupon conditions + * Thelia variables are given by the AdapterInterface * * @return bool */ public function isMatching() { - return $this->constraintValidator->isMatching($this->rules); + return $this->conditionEvaluator->isMatching($this->conditions); } diff --git a/core/lib/Thelia/Coupon/Type/CouponInterface.php b/core/lib/Thelia/Coupon/Type/CouponInterface.php index be76c1878..192a608e8 100644 --- a/core/lib/Thelia/Coupon/Type/CouponInterface.php +++ b/core/lib/Thelia/Coupon/Type/CouponInterface.php @@ -23,8 +23,8 @@ namespace Thelia\Coupon\Type; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\CouponRuleCollection; +use Thelia\Coupon\AdapterInterface; +use Thelia\Coupon\ConditionCollection; /** * Created by JetBrains PhpStorm. @@ -140,20 +140,20 @@ interface CouponInterface /** * Return condition to validate the Coupon or not * - * @return CouponRuleCollection A set of CouponRuleInterface + * @return ConditionCollection A set of ConditionManagerInterface */ - public function getRules(); + public function getConditions(); /** * Replace the existing Rules by those given in parameter * If one Rule is badly implemented, no Rule will be added * - * @param CouponRuleCollection $rules CouponRuleInterface to add + * @param ConditionCollection $rules ConditionManagerInterface to add * * @return $this - * @throws \Thelia\Exception\InvalidRuleException + * @throws \Thelia\Exception\InvalidConditionException */ - public function setRules(CouponRuleCollection $rules); + public function setConditions(ConditionCollection $rules); /** * Return Coupon expiration date @@ -209,7 +209,7 @@ interface CouponInterface /** * Check if the current Coupon is matching its conditions (Rules) - * Thelia variables are given by the CouponAdapterInterface + * Thelia variables are given by the AdapterInterface * * @return bool */ diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php b/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php index eb5dc4548..1f9e12420 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmountManager.php @@ -23,7 +23,6 @@ namespace Thelia\Coupon\Type; -use Thelia\Constraint\ConstraintManager; use Thelia\Coupon\Type\CouponAbstract; /** diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php b/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php index c200c620e..d5c45b4d3 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercentManager.php @@ -23,7 +23,6 @@ namespace Thelia\Coupon\Type; -use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\Type\CouponAbstract; use Thelia\Exception\MissingAdapterException; diff --git a/core/lib/Thelia/Exception/InvalidRuleException.php b/core/lib/Thelia/Exception/InvalidConditionException.php similarity index 88% rename from core/lib/Thelia/Exception/InvalidRuleException.php rename to core/lib/Thelia/Exception/InvalidConditionException.php index a891ded4a..dbc3315c8 100644 --- a/core/lib/Thelia/Exception/InvalidRuleException.php +++ b/core/lib/Thelia/Exception/InvalidConditionException.php @@ -30,23 +30,23 @@ use Thelia\Log\Tlog; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule is badly implemented + * Thrown when a Condition is badly implemented * - * @package Coupon + * @package Condition * @author Guillaume MOREL * */ -class InvalidRuleException extends \RuntimeException +class InvalidConditionException extends \RuntimeException { /** - * InvalidRuleOperatorException thrown when a Rule is badly implemented + * InvalidConditionOperatorException thrown when a Condition is badly implemented * * @param string $className Class name */ public function __construct($className) { - $message = 'Invalid Rule given to ' . $className; + $message = 'Invalid Condition given to ' . $className; Tlog::getInstance()->addError($message); parent::__construct($message); diff --git a/core/lib/Thelia/Exception/InvalidRuleValueException.php b/core/lib/Thelia/Exception/InvalidConditionOperatorException.php similarity index 87% rename from core/lib/Thelia/Exception/InvalidRuleValueException.php rename to core/lib/Thelia/Exception/InvalidConditionOperatorException.php index 2f16f32f1..eaef6b9fc 100644 --- a/core/lib/Thelia/Exception/InvalidRuleValueException.php +++ b/core/lib/Thelia/Exception/InvalidConditionOperatorException.php @@ -30,24 +30,23 @@ use Thelia\Log\Tlog; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Parameter + * Thrown when a Condition receive an invalid Operator * - * @package Coupon + * @package Condition * @author Guillaume MOREL * */ -class InvalidRuleValueException extends \RuntimeException +class InvalidConditionOperatorException extends \RuntimeException { /** - * InvalidRuleValueException thrown when a Rule is given a bad Parameter + * InvalidConditionOperatorException thrown when a Condition is given a bad Operator * * @param string $className Class name * @param string $parameter array key parameter */ public function __construct($className, $parameter) { - - $message = 'Invalid Parameter for Rule ' . $className . ' on parameter ' . $parameter; + $message = 'Invalid Operator for Condition ' . $className . ' on parameter ' . $parameter; Tlog::getInstance()->addError($message); parent::__construct($message); diff --git a/core/lib/Thelia/Exception/InvalidRuleOperatorException.php b/core/lib/Thelia/Exception/InvalidConditionValueException.php similarity index 87% rename from core/lib/Thelia/Exception/InvalidRuleOperatorException.php rename to core/lib/Thelia/Exception/InvalidConditionValueException.php index d40c723c2..46e3d3628 100644 --- a/core/lib/Thelia/Exception/InvalidRuleOperatorException.php +++ b/core/lib/Thelia/Exception/InvalidConditionValueException.php @@ -30,16 +30,16 @@ use Thelia\Log\Tlog; * Date: 8/19/13 * Time: 3:24 PM * - * Thrown when a Rule receive an invalid Operator + * Thrown when a Condition receives an invalid Parameter * - * @package Coupon + * @package Condition * @author Guillaume MOREL * */ -class InvalidRuleOperatorException extends \RuntimeException +class InvalidConditionValueException extends \RuntimeException { /** - * InvalidRuleOperatorException thrown when a Rule is given a bad Operator + * InvalidConditionValueException thrown when a Condition is given a bad Parameter * * @param string $className Class name * @param string $parameter array key parameter @@ -47,7 +47,7 @@ class InvalidRuleOperatorException extends \RuntimeException public function __construct($className, $parameter) { - $message = 'Invalid Operator for Rule ' . $className . ' on parameter ' . $parameter; + $message = 'Invalid Parameter for Condition ' . $className . ' on parameter ' . $parameter; Tlog::getInstance()->addError($message); parent::__construct($message); diff --git a/core/lib/Thelia/Exception/OrderException.php b/core/lib/Thelia/Exception/OrderException.php index 70fd21c01..676447858 100755 --- a/core/lib/Thelia/Exception/OrderException.php +++ b/core/lib/Thelia/Exception/OrderException.php @@ -41,7 +41,7 @@ class OrderException extends \RuntimeException public function __construct($message, $code = null, $arguments = array(), $previous = null) { - if(is_array($arguments)) { + if (is_array($arguments)) { $this->arguments = $arguments; } if ($code === null) { diff --git a/core/lib/Thelia/Exception/TaxEngineException.php b/core/lib/Thelia/Exception/TaxEngineException.php index 93f5b8237..86f8952b9 100755 --- a/core/lib/Thelia/Exception/TaxEngineException.php +++ b/core/lib/Thelia/Exception/TaxEngineException.php @@ -39,6 +39,7 @@ class TaxEngineException extends \RuntimeException const UNDEFINED_TAX_RULES_COLLECTION = 503; const UNDEFINED_REQUIREMENTS = 504; const UNDEFINED_REQUIREMENT_VALUE = 505; + const UNDEFINED_TAX_RULE = 506; const BAD_AMOUNT_FORMAT = 601; diff --git a/core/lib/Thelia/Exception/TheliaProcessException.php b/core/lib/Thelia/Exception/TheliaProcessException.php new file mode 100755 index 000000000..f61224dea --- /dev/null +++ b/core/lib/Thelia/Exception/TheliaProcessException.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +/** + * these exception are non fatal exception, due to thelia process exception + * or customer random navigation + * + * they redirect the customer who trig them to a specific error page // @todo + * + * Class TheliaProcessException + * @package Thelia\Exception + */ +class TheliaProcessException extends \RuntimeException +{ + public $data = null; + + const UNKNOWN_EXCEPTION = 0; + + const CART_ITEM_NOT_ENOUGH_STOCK = 100; + const NO_PLACED_ORDER = 101; + const PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER = 102; + + public function __construct($message, $code = null, $data = null, $previous = null) + { + $this->data = $data; + + if ($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Form/AddressCreateForm.php b/core/lib/Thelia/Form/AddressCreateForm.php index 483366a1f..0774f253d 100644 --- a/core/lib/Thelia/Form/AddressCreateForm.php +++ b/core/lib/Thelia/Form/AddressCreateForm.php @@ -102,7 +102,7 @@ class AddressCreateForm extends BaseForm "for" => "address1_create" ) )) - ->add("address2", "text", array( + ->add("address2", "text", array( "label" => Translator::getInstance()->trans("Additional address"), "label_attr" => array( "for" => "address2_create" diff --git a/core/lib/Thelia/Form/AddressUpdateForm.php b/core/lib/Thelia/Form/AddressUpdateForm.php index 4fcf6e29c..055b233c9 100644 --- a/core/lib/Thelia/Form/AddressUpdateForm.php +++ b/core/lib/Thelia/Form/AddressUpdateForm.php @@ -103,7 +103,7 @@ class AddressUpdateForm extends AddressCreateForm "for" => "address1_update" ) )) - ->add("address2", "text", array( + ->add("address2", "text", array( "label" => Translator::getInstance()->trans("Additional address"), "label_attr" => array( "for" => "address2_update" diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 00236161d..ff26bdc8d 100755 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -51,7 +51,7 @@ class AdminLogin extends BaseForm ) )) ->add("remember_me", "checkbox", array( - 'value' => 'yes', + 'value' => 'yes', "label" => Translator::getInstance()->trans("Remember me ?"), "label_attr" => array( "for" => "remember_me" diff --git a/core/lib/Thelia/Form/AttributeAvCreationForm.php b/core/lib/Thelia/Form/AttributeAvCreationForm.php index 2ad202e1d..513fc0c6b 100644 --- a/core/lib/Thelia/Form/AttributeAvCreationForm.php +++ b/core/lib/Thelia/Form/AttributeAvCreationForm.php @@ -23,8 +23,6 @@ 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; @@ -59,4 +57,4 @@ class AttributeAvCreationForm extends BaseForm { return "thelia_attributeav_creation"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/AttributeCreationForm.php b/core/lib/Thelia/Form/AttributeCreationForm.php index a4c6d402f..dc65cc16c 100644 --- a/core/lib/Thelia/Form/AttributeCreationForm.php +++ b/core/lib/Thelia/Form/AttributeCreationForm.php @@ -23,8 +23,6 @@ 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; diff --git a/core/lib/Thelia/Form/AttributeModificationForm.php b/core/lib/Thelia/Form/AttributeModificationForm.php index 45dab7b28..51d4f6c3a 100644 --- a/core/lib/Thelia/Form/AttributeModificationForm.php +++ b/core/lib/Thelia/Form/AttributeModificationForm.php @@ -23,10 +23,6 @@ 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 AttributeModificationForm extends AttributeCreationForm diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForDate.php b/core/lib/Thelia/Form/CategoryDocumentModification.php similarity index 60% rename from core/lib/Thelia/Constraint/Rule/AvailableForDate.php rename to core/lib/Thelia/Form/CategoryDocumentModification.php index 1ddfd0350..9ad7ba890 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForDate.php +++ b/core/lib/Thelia/Form/CategoryDocumentModification.php @@ -1,59 +1,51 @@ . */ -/* */ -/**********************************************************************************/ +/*************************************************************************************/ +/* */ +/* 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 . */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; -namespace Thelia\Constraint\Rule; +use Thelia\Form\Image\DocumentModification; /** * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM + * Date: 9/18/13 + * Time: 3:56 PM * - * @package Constraint + * Form allowing to process an document collection + * + * @package Image * @author Guillaume MOREL * */ -class AvailableForDate extends AvailableForPeriod +class CategoryDocumentModification extends DocumentModification { /** - * Check if backoffice inputs are relevant or not + * Get form name + * This name must be unique * - * @return bool + * @return string */ - public function checkBackOfficeInput() + public function getName() { - // TODO: Implement checkBackOfficeInput() method. + return 'thelia_category_document_modification'; } - - /** - * Check if Checkout inputs are relevant or not - * - * @return bool - */ - public function checkCheckoutInput() - { - // TODO: Implement checkCheckoutInput() method. - } - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/CategoryImageModification.php b/core/lib/Thelia/Form/CategoryImageModification.php new file mode 100644 index 000000000..6f24263eb --- /dev/null +++ b/core/lib/Thelia/Form/CategoryImageModification.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Thelia\Form\Image\ImageModification; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process an image collection + * + * @package Image + * @author Guillaume MOREL + * + */ +class CategoryImageModification extends ImageModification +{ + + /** + * Get form name + * This name must be unique + * + * @return string + */ + public function getName() + { + return 'thelia_category_image_modification'; + } +} diff --git a/core/lib/Thelia/Form/ContentCreationForm.php b/core/lib/Thelia/Form/ContentCreationForm.php index 8d8c2d1ca..df8838f59 100644 --- a/core/lib/Thelia/Form/ContentCreationForm.php +++ b/core/lib/Thelia/Form/ContentCreationForm.php @@ -27,7 +27,7 @@ use Thelia\Core\Translation\Translator; class ContentCreationForm extends BaseForm { - protected function buildForm($change_mode = false) + protected function buildForm() { $this->formBuilder ->add("title", "text", array( @@ -40,9 +40,11 @@ class ContentCreationForm extends BaseForm ) )) ->add("default_folder", "integer", array( + "label" => Translator::getInstance()->trans("Default folder *"), "constraints" => array( new NotBlank() - ) + ), + "label_attr" => array("for" => "default_folder") )) ->add("locale", "text", array( "constraints" => array( diff --git a/core/lib/Thelia/Form/ContentDocumentModification.php b/core/lib/Thelia/Form/ContentDocumentModification.php new file mode 100644 index 000000000..d9d7c0571 --- /dev/null +++ b/core/lib/Thelia/Form/ContentDocumentModification.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Thelia\Form\Image\DocumentModification; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process a file + * + * @package File + * @author Guillaume MOREL + * + */ +class ContentDocumentModification extends DocumentModification +{ + + /** + * Get form name + * This name must be unique + * + * @return string + */ + public function getName() + { + return 'thelia_content_document_modification'; + } +} diff --git a/core/lib/Thelia/Form/ContentImageModification.php b/core/lib/Thelia/Form/ContentImageModification.php new file mode 100644 index 000000000..d80e47224 --- /dev/null +++ b/core/lib/Thelia/Form/ContentImageModification.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Thelia\Form\Image\ImageModification; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process an image collection + * + * @package Image + * @author Guillaume MOREL + * + */ +class ContentImageModification extends ImageModification +{ + + /** + * Get form name + * This name must be unique + * + * @return string + */ + public function getName() + { + return 'thelia_content_image_modification'; + } +} diff --git a/core/lib/Thelia/Form/ContentModificationForm.php b/core/lib/Thelia/Form/ContentModificationForm.php new file mode 100644 index 000000000..14789ab84 --- /dev/null +++ b/core/lib/Thelia/Form/ContentModificationForm.php @@ -0,0 +1,62 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Thelia\Form\StandardDescriptionFieldsTrait; + +/** + * Class ContentModificationForm + * @package Thelia\Form + * @author manuel raynaud + */ +class ContentModificationForm extends ContentCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + parent::buildForm(); + + $this->formBuilder + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewritten_url") + )) + ; + + // Add standard description fields, excluding title and locale, which a re defined in parent class + $this->addStandardDescFields(array('title', 'locale')); + } + + public function getName() + { + return "thelia_content_modification"; + } +} diff --git a/core/lib/Thelia/Form/CountryCreationForm.php b/core/lib/Thelia/Form/CountryCreationForm.php index ad6701a64..1b10ebc07 100644 --- a/core/lib/Thelia/Form/CountryCreationForm.php +++ b/core/lib/Thelia/Form/CountryCreationForm.php @@ -38,7 +38,7 @@ class CountryCreationForm extends BaseForm "label_attr" => array( "for" => "title" ) - )) + )) ->add("area", "text", array( "constraints" => array( new NotBlank() @@ -47,7 +47,7 @@ class CountryCreationForm extends BaseForm "label_attr" => array( "for" => "area" ) - )) + )) ->add("isocode", "text", array( "constraints" => array( new NotBlank() @@ -56,7 +56,7 @@ class CountryCreationForm extends BaseForm "label_attr" => array( "for" => "isocode" ) - )) + )) ->add("isoalpha2", "text", array( "constraints" => array( new NotBlank() @@ -65,7 +65,7 @@ class CountryCreationForm extends BaseForm "label_attr" => array( "for" => "isoalpha2" ) - )) + )) ->add("isoalpha3", "text", array( "constraints" => array( new NotBlank() @@ -74,7 +74,7 @@ class CountryCreationForm extends BaseForm "label_attr" => array( "for" => "isoalpha3" ) - )) + )) ; } diff --git a/core/lib/Thelia/Form/CountryModificationForm.php b/core/lib/Thelia/Form/CountryModificationForm.php index 4c1581664..757db19d0 100644 --- a/core/lib/Thelia/Form/CountryModificationForm.php +++ b/core/lib/Thelia/Form/CountryModificationForm.php @@ -42,7 +42,7 @@ class CountryModificationForm extends CurrencyCreationForm "label_attr" => array( "for" => "title" ) - )) + )) ->add("short-description", "text", array( "constraints" => array( new NotBlank() @@ -51,7 +51,7 @@ class CountryModificationForm extends CurrencyCreationForm "label_attr" => array( "for" => "short-description" ) - )) + )) ->add("description", "text", array( "constraints" => array( new NotBlank() @@ -60,7 +60,7 @@ class CountryModificationForm extends CurrencyCreationForm "label_attr" => array( "for" => "description" ) - )) + )) ->add("area", "text", array( "constraints" => array( new NotBlank() @@ -69,7 +69,7 @@ class CountryModificationForm extends CurrencyCreationForm "label_attr" => array( "for" => "area" ) - )) + )) ->add("isocode", "text", array( "constraints" => array( new NotBlank() @@ -78,7 +78,7 @@ class CountryModificationForm extends CurrencyCreationForm "label_attr" => array( "for" => "isocode" ) - )) + )) ->add("isoalpha2", "text", array( "constraints" => array( new NotBlank() @@ -87,7 +87,7 @@ class CountryModificationForm extends CurrencyCreationForm "label_attr" => array( "for" => "isoalpha2" ) - )) + )) ->add("isoalpha3", "text", array( "constraints" => array( new NotBlank() diff --git a/core/lib/Thelia/Form/CouponCreationForm.php b/core/lib/Thelia/Form/CouponCreationForm.php index 1625ab685..8edc26fbf 100755 --- a/core/lib/Thelia/Form/CouponCreationForm.php +++ b/core/lib/Thelia/Form/CouponCreationForm.php @@ -24,7 +24,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\Date; -use Symfony\Component\Validator\Constraints\DateTime; use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotEqualTo; @@ -87,7 +86,7 @@ class CouponCreationForm extends BaseForm ) ) ->add( - 'effect', + 'type', 'text', array( 'constraints' => array( diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 24e64faff..cc74585e7 100755 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -220,4 +220,4 @@ class CustomerCreation extends BaseForm { return "thelia_customer_creation"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/CustomerLostPasswordForm.php b/core/lib/Thelia/Form/CustomerLostPasswordForm.php index d950bf614..83ff1f3d6 100644 --- a/core/lib/Thelia/Form/CustomerLostPasswordForm.php +++ b/core/lib/Thelia/Form/CustomerLostPasswordForm.php @@ -35,8 +35,8 @@ use Thelia\Model\CustomerQuery; * @package Thelia\Form * @author Manuel Raynaud */ -class CustomerLostPasswordForm extends BaseForm { - +class CustomerLostPasswordForm extends BaseForm +{ /** * * in this function you add all the fields you need for your Form. @@ -93,4 +93,4 @@ class CustomerLostPasswordForm extends BaseForm { { return "thelia_customer_creation"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/FeatureAvCreationForm.php b/core/lib/Thelia/Form/FeatureAvCreationForm.php index 504cc9338..9245bf28d 100644 --- a/core/lib/Thelia/Form/FeatureAvCreationForm.php +++ b/core/lib/Thelia/Form/FeatureAvCreationForm.php @@ -23,8 +23,6 @@ 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; @@ -59,4 +57,4 @@ class FeatureAvCreationForm extends BaseForm { return "thelia_featureav_creation"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/FeatureCreationForm.php b/core/lib/Thelia/Form/FeatureCreationForm.php index 1977bd78b..cbbc7692f 100644 --- a/core/lib/Thelia/Form/FeatureCreationForm.php +++ b/core/lib/Thelia/Form/FeatureCreationForm.php @@ -23,8 +23,6 @@ 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; diff --git a/core/lib/Thelia/Form/FeatureModificationForm.php b/core/lib/Thelia/Form/FeatureModificationForm.php index 1702f299e..576db4bfc 100644 --- a/core/lib/Thelia/Form/FeatureModificationForm.php +++ b/core/lib/Thelia/Form/FeatureModificationForm.php @@ -23,10 +23,6 @@ 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 diff --git a/core/lib/Thelia/Form/FolderDocumentModification.php b/core/lib/Thelia/Form/FolderDocumentModification.php new file mode 100644 index 000000000..47bcd7c7f --- /dev/null +++ b/core/lib/Thelia/Form/FolderDocumentModification.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Thelia\Form\Image\DocumentModification; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process a file + * + * @package Image + * @author Guillaume MOREL + * + */ +class FolderDocumentModification extends DocumentModification +{ + + /** + * Get form name + * This name must be unique + * + * @return string + */ + public function getName() + { + return 'thelia_folder_document_modification'; + } +} diff --git a/core/lib/Thelia/Form/FolderImageModification.php b/core/lib/Thelia/Form/FolderImageModification.php new file mode 100644 index 000000000..004c4676b --- /dev/null +++ b/core/lib/Thelia/Form/FolderImageModification.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Thelia\Form\Image\ImageModification; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process an image collection + * + * @package Image + * @author Guillaume MOREL + * + */ +class FolderImageModification extends ImageModification +{ + + /** + * Get form name + * This name must be unique + * + * @return string + */ + public function getName() + { + return 'thelia_folder_image_modification'; + } +} diff --git a/core/lib/Thelia/Form/FolderModificationForm.php b/core/lib/Thelia/Form/FolderModificationForm.php index e075ea827..0ff90868c 100644 --- a/core/lib/Thelia/Form/FolderModificationForm.php +++ b/core/lib/Thelia/Form/FolderModificationForm.php @@ -32,7 +32,7 @@ class FolderModificationForm extends FolderCreationForm protected function buildForm() { - parent::buildForm(true); + parent::buildForm(); $this->formBuilder ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) diff --git a/core/lib/Thelia/Form/Image/DocumentModification.php b/core/lib/Thelia/Form/Image/DocumentModification.php new file mode 100644 index 000000000..31de5af98 --- /dev/null +++ b/core/lib/Thelia/Form/Image/DocumentModification.php @@ -0,0 +1,137 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form\Image; + +use Symfony\Component\Validator\Constraints\Image; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Thelia\Form\BaseForm; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process a file + * @todo refactor make all document using propel inheritance and factorise image behaviour into one single clean action + * + * @package File + * @author Guillaume MOREL + * + */ +abstract class DocumentModification extends BaseForm +{ + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->form attribute : + * + * $this->form->add('name', 'text') + * ->add('email', 'email', array( + * 'attr' => array( + * 'class' => 'field' + * ), + * 'label' => 'email', + * 'constraints' => array( + * new NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + $this->formBuilder->add( + 'file', + 'file', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Replace current document by this file'), + 'label_attr' => array( + 'for' => 'file' + ) + ) + ); + + $this->formBuilder + ->add( + 'title', + 'text', + array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('Title'), + 'label_attr' => array( + 'for' => 'title' + ) + ) + ) + ->add( + 'description', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Description'), + 'label_attr' => array( + 'for' => 'description' + ) + ) + ) + ->add( + 'chapo', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Chapo'), + 'label_attr' => array( + 'for' => 'chapo' + ) + ) + ) + ->add( + 'postscriptum', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Post Scriptum'), + 'label_attr' => array( + 'for' => 'postscriptum' + ) + ) + ) + ->add( + 'postscriptum', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Post Scriptum'), + 'label_attr' => array( + 'for' => 'postscriptum' + ) + ) + ); + } +} diff --git a/core/lib/Thelia/Form/Image/ImageModification.php b/core/lib/Thelia/Form/Image/ImageModification.php new file mode 100644 index 000000000..e95a39c37 --- /dev/null +++ b/core/lib/Thelia/Form/Image/ImageModification.php @@ -0,0 +1,145 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form\Image; + +use Symfony\Component\Validator\Constraints\Image; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Thelia\Form\BaseForm; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process an image + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + * + * @package Image + * @author Guillaume MOREL + * + */ +abstract class ImageModification extends BaseForm +{ + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->form attribute : + * + * $this->form->add('name', 'text') + * ->add('email', 'email', array( + * 'attr' => array( + * 'class' => 'field' + * ), + * 'label' => 'email', + * 'constraints' => array( + * new NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + $this->formBuilder->add( + 'file', + 'file', + array( + 'constraints' => array( + new Image( + array( +// 'minWidth' => 200, +// 'minHeight' => 200 + ) + ) + ), + 'label' => Translator::getInstance()->trans('Replace current image by this file'), + 'label_attr' => array( + 'for' => 'file' + ) + ) + ); + + $this->formBuilder + ->add( + 'title', + 'text', + array( + 'constraints' => array( + new NotBlank() + ), + 'label' => Translator::getInstance()->trans('Title'), + 'label_attr' => array( + 'for' => 'title' + ) + ) + ) + ->add( + 'description', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Description'), + 'label_attr' => array( + 'for' => 'description' + ) + ) + ) + ->add( + 'chapo', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Chapo'), + 'label_attr' => array( + 'for' => 'chapo' + ) + ) + ) + ->add( + 'postscriptum', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Post Scriptum'), + 'label_attr' => array( + 'for' => 'postscriptum' + ) + ) + ) + ->add( + 'postscriptum', + 'text', + array( + 'constraints' => array(), + 'label' => Translator::getInstance()->trans('Post Scriptum'), + 'label_attr' => array( + 'for' => 'postscriptum' + ) + ) + ); + } +} diff --git a/core/lib/Thelia/Form/OrderDelivery.php b/core/lib/Thelia/Form/OrderDelivery.php index e23ae92b2..b7eb4696d 100755 --- a/core/lib/Thelia/Form/OrderDelivery.php +++ b/core/lib/Thelia/Form/OrderDelivery.php @@ -25,8 +25,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Model\AddressQuery; -use Thelia\Model\ConfigQuery; -use Thelia\Core\Translation\Translator; use Thelia\Model\ModuleQuery; use Thelia\Module\BaseModule; @@ -69,7 +67,7 @@ class OrderDelivery extends BaseForm $address = AddressQuery::create() ->findPk($value); - if(null === $address) { + if (null === $address) { $context->addViolation("Address ID not found"); } } @@ -80,9 +78,9 @@ class OrderDelivery extends BaseForm ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) ->filterByActivate(1) ->filterById($value) - ->find(); + ->findOne(); - if(null === $module) { + if (null === $module) { $context->addViolation("Delivery module ID not found"); } @@ -98,4 +96,4 @@ class OrderDelivery extends BaseForm { return "thelia_order_delivery"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/OrderPayment.php b/core/lib/Thelia/Form/OrderPayment.php index 6a6305971..6a0d6ec61 100755 --- a/core/lib/Thelia/Form/OrderPayment.php +++ b/core/lib/Thelia/Form/OrderPayment.php @@ -25,8 +25,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Model\AddressQuery; -use Thelia\Model\ConfigQuery; -use Thelia\Core\Translation\Translator; use Thelia\Model\ModuleQuery; use Thelia\Module\BaseModule; @@ -69,7 +67,7 @@ class OrderPayment extends BaseForm $address = AddressQuery::create() ->findPk($value); - if(null === $address) { + if (null === $address) { $context->addViolation("Address ID not found"); } } @@ -82,7 +80,7 @@ class OrderPayment extends BaseForm ->filterById($value) ->findOne(); - if(null === $module) { + if (null === $module) { $context->addViolation("Payment module ID not found"); } @@ -98,4 +96,4 @@ class OrderPayment extends BaseForm { return "thelia_order_payment"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/OrderUpdateAddress.php b/core/lib/Thelia/Form/OrderUpdateAddress.php new file mode 100644 index 000000000..f8aabf628 --- /dev/null +++ b/core/lib/Thelia/Form/OrderUpdateAddress.php @@ -0,0 +1,192 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Core\Translation\Translator; +use Thelia\Model\CountryQuery; +use Thelia\Model\CustomerTitleQuery; +use Thelia\Model\OrderAddressQuery; + +/** + * Class AddressUpdateForm + * @package Thelia\Form + * @author Etienne Roudeix + */ +class OrderUpdateAddress extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("id", "integer", array( + "constraints" => array( + new NotBlank(), + new Callback(array( + "methods" => array( + array($this, "verifyId") + ) + )) + ), + "required" => true + )) + ->add("title", "text", array( + "constraints" => array( + new NotBlank(), + new Callback(array( + "methods" => array( + array($this, "verifyTitle") + ) + )) + ), + "label" => Translator::getInstance()->trans("Title"), + "label_attr" => array( + "for" => "title_update" + ) + )) + ->add("firstname", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Firstname"), + "label_attr" => array( + "for" => "firstname_update" + ) + )) + ->add("lastname", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Lastname"), + "label_attr" => array( + "for" => "lastname_update" + ) + )) + ->add("address1", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Street Address"), + "label_attr" => array( + "for" => "address1_update" + ) + )) + ->add("address2", "text", array( + "label" => Translator::getInstance()->trans("Additional address"), + "label_attr" => array( + "for" => "address2_update" + ) + )) + ->add("address3", "text", array( + "label" => Translator::getInstance()->trans("Additional address"), + "label_attr" => array( + "for" => "address3_update" + ) + )) + ->add("zipcode", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Zip code"), + "label_attr" => array( + "for" => "zipcode_update" + ) + )) + ->add("city", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("City"), + "label_attr" => array( + "for" => "city_update" + ) + )) + ->add("country", "text", array( + "constraints" => array( + new NotBlank(), + new Callback(array( + "methods" => array( + array($this, "verifyCountry") + ) + )) + ), + "label" => Translator::getInstance()->trans("Country"), + "label_attr" => array( + "for" => "country_update" + ) + )) + ->add("phone", "text", array( + "label" => Translator::getInstance()->trans("Phone"), + "label_attr" => array( + "for" => "phone_update" + ) + )) + ->add("company", "text", array( + "label" => Translator::getInstance()->trans("Compagny"), + "label_attr" => array( + "for" => "company_update" + ) + )) + ; + + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return "thelia_order_address_update"; + } + + public function verifyId($value, ExecutionContextInterface $context) + { + $address = OrderAddressQuery::create() + ->findPk($value); + + if (null === $address) { + $context->addViolation("Order address ID not found"); + } + } + + public function verifyTitle($value, ExecutionContextInterface $context) + { + $address = CustomerTitleQuery::create() + ->findPk($value); + + if (null === $address) { + $context->addViolation("Title ID not found"); + } + } + + public function verifyCountry($value, ExecutionContextInterface $context) + { + $address = CountryQuery::create() + ->findPk($value); + + if (null === $address) { + $context->addViolation("Country ID not found"); + } + } +} diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php index 9329ca2ec..c1b8bd6b4 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -47,25 +47,48 @@ class ProductCreationForm extends BaseForm "label_attr" => array("for" => "ref") )) ->add("title", "text", array( - "constraints" => array( - new NotBlank() - ), + "constraints" => array(new NotBlank()), "label" => "Product title *", "label_attr" => array("for" => "title") )) ->add("default_category", "integer", array( "constraints" => array(new NotBlank()), - "label" => Translator::getInstance()->trans("Default product category."), + "label" => Translator::getInstance()->trans("Default product category *"), "label_attr" => array("for" => "default_category_field") )) ->add("locale", "text", array( "constraints" => array(new NotBlank()) )) ->add("visible", "integer", array( - "label" => Translator::getInstance()->trans("This product is online."), + "label" => Translator::getInstance()->trans("This product is online"), "label_attr" => array("for" => "visible_field") )) - ; + ; + + if (! $change_mode) { + $this->formBuilder + ->add("price", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Product base price excluding taxes *"), + "label_attr" => array("for" => "price_field") + )) + ->add("currency", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Price currency *"), + "label_attr" => array("for" => "currency_field") + )) + ->add("tax_rule", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Tax rule for this product *"), + "label_attr" => array("for" => "tax_rule_field") + )) + ->add("weight", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Weight *"), + "label_attr" => array("for" => "weight_field") + )) + ; + } } public function checkDuplicateRef($value, ExecutionContextInterface $context) diff --git a/core/lib/Thelia/Form/ProductDetailsModificationForm.php b/core/lib/Thelia/Form/ProductDetailsModificationForm.php new file mode 100644 index 000000000..dbc6bb238 --- /dev/null +++ b/core/lib/Thelia/Form/ProductDetailsModificationForm.php @@ -0,0 +1,90 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; + +class ProductDetailsModificationForm extends BaseForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + $this->formBuilder + ->add("id", "integer", array( + "label" => Translator::getInstance()->trans("Prodcut ID *"), + "label_attr" => array("for" => "product_id_field"), + "constraints" => array(new GreaterThan(array('value' => 0))) + )) + ->add("price", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Product base price excluding taxes *"), + "label_attr" => array("for" => "price_field") + )) + ->add("price_with_tax", "number", array( + "label" => Translator::getInstance()->trans("Product base price including taxes *"), + "label_attr" => array("for" => "price_with_tax_field") + )) + ->add("currency", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Price currency *"), + "label_attr" => array("for" => "currency_field") + )) + ->add("tax_rule", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Tax rule for this product *"), + "label_attr" => array("for" => "tax_rule_field") + )) + ->add("weight", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Weight *"), + "label_attr" => array("for" => "weight_field") + )) + ->add("quantity", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Current quantity *"), + "label_attr" => array("for" => "quantity_field") + )) + ->add("sale_price", "number", array( + "label" => Translator::getInstance()->trans("Sale price *"), + "label_attr" => array("for" => "price_with_tax_field") + )) + ->add("onsale", "integer", array( + "label" => Translator::getInstance()->trans("This product is on sale"), + "label_attr" => array("for" => "onsale_field") + )) + ->add("isnew", "integer", array( + "label" => Translator::getInstance()->trans("Advertise this product as new"), + "label_attr" => array("for" => "isnew_field") + )) + + ; + } + + public function getName() + { + return "thelia_product_details_modification"; + } +} diff --git a/core/lib/Thelia/Form/ProductDocumentModification.php b/core/lib/Thelia/Form/ProductDocumentModification.php new file mode 100644 index 000000000..a9d7617e4 --- /dev/null +++ b/core/lib/Thelia/Form/ProductDocumentModification.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Thelia\Form\Image\DocumentModification; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process a file + * + * @package File + * @author Guillaume MOREL + * + */ +class ProductDocumentModification extends DocumentModification +{ + + /** + * Get form name + * This name must be unique + * + * @return string + */ + public function getName() + { + return 'thelia_product_document_modification'; + } +} diff --git a/core/lib/Thelia/Form/ProductImageModification.php b/core/lib/Thelia/Form/ProductImageModification.php new file mode 100644 index 000000000..9c81ca839 --- /dev/null +++ b/core/lib/Thelia/Form/ProductImageModification.php @@ -0,0 +1,51 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Thelia\Form\Image\ImageModification; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/18/13 + * Time: 3:56 PM + * + * Form allowing to process an image collection + * + * @package Image + * @author Guillaume MOREL + * + */ +class ProductImageModification extends ImageModification +{ + + /** + * Get form name + * This name must be unique + * + * @return string + */ + public function getName() + { + return 'thelia_product_image_modification'; + } +} diff --git a/core/lib/Thelia/Form/ProductModificationForm.php b/core/lib/Thelia/Form/ProductModificationForm.php index dbda15eaa..34785cf45 100644 --- a/core/lib/Thelia/Form/ProductModificationForm.php +++ b/core/lib/Thelia/Form/ProductModificationForm.php @@ -61,4 +61,4 @@ class ProductModificationForm extends ProductCreationForm { return "thelia_product_modification"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/ProfileModificationForm.php b/core/lib/Thelia/Form/ProfileModificationForm.php index e3119cfee..618fbdfb4 100644 --- a/core/lib/Thelia/Form/ProfileModificationForm.php +++ b/core/lib/Thelia/Form/ProfileModificationForm.php @@ -35,7 +35,6 @@ use Thelia\Model\ConfigQuery; class ProfileModificationForm extends BaseForm { - protected function buildForm() { diff --git a/core/lib/Thelia/Form/TemplateCreationForm.php b/core/lib/Thelia/Form/TemplateCreationForm.php index 42e6db5a4..82d3560eb 100644 --- a/core/lib/Thelia/Form/TemplateCreationForm.php +++ b/core/lib/Thelia/Form/TemplateCreationForm.php @@ -23,8 +23,6 @@ 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; diff --git a/core/lib/Thelia/Form/TemplateModificationForm.php b/core/lib/Thelia/Form/TemplateModificationForm.php index b2b50a3ca..7d4248143 100644 --- a/core/lib/Thelia/Form/TemplateModificationForm.php +++ b/core/lib/Thelia/Form/TemplateModificationForm.php @@ -23,10 +23,6 @@ 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 TemplateModificationForm extends TemplateCreationForm diff --git a/core/lib/Thelia/Model/Address.php b/core/lib/Thelia/Model/Address.php index 8c9bd4552..b4d5bc29a 100755 --- a/core/lib/Thelia/Model/Address.php +++ b/core/lib/Thelia/Model/Address.php @@ -4,7 +4,7 @@ namespace Thelia\Model; use Propel\Runtime\Connection\ConnectionInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Thelia\Core\Event\AddressEvent; +use Thelia\Core\Event\Address\AddressEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Address as BaseAddress; use Thelia\Model\AddressQuery; diff --git a/core/lib/Thelia/Model/Attribute.php b/core/lib/Thelia/Model/Attribute.php index b4101da8c..615fa643e 100755 --- a/core/lib/Thelia/Model/Attribute.php +++ b/core/lib/Thelia/Model/Attribute.php @@ -5,7 +5,7 @@ namespace Thelia\Model; use Thelia\Model\Base\Attribute as BaseAttribute; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\AttributeEvent; +use Thelia\Core\Event\Attribute\AttributeEvent; class Attribute extends BaseAttribute { @@ -20,7 +20,7 @@ class Attribute extends BaseAttribute { $this->dispatchEvent(TheliaEvents::BEFORE_CREATEATTRIBUTE, new AttributeEvent($this)); // Set the current position for the new object - $this->setPosition($this->getNextPosition()); + //$this->setPosition($this->getNextPosition()); return true; } diff --git a/core/lib/Thelia/Model/AttributeAv.php b/core/lib/Thelia/Model/AttributeAv.php index d45b16192..8059b217e 100755 --- a/core/lib/Thelia/Model/AttributeAv.php +++ b/core/lib/Thelia/Model/AttributeAv.php @@ -3,7 +3,7 @@ namespace Thelia\Model; use Thelia\Model\Base\AttributeAv as BaseAttributeAv; -use Thelia\Core\Event\AttributeAvEvent; +use Thelia\Core\Event\Attribute\AttributeAvEvent; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Event\TheliaEvents; use Propel\Runtime\ActiveQuery\Criteria; diff --git a/core/lib/Thelia/Model/AttributeTemplate.php b/core/lib/Thelia/Model/AttributeTemplate.php index 57b4c3745..bb5a0c02c 100644 --- a/core/lib/Thelia/Model/AttributeTemplate.php +++ b/core/lib/Thelia/Model/AttributeTemplate.php @@ -3,8 +3,29 @@ namespace Thelia\Model; use Thelia\Model\Base\AttributeTemplate as BaseAttributeTemplate; +use Propel\Runtime\Connection\ConnectionInterface; - class AttributeTemplate extends BaseAttributeTemplate +class AttributeTemplate extends BaseAttributeTemplate { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * Calculate next position relative to our template + */ + protected function addCriteriaToPositionQuery($query) + { + $query->filterByTemplateId($this->getTemplateId()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/Base/Accessory.php b/core/lib/Thelia/Model/Base/Accessory.php index 183f59947..df3de2bc3 100644 --- a/core/lib/Thelia/Model/Base/Accessory.php +++ b/core/lib/Thelia/Model/Base/Accessory.php @@ -152,7 +152,7 @@ abstract class Accessory implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -210,8 +210,8 @@ abstract class Accessory implements ActiveRecordInterface * obj is an instance of Accessory, delegates to * equals(Accessory). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -250,8 +250,6 @@ abstract class Accessory implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -262,6 +260,7 @@ abstract class Accessory implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -272,7 +271,10 @@ abstract class Accessory implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -329,7 +331,9 @@ abstract class Accessory implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -424,7 +428,7 @@ abstract class Accessory implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -444,7 +448,7 @@ abstract class Accessory implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1061,8 +1065,7 @@ abstract class Accessory implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php index 2dc666a08..47bcd35a3 100644 --- a/core/lib/Thelia/Model/Base/Address.php +++ b/core/lib/Thelia/Model/Base/Address.php @@ -274,7 +274,7 @@ abstract class Address implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -332,8 +332,8 @@ abstract class Address implements ActiveRecordInterface * obj is an instance of Address, delegates to * equals(Address). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -372,8 +372,6 @@ abstract class Address implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -384,6 +382,7 @@ abstract class Address implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -394,7 +393,10 @@ abstract class Address implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -451,7 +453,9 @@ abstract class Address implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -678,7 +682,7 @@ abstract class Address implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -698,7 +702,7 @@ abstract class Address implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1782,8 +1786,7 @@ abstract class Address implements ActiveRecordInterface $keys[17] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Admin.php b/core/lib/Thelia/Model/Base/Admin.php index edcdb27e8..bb26ed270 100644 --- a/core/lib/Thelia/Model/Base/Admin.php +++ b/core/lib/Thelia/Model/Base/Admin.php @@ -198,7 +198,7 @@ abstract class Admin implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -256,8 +256,8 @@ abstract class Admin implements ActiveRecordInterface * obj is an instance of Admin, delegates to * equals(Admin). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -296,8 +296,6 @@ abstract class Admin implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -308,6 +306,7 @@ abstract class Admin implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -318,7 +317,10 @@ abstract class Admin implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -375,7 +377,9 @@ abstract class Admin implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -525,7 +529,7 @@ abstract class Admin implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -545,7 +549,7 @@ abstract class Admin implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1344,8 +1348,7 @@ abstract class Admin implements ActiveRecordInterface $keys[10] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AdminGroup.php b/core/lib/Thelia/Model/Base/AdminGroup.php index 9eadbb107..663e437a4 100644 --- a/core/lib/Thelia/Model/Base/AdminGroup.php +++ b/core/lib/Thelia/Model/Base/AdminGroup.php @@ -148,7 +148,7 @@ abstract class AdminGroup implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -206,8 +206,8 @@ abstract class AdminGroup implements ActiveRecordInterface * obj is an instance of AdminGroup, delegates to * equals(AdminGroup). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -246,8 +246,6 @@ abstract class AdminGroup implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -258,6 +256,7 @@ abstract class AdminGroup implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -268,7 +267,10 @@ abstract class AdminGroup implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -325,7 +327,9 @@ abstract class AdminGroup implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -409,7 +413,7 @@ abstract class AdminGroup implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -429,7 +433,7 @@ abstract class AdminGroup implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1012,8 +1016,7 @@ abstract class AdminGroup implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AdminLog.php b/core/lib/Thelia/Model/Base/AdminLog.php index ae828e4bb..dfce950eb 100644 --- a/core/lib/Thelia/Model/Base/AdminLog.php +++ b/core/lib/Thelia/Model/Base/AdminLog.php @@ -152,7 +152,7 @@ abstract class AdminLog implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -210,8 +210,8 @@ abstract class AdminLog implements ActiveRecordInterface * obj is an instance of AdminLog, delegates to * equals(AdminLog). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -250,8 +250,6 @@ abstract class AdminLog implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -262,6 +260,7 @@ abstract class AdminLog implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -272,7 +271,10 @@ abstract class AdminLog implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -329,7 +331,9 @@ abstract class AdminLog implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -446,7 +450,7 @@ abstract class AdminLog implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -466,7 +470,7 @@ abstract class AdminLog implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1115,8 +1119,7 @@ abstract class AdminLog implements ActiveRecordInterface $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Area.php b/core/lib/Thelia/Model/Base/Area.php index f561ba330..14d834929 100644 --- a/core/lib/Thelia/Model/Base/Area.php +++ b/core/lib/Thelia/Model/Base/Area.php @@ -163,7 +163,7 @@ abstract class Area implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -221,8 +221,8 @@ abstract class Area implements ActiveRecordInterface * obj is an instance of Area, delegates to * equals(Area). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -261,8 +261,6 @@ abstract class Area implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -273,6 +271,7 @@ abstract class Area implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -283,7 +282,10 @@ abstract class Area implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -340,7 +342,9 @@ abstract class Area implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -424,7 +428,7 @@ abstract class Area implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -444,7 +448,7 @@ abstract class Area implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1031,8 +1035,7 @@ abstract class Area implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AreaDeliveryModule.php b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php index 38a16dd5a..1e2996fb4 100644 --- a/core/lib/Thelia/Model/Base/AreaDeliveryModule.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php @@ -148,7 +148,7 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -206,8 +206,8 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface * obj is an instance of AreaDeliveryModule, delegates to * equals(AreaDeliveryModule). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -246,8 +246,6 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -258,6 +256,7 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -268,7 +267,10 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -325,7 +327,9 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -409,7 +413,7 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -429,7 +433,7 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1012,8 +1016,7 @@ abstract class AreaDeliveryModule implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php index 64e765fdd..f9cee31c7 100644 --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -212,7 +212,7 @@ abstract class Attribute implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -270,8 +270,8 @@ abstract class Attribute implements ActiveRecordInterface * obj is an instance of Attribute, delegates to * equals(Attribute). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -310,8 +310,6 @@ abstract class Attribute implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -322,6 +320,7 @@ abstract class Attribute implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -332,7 +331,10 @@ abstract class Attribute implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -389,7 +391,9 @@ abstract class Attribute implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -462,7 +466,7 @@ abstract class Attribute implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -482,7 +486,7 @@ abstract class Attribute implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1100,8 +1104,7 @@ abstract class Attribute implements ActiveRecordInterface $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php index b94288753..83b55fab8 100644 --- a/core/lib/Thelia/Model/Base/AttributeAv.php +++ b/core/lib/Thelia/Model/Base/AttributeAv.php @@ -184,7 +184,7 @@ abstract class AttributeAv implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -242,8 +242,8 @@ abstract class AttributeAv implements ActiveRecordInterface * obj is an instance of AttributeAv, delegates to * equals(AttributeAv). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -282,8 +282,6 @@ abstract class AttributeAv implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -294,6 +292,7 @@ abstract class AttributeAv implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -304,7 +303,10 @@ abstract class AttributeAv implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -361,7 +363,9 @@ abstract class AttributeAv implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -445,7 +449,7 @@ abstract class AttributeAv implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -465,7 +469,7 @@ abstract class AttributeAv implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1071,8 +1075,7 @@ abstract class AttributeAv implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php index ec6f8811f..dd2a973b7 100644 --- a/core/lib/Thelia/Model/Base/AttributeAvI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeAvI18n.php @@ -158,7 +158,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class AttributeAvI18n implements ActiveRecordInterface * obj is an instance of AttributeAvI18n, delegates to * equals(AttributeAvI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class AttributeAvI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class AttributeAvI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class AttributeAvI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AttributeCombination.php b/core/lib/Thelia/Model/Base/AttributeCombination.php index ef840a5a1..543e86476 100644 --- a/core/lib/Thelia/Model/Base/AttributeCombination.php +++ b/core/lib/Thelia/Model/Base/AttributeCombination.php @@ -155,7 +155,7 @@ abstract class AttributeCombination implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -213,8 +213,8 @@ abstract class AttributeCombination implements ActiveRecordInterface * obj is an instance of AttributeCombination, delegates to * equals(AttributeCombination). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -253,8 +253,6 @@ abstract class AttributeCombination implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -265,6 +263,7 @@ abstract class AttributeCombination implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -275,7 +274,10 @@ abstract class AttributeCombination implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -332,7 +334,9 @@ abstract class AttributeCombination implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -416,7 +420,7 @@ abstract class AttributeCombination implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -436,7 +440,7 @@ abstract class AttributeCombination implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1023,8 +1027,7 @@ abstract class AttributeCombination implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php index d75c24412..30bd331a3 100644 --- a/core/lib/Thelia/Model/Base/AttributeI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeI18n.php @@ -158,7 +158,7 @@ abstract class AttributeI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class AttributeI18n implements ActiveRecordInterface * obj is an instance of AttributeI18n, delegates to * equals(AttributeI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class AttributeI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class AttributeI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class AttributeI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class AttributeI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class AttributeI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/AttributeTemplate.php b/core/lib/Thelia/Model/Base/AttributeTemplate.php index cedc85431..ae45495ee 100644 --- a/core/lib/Thelia/Model/Base/AttributeTemplate.php +++ b/core/lib/Thelia/Model/Base/AttributeTemplate.php @@ -76,6 +76,12 @@ abstract class AttributeTemplate implements ActiveRecordInterface */ protected $template_id; + /** + * The value for the position field. + * @var int + */ + protected $position; + /** * The value for the created_at field. * @var string @@ -148,7 +154,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -206,8 +212,8 @@ abstract class AttributeTemplate implements ActiveRecordInterface * obj is an instance of AttributeTemplate, delegates to * equals(AttributeTemplate). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -246,8 +252,6 @@ abstract class AttributeTemplate implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -258,6 +262,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -268,7 +273,10 @@ abstract class AttributeTemplate implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -325,7 +333,9 @@ abstract class AttributeTemplate implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -393,6 +403,17 @@ abstract class AttributeTemplate implements ActiveRecordInterface return $this->template_id; } + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -409,7 +430,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -429,7 +450,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -504,6 +525,27 @@ abstract class AttributeTemplate implements ActiveRecordInterface return $this; } // setTemplateId() + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = AttributeTemplateTableMap::POSITION; + } + + + return $this; + } // setPosition() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -592,13 +634,16 @@ abstract class AttributeTemplate implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeTemplateTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; $this->template_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTemplateTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeTemplateTableMap::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 ? 4 + $startcol : AttributeTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -611,7 +656,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = AttributeTemplateTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = AttributeTemplateTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\AttributeTemplate object", 0, $e); @@ -867,6 +912,9 @@ abstract class AttributeTemplate implements ActiveRecordInterface if ($this->isColumnModified(AttributeTemplateTableMap::TEMPLATE_ID)) { $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; } + if ($this->isColumnModified(AttributeTemplateTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } if ($this->isColumnModified(AttributeTemplateTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -893,6 +941,9 @@ abstract class AttributeTemplate implements ActiveRecordInterface case 'TEMPLATE_ID': $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, 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; @@ -971,9 +1022,12 @@ abstract class AttributeTemplate implements ActiveRecordInterface return $this->getTemplateId(); break; case 3: - return $this->getCreatedAt(); + return $this->getPosition(); break; case 4: + return $this->getCreatedAt(); + break; + case 5: return $this->getUpdatedAt(); break; default: @@ -1008,12 +1062,12 @@ abstract class AttributeTemplate implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getAttributeId(), $keys[2] => $this->getTemplateId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } @@ -1068,9 +1122,12 @@ abstract class AttributeTemplate implements ActiveRecordInterface $this->setTemplateId($value); break; case 3: - $this->setCreatedAt($value); + $this->setPosition($value); break; case 4: + $this->setCreatedAt($value); + break; + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1100,8 +1157,9 @@ abstract class AttributeTemplate implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setTemplateId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1116,6 +1174,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface if ($this->isColumnModified(AttributeTemplateTableMap::ID)) $criteria->add(AttributeTemplateTableMap::ID, $this->id); if ($this->isColumnModified(AttributeTemplateTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeTemplateTableMap::ATTRIBUTE_ID, $this->attribute_id); if ($this->isColumnModified(AttributeTemplateTableMap::TEMPLATE_ID)) $criteria->add(AttributeTemplateTableMap::TEMPLATE_ID, $this->template_id); + if ($this->isColumnModified(AttributeTemplateTableMap::POSITION)) $criteria->add(AttributeTemplateTableMap::POSITION, $this->position); if ($this->isColumnModified(AttributeTemplateTableMap::CREATED_AT)) $criteria->add(AttributeTemplateTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AttributeTemplateTableMap::UPDATED_AT)) $criteria->add(AttributeTemplateTableMap::UPDATED_AT, $this->updated_at); @@ -1183,6 +1242,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface { $copyObj->setAttributeId($this->getAttributeId()); $copyObj->setTemplateId($this->getTemplateId()); + $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1323,6 +1383,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface $this->id = null; $this->attribute_id = null; $this->template_id = null; + $this->position = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php b/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php index bd895360b..e1a8d0320 100644 --- a/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php @@ -24,12 +24,14 @@ use Thelia\Model\Map\AttributeTemplateTableMap; * @method ChildAttributeTemplateQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildAttributeTemplateQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column * @method ChildAttributeTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column + * @method ChildAttributeTemplateQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildAttributeTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAttributeTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildAttributeTemplateQuery groupById() Group by the id column * @method ChildAttributeTemplateQuery groupByAttributeId() Group by the attribute_id column * @method ChildAttributeTemplateQuery groupByTemplateId() Group by the template_id column + * @method ChildAttributeTemplateQuery groupByPosition() Group by the position column * @method ChildAttributeTemplateQuery groupByCreatedAt() Group by the created_at column * @method ChildAttributeTemplateQuery groupByUpdatedAt() Group by the updated_at column * @@ -51,12 +53,14 @@ use Thelia\Model\Map\AttributeTemplateTableMap; * @method ChildAttributeTemplate findOneById(int $id) Return the first ChildAttributeTemplate filtered by the id column * @method ChildAttributeTemplate findOneByAttributeId(int $attribute_id) Return the first ChildAttributeTemplate filtered by the attribute_id column * @method ChildAttributeTemplate findOneByTemplateId(int $template_id) Return the first ChildAttributeTemplate filtered by the template_id column + * @method ChildAttributeTemplate findOneByPosition(int $position) Return the first ChildAttributeTemplate filtered by the position column * @method ChildAttributeTemplate findOneByCreatedAt(string $created_at) Return the first ChildAttributeTemplate filtered by the created_at column * @method ChildAttributeTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeTemplate filtered by the updated_at column * * @method array findById(int $id) Return ChildAttributeTemplate objects filtered by the id column * @method array findByAttributeId(int $attribute_id) Return ChildAttributeTemplate objects filtered by the attribute_id column * @method array findByTemplateId(int $template_id) Return ChildAttributeTemplate objects filtered by the template_id column + * @method array findByPosition(int $position) Return ChildAttributeTemplate objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildAttributeTemplate objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildAttributeTemplate objects filtered by the updated_at column * @@ -147,7 +151,7 @@ abstract class AttributeTemplateQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ATTRIBUTE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM attribute_template WHERE ID = :p0'; + $sql = 'SELECT ID, ATTRIBUTE_ID, TEMPLATE_ID, POSITION, CREATED_AT, UPDATED_AT FROM attribute_template WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -363,6 +367,47 @@ abstract class AttributeTemplateQuery extends ModelCriteria return $this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId, $comparison); } + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position 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 ChildAttributeTemplateQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Cart.php b/core/lib/Thelia/Model/Base/Cart.php index 2ef18297c..96880be66 100644 --- a/core/lib/Thelia/Model/Base/Cart.php +++ b/core/lib/Thelia/Model/Base/Cart.php @@ -213,7 +213,7 @@ abstract class Cart implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -271,8 +271,8 @@ abstract class Cart implements ActiveRecordInterface * obj is an instance of Cart, delegates to * equals(Cart). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -311,8 +311,6 @@ abstract class Cart implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -323,6 +321,7 @@ abstract class Cart implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -333,7 +332,10 @@ abstract class Cart implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -390,7 +392,9 @@ abstract class Cart implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -518,7 +522,7 @@ abstract class Cart implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -538,7 +542,7 @@ abstract class Cart implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1310,8 +1314,7 @@ abstract class Cart implements ActiveRecordInterface $keys[8] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index e785ae0a5..53b3ef411 100644 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -213,7 +213,7 @@ abstract class CartItem implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -271,8 +271,8 @@ abstract class CartItem implements ActiveRecordInterface * obj is an instance of CartItem, delegates to * equals(CartItem). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -311,8 +311,6 @@ abstract class CartItem implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -323,6 +321,7 @@ abstract class CartItem implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -333,7 +332,10 @@ abstract class CartItem implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -390,7 +392,9 @@ abstract class CartItem implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -518,7 +522,7 @@ abstract class CartItem implements ActiveRecordInterface if ($format === null) { return $this->price_end_of_life; } else { - return $this->price_end_of_life !== null ? $this->price_end_of_life->format($format) : null; + return $this->price_end_of_life instanceof \DateTime ? $this->price_end_of_life->format($format) : null; } } @@ -560,7 +564,7 @@ abstract class CartItem implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -580,7 +584,7 @@ abstract class CartItem implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1427,8 +1431,7 @@ abstract class CartItem implements ActiveRecordInterface $keys[11] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index 6dc9b727a..d5272d1e4 100644 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -293,7 +293,7 @@ abstract class Category implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -351,8 +351,8 @@ abstract class Category implements ActiveRecordInterface * obj is an instance of Category, delegates to * equals(Category). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -391,8 +391,6 @@ abstract class Category implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -403,6 +401,7 @@ abstract class Category implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -413,7 +412,10 @@ abstract class Category implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -470,7 +472,9 @@ abstract class Category implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -565,7 +569,7 @@ abstract class Category implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -585,7 +589,7 @@ abstract class Category implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -616,7 +620,7 @@ abstract class Category implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1472,8 +1476,7 @@ abstract class Category implements ActiveRecordInterface $keys[8] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php index 142ab543f..8079eb563 100644 --- a/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php +++ b/core/lib/Thelia/Model/Base/CategoryAssociatedContent.php @@ -154,7 +154,7 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -212,8 +212,8 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface * obj is an instance of CategoryAssociatedContent, delegates to * equals(CategoryAssociatedContent). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -252,8 +252,6 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -264,6 +262,7 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -274,7 +273,10 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -331,7 +333,9 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -426,7 +430,7 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -446,7 +450,7 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1063,8 +1067,7 @@ abstract class CategoryAssociatedContent implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CategoryDocument.php b/core/lib/Thelia/Model/Base/CategoryDocument.php index 7539312cc..83660e717 100644 --- a/core/lib/Thelia/Model/Base/CategoryDocument.php +++ b/core/lib/Thelia/Model/Base/CategoryDocument.php @@ -176,7 +176,7 @@ abstract class CategoryDocument implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class CategoryDocument implements ActiveRecordInterface * obj is an instance of CategoryDocument, delegates to * equals(CategoryDocument). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class CategoryDocument implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class CategoryDocument implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class CategoryDocument implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class CategoryDocument implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class CategoryDocument implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class CategoryDocument implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class CategoryDocument implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php index 4d284b57e..c4348da52 100644 --- a/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryDocumentI18n.php @@ -158,7 +158,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface * obj is an instance of CategoryDocumentI18n, delegates to * equals(CategoryDocumentI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class CategoryDocumentI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php index 9ae8c8cf3..bd9bf2608 100644 --- a/core/lib/Thelia/Model/Base/CategoryI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryI18n.php @@ -158,7 +158,7 @@ abstract class CategoryI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class CategoryI18n implements ActiveRecordInterface * obj is an instance of CategoryI18n, delegates to * equals(CategoryI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class CategoryI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class CategoryI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class CategoryI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class CategoryI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class CategoryI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CategoryImage.php b/core/lib/Thelia/Model/Base/CategoryImage.php index 353c79c4f..2a7e826c7 100644 --- a/core/lib/Thelia/Model/Base/CategoryImage.php +++ b/core/lib/Thelia/Model/Base/CategoryImage.php @@ -176,7 +176,7 @@ abstract class CategoryImage implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class CategoryImage implements ActiveRecordInterface * obj is an instance of CategoryImage, delegates to * equals(CategoryImage). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class CategoryImage implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class CategoryImage implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class CategoryImage implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class CategoryImage implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class CategoryImage implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class CategoryImage implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class CategoryImage implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CategoryImageI18n.php b/core/lib/Thelia/Model/Base/CategoryImageI18n.php index 61b4fc413..1197930c8 100644 --- a/core/lib/Thelia/Model/Base/CategoryImageI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryImageI18n.php @@ -158,7 +158,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class CategoryImageI18n implements ActiveRecordInterface * obj is an instance of CategoryImageI18n, delegates to * equals(CategoryImageI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class CategoryImageI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class CategoryImageI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class CategoryImageI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class CategoryImageI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CategoryVersion.php b/core/lib/Thelia/Model/Base/CategoryVersion.php index 416ad95d5..7abd40b21 100644 --- a/core/lib/Thelia/Model/Base/CategoryVersion.php +++ b/core/lib/Thelia/Model/Base/CategoryVersion.php @@ -178,7 +178,7 @@ abstract class CategoryVersion implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -236,8 +236,8 @@ abstract class CategoryVersion implements ActiveRecordInterface * obj is an instance of CategoryVersion, delegates to * equals(CategoryVersion). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -276,8 +276,6 @@ abstract class CategoryVersion implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -288,6 +286,7 @@ abstract class CategoryVersion implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -298,7 +297,10 @@ abstract class CategoryVersion implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -355,7 +357,9 @@ abstract class CategoryVersion implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -450,7 +454,7 @@ abstract class CategoryVersion implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -470,7 +474,7 @@ abstract class CategoryVersion implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -501,7 +505,7 @@ abstract class CategoryVersion implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1201,8 +1205,7 @@ abstract class CategoryVersion implements ActiveRecordInterface $keys[8] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Config.php b/core/lib/Thelia/Model/Base/Config.php index 9f2080d1f..72837ec39 100644 --- a/core/lib/Thelia/Model/Base/Config.php +++ b/core/lib/Thelia/Model/Base/Config.php @@ -191,7 +191,7 @@ abstract class Config implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -249,8 +249,8 @@ abstract class Config implements ActiveRecordInterface * obj is an instance of Config, delegates to * equals(Config). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -289,8 +289,6 @@ abstract class Config implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -301,6 +299,7 @@ abstract class Config implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -311,7 +310,10 @@ abstract class Config implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -368,7 +370,9 @@ abstract class Config implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -474,7 +478,7 @@ abstract class Config implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -494,7 +498,7 @@ abstract class Config implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1137,8 +1141,7 @@ abstract class Config implements ActiveRecordInterface $keys[6] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php index 71f1d5287..370860b61 100644 --- a/core/lib/Thelia/Model/Base/ConfigI18n.php +++ b/core/lib/Thelia/Model/Base/ConfigI18n.php @@ -158,7 +158,7 @@ abstract class ConfigI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ConfigI18n implements ActiveRecordInterface * obj is an instance of ConfigI18n, delegates to * equals(ConfigI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ConfigI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ConfigI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ConfigI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ConfigI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ConfigI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index aa53fb9b5..bb7299f17 100644 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -301,7 +301,7 @@ abstract class Content implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -359,8 +359,8 @@ abstract class Content implements ActiveRecordInterface * obj is an instance of Content, delegates to * equals(Content). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -399,8 +399,6 @@ abstract class Content implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -411,6 +409,7 @@ abstract class Content implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -421,7 +420,10 @@ abstract class Content implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -478,7 +480,9 @@ abstract class Content implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -562,7 +566,7 @@ abstract class Content implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -582,7 +586,7 @@ abstract class Content implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -613,7 +617,7 @@ abstract class Content implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1454,8 +1458,7 @@ abstract class Content implements ActiveRecordInterface $keys[7] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ContentDocument.php b/core/lib/Thelia/Model/Base/ContentDocument.php index a8207bb14..f59b52af0 100644 --- a/core/lib/Thelia/Model/Base/ContentDocument.php +++ b/core/lib/Thelia/Model/Base/ContentDocument.php @@ -176,7 +176,7 @@ abstract class ContentDocument implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class ContentDocument implements ActiveRecordInterface * obj is an instance of ContentDocument, delegates to * equals(ContentDocument). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class ContentDocument implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class ContentDocument implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class ContentDocument implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class ContentDocument implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class ContentDocument implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class ContentDocument implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class ContentDocument implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php index 1e1f1bd52..e51c76524 100644 --- a/core/lib/Thelia/Model/Base/ContentDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentDocumentI18n.php @@ -158,7 +158,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface * obj is an instance of ContentDocumentI18n, delegates to * equals(ContentDocumentI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ContentDocumentI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php index 809825d51..8200b942c 100644 --- a/core/lib/Thelia/Model/Base/ContentFolder.php +++ b/core/lib/Thelia/Model/Base/ContentFolder.php @@ -148,7 +148,7 @@ abstract class ContentFolder implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -206,8 +206,8 @@ abstract class ContentFolder implements ActiveRecordInterface * obj is an instance of ContentFolder, delegates to * equals(ContentFolder). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -246,8 +246,6 @@ abstract class ContentFolder implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -258,6 +256,7 @@ abstract class ContentFolder implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -268,7 +267,10 @@ abstract class ContentFolder implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -325,7 +327,9 @@ abstract class ContentFolder implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -409,7 +413,7 @@ abstract class ContentFolder implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -429,7 +433,7 @@ abstract class ContentFolder implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1009,8 +1013,7 @@ abstract class ContentFolder implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php index 6ffc1d4bf..e5de214c8 100644 --- a/core/lib/Thelia/Model/Base/ContentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentI18n.php @@ -158,7 +158,7 @@ abstract class ContentI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ContentI18n implements ActiveRecordInterface * obj is an instance of ContentI18n, delegates to * equals(ContentI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ContentI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ContentI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ContentI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ContentI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ContentI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ContentImage.php b/core/lib/Thelia/Model/Base/ContentImage.php index 8a0a5a77c..17fa9d1f8 100644 --- a/core/lib/Thelia/Model/Base/ContentImage.php +++ b/core/lib/Thelia/Model/Base/ContentImage.php @@ -176,7 +176,7 @@ abstract class ContentImage implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class ContentImage implements ActiveRecordInterface * obj is an instance of ContentImage, delegates to * equals(ContentImage). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class ContentImage implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class ContentImage implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class ContentImage implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class ContentImage implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class ContentImage implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class ContentImage implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class ContentImage implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ContentImageI18n.php b/core/lib/Thelia/Model/Base/ContentImageI18n.php index 54016f0df..dcee14315 100644 --- a/core/lib/Thelia/Model/Base/ContentImageI18n.php +++ b/core/lib/Thelia/Model/Base/ContentImageI18n.php @@ -158,7 +158,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ContentImageI18n implements ActiveRecordInterface * obj is an instance of ContentImageI18n, delegates to * equals(ContentImageI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ContentImageI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ContentImageI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ContentImageI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ContentImageI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ContentVersion.php b/core/lib/Thelia/Model/Base/ContentVersion.php index ef2897030..beb02456e 100644 --- a/core/lib/Thelia/Model/Base/ContentVersion.php +++ b/core/lib/Thelia/Model/Base/ContentVersion.php @@ -172,7 +172,7 @@ abstract class ContentVersion implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -230,8 +230,8 @@ abstract class ContentVersion implements ActiveRecordInterface * obj is an instance of ContentVersion, delegates to * equals(ContentVersion). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -270,8 +270,6 @@ abstract class ContentVersion implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -282,6 +280,7 @@ abstract class ContentVersion implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -292,7 +291,10 @@ abstract class ContentVersion implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -349,7 +351,9 @@ abstract class ContentVersion implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -433,7 +437,7 @@ abstract class ContentVersion implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -453,7 +457,7 @@ abstract class ContentVersion implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -484,7 +488,7 @@ abstract class ContentVersion implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1150,8 +1154,7 @@ abstract class ContentVersion implements ActiveRecordInterface $keys[7] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php index 86cc8220b..fd16e148d 100644 --- a/core/lib/Thelia/Model/Base/Country.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -216,7 +216,7 @@ abstract class Country implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -274,8 +274,8 @@ abstract class Country implements ActiveRecordInterface * obj is an instance of Country, delegates to * equals(Country). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -314,8 +314,6 @@ abstract class Country implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -326,6 +324,7 @@ abstract class Country implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -336,7 +335,10 @@ abstract class Country implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -393,7 +395,9 @@ abstract class Country implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -510,7 +514,7 @@ abstract class Country implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -530,7 +534,7 @@ abstract class Country implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1246,8 +1250,7 @@ abstract class Country implements ActiveRecordInterface $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php index 3e3e314cb..2c660e200 100644 --- a/core/lib/Thelia/Model/Base/CountryI18n.php +++ b/core/lib/Thelia/Model/Base/CountryI18n.php @@ -158,7 +158,7 @@ abstract class CountryI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class CountryI18n implements ActiveRecordInterface * obj is an instance of CountryI18n, delegates to * equals(CountryI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class CountryI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class CountryI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class CountryI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class CountryI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class CountryI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php index 4c5dcd917..012b97313 100644 --- a/core/lib/Thelia/Model/Base/Coupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -84,15 +84,9 @@ abstract class Coupon implements ActiveRecordInterface */ protected $amount; - /** - * The value for the is_used field. - * @var int - */ - protected $is_used; - /** * The value for the is_enabled field. - * @var int + * @var boolean */ protected $is_enabled; @@ -102,36 +96,42 @@ abstract class Coupon implements ActiveRecordInterface */ protected $expiration_date; - /** - * The value for the serialized_rules field. - * @var string - */ - protected $serialized_rules; - - /** - * The value for the is_cumulative field. - * @var int - */ - protected $is_cumulative; - - /** - * The value for the is_removing_postage field. - * @var int - */ - protected $is_removing_postage; - /** * The value for the max_usage field. * @var int */ protected $max_usage; + /** + * The value for the is_cumulative field. + * @var boolean + */ + protected $is_cumulative; + + /** + * The value for the is_removing_postage field. + * @var boolean + */ + protected $is_removing_postage; + /** * The value for the is_available_on_special_offers field. * @var boolean */ protected $is_available_on_special_offers; + /** + * The value for the is_used field. + * @var boolean + */ + protected $is_used; + + /** + * The value for the serialized_conditions field. + * @var string + */ + protected $serialized_conditions; + /** * The value for the created_at field. * @var string @@ -260,7 +260,7 @@ abstract class Coupon implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -318,8 +318,8 @@ abstract class Coupon implements ActiveRecordInterface * obj is an instance of Coupon, delegates to * equals(Coupon). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -358,8 +358,6 @@ abstract class Coupon implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -370,6 +368,7 @@ abstract class Coupon implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -380,7 +379,10 @@ abstract class Coupon implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -437,7 +439,9 @@ abstract class Coupon implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -516,21 +520,10 @@ abstract class Coupon implements ActiveRecordInterface return $this->amount; } - /** - * Get the [is_used] column value. - * - * @return int - */ - public function getIsUsed() - { - - return $this->is_used; - } - /** * Get the [is_enabled] column value. * - * @return int + * @return boolean */ public function getIsEnabled() { @@ -554,43 +547,10 @@ abstract class Coupon implements ActiveRecordInterface if ($format === null) { return $this->expiration_date; } else { - return $this->expiration_date !== null ? $this->expiration_date->format($format) : null; + return $this->expiration_date instanceof \DateTime ? $this->expiration_date->format($format) : null; } } - /** - * Get the [serialized_rules] column value. - * - * @return string - */ - public function getSerializedRules() - { - - return $this->serialized_rules; - } - - /** - * Get the [is_cumulative] column value. - * - * @return int - */ - public function getIsCumulative() - { - - return $this->is_cumulative; - } - - /** - * Get the [is_removing_postage] column value. - * - * @return int - */ - public function getIsRemovingPostage() - { - - return $this->is_removing_postage; - } - /** * Get the [max_usage] column value. * @@ -602,6 +562,28 @@ abstract class Coupon implements ActiveRecordInterface return $this->max_usage; } + /** + * Get the [is_cumulative] column value. + * + * @return boolean + */ + public function getIsCumulative() + { + + return $this->is_cumulative; + } + + /** + * Get the [is_removing_postage] column value. + * + * @return boolean + */ + public function getIsRemovingPostage() + { + + return $this->is_removing_postage; + } + /** * Get the [is_available_on_special_offers] column value. * @@ -613,6 +595,28 @@ abstract class Coupon implements ActiveRecordInterface return $this->is_available_on_special_offers; } + /** + * Get the [is_used] column value. + * + * @return boolean + */ + public function getIsUsed() + { + + return $this->is_used; + } + + /** + * Get the [serialized_conditions] column value. + * + * @return string + */ + public function getSerializedConditions() + { + + return $this->serialized_conditions; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -629,7 +633,7 @@ abstract class Coupon implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -649,7 +653,7 @@ abstract class Coupon implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -749,36 +753,23 @@ abstract class Coupon implements ActiveRecordInterface } // setAmount() /** - * Set the value of [is_used] column. + * Sets the value of the [is_enabled] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). * - * @param int $v new value - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setIsUsed($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->is_used !== $v) { - $this->is_used = $v; - $this->modifiedColumns[] = CouponTableMap::IS_USED; - } - - - return $this; - } // setIsUsed() - - /** - * Set the value of [is_enabled] column. - * - * @param int $v new value + * @param boolean|integer|string $v The new value * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setIsEnabled($v) { if ($v !== null) { - $v = (int) $v; + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } } if ($this->is_enabled !== $v) { @@ -811,69 +802,6 @@ abstract class Coupon implements ActiveRecordInterface return $this; } // setExpirationDate() - /** - * Set the value of [serialized_rules] column. - * - * @param string $v new value - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setSerializedRules($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->serialized_rules !== $v) { - $this->serialized_rules = $v; - $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES; - } - - - return $this; - } // setSerializedRules() - - /** - * Set the value of [is_cumulative] column. - * - * @param int $v new value - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setIsCumulative($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->is_cumulative !== $v) { - $this->is_cumulative = $v; - $this->modifiedColumns[] = CouponTableMap::IS_CUMULATIVE; - } - - - return $this; - } // setIsCumulative() - - /** - * Set the value of [is_removing_postage] column. - * - * @param int $v new value - * @return \Thelia\Model\Coupon The current object (for fluent API support) - */ - public function setIsRemovingPostage($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->is_removing_postage !== $v) { - $this->is_removing_postage = $v; - $this->modifiedColumns[] = CouponTableMap::IS_REMOVING_POSTAGE; - } - - - return $this; - } // setIsRemovingPostage() - /** * Set the value of [max_usage] column. * @@ -895,6 +823,64 @@ abstract class Coupon implements ActiveRecordInterface return $this; } // setMaxUsage() + /** + * Sets the value of the [is_cumulative] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsCumulative($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_cumulative !== $v) { + $this->is_cumulative = $v; + $this->modifiedColumns[] = CouponTableMap::IS_CUMULATIVE; + } + + + return $this; + } // setIsCumulative() + + /** + * Sets the value of the [is_removing_postage] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsRemovingPostage($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_removing_postage !== $v) { + $this->is_removing_postage = $v; + $this->modifiedColumns[] = CouponTableMap::IS_REMOVING_POSTAGE; + } + + + return $this; + } // setIsRemovingPostage() + /** * Sets the value of the [is_available_on_special_offers] column. * Non-boolean arguments are converted using the following rules: @@ -924,6 +910,56 @@ abstract class Coupon implements ActiveRecordInterface return $this; } // setIsAvailableOnSpecialOffers() + /** + * Sets the value of the [is_used] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setIsUsed($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_used !== $v) { + $this->is_used = $v; + $this->modifiedColumns[] = CouponTableMap::IS_USED; + } + + + return $this; + } // setIsUsed() + + /** + * Set the value of [serialized_conditions] column. + * + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) + */ + public function setSerializedConditions($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_conditions !== $v) { + $this->serialized_conditions = $v; + $this->modifiedColumns[] = CouponTableMap::SERIALIZED_CONDITIONS; + } + + + return $this; + } // setSerializedConditions() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -1040,33 +1076,33 @@ abstract class Coupon implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; $this->amount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_used = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_enabled = (null !== $col) ? (boolean) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_enabled = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_rules = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_cumulative = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_removing_postage = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; $this->max_usage = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_cumulative = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_removing_postage = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_used = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponTableMap::translateFieldName('SerializedConditions', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_conditions = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; @@ -1368,17 +1404,14 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::AMOUNT)) { $modifiedColumns[':p' . $index++] = 'AMOUNT'; } - if ($this->isColumnModified(CouponTableMap::IS_USED)) { - $modifiedColumns[':p' . $index++] = 'IS_USED'; - } if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) { $modifiedColumns[':p' . $index++] = 'IS_ENABLED'; } if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) { $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; } - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; + if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) { + $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; } if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) { $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; @@ -1386,12 +1419,15 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) { $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; } - if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) { - $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; - } if ($this->isColumnModified(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) { $modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS'; } + if ($this->isColumnModified(CouponTableMap::IS_USED)) { + $modifiedColumns[':p' . $index++] = 'IS_USED'; + } + if ($this->isColumnModified(CouponTableMap::SERIALIZED_CONDITIONS)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_CONDITIONS'; + } if ($this->isColumnModified(CouponTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1424,30 +1460,30 @@ abstract class Coupon implements ActiveRecordInterface case 'AMOUNT': $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); break; - case 'IS_USED': - $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); - break; case 'IS_ENABLED': - $stmt->bindValue($identifier, $this->is_enabled, PDO::PARAM_INT); + $stmt->bindValue($identifier, (int) $this->is_enabled, PDO::PARAM_INT); break; case 'EXPIRATION_DATE': $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case 'SERIALIZED_RULES': - $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); - break; - case 'IS_CUMULATIVE': - $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); - break; - case 'IS_REMOVING_POSTAGE': - $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); - break; case 'MAX_USAGE': $stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT); break; + case 'IS_CUMULATIVE': + $stmt->bindValue($identifier, (int) $this->is_cumulative, PDO::PARAM_INT); + break; + case 'IS_REMOVING_POSTAGE': + $stmt->bindValue($identifier, (int) $this->is_removing_postage, PDO::PARAM_INT); + break; case 'IS_AVAILABLE_ON_SPECIAL_OFFERS': $stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT); break; + case 'IS_USED': + $stmt->bindValue($identifier, (int) $this->is_used, PDO::PARAM_INT); + break; + case 'SERIALIZED_CONDITIONS': + $stmt->bindValue($identifier, $this->serialized_conditions, PDO::PARAM_STR); + 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; @@ -1532,29 +1568,29 @@ abstract class Coupon implements ActiveRecordInterface return $this->getAmount(); break; case 4: - return $this->getIsUsed(); - break; - case 5: return $this->getIsEnabled(); break; - case 6: + case 5: return $this->getExpirationDate(); break; - case 7: - return $this->getSerializedRules(); - break; - case 8: - return $this->getIsCumulative(); - break; - case 9: - return $this->getIsRemovingPostage(); - break; - case 10: + case 6: return $this->getMaxUsage(); break; - case 11: + case 7: + return $this->getIsCumulative(); + break; + case 8: + return $this->getIsRemovingPostage(); + break; + case 9: return $this->getIsAvailableOnSpecialOffers(); break; + case 10: + return $this->getIsUsed(); + break; + case 11: + return $this->getSerializedConditions(); + break; case 12: return $this->getCreatedAt(); break; @@ -1597,21 +1633,20 @@ abstract class Coupon implements ActiveRecordInterface $keys[1] => $this->getCode(), $keys[2] => $this->getType(), $keys[3] => $this->getAmount(), - $keys[4] => $this->getIsUsed(), - $keys[5] => $this->getIsEnabled(), - $keys[6] => $this->getExpirationDate(), - $keys[7] => $this->getSerializedRules(), - $keys[8] => $this->getIsCumulative(), - $keys[9] => $this->getIsRemovingPostage(), - $keys[10] => $this->getMaxUsage(), - $keys[11] => $this->getIsAvailableOnSpecialOffers(), + $keys[4] => $this->getIsEnabled(), + $keys[5] => $this->getExpirationDate(), + $keys[6] => $this->getMaxUsage(), + $keys[7] => $this->getIsCumulative(), + $keys[8] => $this->getIsRemovingPostage(), + $keys[9] => $this->getIsAvailableOnSpecialOffers(), + $keys[10] => $this->getIsUsed(), + $keys[11] => $this->getSerializedConditions(), $keys[12] => $this->getCreatedAt(), $keys[13] => $this->getUpdatedAt(), $keys[14] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } @@ -1669,29 +1704,29 @@ abstract class Coupon implements ActiveRecordInterface $this->setAmount($value); break; case 4: - $this->setIsUsed($value); - break; - case 5: $this->setIsEnabled($value); break; - case 6: + case 5: $this->setExpirationDate($value); break; - case 7: - $this->setSerializedRules($value); - break; - case 8: - $this->setIsCumulative($value); - break; - case 9: - $this->setIsRemovingPostage($value); - break; - case 10: + case 6: $this->setMaxUsage($value); break; - case 11: + case 7: + $this->setIsCumulative($value); + break; + case 8: + $this->setIsRemovingPostage($value); + break; + case 9: $this->setIsAvailableOnSpecialOffers($value); break; + case 10: + $this->setIsUsed($value); + break; + case 11: + $this->setSerializedConditions($value); + break; case 12: $this->setCreatedAt($value); break; @@ -1729,14 +1764,14 @@ abstract class Coupon implements ActiveRecordInterface if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setAmount($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setIsUsed($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setIsEnabled($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setExpirationDate($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setSerializedRules($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setIsCumulative($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setIsRemovingPostage($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setMaxUsage($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[11]]); + if (array_key_exists($keys[4], $arr)) $this->setIsEnabled($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setExpirationDate($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMaxUsage($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setIsCumulative($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setIsRemovingPostage($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setIsUsed($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setSerializedConditions($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]); if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]); @@ -1755,14 +1790,14 @@ abstract class Coupon implements ActiveRecordInterface if ($this->isColumnModified(CouponTableMap::CODE)) $criteria->add(CouponTableMap::CODE, $this->code); if ($this->isColumnModified(CouponTableMap::TYPE)) $criteria->add(CouponTableMap::TYPE, $this->type); if ($this->isColumnModified(CouponTableMap::AMOUNT)) $criteria->add(CouponTableMap::AMOUNT, $this->amount); - if ($this->isColumnModified(CouponTableMap::IS_USED)) $criteria->add(CouponTableMap::IS_USED, $this->is_used); if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) $criteria->add(CouponTableMap::IS_ENABLED, $this->is_enabled); if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) $criteria->add(CouponTableMap::EXPIRATION_DATE, $this->expiration_date); - if ($this->isColumnModified(CouponTableMap::SERIALIZED_RULES)) $criteria->add(CouponTableMap::SERIALIZED_RULES, $this->serialized_rules); + if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) $criteria->add(CouponTableMap::MAX_USAGE, $this->max_usage); if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) $criteria->add(CouponTableMap::IS_CUMULATIVE, $this->is_cumulative); if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); - if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) $criteria->add(CouponTableMap::MAX_USAGE, $this->max_usage); if ($this->isColumnModified(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers); + if ($this->isColumnModified(CouponTableMap::IS_USED)) $criteria->add(CouponTableMap::IS_USED, $this->is_used); + if ($this->isColumnModified(CouponTableMap::SERIALIZED_CONDITIONS)) $criteria->add(CouponTableMap::SERIALIZED_CONDITIONS, $this->serialized_conditions); if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(CouponTableMap::VERSION)) $criteria->add(CouponTableMap::VERSION, $this->version); @@ -1832,14 +1867,14 @@ abstract class Coupon implements ActiveRecordInterface $copyObj->setCode($this->getCode()); $copyObj->setType($this->getType()); $copyObj->setAmount($this->getAmount()); - $copyObj->setIsUsed($this->getIsUsed()); $copyObj->setIsEnabled($this->getIsEnabled()); $copyObj->setExpirationDate($this->getExpirationDate()); - $copyObj->setSerializedRules($this->getSerializedRules()); + $copyObj->setMaxUsage($this->getMaxUsage()); $copyObj->setIsCumulative($this->getIsCumulative()); $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); - $copyObj->setMaxUsage($this->getMaxUsage()); $copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); + $copyObj->setIsUsed($this->getIsUsed()); + $copyObj->setSerializedConditions($this->getSerializedConditions()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -2365,14 +2400,14 @@ abstract class Coupon implements ActiveRecordInterface $this->code = null; $this->type = null; $this->amount = null; - $this->is_used = null; $this->is_enabled = null; $this->expiration_date = null; - $this->serialized_rules = null; + $this->max_usage = null; $this->is_cumulative = null; $this->is_removing_postage = null; - $this->max_usage = null; $this->is_available_on_special_offers = null; + $this->is_used = null; + $this->serialized_conditions = null; $this->created_at = null; $this->updated_at = null; $this->version = null; @@ -2669,14 +2704,14 @@ abstract class Coupon implements ActiveRecordInterface $version->setCode($this->getCode()); $version->setType($this->getType()); $version->setAmount($this->getAmount()); - $version->setIsUsed($this->getIsUsed()); $version->setIsEnabled($this->getIsEnabled()); $version->setExpirationDate($this->getExpirationDate()); - $version->setSerializedRules($this->getSerializedRules()); + $version->setMaxUsage($this->getMaxUsage()); $version->setIsCumulative($this->getIsCumulative()); $version->setIsRemovingPostage($this->getIsRemovingPostage()); - $version->setMaxUsage($this->getMaxUsage()); $version->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); + $version->setIsUsed($this->getIsUsed()); + $version->setSerializedConditions($this->getSerializedConditions()); $version->setCreatedAt($this->getCreatedAt()); $version->setUpdatedAt($this->getUpdatedAt()); $version->setVersion($this->getVersion()); @@ -2721,14 +2756,14 @@ abstract class Coupon implements ActiveRecordInterface $this->setCode($version->getCode()); $this->setType($version->getType()); $this->setAmount($version->getAmount()); - $this->setIsUsed($version->getIsUsed()); $this->setIsEnabled($version->getIsEnabled()); $this->setExpirationDate($version->getExpirationDate()); - $this->setSerializedRules($version->getSerializedRules()); + $this->setMaxUsage($version->getMaxUsage()); $this->setIsCumulative($version->getIsCumulative()); $this->setIsRemovingPostage($version->getIsRemovingPostage()); - $this->setMaxUsage($version->getMaxUsage()); $this->setIsAvailableOnSpecialOffers($version->getIsAvailableOnSpecialOffers()); + $this->setIsUsed($version->getIsUsed()); + $this->setSerializedConditions($version->getSerializedConditions()); $this->setCreatedAt($version->getCreatedAt()); $this->setUpdatedAt($version->getUpdatedAt()); $this->setVersion($version->getVersion()); diff --git a/core/lib/Thelia/Model/Base/CouponI18n.php b/core/lib/Thelia/Model/Base/CouponI18n.php index 0ea9027b6..7bb7d8314 100644 --- a/core/lib/Thelia/Model/Base/CouponI18n.php +++ b/core/lib/Thelia/Model/Base/CouponI18n.php @@ -152,7 +152,7 @@ abstract class CouponI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -210,8 +210,8 @@ abstract class CouponI18n implements ActiveRecordInterface * obj is an instance of CouponI18n, delegates to * equals(CouponI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -250,8 +250,6 @@ abstract class CouponI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -262,6 +260,7 @@ abstract class CouponI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -272,7 +271,10 @@ abstract class CouponI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -329,7 +331,9 @@ abstract class CouponI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -959,8 +963,7 @@ abstract class CouponI18n implements ActiveRecordInterface $keys[4] => $this->getDescription(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php index b2685ea74..4488e8ec6 100644 --- a/core/lib/Thelia/Model/Base/CouponOrder.php +++ b/core/lib/Thelia/Model/Base/CouponOrder.php @@ -141,7 +141,7 @@ abstract class CouponOrder implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -199,8 +199,8 @@ abstract class CouponOrder implements ActiveRecordInterface * obj is an instance of CouponOrder, delegates to * equals(CouponOrder). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -239,8 +239,6 @@ abstract class CouponOrder implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -251,6 +249,7 @@ abstract class CouponOrder implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -261,7 +260,10 @@ abstract class CouponOrder implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -318,7 +320,9 @@ abstract class CouponOrder implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -402,7 +406,7 @@ abstract class CouponOrder implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -422,7 +426,7 @@ abstract class CouponOrder implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -990,8 +994,7 @@ abstract class CouponOrder implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php index e92380879..d480f06c4 100644 --- a/core/lib/Thelia/Model/Base/CouponQuery.php +++ b/core/lib/Thelia/Model/Base/CouponQuery.php @@ -26,14 +26,14 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery orderByCode($order = Criteria::ASC) Order by the code column * @method ChildCouponQuery orderByType($order = Criteria::ASC) Order by the type column * @method ChildCouponQuery orderByAmount($order = Criteria::ASC) Order by the amount column - * @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column * @method ChildCouponQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column * @method ChildCouponQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column - * @method ChildCouponQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column + * @method ChildCouponQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column * @method ChildCouponQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column * @method ChildCouponQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column - * @method ChildCouponQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column * @method ChildCouponQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column + * @method ChildCouponQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column + * @method ChildCouponQuery orderBySerializedConditions($order = Criteria::ASC) Order by the serialized_conditions column * @method ChildCouponQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildCouponQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -42,14 +42,14 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCouponQuery groupByCode() Group by the code column * @method ChildCouponQuery groupByType() Group by the type column * @method ChildCouponQuery groupByAmount() Group by the amount column - * @method ChildCouponQuery groupByIsUsed() Group by the is_used column * @method ChildCouponQuery groupByIsEnabled() Group by the is_enabled column * @method ChildCouponQuery groupByExpirationDate() Group by the expiration_date column - * @method ChildCouponQuery groupBySerializedRules() Group by the serialized_rules column + * @method ChildCouponQuery groupByMaxUsage() Group by the max_usage column * @method ChildCouponQuery groupByIsCumulative() Group by the is_cumulative column * @method ChildCouponQuery groupByIsRemovingPostage() Group by the is_removing_postage column - * @method ChildCouponQuery groupByMaxUsage() Group by the max_usage column * @method ChildCouponQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column + * @method ChildCouponQuery groupByIsUsed() Group by the is_used column + * @method ChildCouponQuery groupBySerializedConditions() Group by the serialized_conditions column * @method ChildCouponQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponQuery groupByUpdatedAt() Group by the updated_at column * @method ChildCouponQuery groupByVersion() Group by the version column @@ -73,14 +73,14 @@ use Thelia\Model\Map\CouponTableMap; * @method ChildCoupon findOneByCode(string $code) Return the first ChildCoupon filtered by the code column * @method ChildCoupon findOneByType(string $type) Return the first ChildCoupon filtered by the type column * @method ChildCoupon findOneByAmount(double $amount) Return the first ChildCoupon filtered by the amount column - * @method ChildCoupon findOneByIsUsed(int $is_used) Return the first ChildCoupon filtered by the is_used column - * @method ChildCoupon findOneByIsEnabled(int $is_enabled) Return the first ChildCoupon filtered by the is_enabled column + * @method ChildCoupon findOneByIsEnabled(boolean $is_enabled) Return the first ChildCoupon filtered by the is_enabled column * @method ChildCoupon findOneByExpirationDate(string $expiration_date) Return the first ChildCoupon filtered by the expiration_date column - * @method ChildCoupon findOneBySerializedRules(string $serialized_rules) Return the first ChildCoupon filtered by the serialized_rules column - * @method ChildCoupon findOneByIsCumulative(int $is_cumulative) Return the first ChildCoupon filtered by the is_cumulative column - * @method ChildCoupon findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCoupon filtered by the is_removing_postage column * @method ChildCoupon findOneByMaxUsage(int $max_usage) Return the first ChildCoupon filtered by the max_usage column + * @method ChildCoupon findOneByIsCumulative(boolean $is_cumulative) Return the first ChildCoupon filtered by the is_cumulative column + * @method ChildCoupon findOneByIsRemovingPostage(boolean $is_removing_postage) Return the first ChildCoupon filtered by the is_removing_postage column * @method ChildCoupon findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCoupon filtered by the is_available_on_special_offers column + * @method ChildCoupon findOneByIsUsed(boolean $is_used) Return the first ChildCoupon filtered by the is_used column + * @method ChildCoupon findOneBySerializedConditions(string $serialized_conditions) Return the first ChildCoupon filtered by the serialized_conditions column * @method ChildCoupon findOneByCreatedAt(string $created_at) Return the first ChildCoupon filtered by the created_at column * @method ChildCoupon findOneByUpdatedAt(string $updated_at) Return the first ChildCoupon filtered by the updated_at column * @method ChildCoupon findOneByVersion(int $version) Return the first ChildCoupon filtered by the version column @@ -89,14 +89,14 @@ use Thelia\Model\Map\CouponTableMap; * @method array findByCode(string $code) Return ChildCoupon objects filtered by the code column * @method array findByType(string $type) Return ChildCoupon objects filtered by the type column * @method array findByAmount(double $amount) Return ChildCoupon objects filtered by the amount column - * @method array findByIsUsed(int $is_used) Return ChildCoupon objects filtered by the is_used column - * @method array findByIsEnabled(int $is_enabled) Return ChildCoupon objects filtered by the is_enabled column + * @method array findByIsEnabled(boolean $is_enabled) Return ChildCoupon objects filtered by the is_enabled column * @method array findByExpirationDate(string $expiration_date) Return ChildCoupon objects filtered by the expiration_date column - * @method array findBySerializedRules(string $serialized_rules) Return ChildCoupon objects filtered by the serialized_rules column - * @method array findByIsCumulative(int $is_cumulative) Return ChildCoupon objects filtered by the is_cumulative column - * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCoupon objects filtered by the is_removing_postage column * @method array findByMaxUsage(int $max_usage) Return ChildCoupon objects filtered by the max_usage column + * @method array findByIsCumulative(boolean $is_cumulative) Return ChildCoupon objects filtered by the is_cumulative column + * @method array findByIsRemovingPostage(boolean $is_removing_postage) Return ChildCoupon objects filtered by the is_removing_postage column * @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCoupon objects filtered by the is_available_on_special_offers column + * @method array findByIsUsed(boolean $is_used) Return ChildCoupon objects filtered by the is_used column + * @method array findBySerializedConditions(string $serialized_conditions) Return ChildCoupon objects filtered by the serialized_conditions column * @method array findByCreatedAt(string $created_at) Return ChildCoupon objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCoupon objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildCoupon objects filtered by the version column @@ -195,7 +195,7 @@ abstract class CouponQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, TYPE, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, IS_CUMULATIVE, IS_REMOVING_POSTAGE, MAX_USAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, TYPE, AMOUNT, IS_ENABLED, EXPIRATION_DATE, MAX_USAGE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, IS_USED, SERIALIZED_CONDITIONS, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -424,83 +424,28 @@ abstract class CouponQuery extends ModelCriteria return $this->addUsingAlias(CouponTableMap::AMOUNT, $amount, $comparison); } - /** - * Filter the query on the is_used column - * - * Example usage: - * - * $query->filterByIsUsed(1234); // WHERE is_used = 1234 - * $query->filterByIsUsed(array(12, 34)); // WHERE is_used IN (12, 34) - * $query->filterByIsUsed(array('min' => 12)); // WHERE is_used > 12 - * - * - * @param mixed $isUsed 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 ChildCouponQuery The current query, for fluid interface - */ - public function filterByIsUsed($isUsed = null, $comparison = null) - { - if (is_array($isUsed)) { - $useMinMax = false; - if (isset($isUsed['min'])) { - $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isUsed['max'])) { - $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed, $comparison); - } - /** * Filter the query on the is_enabled column * * Example usage: * - * $query->filterByIsEnabled(1234); // WHERE is_enabled = 1234 - * $query->filterByIsEnabled(array(12, 34)); // WHERE is_enabled IN (12, 34) - * $query->filterByIsEnabled(array('min' => 12)); // WHERE is_enabled > 12 + * $query->filterByIsEnabled(true); // WHERE is_enabled = true + * $query->filterByIsEnabled('yes'); // WHERE is_enabled = true * * - * @param mixed $isEnabled 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 boolean|string $isEnabled The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponQuery The current query, for fluid interface */ public function filterByIsEnabled($isEnabled = null, $comparison = null) { - if (is_array($isEnabled)) { - $useMinMax = false; - if (isset($isEnabled['min'])) { - $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isEnabled['max'])) { - $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } + if (is_string($isEnabled)) { + $is_enabled = in_array(strtolower($isEnabled), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(CouponTableMap::IS_ENABLED, $isEnabled, $comparison); @@ -549,117 +494,6 @@ abstract class CouponQuery extends ModelCriteria return $this->addUsingAlias(CouponTableMap::EXPIRATION_DATE, $expirationDate, $comparison); } - /** - * Filter the query on the serialized_rules column - * - * Example usage: - * - * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' - * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' - * - * - * @param string $serializedRules The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCouponQuery The current query, for fluid interface - */ - public function filterBySerializedRules($serializedRules = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($serializedRules)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $serializedRules)) { - $serializedRules = str_replace('*', '%', $serializedRules); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponTableMap::SERIALIZED_RULES, $serializedRules, $comparison); - } - - /** - * Filter the query on the is_cumulative column - * - * Example usage: - * - * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234 - * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34) - * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12 - * - * - * @param mixed $isCumulative 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 ChildCouponQuery The current query, for fluid interface - */ - public function filterByIsCumulative($isCumulative = null, $comparison = null) - { - if (is_array($isCumulative)) { - $useMinMax = false; - if (isset($isCumulative['min'])) { - $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isCumulative['max'])) { - $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative, $comparison); - } - - /** - * Filter the query on the is_removing_postage column - * - * Example usage: - * - * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234 - * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34) - * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12 - * - * - * @param mixed $isRemovingPostage 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 ChildCouponQuery The current query, for fluid interface - */ - public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) - { - if (is_array($isRemovingPostage)) { - $useMinMax = false; - if (isset($isRemovingPostage['min'])) { - $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isRemovingPostage['max'])) { - $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); - } - /** * Filter the query on the max_usage column * @@ -701,6 +535,60 @@ abstract class CouponQuery extends ModelCriteria return $this->addUsingAlias(CouponTableMap::MAX_USAGE, $maxUsage, $comparison); } + /** + * Filter the query on the is_cumulative column + * + * Example usage: + * + * $query->filterByIsCumulative(true); // WHERE is_cumulative = true + * $query->filterByIsCumulative('yes'); // WHERE is_cumulative = true + * + * + * @param boolean|string $isCumulative The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsCumulative($isCumulative = null, $comparison = null) + { + if (is_string($isCumulative)) { + $is_cumulative = in_array(strtolower($isCumulative), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponTableMap::IS_CUMULATIVE, $isCumulative, $comparison); + } + + /** + * Filter the query on the is_removing_postage column + * + * Example usage: + * + * $query->filterByIsRemovingPostage(true); // WHERE is_removing_postage = true + * $query->filterByIsRemovingPostage('yes'); // WHERE is_removing_postage = true + * + * + * @param boolean|string $isRemovingPostage The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) + { + if (is_string($isRemovingPostage)) { + $is_removing_postage = in_array(strtolower($isRemovingPostage), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); + } + /** * Filter the query on the is_available_on_special_offers column * @@ -728,6 +616,62 @@ abstract class CouponQuery extends ModelCriteria return $this->addUsingAlias(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison); } + /** + * Filter the query on the is_used column + * + * Example usage: + * + * $query->filterByIsUsed(true); // WHERE is_used = true + * $query->filterByIsUsed('yes'); // WHERE is_used = true + * + * + * @param boolean|string $isUsed The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterByIsUsed($isUsed = null, $comparison = null) + { + if (is_string($isUsed)) { + $is_used = in_array(strtolower($isUsed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponTableMap::IS_USED, $isUsed, $comparison); + } + + /** + * Filter the query on the serialized_conditions column + * + * Example usage: + * + * $query->filterBySerializedConditions('fooValue'); // WHERE serialized_conditions = 'fooValue' + * $query->filterBySerializedConditions('%fooValue%'); // WHERE serialized_conditions LIKE '%fooValue%' + * + * + * @param string $serializedConditions The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function filterBySerializedConditions($serializedConditions = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($serializedConditions)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedConditions)) { + $serializedConditions = str_replace('*', '%', $serializedConditions); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponTableMap::SERIALIZED_CONDITIONS, $serializedConditions, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/CouponVersion.php b/core/lib/Thelia/Model/Base/CouponVersion.php index efa4898f4..67c077cfa 100644 --- a/core/lib/Thelia/Model/Base/CouponVersion.php +++ b/core/lib/Thelia/Model/Base/CouponVersion.php @@ -79,15 +79,9 @@ abstract class CouponVersion implements ActiveRecordInterface */ protected $amount; - /** - * The value for the is_used field. - * @var int - */ - protected $is_used; - /** * The value for the is_enabled field. - * @var int + * @var boolean */ protected $is_enabled; @@ -97,36 +91,42 @@ abstract class CouponVersion implements ActiveRecordInterface */ protected $expiration_date; - /** - * The value for the serialized_rules field. - * @var string - */ - protected $serialized_rules; - - /** - * The value for the is_cumulative field. - * @var int - */ - protected $is_cumulative; - - /** - * The value for the is_removing_postage field. - * @var int - */ - protected $is_removing_postage; - /** * The value for the max_usage field. * @var int */ protected $max_usage; + /** + * The value for the is_cumulative field. + * @var boolean + */ + protected $is_cumulative; + + /** + * The value for the is_removing_postage field. + * @var boolean + */ + protected $is_removing_postage; + /** * The value for the is_available_on_special_offers field. * @var boolean */ protected $is_available_on_special_offers; + /** + * The value for the is_used field. + * @var boolean + */ + protected $is_used; + + /** + * The value for the serialized_conditions field. + * @var string + */ + protected $serialized_conditions; + /** * The value for the created_at field. * @var string @@ -214,7 +214,7 @@ abstract class CouponVersion implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -272,8 +272,8 @@ abstract class CouponVersion implements ActiveRecordInterface * obj is an instance of CouponVersion, delegates to * equals(CouponVersion). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -312,8 +312,6 @@ abstract class CouponVersion implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -324,6 +322,7 @@ abstract class CouponVersion implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -334,7 +333,10 @@ abstract class CouponVersion implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -391,7 +393,9 @@ abstract class CouponVersion implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -470,21 +474,10 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->amount; } - /** - * Get the [is_used] column value. - * - * @return int - */ - public function getIsUsed() - { - - return $this->is_used; - } - /** * Get the [is_enabled] column value. * - * @return int + * @return boolean */ public function getIsEnabled() { @@ -508,43 +501,10 @@ abstract class CouponVersion implements ActiveRecordInterface if ($format === null) { return $this->expiration_date; } else { - return $this->expiration_date !== null ? $this->expiration_date->format($format) : null; + return $this->expiration_date instanceof \DateTime ? $this->expiration_date->format($format) : null; } } - /** - * Get the [serialized_rules] column value. - * - * @return string - */ - public function getSerializedRules() - { - - return $this->serialized_rules; - } - - /** - * Get the [is_cumulative] column value. - * - * @return int - */ - public function getIsCumulative() - { - - return $this->is_cumulative; - } - - /** - * Get the [is_removing_postage] column value. - * - * @return int - */ - public function getIsRemovingPostage() - { - - return $this->is_removing_postage; - } - /** * Get the [max_usage] column value. * @@ -556,6 +516,28 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->max_usage; } + /** + * Get the [is_cumulative] column value. + * + * @return boolean + */ + public function getIsCumulative() + { + + return $this->is_cumulative; + } + + /** + * Get the [is_removing_postage] column value. + * + * @return boolean + */ + public function getIsRemovingPostage() + { + + return $this->is_removing_postage; + } + /** * Get the [is_available_on_special_offers] column value. * @@ -567,6 +549,28 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->is_available_on_special_offers; } + /** + * Get the [is_used] column value. + * + * @return boolean + */ + public function getIsUsed() + { + + return $this->is_used; + } + + /** + * Get the [serialized_conditions] column value. + * + * @return string + */ + public function getSerializedConditions() + { + + return $this->serialized_conditions; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -583,7 +587,7 @@ abstract class CouponVersion implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -603,7 +607,7 @@ abstract class CouponVersion implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -707,36 +711,23 @@ abstract class CouponVersion implements ActiveRecordInterface } // setAmount() /** - * Set the value of [is_used] column. + * Sets the value of the [is_enabled] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). * - * @param int $v new value - * @return \Thelia\Model\CouponVersion The current object (for fluent API support) - */ - public function setIsUsed($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->is_used !== $v) { - $this->is_used = $v; - $this->modifiedColumns[] = CouponVersionTableMap::IS_USED; - } - - - return $this; - } // setIsUsed() - - /** - * Set the value of [is_enabled] column. - * - * @param int $v new value + * @param boolean|integer|string $v The new value * @return \Thelia\Model\CouponVersion The current object (for fluent API support) */ public function setIsEnabled($v) { if ($v !== null) { - $v = (int) $v; + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } } if ($this->is_enabled !== $v) { @@ -769,69 +760,6 @@ abstract class CouponVersion implements ActiveRecordInterface return $this; } // setExpirationDate() - /** - * Set the value of [serialized_rules] column. - * - * @param string $v new value - * @return \Thelia\Model\CouponVersion The current object (for fluent API support) - */ - public function setSerializedRules($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->serialized_rules !== $v) { - $this->serialized_rules = $v; - $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_RULES; - } - - - return $this; - } // setSerializedRules() - - /** - * Set the value of [is_cumulative] column. - * - * @param int $v new value - * @return \Thelia\Model\CouponVersion The current object (for fluent API support) - */ - public function setIsCumulative($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->is_cumulative !== $v) { - $this->is_cumulative = $v; - $this->modifiedColumns[] = CouponVersionTableMap::IS_CUMULATIVE; - } - - - return $this; - } // setIsCumulative() - - /** - * Set the value of [is_removing_postage] column. - * - * @param int $v new value - * @return \Thelia\Model\CouponVersion The current object (for fluent API support) - */ - public function setIsRemovingPostage($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->is_removing_postage !== $v) { - $this->is_removing_postage = $v; - $this->modifiedColumns[] = CouponVersionTableMap::IS_REMOVING_POSTAGE; - } - - - return $this; - } // setIsRemovingPostage() - /** * Set the value of [max_usage] column. * @@ -853,6 +781,64 @@ abstract class CouponVersion implements ActiveRecordInterface return $this; } // setMaxUsage() + /** + * Sets the value of the [is_cumulative] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsCumulative($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_cumulative !== $v) { + $this->is_cumulative = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_CUMULATIVE; + } + + + return $this; + } // setIsCumulative() + + /** + * Sets the value of the [is_removing_postage] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsRemovingPostage($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_removing_postage !== $v) { + $this->is_removing_postage = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_REMOVING_POSTAGE; + } + + + return $this; + } // setIsRemovingPostage() + /** * Sets the value of the [is_available_on_special_offers] column. * Non-boolean arguments are converted using the following rules: @@ -882,6 +868,56 @@ abstract class CouponVersion implements ActiveRecordInterface return $this; } // setIsAvailableOnSpecialOffers() + /** + * Sets the value of the [is_used] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setIsUsed($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_used !== $v) { + $this->is_used = $v; + $this->modifiedColumns[] = CouponVersionTableMap::IS_USED; + } + + + return $this; + } // setIsUsed() + + /** + * Set the value of [serialized_conditions] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponVersion The current object (for fluent API support) + */ + public function setSerializedConditions($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->serialized_conditions !== $v) { + $this->serialized_conditions = $v; + $this->modifiedColumns[] = CouponVersionTableMap::SERIALIZED_CONDITIONS; + } + + + return $this; + } // setSerializedConditions() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -998,33 +1034,33 @@ abstract class CouponVersion implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponVersionTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; $this->amount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponVersionTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_used = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponVersionTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_enabled = (null !== $col) ? (boolean) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponVersionTableMap::translateFieldName('IsEnabled', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_enabled = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponVersionTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponVersionTableMap::translateFieldName('SerializedRules', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_rules = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_cumulative = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_removing_postage = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponVersionTableMap::translateFieldName('MaxUsage', TableMap::TYPE_PHPNAME, $indexType)]; $this->max_usage = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponVersionTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_cumulative = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponVersionTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_removing_postage = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponVersionTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CouponVersionTableMap::translateFieldName('IsUsed', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_used = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CouponVersionTableMap::translateFieldName('SerializedConditions', TableMap::TYPE_PHPNAME, $indexType)]; + $this->serialized_conditions = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CouponVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; @@ -1280,17 +1316,14 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) { $modifiedColumns[':p' . $index++] = 'AMOUNT'; } - if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) { - $modifiedColumns[':p' . $index++] = 'IS_USED'; - } if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) { $modifiedColumns[':p' . $index++] = 'IS_ENABLED'; } if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) { $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; } - if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_RULES'; + if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) { + $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; } if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) { $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; @@ -1298,12 +1331,15 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) { $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; } - if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) { - $modifiedColumns[':p' . $index++] = 'MAX_USAGE'; - } if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) { $modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS'; } + if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) { + $modifiedColumns[':p' . $index++] = 'IS_USED'; + } + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) { + $modifiedColumns[':p' . $index++] = 'SERIALIZED_CONDITIONS'; + } if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1336,30 +1372,30 @@ abstract class CouponVersion implements ActiveRecordInterface case 'AMOUNT': $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); break; - case 'IS_USED': - $stmt->bindValue($identifier, $this->is_used, PDO::PARAM_INT); - break; case 'IS_ENABLED': - $stmt->bindValue($identifier, $this->is_enabled, PDO::PARAM_INT); + $stmt->bindValue($identifier, (int) $this->is_enabled, PDO::PARAM_INT); break; case 'EXPIRATION_DATE': $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case 'SERIALIZED_RULES': - $stmt->bindValue($identifier, $this->serialized_rules, PDO::PARAM_STR); - break; - case 'IS_CUMULATIVE': - $stmt->bindValue($identifier, $this->is_cumulative, PDO::PARAM_INT); - break; - case 'IS_REMOVING_POSTAGE': - $stmt->bindValue($identifier, $this->is_removing_postage, PDO::PARAM_INT); - break; case 'MAX_USAGE': $stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT); break; + case 'IS_CUMULATIVE': + $stmt->bindValue($identifier, (int) $this->is_cumulative, PDO::PARAM_INT); + break; + case 'IS_REMOVING_POSTAGE': + $stmt->bindValue($identifier, (int) $this->is_removing_postage, PDO::PARAM_INT); + break; case 'IS_AVAILABLE_ON_SPECIAL_OFFERS': $stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT); break; + case 'IS_USED': + $stmt->bindValue($identifier, (int) $this->is_used, PDO::PARAM_INT); + break; + case 'SERIALIZED_CONDITIONS': + $stmt->bindValue($identifier, $this->serialized_conditions, PDO::PARAM_STR); + 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; @@ -1437,29 +1473,29 @@ abstract class CouponVersion implements ActiveRecordInterface return $this->getAmount(); break; case 4: - return $this->getIsUsed(); - break; - case 5: return $this->getIsEnabled(); break; - case 6: + case 5: return $this->getExpirationDate(); break; - case 7: - return $this->getSerializedRules(); - break; - case 8: - return $this->getIsCumulative(); - break; - case 9: - return $this->getIsRemovingPostage(); - break; - case 10: + case 6: return $this->getMaxUsage(); break; - case 11: + case 7: + return $this->getIsCumulative(); + break; + case 8: + return $this->getIsRemovingPostage(); + break; + case 9: return $this->getIsAvailableOnSpecialOffers(); break; + case 10: + return $this->getIsUsed(); + break; + case 11: + return $this->getSerializedConditions(); + break; case 12: return $this->getCreatedAt(); break; @@ -1502,21 +1538,20 @@ abstract class CouponVersion implements ActiveRecordInterface $keys[1] => $this->getCode(), $keys[2] => $this->getType(), $keys[3] => $this->getAmount(), - $keys[4] => $this->getIsUsed(), - $keys[5] => $this->getIsEnabled(), - $keys[6] => $this->getExpirationDate(), - $keys[7] => $this->getSerializedRules(), - $keys[8] => $this->getIsCumulative(), - $keys[9] => $this->getIsRemovingPostage(), - $keys[10] => $this->getMaxUsage(), - $keys[11] => $this->getIsAvailableOnSpecialOffers(), + $keys[4] => $this->getIsEnabled(), + $keys[5] => $this->getExpirationDate(), + $keys[6] => $this->getMaxUsage(), + $keys[7] => $this->getIsCumulative(), + $keys[8] => $this->getIsRemovingPostage(), + $keys[9] => $this->getIsAvailableOnSpecialOffers(), + $keys[10] => $this->getIsUsed(), + $keys[11] => $this->getSerializedConditions(), $keys[12] => $this->getCreatedAt(), $keys[13] => $this->getUpdatedAt(), $keys[14] => $this->getVersion(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } @@ -1571,29 +1606,29 @@ abstract class CouponVersion implements ActiveRecordInterface $this->setAmount($value); break; case 4: - $this->setIsUsed($value); - break; - case 5: $this->setIsEnabled($value); break; - case 6: + case 5: $this->setExpirationDate($value); break; - case 7: - $this->setSerializedRules($value); - break; - case 8: - $this->setIsCumulative($value); - break; - case 9: - $this->setIsRemovingPostage($value); - break; - case 10: + case 6: $this->setMaxUsage($value); break; - case 11: + case 7: + $this->setIsCumulative($value); + break; + case 8: + $this->setIsRemovingPostage($value); + break; + case 9: $this->setIsAvailableOnSpecialOffers($value); break; + case 10: + $this->setIsUsed($value); + break; + case 11: + $this->setSerializedConditions($value); + break; case 12: $this->setCreatedAt($value); break; @@ -1631,14 +1666,14 @@ abstract class CouponVersion implements ActiveRecordInterface if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setAmount($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setIsUsed($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setIsEnabled($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setExpirationDate($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setSerializedRules($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setIsCumulative($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setIsRemovingPostage($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setMaxUsage($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[11]]); + if (array_key_exists($keys[4], $arr)) $this->setIsEnabled($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setExpirationDate($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setMaxUsage($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setIsCumulative($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setIsRemovingPostage($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setIsUsed($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setSerializedConditions($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]); if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]); @@ -1657,14 +1692,14 @@ abstract class CouponVersion implements ActiveRecordInterface if ($this->isColumnModified(CouponVersionTableMap::CODE)) $criteria->add(CouponVersionTableMap::CODE, $this->code); if ($this->isColumnModified(CouponVersionTableMap::TYPE)) $criteria->add(CouponVersionTableMap::TYPE, $this->type); if ($this->isColumnModified(CouponVersionTableMap::AMOUNT)) $criteria->add(CouponVersionTableMap::AMOUNT, $this->amount); - if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used); if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) $criteria->add(CouponVersionTableMap::IS_ENABLED, $this->is_enabled); if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) $criteria->add(CouponVersionTableMap::EXPIRATION_DATE, $this->expiration_date); - if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_RULES)) $criteria->add(CouponVersionTableMap::SERIALIZED_RULES, $this->serialized_rules); + if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) $criteria->add(CouponVersionTableMap::MAX_USAGE, $this->max_usage); if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) $criteria->add(CouponVersionTableMap::IS_CUMULATIVE, $this->is_cumulative); if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) $criteria->add(CouponVersionTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); - if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) $criteria->add(CouponVersionTableMap::MAX_USAGE, $this->max_usage); if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers); + if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) $criteria->add(CouponVersionTableMap::IS_USED, $this->is_used); + if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) $criteria->add(CouponVersionTableMap::SERIALIZED_CONDITIONS, $this->serialized_conditions); if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) $criteria->add(CouponVersionTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) $criteria->add(CouponVersionTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(CouponVersionTableMap::VERSION)) $criteria->add(CouponVersionTableMap::VERSION, $this->version); @@ -1742,14 +1777,14 @@ abstract class CouponVersion implements ActiveRecordInterface $copyObj->setCode($this->getCode()); $copyObj->setType($this->getType()); $copyObj->setAmount($this->getAmount()); - $copyObj->setIsUsed($this->getIsUsed()); $copyObj->setIsEnabled($this->getIsEnabled()); $copyObj->setExpirationDate($this->getExpirationDate()); - $copyObj->setSerializedRules($this->getSerializedRules()); + $copyObj->setMaxUsage($this->getMaxUsage()); $copyObj->setIsCumulative($this->getIsCumulative()); $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); - $copyObj->setMaxUsage($this->getMaxUsage()); $copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); + $copyObj->setIsUsed($this->getIsUsed()); + $copyObj->setSerializedConditions($this->getSerializedConditions()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setVersion($this->getVersion()); @@ -1840,14 +1875,14 @@ abstract class CouponVersion implements ActiveRecordInterface $this->code = null; $this->type = null; $this->amount = null; - $this->is_used = null; $this->is_enabled = null; $this->expiration_date = null; - $this->serialized_rules = null; + $this->max_usage = null; $this->is_cumulative = null; $this->is_removing_postage = null; - $this->max_usage = null; $this->is_available_on_special_offers = null; + $this->is_used = null; + $this->serialized_conditions = null; $this->created_at = null; $this->updated_at = null; $this->version = null; diff --git a/core/lib/Thelia/Model/Base/CouponVersionQuery.php b/core/lib/Thelia/Model/Base/CouponVersionQuery.php index ed7e587e7..eebd85dd9 100644 --- a/core/lib/Thelia/Model/Base/CouponVersionQuery.php +++ b/core/lib/Thelia/Model/Base/CouponVersionQuery.php @@ -25,14 +25,14 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersionQuery orderByCode($order = Criteria::ASC) Order by the code column * @method ChildCouponVersionQuery orderByType($order = Criteria::ASC) Order by the type column * @method ChildCouponVersionQuery orderByAmount($order = Criteria::ASC) Order by the amount column - * @method ChildCouponVersionQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column * @method ChildCouponVersionQuery orderByIsEnabled($order = Criteria::ASC) Order by the is_enabled column * @method ChildCouponVersionQuery orderByExpirationDate($order = Criteria::ASC) Order by the expiration_date column - * @method ChildCouponVersionQuery orderBySerializedRules($order = Criteria::ASC) Order by the serialized_rules column + * @method ChildCouponVersionQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column * @method ChildCouponVersionQuery orderByIsCumulative($order = Criteria::ASC) Order by the is_cumulative column * @method ChildCouponVersionQuery orderByIsRemovingPostage($order = Criteria::ASC) Order by the is_removing_postage column - * @method ChildCouponVersionQuery orderByMaxUsage($order = Criteria::ASC) Order by the max_usage column * @method ChildCouponVersionQuery orderByIsAvailableOnSpecialOffers($order = Criteria::ASC) Order by the is_available_on_special_offers column + * @method ChildCouponVersionQuery orderByIsUsed($order = Criteria::ASC) Order by the is_used column + * @method ChildCouponVersionQuery orderBySerializedConditions($order = Criteria::ASC) Order by the serialized_conditions column * @method ChildCouponVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCouponVersionQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildCouponVersionQuery orderByVersion($order = Criteria::ASC) Order by the version column @@ -41,14 +41,14 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersionQuery groupByCode() Group by the code column * @method ChildCouponVersionQuery groupByType() Group by the type column * @method ChildCouponVersionQuery groupByAmount() Group by the amount column - * @method ChildCouponVersionQuery groupByIsUsed() Group by the is_used column * @method ChildCouponVersionQuery groupByIsEnabled() Group by the is_enabled column * @method ChildCouponVersionQuery groupByExpirationDate() Group by the expiration_date column - * @method ChildCouponVersionQuery groupBySerializedRules() Group by the serialized_rules column + * @method ChildCouponVersionQuery groupByMaxUsage() Group by the max_usage column * @method ChildCouponVersionQuery groupByIsCumulative() Group by the is_cumulative column * @method ChildCouponVersionQuery groupByIsRemovingPostage() Group by the is_removing_postage column - * @method ChildCouponVersionQuery groupByMaxUsage() Group by the max_usage column * @method ChildCouponVersionQuery groupByIsAvailableOnSpecialOffers() Group by the is_available_on_special_offers column + * @method ChildCouponVersionQuery groupByIsUsed() Group by the is_used column + * @method ChildCouponVersionQuery groupBySerializedConditions() Group by the serialized_conditions column * @method ChildCouponVersionQuery groupByCreatedAt() Group by the created_at column * @method ChildCouponVersionQuery groupByUpdatedAt() Group by the updated_at column * @method ChildCouponVersionQuery groupByVersion() Group by the version column @@ -68,14 +68,14 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method ChildCouponVersion findOneByCode(string $code) Return the first ChildCouponVersion filtered by the code column * @method ChildCouponVersion findOneByType(string $type) Return the first ChildCouponVersion filtered by the type column * @method ChildCouponVersion findOneByAmount(double $amount) Return the first ChildCouponVersion filtered by the amount column - * @method ChildCouponVersion findOneByIsUsed(int $is_used) Return the first ChildCouponVersion filtered by the is_used column - * @method ChildCouponVersion findOneByIsEnabled(int $is_enabled) Return the first ChildCouponVersion filtered by the is_enabled column + * @method ChildCouponVersion findOneByIsEnabled(boolean $is_enabled) Return the first ChildCouponVersion filtered by the is_enabled column * @method ChildCouponVersion findOneByExpirationDate(string $expiration_date) Return the first ChildCouponVersion filtered by the expiration_date column - * @method ChildCouponVersion findOneBySerializedRules(string $serialized_rules) Return the first ChildCouponVersion filtered by the serialized_rules column - * @method ChildCouponVersion findOneByIsCumulative(int $is_cumulative) Return the first ChildCouponVersion filtered by the is_cumulative column - * @method ChildCouponVersion findOneByIsRemovingPostage(int $is_removing_postage) Return the first ChildCouponVersion filtered by the is_removing_postage column * @method ChildCouponVersion findOneByMaxUsage(int $max_usage) Return the first ChildCouponVersion filtered by the max_usage column + * @method ChildCouponVersion findOneByIsCumulative(boolean $is_cumulative) Return the first ChildCouponVersion filtered by the is_cumulative column + * @method ChildCouponVersion findOneByIsRemovingPostage(boolean $is_removing_postage) Return the first ChildCouponVersion filtered by the is_removing_postage column * @method ChildCouponVersion findOneByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return the first ChildCouponVersion filtered by the is_available_on_special_offers column + * @method ChildCouponVersion findOneByIsUsed(boolean $is_used) Return the first ChildCouponVersion filtered by the is_used column + * @method ChildCouponVersion findOneBySerializedConditions(string $serialized_conditions) Return the first ChildCouponVersion filtered by the serialized_conditions column * @method ChildCouponVersion findOneByCreatedAt(string $created_at) Return the first ChildCouponVersion filtered by the created_at column * @method ChildCouponVersion findOneByUpdatedAt(string $updated_at) Return the first ChildCouponVersion filtered by the updated_at column * @method ChildCouponVersion findOneByVersion(int $version) Return the first ChildCouponVersion filtered by the version column @@ -84,14 +84,14 @@ use Thelia\Model\Map\CouponVersionTableMap; * @method array findByCode(string $code) Return ChildCouponVersion objects filtered by the code column * @method array findByType(string $type) Return ChildCouponVersion objects filtered by the type column * @method array findByAmount(double $amount) Return ChildCouponVersion objects filtered by the amount column - * @method array findByIsUsed(int $is_used) Return ChildCouponVersion objects filtered by the is_used column - * @method array findByIsEnabled(int $is_enabled) Return ChildCouponVersion objects filtered by the is_enabled column + * @method array findByIsEnabled(boolean $is_enabled) Return ChildCouponVersion objects filtered by the is_enabled column * @method array findByExpirationDate(string $expiration_date) Return ChildCouponVersion objects filtered by the expiration_date column - * @method array findBySerializedRules(string $serialized_rules) Return ChildCouponVersion objects filtered by the serialized_rules column - * @method array findByIsCumulative(int $is_cumulative) Return ChildCouponVersion objects filtered by the is_cumulative column - * @method array findByIsRemovingPostage(int $is_removing_postage) Return ChildCouponVersion objects filtered by the is_removing_postage column * @method array findByMaxUsage(int $max_usage) Return ChildCouponVersion objects filtered by the max_usage column + * @method array findByIsCumulative(boolean $is_cumulative) Return ChildCouponVersion objects filtered by the is_cumulative column + * @method array findByIsRemovingPostage(boolean $is_removing_postage) Return ChildCouponVersion objects filtered by the is_removing_postage column * @method array findByIsAvailableOnSpecialOffers(boolean $is_available_on_special_offers) Return ChildCouponVersion objects filtered by the is_available_on_special_offers column + * @method array findByIsUsed(boolean $is_used) Return ChildCouponVersion objects filtered by the is_used column + * @method array findBySerializedConditions(string $serialized_conditions) Return ChildCouponVersion objects filtered by the serialized_conditions column * @method array findByCreatedAt(string $created_at) Return ChildCouponVersion objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCouponVersion objects filtered by the updated_at column * @method array findByVersion(int $version) Return ChildCouponVersion objects filtered by the version column @@ -183,7 +183,7 @@ abstract class CouponVersionQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CODE, TYPE, AMOUNT, IS_USED, IS_ENABLED, EXPIRATION_DATE, SERIALIZED_RULES, IS_CUMULATIVE, IS_REMOVING_POSTAGE, MAX_USAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; + $sql = 'SELECT ID, CODE, TYPE, AMOUNT, IS_ENABLED, EXPIRATION_DATE, MAX_USAGE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, IS_USED, SERIALIZED_CONDITIONS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -426,83 +426,28 @@ abstract class CouponVersionQuery extends ModelCriteria return $this->addUsingAlias(CouponVersionTableMap::AMOUNT, $amount, $comparison); } - /** - * Filter the query on the is_used column - * - * Example usage: - * - * $query->filterByIsUsed(1234); // WHERE is_used = 1234 - * $query->filterByIsUsed(array(12, 34)); // WHERE is_used IN (12, 34) - * $query->filterByIsUsed(array('min' => 12)); // WHERE is_used > 12 - * - * - * @param mixed $isUsed 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 ChildCouponVersionQuery The current query, for fluid interface - */ - public function filterByIsUsed($isUsed = null, $comparison = null) - { - if (is_array($isUsed)) { - $useMinMax = false; - if (isset($isUsed['min'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isUsed['max'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed, $comparison); - } - /** * Filter the query on the is_enabled column * * Example usage: * - * $query->filterByIsEnabled(1234); // WHERE is_enabled = 1234 - * $query->filterByIsEnabled(array(12, 34)); // WHERE is_enabled IN (12, 34) - * $query->filterByIsEnabled(array('min' => 12)); // WHERE is_enabled > 12 + * $query->filterByIsEnabled(true); // WHERE is_enabled = true + * $query->filterByIsEnabled('yes'); // WHERE is_enabled = true * * - * @param mixed $isEnabled 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 boolean|string $isEnabled The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCouponVersionQuery The current query, for fluid interface */ public function filterByIsEnabled($isEnabled = null, $comparison = null) { - if (is_array($isEnabled)) { - $useMinMax = false; - if (isset($isEnabled['min'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isEnabled['max'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } + if (is_string($isEnabled)) { + $is_enabled = in_array(strtolower($isEnabled), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(CouponVersionTableMap::IS_ENABLED, $isEnabled, $comparison); @@ -551,117 +496,6 @@ abstract class CouponVersionQuery extends ModelCriteria return $this->addUsingAlias(CouponVersionTableMap::EXPIRATION_DATE, $expirationDate, $comparison); } - /** - * Filter the query on the serialized_rules column - * - * Example usage: - * - * $query->filterBySerializedRules('fooValue'); // WHERE serialized_rules = 'fooValue' - * $query->filterBySerializedRules('%fooValue%'); // WHERE serialized_rules LIKE '%fooValue%' - * - * - * @param string $serializedRules The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCouponVersionQuery The current query, for fluid interface - */ - public function filterBySerializedRules($serializedRules = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($serializedRules)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $serializedRules)) { - $serializedRules = str_replace('*', '%', $serializedRules); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_RULES, $serializedRules, $comparison); - } - - /** - * Filter the query on the is_cumulative column - * - * Example usage: - * - * $query->filterByIsCumulative(1234); // WHERE is_cumulative = 1234 - * $query->filterByIsCumulative(array(12, 34)); // WHERE is_cumulative IN (12, 34) - * $query->filterByIsCumulative(array('min' => 12)); // WHERE is_cumulative > 12 - * - * - * @param mixed $isCumulative 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 ChildCouponVersionQuery The current query, for fluid interface - */ - public function filterByIsCumulative($isCumulative = null, $comparison = null) - { - if (is_array($isCumulative)) { - $useMinMax = false; - if (isset($isCumulative['min'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isCumulative['max'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative, $comparison); - } - - /** - * Filter the query on the is_removing_postage column - * - * Example usage: - * - * $query->filterByIsRemovingPostage(1234); // WHERE is_removing_postage = 1234 - * $query->filterByIsRemovingPostage(array(12, 34)); // WHERE is_removing_postage IN (12, 34) - * $query->filterByIsRemovingPostage(array('min' => 12)); // WHERE is_removing_postage > 12 - * - * - * @param mixed $isRemovingPostage 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 ChildCouponVersionQuery The current query, for fluid interface - */ - public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) - { - if (is_array($isRemovingPostage)) { - $useMinMax = false; - if (isset($isRemovingPostage['min'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($isRemovingPostage['max'])) { - $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); - } - /** * Filter the query on the max_usage column * @@ -703,6 +537,60 @@ abstract class CouponVersionQuery extends ModelCriteria return $this->addUsingAlias(CouponVersionTableMap::MAX_USAGE, $maxUsage, $comparison); } + /** + * Filter the query on the is_cumulative column + * + * Example usage: + * + * $query->filterByIsCumulative(true); // WHERE is_cumulative = true + * $query->filterByIsCumulative('yes'); // WHERE is_cumulative = true + * + * + * @param boolean|string $isCumulative The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsCumulative($isCumulative = null, $comparison = null) + { + if (is_string($isCumulative)) { + $is_cumulative = in_array(strtolower($isCumulative), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_CUMULATIVE, $isCumulative, $comparison); + } + + /** + * Filter the query on the is_removing_postage column + * + * Example usage: + * + * $query->filterByIsRemovingPostage(true); // WHERE is_removing_postage = true + * $query->filterByIsRemovingPostage('yes'); // WHERE is_removing_postage = true + * + * + * @param boolean|string $isRemovingPostage The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsRemovingPostage($isRemovingPostage = null, $comparison = null) + { + if (is_string($isRemovingPostage)) { + $is_removing_postage = in_array(strtolower($isRemovingPostage), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_REMOVING_POSTAGE, $isRemovingPostage, $comparison); + } + /** * Filter the query on the is_available_on_special_offers column * @@ -730,6 +618,62 @@ abstract class CouponVersionQuery extends ModelCriteria return $this->addUsingAlias(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $isAvailableOnSpecialOffers, $comparison); } + /** + * Filter the query on the is_used column + * + * Example usage: + * + * $query->filterByIsUsed(true); // WHERE is_used = true + * $query->filterByIsUsed('yes'); // WHERE is_used = true + * + * + * @param boolean|string $isUsed The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterByIsUsed($isUsed = null, $comparison = null) + { + if (is_string($isUsed)) { + $is_used = in_array(strtolower($isUsed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(CouponVersionTableMap::IS_USED, $isUsed, $comparison); + } + + /** + * Filter the query on the serialized_conditions column + * + * Example usage: + * + * $query->filterBySerializedConditions('fooValue'); // WHERE serialized_conditions = 'fooValue' + * $query->filterBySerializedConditions('%fooValue%'); // WHERE serialized_conditions LIKE '%fooValue%' + * + * + * @param string $serializedConditions The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponVersionQuery The current query, for fluid interface + */ + public function filterBySerializedConditions($serializedConditions = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($serializedConditions)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $serializedConditions)) { + $serializedConditions = str_replace('*', '%', $serializedConditions); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CouponVersionTableMap::SERIALIZED_CONDITIONS, $serializedConditions, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php index e46176739..fea63f546 100644 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -223,7 +223,7 @@ abstract class Currency implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -281,8 +281,8 @@ abstract class Currency implements ActiveRecordInterface * obj is an instance of Currency, delegates to * equals(Currency). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -321,8 +321,6 @@ abstract class Currency implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -333,6 +331,7 @@ abstract class Currency implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -343,7 +342,10 @@ abstract class Currency implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -400,7 +402,9 @@ abstract class Currency implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -517,7 +521,7 @@ abstract class Currency implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -537,7 +541,7 @@ abstract class Currency implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1264,8 +1268,7 @@ abstract class Currency implements ActiveRecordInterface $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CurrencyI18n.php b/core/lib/Thelia/Model/Base/CurrencyI18n.php index df5ff7240..c3e6af289 100644 --- a/core/lib/Thelia/Model/Base/CurrencyI18n.php +++ b/core/lib/Thelia/Model/Base/CurrencyI18n.php @@ -140,7 +140,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -198,8 +198,8 @@ abstract class CurrencyI18n implements ActiveRecordInterface * obj is an instance of CurrencyI18n, delegates to * equals(CurrencyI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -238,8 +238,6 @@ abstract class CurrencyI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -250,6 +248,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -260,7 +259,10 @@ abstract class CurrencyI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -317,7 +319,9 @@ abstract class CurrencyI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -857,8 +861,7 @@ abstract class CurrencyI18n implements ActiveRecordInterface $keys[2] => $this->getName(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index e7bd688af..8ec119627 100644 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -250,7 +250,7 @@ abstract class Customer implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -308,8 +308,8 @@ abstract class Customer implements ActiveRecordInterface * obj is an instance of Customer, delegates to * equals(Customer). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -348,8 +348,6 @@ abstract class Customer implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -360,6 +358,7 @@ abstract class Customer implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -370,7 +369,10 @@ abstract class Customer implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -427,7 +429,9 @@ abstract class Customer implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -632,7 +636,7 @@ abstract class Customer implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -652,7 +656,7 @@ abstract class Customer implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1652,8 +1656,7 @@ abstract class Customer implements ActiveRecordInterface $keys[15] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index 6b1295d2b..978b779b1 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -205,7 +205,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -263,8 +263,8 @@ abstract class CustomerTitle implements ActiveRecordInterface * obj is an instance of CustomerTitle, delegates to * equals(CustomerTitle). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -303,8 +303,6 @@ abstract class CustomerTitle implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -315,6 +313,7 @@ abstract class CustomerTitle implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -325,7 +324,10 @@ abstract class CustomerTitle implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -382,7 +384,9 @@ abstract class CustomerTitle implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -466,7 +470,7 @@ abstract class CustomerTitle implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -486,7 +490,7 @@ abstract class CustomerTitle implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1095,8 +1099,7 @@ abstract class CustomerTitle implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php index b384210b1..5c173543b 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php @@ -146,7 +146,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -204,8 +204,8 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface * obj is an instance of CustomerTitleI18n, delegates to * equals(CustomerTitleI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -244,8 +244,6 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -256,6 +254,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -266,7 +265,10 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -323,7 +325,9 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -908,8 +912,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface $keys[3] => $this->getLong(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php index c9b6c5ed4..7d3a0e7f3 100644 --- a/core/lib/Thelia/Model/Base/Feature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -232,7 +232,7 @@ abstract class Feature implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -290,8 +290,8 @@ abstract class Feature implements ActiveRecordInterface * obj is an instance of Feature, delegates to * equals(Feature). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -330,8 +330,6 @@ abstract class Feature implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -342,6 +340,7 @@ abstract class Feature implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -352,7 +351,10 @@ abstract class Feature implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -409,7 +411,9 @@ abstract class Feature implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -493,7 +497,7 @@ abstract class Feature implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -513,7 +517,7 @@ abstract class Feature implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1169,8 +1173,7 @@ abstract class Feature implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php index bf1bfc41e..7f5191418 100644 --- a/core/lib/Thelia/Model/Base/FeatureAv.php +++ b/core/lib/Thelia/Model/Base/FeatureAv.php @@ -184,7 +184,7 @@ abstract class FeatureAv implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -242,8 +242,8 @@ abstract class FeatureAv implements ActiveRecordInterface * obj is an instance of FeatureAv, delegates to * equals(FeatureAv). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -282,8 +282,6 @@ abstract class FeatureAv implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -294,6 +292,7 @@ abstract class FeatureAv implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -304,7 +303,10 @@ abstract class FeatureAv implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -361,7 +363,9 @@ abstract class FeatureAv implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -445,7 +449,7 @@ abstract class FeatureAv implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -465,7 +469,7 @@ abstract class FeatureAv implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1071,8 +1075,7 @@ abstract class FeatureAv implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php index 44e7893a2..e88356a16 100644 --- a/core/lib/Thelia/Model/Base/FeatureAvI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureAvI18n.php @@ -158,7 +158,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class FeatureAvI18n implements ActiveRecordInterface * obj is an instance of FeatureAvI18n, delegates to * equals(FeatureAvI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class FeatureAvI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class FeatureAvI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class FeatureAvI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php index 57c7a0b30..ed475e87f 100644 --- a/core/lib/Thelia/Model/Base/FeatureI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureI18n.php @@ -158,7 +158,7 @@ abstract class FeatureI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class FeatureI18n implements ActiveRecordInterface * obj is an instance of FeatureI18n, delegates to * equals(FeatureI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class FeatureI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class FeatureI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class FeatureI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class FeatureI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class FeatureI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FeatureProduct.php b/core/lib/Thelia/Model/Base/FeatureProduct.php index 4af200d51..f8ddbd9b7 100644 --- a/core/lib/Thelia/Model/Base/FeatureProduct.php +++ b/core/lib/Thelia/Model/Base/FeatureProduct.php @@ -85,10 +85,10 @@ abstract class FeatureProduct implements ActiveRecordInterface protected $feature_av_id; /** - * The value for the by_default field. + * The value for the free_text_value field. * @var string */ - protected $by_default; + protected $free_text_value; /** * The value for the position field. @@ -173,7 +173,7 @@ abstract class FeatureProduct implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -231,8 +231,8 @@ abstract class FeatureProduct implements ActiveRecordInterface * obj is an instance of FeatureProduct, delegates to * equals(FeatureProduct). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -271,8 +271,6 @@ abstract class FeatureProduct implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -283,6 +281,7 @@ abstract class FeatureProduct implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -293,7 +292,10 @@ abstract class FeatureProduct implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -350,7 +352,9 @@ abstract class FeatureProduct implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -430,14 +434,14 @@ abstract class FeatureProduct implements ActiveRecordInterface } /** - * Get the [by_default] column value. + * Get the [free_text_value] column value. * * @return string */ - public function getByDefault() + public function getFreeTextValue() { - return $this->by_default; + return $this->free_text_value; } /** @@ -467,7 +471,7 @@ abstract class FeatureProduct implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -487,7 +491,7 @@ abstract class FeatureProduct implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -588,25 +592,25 @@ abstract class FeatureProduct implements ActiveRecordInterface } // setFeatureAvId() /** - * Set the value of [by_default] column. + * Set the value of [free_text_value] column. * * @param string $v new value * @return \Thelia\Model\FeatureProduct The current object (for fluent API support) */ - public function setByDefault($v) + public function setFreeTextValue($v) { if ($v !== null) { $v = (string) $v; } - if ($this->by_default !== $v) { - $this->by_default = $v; - $this->modifiedColumns[] = FeatureProductTableMap::BY_DEFAULT; + if ($this->free_text_value !== $v) { + $this->free_text_value = $v; + $this->modifiedColumns[] = FeatureProductTableMap::FREE_TEXT_VALUE; } return $this; - } // setByDefault() + } // setFreeTextValue() /** * Set the value of [position] column. @@ -720,8 +724,8 @@ abstract class FeatureProduct implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureProductTableMap::translateFieldName('FeatureAvId', TableMap::TYPE_PHPNAME, $indexType)]; $this->feature_av_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProductTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; - $this->by_default = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProductTableMap::translateFieldName('FreeTextValue', TableMap::TYPE_PHPNAME, $indexType)]; + $this->free_text_value = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureProductTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; @@ -1015,8 +1019,8 @@ abstract class FeatureProduct implements ActiveRecordInterface if ($this->isColumnModified(FeatureProductTableMap::FEATURE_AV_ID)) { $modifiedColumns[':p' . $index++] = 'FEATURE_AV_ID'; } - if ($this->isColumnModified(FeatureProductTableMap::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; + if ($this->isColumnModified(FeatureProductTableMap::FREE_TEXT_VALUE)) { + $modifiedColumns[':p' . $index++] = 'FREE_TEXT_VALUE'; } if ($this->isColumnModified(FeatureProductTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = 'POSITION'; @@ -1050,8 +1054,8 @@ abstract class FeatureProduct implements ActiveRecordInterface case 'FEATURE_AV_ID': $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT); break; - case 'BY_DEFAULT': - $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR); + case 'FREE_TEXT_VALUE': + $stmt->bindValue($identifier, $this->free_text_value, PDO::PARAM_STR); break; case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); @@ -1137,7 +1141,7 @@ abstract class FeatureProduct implements ActiveRecordInterface return $this->getFeatureAvId(); break; case 4: - return $this->getByDefault(); + return $this->getFreeTextValue(); break; case 5: return $this->getPosition(); @@ -1181,14 +1185,13 @@ abstract class FeatureProduct implements ActiveRecordInterface $keys[1] => $this->getProductId(), $keys[2] => $this->getFeatureId(), $keys[3] => $this->getFeatureAvId(), - $keys[4] => $this->getByDefault(), + $keys[4] => $this->getFreeTextValue(), $keys[5] => $this->getPosition(), $keys[6] => $this->getCreatedAt(), $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } @@ -1249,7 +1252,7 @@ abstract class FeatureProduct implements ActiveRecordInterface $this->setFeatureAvId($value); break; case 4: - $this->setByDefault($value); + $this->setFreeTextValue($value); break; case 5: $this->setPosition($value); @@ -1288,7 +1291,7 @@ abstract class FeatureProduct implements ActiveRecordInterface if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setFeatureId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setFeatureAvId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]); + if (array_key_exists($keys[4], $arr)) $this->setFreeTextValue($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPosition($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]]); @@ -1307,7 +1310,7 @@ abstract class FeatureProduct implements ActiveRecordInterface if ($this->isColumnModified(FeatureProductTableMap::PRODUCT_ID)) $criteria->add(FeatureProductTableMap::PRODUCT_ID, $this->product_id); if ($this->isColumnModified(FeatureProductTableMap::FEATURE_ID)) $criteria->add(FeatureProductTableMap::FEATURE_ID, $this->feature_id); if ($this->isColumnModified(FeatureProductTableMap::FEATURE_AV_ID)) $criteria->add(FeatureProductTableMap::FEATURE_AV_ID, $this->feature_av_id); - if ($this->isColumnModified(FeatureProductTableMap::BY_DEFAULT)) $criteria->add(FeatureProductTableMap::BY_DEFAULT, $this->by_default); + if ($this->isColumnModified(FeatureProductTableMap::FREE_TEXT_VALUE)) $criteria->add(FeatureProductTableMap::FREE_TEXT_VALUE, $this->free_text_value); if ($this->isColumnModified(FeatureProductTableMap::POSITION)) $criteria->add(FeatureProductTableMap::POSITION, $this->position); if ($this->isColumnModified(FeatureProductTableMap::CREATED_AT)) $criteria->add(FeatureProductTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(FeatureProductTableMap::UPDATED_AT)) $criteria->add(FeatureProductTableMap::UPDATED_AT, $this->updated_at); @@ -1377,7 +1380,7 @@ abstract class FeatureProduct implements ActiveRecordInterface $copyObj->setProductId($this->getProductId()); $copyObj->setFeatureId($this->getFeatureId()); $copyObj->setFeatureAvId($this->getFeatureAvId()); - $copyObj->setByDefault($this->getByDefault()); + $copyObj->setFreeTextValue($this->getFreeTextValue()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1571,7 +1574,7 @@ abstract class FeatureProduct implements ActiveRecordInterface $this->product_id = null; $this->feature_id = null; $this->feature_av_id = null; - $this->by_default = null; + $this->free_text_value = null; $this->position = null; $this->created_at = null; $this->updated_at = null; diff --git a/core/lib/Thelia/Model/Base/FeatureProductQuery.php b/core/lib/Thelia/Model/Base/FeatureProductQuery.php index c6a8f2a73..eb2ee7ec1 100644 --- a/core/lib/Thelia/Model/Base/FeatureProductQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureProductQuery.php @@ -25,7 +25,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method ChildFeatureProductQuery orderByProductId($order = Criteria::ASC) Order by the product_id column * @method ChildFeatureProductQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column * @method ChildFeatureProductQuery orderByFeatureAvId($order = Criteria::ASC) Order by the feature_av_id column - * @method ChildFeatureProductQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column + * @method ChildFeatureProductQuery orderByFreeTextValue($order = Criteria::ASC) Order by the free_text_value column * @method ChildFeatureProductQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildFeatureProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildFeatureProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -34,7 +34,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method ChildFeatureProductQuery groupByProductId() Group by the product_id column * @method ChildFeatureProductQuery groupByFeatureId() Group by the feature_id column * @method ChildFeatureProductQuery groupByFeatureAvId() Group by the feature_av_id column - * @method ChildFeatureProductQuery groupByByDefault() Group by the by_default column + * @method ChildFeatureProductQuery groupByFreeTextValue() Group by the free_text_value column * @method ChildFeatureProductQuery groupByPosition() Group by the position column * @method ChildFeatureProductQuery groupByCreatedAt() Group by the created_at column * @method ChildFeatureProductQuery groupByUpdatedAt() Group by the updated_at column @@ -62,7 +62,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method ChildFeatureProduct findOneByProductId(int $product_id) Return the first ChildFeatureProduct filtered by the product_id column * @method ChildFeatureProduct findOneByFeatureId(int $feature_id) Return the first ChildFeatureProduct filtered by the feature_id column * @method ChildFeatureProduct findOneByFeatureAvId(int $feature_av_id) Return the first ChildFeatureProduct filtered by the feature_av_id column - * @method ChildFeatureProduct findOneByByDefault(string $by_default) Return the first ChildFeatureProduct filtered by the by_default column + * @method ChildFeatureProduct findOneByFreeTextValue(string $free_text_value) Return the first ChildFeatureProduct filtered by the free_text_value column * @method ChildFeatureProduct findOneByPosition(int $position) Return the first ChildFeatureProduct filtered by the position column * @method ChildFeatureProduct findOneByCreatedAt(string $created_at) Return the first ChildFeatureProduct filtered by the created_at column * @method ChildFeatureProduct findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureProduct filtered by the updated_at column @@ -71,7 +71,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method array findByProductId(int $product_id) Return ChildFeatureProduct objects filtered by the product_id column * @method array findByFeatureId(int $feature_id) Return ChildFeatureProduct objects filtered by the feature_id column * @method array findByFeatureAvId(int $feature_av_id) Return ChildFeatureProduct objects filtered by the feature_av_id column - * @method array findByByDefault(string $by_default) Return ChildFeatureProduct objects filtered by the by_default column + * @method array findByFreeTextValue(string $free_text_value) Return ChildFeatureProduct objects filtered by the free_text_value column * @method array findByPosition(int $position) Return ChildFeatureProduct objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildFeatureProduct objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildFeatureProduct objects filtered by the updated_at column @@ -163,7 +163,7 @@ abstract class FeatureProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PRODUCT_ID, FEATURE_ID, FEATURE_AV_ID, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM feature_product WHERE ID = :p0'; + $sql = 'SELECT ID, PRODUCT_ID, FEATURE_ID, FEATURE_AV_ID, FREE_TEXT_VALUE, POSITION, CREATED_AT, UPDATED_AT FROM feature_product WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -423,32 +423,32 @@ abstract class FeatureProductQuery extends ModelCriteria } /** - * Filter the query on the by_default column + * Filter the query on the free_text_value column * * Example usage: * - * $query->filterByByDefault('fooValue'); // WHERE by_default = 'fooValue' - * $query->filterByByDefault('%fooValue%'); // WHERE by_default LIKE '%fooValue%' + * $query->filterByFreeTextValue('fooValue'); // WHERE free_text_value = 'fooValue' + * $query->filterByFreeTextValue('%fooValue%'); // WHERE free_text_value LIKE '%fooValue%' * * - * @param string $byDefault The value to use as filter. + * @param string $freeTextValue The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildFeatureProductQuery The current query, for fluid interface */ - public function filterByByDefault($byDefault = null, $comparison = null) + public function filterByFreeTextValue($freeTextValue = null, $comparison = null) { if (null === $comparison) { - if (is_array($byDefault)) { + if (is_array($freeTextValue)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $byDefault)) { - $byDefault = str_replace('*', '%', $byDefault); + } elseif (preg_match('/[\%\*]/', $freeTextValue)) { + $freeTextValue = str_replace('*', '%', $freeTextValue); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(FeatureProductTableMap::BY_DEFAULT, $byDefault, $comparison); + return $this->addUsingAlias(FeatureProductTableMap::FREE_TEXT_VALUE, $freeTextValue, $comparison); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureTemplate.php b/core/lib/Thelia/Model/Base/FeatureTemplate.php index bbccd9251..bc7b4f921 100644 --- a/core/lib/Thelia/Model/Base/FeatureTemplate.php +++ b/core/lib/Thelia/Model/Base/FeatureTemplate.php @@ -76,6 +76,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface */ protected $template_id; + /** + * The value for the position field. + * @var int + */ + protected $position; + /** * The value for the created_at field. * @var string @@ -148,7 +154,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -206,8 +212,8 @@ abstract class FeatureTemplate implements ActiveRecordInterface * obj is an instance of FeatureTemplate, delegates to * equals(FeatureTemplate). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -246,8 +252,6 @@ abstract class FeatureTemplate implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -258,6 +262,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -268,7 +273,10 @@ abstract class FeatureTemplate implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -325,7 +333,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -393,6 +403,17 @@ abstract class FeatureTemplate implements ActiveRecordInterface return $this->template_id; } + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -409,7 +430,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -429,7 +450,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -504,6 +525,27 @@ abstract class FeatureTemplate implements ActiveRecordInterface return $this; } // setTemplateId() + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = FeatureTemplateTableMap::POSITION; + } + + + return $this; + } // setPosition() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -592,13 +634,16 @@ abstract class FeatureTemplate implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTemplateTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; $this->template_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTemplateTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTemplateTableMap::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 ? 4 + $startcol : FeatureTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -611,7 +656,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\FeatureTemplate object", 0, $e); @@ -867,6 +912,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) { $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; } + if ($this->isColumnModified(FeatureTemplateTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -893,6 +941,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface case 'TEMPLATE_ID': $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, 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; @@ -971,9 +1022,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface return $this->getTemplateId(); break; case 3: - return $this->getCreatedAt(); + return $this->getPosition(); break; case 4: + return $this->getCreatedAt(); + break; + case 5: return $this->getUpdatedAt(); break; default: @@ -1008,12 +1062,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getFeatureId(), $keys[2] => $this->getTemplateId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } @@ -1068,9 +1122,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface $this->setTemplateId($value); break; case 3: - $this->setCreatedAt($value); + $this->setPosition($value); break; case 4: + $this->setCreatedAt($value); + break; + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1100,8 +1157,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setTemplateId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1116,6 +1174,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface if ($this->isColumnModified(FeatureTemplateTableMap::ID)) $criteria->add(FeatureTemplateTableMap::ID, $this->id); if ($this->isColumnModified(FeatureTemplateTableMap::FEATURE_ID)) $criteria->add(FeatureTemplateTableMap::FEATURE_ID, $this->feature_id); if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) $criteria->add(FeatureTemplateTableMap::TEMPLATE_ID, $this->template_id); + if ($this->isColumnModified(FeatureTemplateTableMap::POSITION)) $criteria->add(FeatureTemplateTableMap::POSITION, $this->position); if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) $criteria->add(FeatureTemplateTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(FeatureTemplateTableMap::UPDATED_AT)) $criteria->add(FeatureTemplateTableMap::UPDATED_AT, $this->updated_at); @@ -1183,6 +1242,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface { $copyObj->setFeatureId($this->getFeatureId()); $copyObj->setTemplateId($this->getTemplateId()); + $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1323,6 +1383,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface $this->id = null; $this->feature_id = null; $this->template_id = null; + $this->position = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php index c99c1305f..cccad15ae 100644 --- a/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php @@ -24,12 +24,14 @@ use Thelia\Model\Map\FeatureTemplateTableMap; * @method ChildFeatureTemplateQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildFeatureTemplateQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column * @method ChildFeatureTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column + * @method ChildFeatureTemplateQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildFeatureTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildFeatureTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildFeatureTemplateQuery groupById() Group by the id column * @method ChildFeatureTemplateQuery groupByFeatureId() Group by the feature_id column * @method ChildFeatureTemplateQuery groupByTemplateId() Group by the template_id column + * @method ChildFeatureTemplateQuery groupByPosition() Group by the position column * @method ChildFeatureTemplateQuery groupByCreatedAt() Group by the created_at column * @method ChildFeatureTemplateQuery groupByUpdatedAt() Group by the updated_at column * @@ -51,12 +53,14 @@ use Thelia\Model\Map\FeatureTemplateTableMap; * @method ChildFeatureTemplate findOneById(int $id) Return the first ChildFeatureTemplate filtered by the id column * @method ChildFeatureTemplate findOneByFeatureId(int $feature_id) Return the first ChildFeatureTemplate filtered by the feature_id column * @method ChildFeatureTemplate findOneByTemplateId(int $template_id) Return the first ChildFeatureTemplate filtered by the template_id column + * @method ChildFeatureTemplate findOneByPosition(int $position) Return the first ChildFeatureTemplate filtered by the position column * @method ChildFeatureTemplate findOneByCreatedAt(string $created_at) Return the first ChildFeatureTemplate filtered by the created_at column * @method ChildFeatureTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureTemplate filtered by the updated_at column * * @method array findById(int $id) Return ChildFeatureTemplate objects filtered by the id column * @method array findByFeatureId(int $feature_id) Return ChildFeatureTemplate objects filtered by the feature_id column * @method array findByTemplateId(int $template_id) Return ChildFeatureTemplate objects filtered by the template_id column + * @method array findByPosition(int $position) Return ChildFeatureTemplate objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildFeatureTemplate objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildFeatureTemplate objects filtered by the updated_at column * @@ -147,7 +151,7 @@ abstract class FeatureTemplateQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, FEATURE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM feature_template WHERE ID = :p0'; + $sql = 'SELECT ID, FEATURE_ID, TEMPLATE_ID, POSITION, CREATED_AT, UPDATED_AT FROM feature_template WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -363,6 +367,47 @@ abstract class FeatureTemplateQuery extends ModelCriteria return $this->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $templateId, $comparison); } + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position 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 ChildFeatureTemplateQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index 4457c5042..e62e9b71e 100644 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -279,7 +279,7 @@ abstract class Folder implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -337,8 +337,8 @@ abstract class Folder implements ActiveRecordInterface * obj is an instance of Folder, delegates to * equals(Folder). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -377,8 +377,6 @@ abstract class Folder implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -389,6 +387,7 @@ abstract class Folder implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -399,7 +398,10 @@ abstract class Folder implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -456,7 +458,9 @@ abstract class Folder implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -551,7 +555,7 @@ abstract class Folder implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -571,7 +575,7 @@ abstract class Folder implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -602,7 +606,7 @@ abstract class Folder implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1439,8 +1443,7 @@ abstract class Folder implements ActiveRecordInterface $keys[8] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FolderDocument.php b/core/lib/Thelia/Model/Base/FolderDocument.php index 8e24ee9d4..ea1a35d74 100644 --- a/core/lib/Thelia/Model/Base/FolderDocument.php +++ b/core/lib/Thelia/Model/Base/FolderDocument.php @@ -176,7 +176,7 @@ abstract class FolderDocument implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class FolderDocument implements ActiveRecordInterface * obj is an instance of FolderDocument, delegates to * equals(FolderDocument). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class FolderDocument implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class FolderDocument implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class FolderDocument implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class FolderDocument implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class FolderDocument implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class FolderDocument implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class FolderDocument implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php index b68c8ce9d..600890a03 100644 --- a/core/lib/Thelia/Model/Base/FolderDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/FolderDocumentI18n.php @@ -158,7 +158,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface * obj is an instance of FolderDocumentI18n, delegates to * equals(FolderDocumentI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class FolderDocumentI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php index 976c6b041..8e972b307 100644 --- a/core/lib/Thelia/Model/Base/FolderI18n.php +++ b/core/lib/Thelia/Model/Base/FolderI18n.php @@ -158,7 +158,7 @@ abstract class FolderI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class FolderI18n implements ActiveRecordInterface * obj is an instance of FolderI18n, delegates to * equals(FolderI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class FolderI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class FolderI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class FolderI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class FolderI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class FolderI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FolderImage.php b/core/lib/Thelia/Model/Base/FolderImage.php index 525dc9d48..2440c7232 100644 --- a/core/lib/Thelia/Model/Base/FolderImage.php +++ b/core/lib/Thelia/Model/Base/FolderImage.php @@ -176,7 +176,7 @@ abstract class FolderImage implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class FolderImage implements ActiveRecordInterface * obj is an instance of FolderImage, delegates to * equals(FolderImage). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class FolderImage implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class FolderImage implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class FolderImage implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class FolderImage implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class FolderImage implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class FolderImage implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class FolderImage implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FolderImageI18n.php b/core/lib/Thelia/Model/Base/FolderImageI18n.php index 6ac9575e1..e080b4b5c 100644 --- a/core/lib/Thelia/Model/Base/FolderImageI18n.php +++ b/core/lib/Thelia/Model/Base/FolderImageI18n.php @@ -158,7 +158,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class FolderImageI18n implements ActiveRecordInterface * obj is an instance of FolderImageI18n, delegates to * equals(FolderImageI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class FolderImageI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class FolderImageI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class FolderImageI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class FolderImageI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/FolderVersion.php b/core/lib/Thelia/Model/Base/FolderVersion.php index ec588dcbd..657bdeb44 100644 --- a/core/lib/Thelia/Model/Base/FolderVersion.php +++ b/core/lib/Thelia/Model/Base/FolderVersion.php @@ -178,7 +178,7 @@ abstract class FolderVersion implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -236,8 +236,8 @@ abstract class FolderVersion implements ActiveRecordInterface * obj is an instance of FolderVersion, delegates to * equals(FolderVersion). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -276,8 +276,6 @@ abstract class FolderVersion implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -288,6 +286,7 @@ abstract class FolderVersion implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -298,7 +297,10 @@ abstract class FolderVersion implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -355,7 +357,9 @@ abstract class FolderVersion implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -450,7 +454,7 @@ abstract class FolderVersion implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -470,7 +474,7 @@ abstract class FolderVersion implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -501,7 +505,7 @@ abstract class FolderVersion implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1201,8 +1205,7 @@ abstract class FolderVersion implements ActiveRecordInterface $keys[8] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php index 19d41e38c..751111952 100644 --- a/core/lib/Thelia/Model/Base/Group.php +++ b/core/lib/Thelia/Model/Base/Group.php @@ -225,7 +225,7 @@ abstract class Group implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -283,8 +283,8 @@ abstract class Group implements ActiveRecordInterface * obj is an instance of Group, delegates to * equals(Group). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -323,8 +323,6 @@ abstract class Group implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -335,6 +333,7 @@ abstract class Group implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -345,7 +344,10 @@ abstract class Group implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -402,7 +404,9 @@ abstract class Group implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -475,7 +479,7 @@ abstract class Group implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -495,7 +499,7 @@ abstract class Group implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1141,8 +1145,7 @@ abstract class Group implements ActiveRecordInterface $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php index df8f3f81a..07274e969 100644 --- a/core/lib/Thelia/Model/Base/GroupI18n.php +++ b/core/lib/Thelia/Model/Base/GroupI18n.php @@ -158,7 +158,7 @@ abstract class GroupI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class GroupI18n implements ActiveRecordInterface * obj is an instance of GroupI18n, delegates to * equals(GroupI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class GroupI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class GroupI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class GroupI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class GroupI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class GroupI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/GroupModule.php b/core/lib/Thelia/Model/Base/GroupModule.php index 82d6056f2..e3f9d9e15 100644 --- a/core/lib/Thelia/Model/Base/GroupModule.php +++ b/core/lib/Thelia/Model/Base/GroupModule.php @@ -168,7 +168,7 @@ abstract class GroupModule implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -226,8 +226,8 @@ abstract class GroupModule implements ActiveRecordInterface * obj is an instance of GroupModule, delegates to * equals(GroupModule). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -266,8 +266,6 @@ abstract class GroupModule implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -278,6 +276,7 @@ abstract class GroupModule implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -288,7 +287,10 @@ abstract class GroupModule implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -345,7 +347,9 @@ abstract class GroupModule implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -440,7 +444,7 @@ abstract class GroupModule implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -460,7 +464,7 @@ abstract class GroupModule implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1081,8 +1085,7 @@ abstract class GroupModule implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/GroupResource.php b/core/lib/Thelia/Model/Base/GroupResource.php index ea6c0ff47..8bfcd442f 100644 --- a/core/lib/Thelia/Model/Base/GroupResource.php +++ b/core/lib/Thelia/Model/Base/GroupResource.php @@ -176,7 +176,7 @@ abstract class GroupResource implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class GroupResource implements ActiveRecordInterface * obj is an instance of GroupResource, delegates to * equals(GroupResource). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class GroupResource implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class GroupResource implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class GroupResource implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class GroupResource implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -459,7 +463,7 @@ abstract class GroupResource implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -479,7 +483,7 @@ abstract class GroupResource implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1138,8 +1142,7 @@ abstract class GroupResource implements ActiveRecordInterface $keys[6] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php index 59836e27d..ac6f1f63c 100644 --- a/core/lib/Thelia/Model/Base/Lang.php +++ b/core/lib/Thelia/Model/Base/Lang.php @@ -209,7 +209,7 @@ abstract class Lang implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -267,8 +267,8 @@ abstract class Lang implements ActiveRecordInterface * obj is an instance of Lang, delegates to * equals(Lang). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -307,8 +307,6 @@ abstract class Lang implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -319,6 +317,7 @@ abstract class Lang implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -329,7 +328,10 @@ abstract class Lang implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -386,7 +388,9 @@ abstract class Lang implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -580,7 +584,7 @@ abstract class Lang implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -600,7 +604,7 @@ abstract class Lang implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1507,8 +1511,7 @@ abstract class Lang implements ActiveRecordInterface $keys[14] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Message.php b/core/lib/Thelia/Model/Base/Message.php index 4ee6b4cab..fbea5b241 100644 --- a/core/lib/Thelia/Model/Base/Message.php +++ b/core/lib/Thelia/Model/Base/Message.php @@ -218,7 +218,7 @@ abstract class Message implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -276,8 +276,8 @@ abstract class Message implements ActiveRecordInterface * obj is an instance of Message, delegates to * equals(Message). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -316,8 +316,6 @@ abstract class Message implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -328,6 +326,7 @@ abstract class Message implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -338,7 +337,10 @@ abstract class Message implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -395,7 +397,9 @@ abstract class Message implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -479,7 +483,7 @@ abstract class Message implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -499,7 +503,7 @@ abstract class Message implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -530,7 +534,7 @@ abstract class Message implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1248,8 +1252,7 @@ abstract class Message implements ActiveRecordInterface $keys[7] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php index d37682f97..42923cb69 100644 --- a/core/lib/Thelia/Model/Base/MessageI18n.php +++ b/core/lib/Thelia/Model/Base/MessageI18n.php @@ -158,7 +158,7 @@ abstract class MessageI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class MessageI18n implements ActiveRecordInterface * obj is an instance of MessageI18n, delegates to * equals(MessageI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class MessageI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class MessageI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class MessageI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class MessageI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class MessageI18n implements ActiveRecordInterface $keys[5] => $this->getHtmlMessage(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/MessageVersion.php b/core/lib/Thelia/Model/Base/MessageVersion.php index 60e12da8d..0c58a5bb2 100644 --- a/core/lib/Thelia/Model/Base/MessageVersion.php +++ b/core/lib/Thelia/Model/Base/MessageVersion.php @@ -172,7 +172,7 @@ abstract class MessageVersion implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -230,8 +230,8 @@ abstract class MessageVersion implements ActiveRecordInterface * obj is an instance of MessageVersion, delegates to * equals(MessageVersion). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -270,8 +270,6 @@ abstract class MessageVersion implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -282,6 +280,7 @@ abstract class MessageVersion implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -292,7 +291,10 @@ abstract class MessageVersion implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -349,7 +351,9 @@ abstract class MessageVersion implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -433,7 +437,7 @@ abstract class MessageVersion implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -453,7 +457,7 @@ abstract class MessageVersion implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -484,7 +488,7 @@ abstract class MessageVersion implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1150,8 +1154,7 @@ abstract class MessageVersion implements ActiveRecordInterface $keys[7] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index 88080dbe2..09858a877 100644 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -249,7 +249,7 @@ abstract class Module implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -307,8 +307,8 @@ abstract class Module implements ActiveRecordInterface * obj is an instance of Module, delegates to * equals(Module). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -347,8 +347,6 @@ abstract class Module implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -359,6 +357,7 @@ abstract class Module implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -369,7 +368,10 @@ abstract class Module implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -426,7 +428,9 @@ abstract class Module implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -543,7 +547,7 @@ abstract class Module implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -563,7 +567,7 @@ abstract class Module implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1327,8 +1331,7 @@ abstract class Module implements ActiveRecordInterface $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php index 9c7d603d1..359fb530e 100644 --- a/core/lib/Thelia/Model/Base/ModuleI18n.php +++ b/core/lib/Thelia/Model/Base/ModuleI18n.php @@ -158,7 +158,7 @@ abstract class ModuleI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ModuleI18n implements ActiveRecordInterface * obj is an instance of ModuleI18n, delegates to * equals(ModuleI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ModuleI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ModuleI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ModuleI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ModuleI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ModuleI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ModuleImage.php b/core/lib/Thelia/Model/Base/ModuleImage.php index f488e289c..4185d26c9 100644 --- a/core/lib/Thelia/Model/Base/ModuleImage.php +++ b/core/lib/Thelia/Model/Base/ModuleImage.php @@ -176,7 +176,7 @@ abstract class ModuleImage implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class ModuleImage implements ActiveRecordInterface * obj is an instance of ModuleImage, delegates to * equals(ModuleImage). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class ModuleImage implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class ModuleImage implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class ModuleImage implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class ModuleImage implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class ModuleImage implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class ModuleImage implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class ModuleImage implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ModuleImageI18n.php b/core/lib/Thelia/Model/Base/ModuleImageI18n.php index 2425b4e65..92a19a601 100644 --- a/core/lib/Thelia/Model/Base/ModuleImageI18n.php +++ b/core/lib/Thelia/Model/Base/ModuleImageI18n.php @@ -158,7 +158,7 @@ abstract class ModuleImageI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ModuleImageI18n implements ActiveRecordInterface * obj is an instance of ModuleImageI18n, delegates to * equals(ModuleImageI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ModuleImageI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ModuleImageI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ModuleImageI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ModuleImageI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ModuleImageI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index a2cd3f829..befa2abfe 100644 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -293,7 +293,7 @@ abstract class Order implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -351,8 +351,8 @@ abstract class Order implements ActiveRecordInterface * obj is an instance of Order, delegates to * equals(Order). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -391,8 +391,6 @@ abstract class Order implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -403,6 +401,7 @@ abstract class Order implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -413,7 +412,10 @@ abstract class Order implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -470,7 +472,9 @@ abstract class Order implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -576,7 +580,7 @@ abstract class Order implements ActiveRecordInterface if ($format === null) { return $this->invoice_date; } else { - return $this->invoice_date !== null ? $this->invoice_date->format($format) : null; + return $this->invoice_date instanceof \DateTime ? $this->invoice_date->format($format) : null; } } @@ -706,7 +710,7 @@ abstract class Order implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -726,7 +730,7 @@ abstract class Order implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1882,8 +1886,7 @@ abstract class Order implements ActiveRecordInterface $keys[17] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/OrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php index c5502321a..d52fd9de3 100644 --- a/core/lib/Thelia/Model/Base/OrderAddress.php +++ b/core/lib/Thelia/Model/Base/OrderAddress.php @@ -215,7 +215,7 @@ abstract class OrderAddress implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -273,8 +273,8 @@ abstract class OrderAddress implements ActiveRecordInterface * obj is an instance of OrderAddress, delegates to * equals(OrderAddress). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -313,8 +313,6 @@ abstract class OrderAddress implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -325,6 +323,7 @@ abstract class OrderAddress implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -335,7 +334,10 @@ abstract class OrderAddress implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -392,7 +394,9 @@ abstract class OrderAddress implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -575,7 +579,7 @@ abstract class OrderAddress implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -595,7 +599,7 @@ abstract class OrderAddress implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1487,8 +1491,7 @@ abstract class OrderAddress implements ActiveRecordInterface $keys[13] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php index 2bf9c7ace..69e927214 100644 --- a/core/lib/Thelia/Model/Base/OrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -18,10 +18,12 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Order as ChildOrder; -use Thelia\Model\OrderFeature as ChildOrderFeature; -use Thelia\Model\OrderFeatureQuery as ChildOrderFeatureQuery; use Thelia\Model\OrderProduct as ChildOrderProduct; +use Thelia\Model\OrderProductAttributeCombination as ChildOrderProductAttributeCombination; +use Thelia\Model\OrderProductAttributeCombinationQuery as ChildOrderProductAttributeCombinationQuery; use Thelia\Model\OrderProductQuery as ChildOrderProductQuery; +use Thelia\Model\OrderProductTax as ChildOrderProductTax; +use Thelia\Model\OrderProductTaxQuery as ChildOrderProductTaxQuery; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\OrderProductTableMap; @@ -77,12 +79,24 @@ abstract class OrderProduct implements ActiveRecordInterface */ protected $product_ref; + /** + * The value for the product_sale_elements_ref field. + * @var string + */ + protected $product_sale_elements_ref; + /** * The value for the title field. * @var string */ protected $title; + /** + * The value for the chapo field. + * @var string + */ + protected $chapo; + /** * The value for the description field. * @var string @@ -90,10 +104,10 @@ abstract class OrderProduct implements ActiveRecordInterface protected $description; /** - * The value for the chapo field. + * The value for the postscriptum field. * @var string */ - protected $chapo; + protected $postscriptum; /** * The value for the quantity field. @@ -108,10 +122,40 @@ abstract class OrderProduct implements ActiveRecordInterface protected $price; /** - * The value for the tax field. - * @var double + * The value for the promo_price field. + * @var string */ - protected $tax; + protected $promo_price; + + /** + * The value for the was_new field. + * @var int + */ + protected $was_new; + + /** + * The value for the was_in_promo field. + * @var int + */ + protected $was_in_promo; + + /** + * The value for the weight field. + * @var string + */ + protected $weight; + + /** + * The value for the tax_rule_title field. + * @var string + */ + protected $tax_rule_title; + + /** + * The value for the tax_rule_description field. + * @var string + */ + protected $tax_rule_description; /** * The value for the parent field. @@ -137,10 +181,16 @@ abstract class OrderProduct implements ActiveRecordInterface protected $aOrder; /** - * @var ObjectCollection|ChildOrderFeature[] Collection to store aggregation of ChildOrderFeature objects. + * @var ObjectCollection|ChildOrderProductAttributeCombination[] Collection to store aggregation of ChildOrderProductAttributeCombination objects. */ - protected $collOrderFeatures; - protected $collOrderFeaturesPartial; + protected $collOrderProductAttributeCombinations; + protected $collOrderProductAttributeCombinationsPartial; + + /** + * @var ObjectCollection|ChildOrderProductTax[] Collection to store aggregation of ChildOrderProductTax objects. + */ + protected $collOrderProductTaxes; + protected $collOrderProductTaxesPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -154,7 +204,13 @@ abstract class OrderProduct implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $orderFeaturesScheduledForDeletion = null; + protected $orderProductAttributeCombinationsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $orderProductTaxesScheduledForDeletion = null; /** * Initializes internal state of Thelia\Model\Base\OrderProduct object. @@ -198,7 +254,7 @@ abstract class OrderProduct implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -256,8 +312,8 @@ abstract class OrderProduct implements ActiveRecordInterface * obj is an instance of OrderProduct, delegates to * equals(OrderProduct). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -296,8 +352,6 @@ abstract class OrderProduct implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -308,6 +362,7 @@ abstract class OrderProduct implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -318,7 +373,10 @@ abstract class OrderProduct implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -375,7 +433,9 @@ abstract class OrderProduct implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -443,6 +503,17 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->product_ref; } + /** + * Get the [product_sale_elements_ref] column value. + * + * @return string + */ + public function getProductSaleElementsRef() + { + + return $this->product_sale_elements_ref; + } + /** * Get the [title] column value. * @@ -454,6 +525,17 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->title; } + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + /** * Get the [description] column value. * @@ -466,14 +548,14 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Get the [chapo] column value. + * Get the [postscriptum] column value. * * @return string */ - public function getChapo() + public function getPostscriptum() { - return $this->chapo; + return $this->postscriptum; } /** @@ -499,19 +581,74 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Get the [tax] column value. + * Get the [promo_price] column value. * - * @return double + * @return string */ - public function getTax() + public function getPromoPrice() { - return $this->tax; + return $this->promo_price; + } + + /** + * Get the [was_new] column value. + * + * @return int + */ + public function getWasNew() + { + + return $this->was_new; + } + + /** + * Get the [was_in_promo] column value. + * + * @return int + */ + public function getWasInPromo() + { + + return $this->was_in_promo; + } + + /** + * Get the [weight] column value. + * + * @return string + */ + public function getWeight() + { + + return $this->weight; + } + + /** + * Get the [tax_rule_title] column value. + * + * @return string + */ + public function getTaxRuleTitle() + { + + return $this->tax_rule_title; + } + + /** + * Get the [tax_rule_description] column value. + * + * @return string + */ + public function getTaxRuleDescription() + { + + return $this->tax_rule_description; } /** * Get the [parent] column value. - * + * not managed yet * @return int */ public function getParent() @@ -536,7 +673,7 @@ abstract class OrderProduct implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -556,7 +693,7 @@ abstract class OrderProduct implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -627,6 +764,27 @@ abstract class OrderProduct implements ActiveRecordInterface return $this; } // setProductRef() + /** + * Set the value of [product_sale_elements_ref] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setProductSaleElementsRef($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->product_sale_elements_ref !== $v) { + $this->product_sale_elements_ref = $v; + $this->modifiedColumns[] = OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF; + } + + + return $this; + } // setProductSaleElementsRef() + /** * Set the value of [title] column. * @@ -648,6 +806,27 @@ abstract class OrderProduct implements ActiveRecordInterface return $this; } // setTitle() + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = OrderProductTableMap::CHAPO; + } + + + return $this; + } // setChapo() + /** * Set the value of [description] column. * @@ -670,25 +849,25 @@ abstract class OrderProduct implements ActiveRecordInterface } // setDescription() /** - * Set the value of [chapo] column. + * Set the value of [postscriptum] column. * * @param string $v new value * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function setChapo($v) + public function setPostscriptum($v) { if ($v !== null) { $v = (string) $v; } - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = OrderProductTableMap::CHAPO; + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = OrderProductTableMap::POSTSCRIPTUM; } return $this; - } // setChapo() + } // setPostscriptum() /** * Set the value of [quantity] column. @@ -733,29 +912,134 @@ abstract class OrderProduct implements ActiveRecordInterface } // setPrice() /** - * Set the value of [tax] column. + * Set the value of [promo_price] column. * - * @param double $v new value + * @param string $v new value * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function setTax($v) + public function setPromoPrice($v) { if ($v !== null) { - $v = (double) $v; + $v = (string) $v; } - if ($this->tax !== $v) { - $this->tax = $v; - $this->modifiedColumns[] = OrderProductTableMap::TAX; + if ($this->promo_price !== $v) { + $this->promo_price = $v; + $this->modifiedColumns[] = OrderProductTableMap::PROMO_PRICE; } return $this; - } // setTax() + } // setPromoPrice() + + /** + * Set the value of [was_new] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWasNew($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->was_new !== $v) { + $this->was_new = $v; + $this->modifiedColumns[] = OrderProductTableMap::WAS_NEW; + } + + + return $this; + } // setWasNew() + + /** + * Set the value of [was_in_promo] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWasInPromo($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->was_in_promo !== $v) { + $this->was_in_promo = $v; + $this->modifiedColumns[] = OrderProductTableMap::WAS_IN_PROMO; + } + + + return $this; + } // setWasInPromo() + + /** + * Set the value of [weight] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWeight($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->weight !== $v) { + $this->weight = $v; + $this->modifiedColumns[] = OrderProductTableMap::WEIGHT; + } + + + return $this; + } // setWeight() + + /** + * Set the value of [tax_rule_title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setTaxRuleTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->tax_rule_title !== $v) { + $this->tax_rule_title = $v; + $this->modifiedColumns[] = OrderProductTableMap::TAX_RULE_TITLE; + } + + + return $this; + } // setTaxRuleTitle() + + /** + * Set the value of [tax_rule_description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setTaxRuleDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->tax_rule_description !== $v) { + $this->tax_rule_description = $v; + $this->modifiedColumns[] = OrderProductTableMap::TAX_RULE_DESCRIPTION; + } + + + return $this; + } // setTaxRuleDescription() /** * Set the value of [parent] column. - * + * not managed yet * @param int $v new value * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ @@ -862,34 +1146,55 @@ abstract class OrderProduct implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTableMap::translateFieldName('ProductRef', TableMap::TYPE_PHPNAME, $indexType)]; $this->product_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; - $this->title = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('ProductSaleElementsRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_sale_elements_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; - $this->description = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; $this->chapo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; $this->quantity = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; $this->price = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Tax', TableMap::TYPE_PHPNAME, $indexType)]; - $this->tax = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo_price = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderProductTableMap::translateFieldName('WasNew', TableMap::TYPE_PHPNAME, $indexType)]; + $this->was_new = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderProductTableMap::translateFieldName('WasInPromo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->was_in_promo = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderProductTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; + $this->weight = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; $this->parent = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderProductTableMap::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 ? 11 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -902,7 +1207,7 @@ abstract class OrderProduct implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 12; // 12 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 19; // 19 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e); @@ -967,7 +1272,9 @@ abstract class OrderProduct implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aOrder = null; - $this->collOrderFeatures = null; + $this->collOrderProductAttributeCombinations = null; + + $this->collOrderProductTaxes = null; } // if (deep) } @@ -1114,17 +1421,34 @@ abstract class OrderProduct implements ActiveRecordInterface $this->resetModified(); } - if ($this->orderFeaturesScheduledForDeletion !== null) { - if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) { - \Thelia\Model\OrderFeatureQuery::create() - ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->orderProductAttributeCombinationsScheduledForDeletion !== null) { + if (!$this->orderProductAttributeCombinationsScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderProductAttributeCombinationQuery::create() + ->filterByPrimaryKeys($this->orderProductAttributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->orderFeaturesScheduledForDeletion = null; + $this->orderProductAttributeCombinationsScheduledForDeletion = null; } } - if ($this->collOrderFeatures !== null) { - foreach ($this->collOrderFeatures as $referrerFK) { + if ($this->collOrderProductAttributeCombinations !== null) { + foreach ($this->collOrderProductAttributeCombinations as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->orderProductTaxesScheduledForDeletion !== null) { + if (!$this->orderProductTaxesScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderProductTaxQuery::create() + ->filterByPrimaryKeys($this->orderProductTaxesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->orderProductTaxesScheduledForDeletion = null; + } + } + + if ($this->collOrderProductTaxes !== null) { + foreach ($this->collOrderProductTaxes as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1166,14 +1490,20 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) { $modifiedColumns[':p' . $index++] = 'PRODUCT_REF'; } + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_REF'; + } if ($this->isColumnModified(OrderProductTableMap::TITLE)) { $modifiedColumns[':p' . $index++] = 'TITLE'; } + if ($this->isColumnModified(OrderProductTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(OrderProductTableMap::CHAPO)) { - $modifiedColumns[':p' . $index++] = 'CHAPO'; + if ($this->isColumnModified(OrderProductTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; } if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) { $modifiedColumns[':p' . $index++] = 'QUANTITY'; @@ -1181,8 +1511,23 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::PRICE)) { $modifiedColumns[':p' . $index++] = 'PRICE'; } - if ($this->isColumnModified(OrderProductTableMap::TAX)) { - $modifiedColumns[':p' . $index++] = 'TAX'; + if ($this->isColumnModified(OrderProductTableMap::PROMO_PRICE)) { + $modifiedColumns[':p' . $index++] = 'PROMO_PRICE'; + } + if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) { + $modifiedColumns[':p' . $index++] = 'WAS_NEW'; + } + if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) { + $modifiedColumns[':p' . $index++] = 'WAS_IN_PROMO'; + } + if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) { + $modifiedColumns[':p' . $index++] = 'WEIGHT'; + } + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_TITLE'; + } + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_DESCRIPTION'; } if ($this->isColumnModified(OrderProductTableMap::PARENT)) { $modifiedColumns[':p' . $index++] = 'PARENT'; @@ -1213,14 +1558,20 @@ abstract class OrderProduct implements ActiveRecordInterface case 'PRODUCT_REF': $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR); break; + case 'PRODUCT_SALE_ELEMENTS_REF': + $stmt->bindValue($identifier, $this->product_sale_elements_ref, PDO::PARAM_STR); + break; case 'TITLE': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; case 'DESCRIPTION': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case 'CHAPO': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); break; case 'QUANTITY': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); @@ -1228,8 +1579,23 @@ abstract class OrderProduct implements ActiveRecordInterface case 'PRICE': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case 'TAX': - $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); + case 'PROMO_PRICE': + $stmt->bindValue($identifier, $this->promo_price, PDO::PARAM_STR); + break; + case 'WAS_NEW': + $stmt->bindValue($identifier, $this->was_new, PDO::PARAM_INT); + break; + case 'WAS_IN_PROMO': + $stmt->bindValue($identifier, $this->was_in_promo, PDO::PARAM_INT); + break; + case 'WEIGHT': + $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); + break; + case 'TAX_RULE_TITLE': + $stmt->bindValue($identifier, $this->tax_rule_title, PDO::PARAM_STR); + break; + case 'TAX_RULE_DESCRIPTION': + $stmt->bindValue($identifier, $this->tax_rule_description, PDO::PARAM_STR); break; case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); @@ -1312,30 +1678,51 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->getProductRef(); break; case 3: - return $this->getTitle(); + return $this->getProductSaleElementsRef(); break; case 4: - return $this->getDescription(); + return $this->getTitle(); break; case 5: return $this->getChapo(); break; case 6: - return $this->getQuantity(); + return $this->getDescription(); break; case 7: - return $this->getPrice(); + return $this->getPostscriptum(); break; case 8: - return $this->getTax(); + return $this->getQuantity(); break; case 9: - return $this->getParent(); + return $this->getPrice(); break; case 10: - return $this->getCreatedAt(); + return $this->getPromoPrice(); break; case 11: + return $this->getWasNew(); + break; + case 12: + return $this->getWasInPromo(); + break; + case 13: + return $this->getWeight(); + break; + case 14: + return $this->getTaxRuleTitle(); + break; + case 15: + return $this->getTaxRuleDescription(); + break; + case 16: + return $this->getParent(); + break; + case 17: + return $this->getCreatedAt(); + break; + case 18: return $this->getUpdatedAt(); break; default: @@ -1370,19 +1757,25 @@ abstract class OrderProduct implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getOrderId(), $keys[2] => $this->getProductRef(), - $keys[3] => $this->getTitle(), - $keys[4] => $this->getDescription(), + $keys[3] => $this->getProductSaleElementsRef(), + $keys[4] => $this->getTitle(), $keys[5] => $this->getChapo(), - $keys[6] => $this->getQuantity(), - $keys[7] => $this->getPrice(), - $keys[8] => $this->getTax(), - $keys[9] => $this->getParent(), - $keys[10] => $this->getCreatedAt(), - $keys[11] => $this->getUpdatedAt(), + $keys[6] => $this->getDescription(), + $keys[7] => $this->getPostscriptum(), + $keys[8] => $this->getQuantity(), + $keys[9] => $this->getPrice(), + $keys[10] => $this->getPromoPrice(), + $keys[11] => $this->getWasNew(), + $keys[12] => $this->getWasInPromo(), + $keys[13] => $this->getWeight(), + $keys[14] => $this->getTaxRuleTitle(), + $keys[15] => $this->getTaxRuleDescription(), + $keys[16] => $this->getParent(), + $keys[17] => $this->getCreatedAt(), + $keys[18] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } @@ -1390,8 +1783,11 @@ abstract class OrderProduct implements ActiveRecordInterface if (null !== $this->aOrder) { $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->collOrderFeatures) { - $result['OrderFeatures'] = $this->collOrderFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collOrderProductAttributeCombinations) { + $result['OrderProductAttributeCombinations'] = $this->collOrderProductAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collOrderProductTaxes) { + $result['OrderProductTaxes'] = $this->collOrderProductTaxes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1437,30 +1833,51 @@ abstract class OrderProduct implements ActiveRecordInterface $this->setProductRef($value); break; case 3: - $this->setTitle($value); + $this->setProductSaleElementsRef($value); break; case 4: - $this->setDescription($value); + $this->setTitle($value); break; case 5: $this->setChapo($value); break; case 6: - $this->setQuantity($value); + $this->setDescription($value); break; case 7: - $this->setPrice($value); + $this->setPostscriptum($value); break; case 8: - $this->setTax($value); + $this->setQuantity($value); break; case 9: - $this->setParent($value); + $this->setPrice($value); break; case 10: - $this->setCreatedAt($value); + $this->setPromoPrice($value); break; case 11: + $this->setWasNew($value); + break; + case 12: + $this->setWasInPromo($value); + break; + case 13: + $this->setWeight($value); + break; + case 14: + $this->setTaxRuleTitle($value); + break; + case 15: + $this->setTaxRuleDescription($value); + break; + case 16: + $this->setParent($value); + break; + case 17: + $this->setCreatedAt($value); + break; + case 18: $this->setUpdatedAt($value); break; } // switch() @@ -1490,15 +1907,22 @@ abstract class OrderProduct implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setProductRef($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setProductSaleElementsRef($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setTitle($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setQuantity($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setPrice($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setTax($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setParent($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]]); + if (array_key_exists($keys[6], $arr)) $this->setDescription($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setPostscriptum($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setPrice($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setPromoPrice($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setWasNew($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setWasInPromo($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setWeight($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setTaxRuleTitle($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setTaxRuleDescription($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setParent($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]); } /** @@ -1513,12 +1937,19 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::ID)) $criteria->add(OrderProductTableMap::ID, $this->id); if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) $criteria->add(OrderProductTableMap::ORDER_ID, $this->order_id); if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) $criteria->add(OrderProductTableMap::PRODUCT_REF, $this->product_ref); + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF)) $criteria->add(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $this->product_sale_elements_ref); if ($this->isColumnModified(OrderProductTableMap::TITLE)) $criteria->add(OrderProductTableMap::TITLE, $this->title); - if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(OrderProductTableMap::CHAPO)) $criteria->add(OrderProductTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(OrderProductTableMap::POSTSCRIPTUM)) $criteria->add(OrderProductTableMap::POSTSCRIPTUM, $this->postscriptum); if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) $criteria->add(OrderProductTableMap::QUANTITY, $this->quantity); if ($this->isColumnModified(OrderProductTableMap::PRICE)) $criteria->add(OrderProductTableMap::PRICE, $this->price); - if ($this->isColumnModified(OrderProductTableMap::TAX)) $criteria->add(OrderProductTableMap::TAX, $this->tax); + if ($this->isColumnModified(OrderProductTableMap::PROMO_PRICE)) $criteria->add(OrderProductTableMap::PROMO_PRICE, $this->promo_price); + if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) $criteria->add(OrderProductTableMap::WAS_NEW, $this->was_new); + if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) $criteria->add(OrderProductTableMap::WAS_IN_PROMO, $this->was_in_promo); + if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) $criteria->add(OrderProductTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) $criteria->add(OrderProductTableMap::TAX_RULE_TITLE, $this->tax_rule_title); + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_DESCRIPTION)) $criteria->add(OrderProductTableMap::TAX_RULE_DESCRIPTION, $this->tax_rule_description); if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent); if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) $criteria->add(OrderProductTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) $criteria->add(OrderProductTableMap::UPDATED_AT, $this->updated_at); @@ -1587,12 +2018,19 @@ abstract class OrderProduct implements ActiveRecordInterface { $copyObj->setOrderId($this->getOrderId()); $copyObj->setProductRef($this->getProductRef()); + $copyObj->setProductSaleElementsRef($this->getProductSaleElementsRef()); $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); $copyObj->setChapo($this->getChapo()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setPostscriptum($this->getPostscriptum()); $copyObj->setQuantity($this->getQuantity()); $copyObj->setPrice($this->getPrice()); - $copyObj->setTax($this->getTax()); + $copyObj->setPromoPrice($this->getPromoPrice()); + $copyObj->setWasNew($this->getWasNew()); + $copyObj->setWasInPromo($this->getWasInPromo()); + $copyObj->setWeight($this->getWeight()); + $copyObj->setTaxRuleTitle($this->getTaxRuleTitle()); + $copyObj->setTaxRuleDescription($this->getTaxRuleDescription()); $copyObj->setParent($this->getParent()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1602,9 +2040,15 @@ abstract class OrderProduct implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getOrderFeatures() as $relObj) { + foreach ($this->getOrderProductAttributeCombinations() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderFeature($relObj->copy($deepCopy)); + $copyObj->addOrderProductAttributeCombination($relObj->copy($deepCopy)); + } + } + + foreach ($this->getOrderProductTaxes() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderProductTax($relObj->copy($deepCopy)); } } @@ -1700,37 +2144,40 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('OrderFeature' == $relationName) { - return $this->initOrderFeatures(); + if ('OrderProductAttributeCombination' == $relationName) { + return $this->initOrderProductAttributeCombinations(); + } + if ('OrderProductTax' == $relationName) { + return $this->initOrderProductTaxes(); } } /** - * Clears out the collOrderFeatures collection + * Clears out the collOrderProductAttributeCombinations collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addOrderFeatures() + * @see addOrderProductAttributeCombinations() */ - public function clearOrderFeatures() + public function clearOrderProductAttributeCombinations() { - $this->collOrderFeatures = null; // important to set this to NULL since that means it is uninitialized + $this->collOrderProductAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrderFeatures collection loaded partially. + * Reset is the collOrderProductAttributeCombinations collection loaded partially. */ - public function resetPartialOrderFeatures($v = true) + public function resetPartialOrderProductAttributeCombinations($v = true) { - $this->collOrderFeaturesPartial = $v; + $this->collOrderProductAttributeCombinationsPartial = $v; } /** - * Initializes the collOrderFeatures collection. + * Initializes the collOrderProductAttributeCombinations collection. * - * By default this just sets the collOrderFeatures collection to an empty array (like clearcollOrderFeatures()); + * By default this just sets the collOrderProductAttributeCombinations collection to an empty array (like clearcollOrderProductAttributeCombinations()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1739,17 +2186,17 @@ abstract class OrderProduct implements ActiveRecordInterface * * @return void */ - public function initOrderFeatures($overrideExisting = true) + public function initOrderProductAttributeCombinations($overrideExisting = true) { - if (null !== $this->collOrderFeatures && !$overrideExisting) { + if (null !== $this->collOrderProductAttributeCombinations && !$overrideExisting) { return; } - $this->collOrderFeatures = new ObjectCollection(); - $this->collOrderFeatures->setModel('\Thelia\Model\OrderFeature'); + $this->collOrderProductAttributeCombinations = new ObjectCollection(); + $this->collOrderProductAttributeCombinations->setModel('\Thelia\Model\OrderProductAttributeCombination'); } /** - * Gets an array of ChildOrderFeature objects which contain a foreign key that references this object. + * Gets an array of ChildOrderProductAttributeCombination objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1759,109 +2206,109 @@ abstract class OrderProduct implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildOrderFeature[] List of ChildOrderFeature objects + * @return Collection|ChildOrderProductAttributeCombination[] List of ChildOrderProductAttributeCombination objects * @throws PropelException */ - public function getOrderFeatures($criteria = null, ConnectionInterface $con = null) + public function getOrderProductAttributeCombinations($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { + $partial = $this->collOrderProductAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderProductAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductAttributeCombinations) { // return empty collection - $this->initOrderFeatures(); + $this->initOrderProductAttributeCombinations(); } else { - $collOrderFeatures = ChildOrderFeatureQuery::create(null, $criteria) + $collOrderProductAttributeCombinations = ChildOrderProductAttributeCombinationQuery::create(null, $criteria) ->filterByOrderProduct($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrderFeaturesPartial && count($collOrderFeatures)) { - $this->initOrderFeatures(false); + if (false !== $this->collOrderProductAttributeCombinationsPartial && count($collOrderProductAttributeCombinations)) { + $this->initOrderProductAttributeCombinations(false); - foreach ($collOrderFeatures as $obj) { - if (false == $this->collOrderFeatures->contains($obj)) { - $this->collOrderFeatures->append($obj); + foreach ($collOrderProductAttributeCombinations as $obj) { + if (false == $this->collOrderProductAttributeCombinations->contains($obj)) { + $this->collOrderProductAttributeCombinations->append($obj); } } - $this->collOrderFeaturesPartial = true; + $this->collOrderProductAttributeCombinationsPartial = true; } - $collOrderFeatures->getInternalIterator()->rewind(); + $collOrderProductAttributeCombinations->getInternalIterator()->rewind(); - return $collOrderFeatures; + return $collOrderProductAttributeCombinations; } - if ($partial && $this->collOrderFeatures) { - foreach ($this->collOrderFeatures as $obj) { + if ($partial && $this->collOrderProductAttributeCombinations) { + foreach ($this->collOrderProductAttributeCombinations as $obj) { if ($obj->isNew()) { - $collOrderFeatures[] = $obj; + $collOrderProductAttributeCombinations[] = $obj; } } } - $this->collOrderFeatures = $collOrderFeatures; - $this->collOrderFeaturesPartial = false; + $this->collOrderProductAttributeCombinations = $collOrderProductAttributeCombinations; + $this->collOrderProductAttributeCombinationsPartial = false; } } - return $this->collOrderFeatures; + return $this->collOrderProductAttributeCombinations; } /** - * Sets a collection of OrderFeature objects related by a one-to-many relationship + * Sets a collection of OrderProductAttributeCombination objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $orderFeatures A Propel collection. + * @param Collection $orderProductAttributeCombinations A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrderProduct The current object (for fluent API support) */ - public function setOrderFeatures(Collection $orderFeatures, ConnectionInterface $con = null) + public function setOrderProductAttributeCombinations(Collection $orderProductAttributeCombinations, ConnectionInterface $con = null) { - $orderFeaturesToDelete = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures); + $orderProductAttributeCombinationsToDelete = $this->getOrderProductAttributeCombinations(new Criteria(), $con)->diff($orderProductAttributeCombinations); - $this->orderFeaturesScheduledForDeletion = $orderFeaturesToDelete; + $this->orderProductAttributeCombinationsScheduledForDeletion = $orderProductAttributeCombinationsToDelete; - foreach ($orderFeaturesToDelete as $orderFeatureRemoved) { - $orderFeatureRemoved->setOrderProduct(null); + foreach ($orderProductAttributeCombinationsToDelete as $orderProductAttributeCombinationRemoved) { + $orderProductAttributeCombinationRemoved->setOrderProduct(null); } - $this->collOrderFeatures = null; - foreach ($orderFeatures as $orderFeature) { - $this->addOrderFeature($orderFeature); + $this->collOrderProductAttributeCombinations = null; + foreach ($orderProductAttributeCombinations as $orderProductAttributeCombination) { + $this->addOrderProductAttributeCombination($orderProductAttributeCombination); } - $this->collOrderFeatures = $orderFeatures; - $this->collOrderFeaturesPartial = false; + $this->collOrderProductAttributeCombinations = $orderProductAttributeCombinations; + $this->collOrderProductAttributeCombinationsPartial = false; return $this; } /** - * Returns the number of related OrderFeature objects. + * Returns the number of related OrderProductAttributeCombination objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related OrderFeature objects. + * @return int Count of related OrderProductAttributeCombination objects. * @throws PropelException */ - public function countOrderFeatures(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countOrderProductAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { + $partial = $this->collOrderProductAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderProductAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductAttributeCombinations) { return 0; } if ($partial && !$criteria) { - return count($this->getOrderFeatures()); + return count($this->getOrderProductAttributeCombinations()); } - $query = ChildOrderFeatureQuery::create(null, $criteria); + $query = ChildOrderProductAttributeCombinationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1871,53 +2318,271 @@ abstract class OrderProduct implements ActiveRecordInterface ->count($con); } - return count($this->collOrderFeatures); + return count($this->collOrderProductAttributeCombinations); } /** - * Method called to associate a ChildOrderFeature object to this object - * through the ChildOrderFeature foreign key attribute. + * Method called to associate a ChildOrderProductAttributeCombination object to this object + * through the ChildOrderProductAttributeCombination foreign key attribute. * - * @param ChildOrderFeature $l ChildOrderFeature + * @param ChildOrderProductAttributeCombination $l ChildOrderProductAttributeCombination * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function addOrderFeature(ChildOrderFeature $l) + public function addOrderProductAttributeCombination(ChildOrderProductAttributeCombination $l) { - if ($this->collOrderFeatures === null) { - $this->initOrderFeatures(); - $this->collOrderFeaturesPartial = true; + if ($this->collOrderProductAttributeCombinations === null) { + $this->initOrderProductAttributeCombinations(); + $this->collOrderProductAttributeCombinationsPartial = true; } - if (!in_array($l, $this->collOrderFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderFeature($l); + if (!in_array($l, $this->collOrderProductAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderProductAttributeCombination($l); } return $this; } /** - * @param OrderFeature $orderFeature The orderFeature object to add. + * @param OrderProductAttributeCombination $orderProductAttributeCombination The orderProductAttributeCombination object to add. */ - protected function doAddOrderFeature($orderFeature) + protected function doAddOrderProductAttributeCombination($orderProductAttributeCombination) { - $this->collOrderFeatures[]= $orderFeature; - $orderFeature->setOrderProduct($this); + $this->collOrderProductAttributeCombinations[]= $orderProductAttributeCombination; + $orderProductAttributeCombination->setOrderProduct($this); } /** - * @param OrderFeature $orderFeature The orderFeature object to remove. + * @param OrderProductAttributeCombination $orderProductAttributeCombination The orderProductAttributeCombination object to remove. * @return ChildOrderProduct The current object (for fluent API support) */ - public function removeOrderFeature($orderFeature) + public function removeOrderProductAttributeCombination($orderProductAttributeCombination) { - if ($this->getOrderFeatures()->contains($orderFeature)) { - $this->collOrderFeatures->remove($this->collOrderFeatures->search($orderFeature)); - if (null === $this->orderFeaturesScheduledForDeletion) { - $this->orderFeaturesScheduledForDeletion = clone $this->collOrderFeatures; - $this->orderFeaturesScheduledForDeletion->clear(); + if ($this->getOrderProductAttributeCombinations()->contains($orderProductAttributeCombination)) { + $this->collOrderProductAttributeCombinations->remove($this->collOrderProductAttributeCombinations->search($orderProductAttributeCombination)); + if (null === $this->orderProductAttributeCombinationsScheduledForDeletion) { + $this->orderProductAttributeCombinationsScheduledForDeletion = clone $this->collOrderProductAttributeCombinations; + $this->orderProductAttributeCombinationsScheduledForDeletion->clear(); } - $this->orderFeaturesScheduledForDeletion[]= clone $orderFeature; - $orderFeature->setOrderProduct(null); + $this->orderProductAttributeCombinationsScheduledForDeletion[]= clone $orderProductAttributeCombination; + $orderProductAttributeCombination->setOrderProduct(null); + } + + return $this; + } + + /** + * Clears out the collOrderProductTaxes collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addOrderProductTaxes() + */ + public function clearOrderProductTaxes() + { + $this->collOrderProductTaxes = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrderProductTaxes collection loaded partially. + */ + public function resetPartialOrderProductTaxes($v = true) + { + $this->collOrderProductTaxesPartial = $v; + } + + /** + * Initializes the collOrderProductTaxes collection. + * + * By default this just sets the collOrderProductTaxes collection to an empty array (like clearcollOrderProductTaxes()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initOrderProductTaxes($overrideExisting = true) + { + if (null !== $this->collOrderProductTaxes && !$overrideExisting) { + return; + } + $this->collOrderProductTaxes = new ObjectCollection(); + $this->collOrderProductTaxes->setModel('\Thelia\Model\OrderProductTax'); + } + + /** + * Gets an array of ChildOrderProductTax objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildOrderProduct is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrderProductTax[] List of ChildOrderProductTax objects + * @throws PropelException + */ + public function getOrderProductTaxes($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrderProductTaxesPartial && !$this->isNew(); + if (null === $this->collOrderProductTaxes || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductTaxes) { + // return empty collection + $this->initOrderProductTaxes(); + } else { + $collOrderProductTaxes = ChildOrderProductTaxQuery::create(null, $criteria) + ->filterByOrderProduct($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrderProductTaxesPartial && count($collOrderProductTaxes)) { + $this->initOrderProductTaxes(false); + + foreach ($collOrderProductTaxes as $obj) { + if (false == $this->collOrderProductTaxes->contains($obj)) { + $this->collOrderProductTaxes->append($obj); + } + } + + $this->collOrderProductTaxesPartial = true; + } + + $collOrderProductTaxes->getInternalIterator()->rewind(); + + return $collOrderProductTaxes; + } + + if ($partial && $this->collOrderProductTaxes) { + foreach ($this->collOrderProductTaxes as $obj) { + if ($obj->isNew()) { + $collOrderProductTaxes[] = $obj; + } + } + } + + $this->collOrderProductTaxes = $collOrderProductTaxes; + $this->collOrderProductTaxesPartial = false; + } + } + + return $this->collOrderProductTaxes; + } + + /** + * Sets a collection of OrderProductTax objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $orderProductTaxes A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function setOrderProductTaxes(Collection $orderProductTaxes, ConnectionInterface $con = null) + { + $orderProductTaxesToDelete = $this->getOrderProductTaxes(new Criteria(), $con)->diff($orderProductTaxes); + + + $this->orderProductTaxesScheduledForDeletion = $orderProductTaxesToDelete; + + foreach ($orderProductTaxesToDelete as $orderProductTaxRemoved) { + $orderProductTaxRemoved->setOrderProduct(null); + } + + $this->collOrderProductTaxes = null; + foreach ($orderProductTaxes as $orderProductTax) { + $this->addOrderProductTax($orderProductTax); + } + + $this->collOrderProductTaxes = $orderProductTaxes; + $this->collOrderProductTaxesPartial = false; + + return $this; + } + + /** + * Returns the number of related OrderProductTax objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related OrderProductTax objects. + * @throws PropelException + */ + public function countOrderProductTaxes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrderProductTaxesPartial && !$this->isNew(); + if (null === $this->collOrderProductTaxes || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductTaxes) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrderProductTaxes()); + } + + $query = ChildOrderProductTaxQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderProduct($this) + ->count($con); + } + + return count($this->collOrderProductTaxes); + } + + /** + * Method called to associate a ChildOrderProductTax object to this object + * through the ChildOrderProductTax foreign key attribute. + * + * @param ChildOrderProductTax $l ChildOrderProductTax + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function addOrderProductTax(ChildOrderProductTax $l) + { + if ($this->collOrderProductTaxes === null) { + $this->initOrderProductTaxes(); + $this->collOrderProductTaxesPartial = true; + } + + if (!in_array($l, $this->collOrderProductTaxes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderProductTax($l); + } + + return $this; + } + + /** + * @param OrderProductTax $orderProductTax The orderProductTax object to add. + */ + protected function doAddOrderProductTax($orderProductTax) + { + $this->collOrderProductTaxes[]= $orderProductTax; + $orderProductTax->setOrderProduct($this); + } + + /** + * @param OrderProductTax $orderProductTax The orderProductTax object to remove. + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function removeOrderProductTax($orderProductTax) + { + if ($this->getOrderProductTaxes()->contains($orderProductTax)) { + $this->collOrderProductTaxes->remove($this->collOrderProductTaxes->search($orderProductTax)); + if (null === $this->orderProductTaxesScheduledForDeletion) { + $this->orderProductTaxesScheduledForDeletion = clone $this->collOrderProductTaxes; + $this->orderProductTaxesScheduledForDeletion->clear(); + } + $this->orderProductTaxesScheduledForDeletion[]= clone $orderProductTax; + $orderProductTax->setOrderProduct(null); } return $this; @@ -1931,12 +2596,19 @@ abstract class OrderProduct implements ActiveRecordInterface $this->id = null; $this->order_id = null; $this->product_ref = null; + $this->product_sale_elements_ref = null; $this->title = null; - $this->description = null; $this->chapo = null; + $this->description = null; + $this->postscriptum = null; $this->quantity = null; $this->price = null; - $this->tax = null; + $this->promo_price = null; + $this->was_new = null; + $this->was_in_promo = null; + $this->weight = null; + $this->tax_rule_title = null; + $this->tax_rule_description = null; $this->parent = null; $this->created_at = null; $this->updated_at = null; @@ -1959,17 +2631,26 @@ abstract class OrderProduct implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collOrderFeatures) { - foreach ($this->collOrderFeatures as $o) { + if ($this->collOrderProductAttributeCombinations) { + foreach ($this->collOrderProductAttributeCombinations as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collOrderProductTaxes) { + foreach ($this->collOrderProductTaxes as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collOrderFeatures instanceof Collection) { - $this->collOrderFeatures->clearIterator(); + if ($this->collOrderProductAttributeCombinations instanceof Collection) { + $this->collOrderProductAttributeCombinations->clearIterator(); } - $this->collOrderFeatures = null; + $this->collOrderProductAttributeCombinations = null; + if ($this->collOrderProductTaxes instanceof Collection) { + $this->collOrderProductTaxes->clearIterator(); + } + $this->collOrderProductTaxes = null; $this->aOrder = null; } diff --git a/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php b/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php new file mode 100644 index 000000000..bcdcada7a --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php @@ -0,0 +1,1827 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderProductAttributeCombination instance. If + * obj is an instance of OrderProductAttributeCombination, delegates to + * equals(OrderProductAttributeCombination). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderProductAttributeCombination The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderProductAttributeCombination The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [order_product_id] column value. + * + * @return int + */ + public function getOrderProductId() + { + + return $this->order_product_id; + } + + /** + * Get the [attribute_title] column value. + * + * @return string + */ + public function getAttributeTitle() + { + + return $this->attribute_title; + } + + /** + * Get the [attribute_chapo] column value. + * + * @return string + */ + public function getAttributeChapo() + { + + return $this->attribute_chapo; + } + + /** + * Get the [attribute_description] column value. + * + * @return string + */ + public function getAttributeDescription() + { + + return $this->attribute_description; + } + + /** + * Get the [attribute_postscriptum] column value. + * + * @return string + */ + public function getAttributePostscriptum() + { + + return $this->attribute_postscriptum; + } + + /** + * Get the [attribute_av_title] column value. + * + * @return string + */ + public function getAttributeAvTitle() + { + + return $this->attribute_av_title; + } + + /** + * Get the [attribute_av_chapo] column value. + * + * @return string + */ + public function getAttributeAvChapo() + { + + return $this->attribute_av_chapo; + } + + /** + * Get the [attribute_av_description] column value. + * + * @return string + */ + public function getAttributeAvDescription() + { + + return $this->attribute_av_description; + } + + /** + * Get the [attribute_av_postscriptum] column value. + * + * @return string + */ + public function getAttributeAvPostscriptum() + { + + return $this->attribute_av_postscriptum; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [order_product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setOrderProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_product_id !== $v) { + $this->order_product_id = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID; + } + + if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) { + $this->aOrderProduct = null; + } + + + return $this; + } // setOrderProductId() + + /** + * Set the value of [attribute_title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_title !== $v) { + $this->attribute_title = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE; + } + + + return $this; + } // setAttributeTitle() + + /** + * Set the value of [attribute_chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_chapo !== $v) { + $this->attribute_chapo = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO; + } + + + return $this; + } // setAttributeChapo() + + /** + * Set the value of [attribute_description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_description !== $v) { + $this->attribute_description = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION; + } + + + return $this; + } // setAttributeDescription() + + /** + * Set the value of [attribute_postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributePostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_postscriptum !== $v) { + $this->attribute_postscriptum = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM; + } + + + return $this; + } // setAttributePostscriptum() + + /** + * Set the value of [attribute_av_title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_title !== $v) { + $this->attribute_av_title = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE; + } + + + return $this; + } // setAttributeAvTitle() + + /** + * Set the value of [attribute_av_chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_chapo !== $v) { + $this->attribute_av_chapo = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO; + } + + + return $this; + } // setAttributeAvChapo() + + /** + * Set the value of [attribute_av_description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_description !== $v) { + $this->attribute_av_description = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION; + } + + + return $this; + } // setAttributeAvDescription() + + /** + * Set the value of [attribute_av_postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_av_postscriptum !== $v) { + $this->attribute_av_postscriptum = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM; + } + + + return $this; + } // setAttributeAvPostscriptum() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeChapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributePostscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvChapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvPostscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductAttributeCombinationTableMap::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 ? 11 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 12; // 12 = OrderProductAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\OrderProductAttributeCombination object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) { + $this->aOrderProduct = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildOrderProductAttributeCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrderProduct = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see OrderProductAttributeCombination::setDeleted() + * @see OrderProductAttributeCombination::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildOrderProductAttributeCombinationQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderProductAttributeCombinationTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + OrderProductAttributeCombinationTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aOrderProduct !== null) { + if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) { + $affectedRows += $this->aOrderProduct->save($con); + } + $this->setOrderProduct($this->aOrderProduct); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductAttributeCombinationTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_TITLE'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_CHAPO'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_DESCRIPTION'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_POSTSCRIPTUM'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_TITLE'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_CHAPO'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_DESCRIPTION'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_POSTSCRIPTUM'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO order_product_attribute_combination (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'ORDER_PRODUCT_ID': + $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); + break; + case 'ATTRIBUTE_TITLE': + $stmt->bindValue($identifier, $this->attribute_title, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_CHAPO': + $stmt->bindValue($identifier, $this->attribute_chapo, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_DESCRIPTION': + $stmt->bindValue($identifier, $this->attribute_description, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->attribute_postscriptum, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_TITLE': + $stmt->bindValue($identifier, $this->attribute_av_title, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_CHAPO': + $stmt->bindValue($identifier, $this->attribute_av_chapo, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_DESCRIPTION': + $stmt->bindValue($identifier, $this->attribute_av_description, PDO::PARAM_STR); + break; + case 'ATTRIBUTE_AV_POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->attribute_av_postscriptum, PDO::PARAM_STR); + 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; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getOrderProductId(); + break; + case 2: + return $this->getAttributeTitle(); + break; + case 3: + return $this->getAttributeChapo(); + break; + case 4: + return $this->getAttributeDescription(); + break; + case 5: + return $this->getAttributePostscriptum(); + break; + case 6: + return $this->getAttributeAvTitle(); + break; + case 7: + return $this->getAttributeAvChapo(); + break; + case 8: + return $this->getAttributeAvDescription(); + break; + case 9: + return $this->getAttributeAvPostscriptum(); + break; + case 10: + return $this->getCreatedAt(); + break; + case 11: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['OrderProductAttributeCombination'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['OrderProductAttributeCombination'][$this->getPrimaryKey()] = true; + $keys = OrderProductAttributeCombinationTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getOrderProductId(), + $keys[2] => $this->getAttributeTitle(), + $keys[3] => $this->getAttributeChapo(), + $keys[4] => $this->getAttributeDescription(), + $keys[5] => $this->getAttributePostscriptum(), + $keys[6] => $this->getAttributeAvTitle(), + $keys[7] => $this->getAttributeAvChapo(), + $keys[8] => $this->getAttributeAvDescription(), + $keys[9] => $this->getAttributeAvPostscriptum(), + $keys[10] => $this->getCreatedAt(), + $keys[11] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aOrderProduct) { + $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setOrderProductId($value); + break; + case 2: + $this->setAttributeTitle($value); + break; + case 3: + $this->setAttributeChapo($value); + break; + case 4: + $this->setAttributeDescription($value); + break; + case 5: + $this->setAttributePostscriptum($value); + break; + case 6: + $this->setAttributeAvTitle($value); + break; + case 7: + $this->setAttributeAvChapo($value); + break; + case 8: + $this->setAttributeAvDescription($value); + break; + case 9: + $this->setAttributeAvPostscriptum($value); + break; + case 10: + $this->setCreatedAt($value); + break; + case 11: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = OrderProductAttributeCombinationTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setAttributeTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setAttributeChapo($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAttributeDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setAttributePostscriptum($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setAttributeAvTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setAttributeAvChapo($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setAttributeAvDescription($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setAttributeAvPostscriptum($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]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ID)) $criteria->add(OrderProductAttributeCombinationTableMap::ID, $this->id); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $this->order_product_id); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, $this->attribute_title); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $this->attribute_chapo); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $this->attribute_description); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM, $this->attribute_postscriptum); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $this->attribute_av_title); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $this->attribute_av_chapo); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $this->attribute_av_description); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $this->attribute_av_postscriptum); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::CREATED_AT)) $criteria->add(OrderProductAttributeCombinationTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::UPDATED_AT)) $criteria->add(OrderProductAttributeCombinationTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + $criteria->add(OrderProductAttributeCombinationTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\OrderProductAttributeCombination (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setOrderProductId($this->getOrderProductId()); + $copyObj->setAttributeTitle($this->getAttributeTitle()); + $copyObj->setAttributeChapo($this->getAttributeChapo()); + $copyObj->setAttributeDescription($this->getAttributeDescription()); + $copyObj->setAttributePostscriptum($this->getAttributePostscriptum()); + $copyObj->setAttributeAvTitle($this->getAttributeAvTitle()); + $copyObj->setAttributeAvChapo($this->getAttributeAvChapo()); + $copyObj->setAttributeAvDescription($this->getAttributeAvDescription()); + $copyObj->setAttributeAvPostscriptum($this->getAttributeAvPostscriptum()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderProductAttributeCombination Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildOrderProduct object. + * + * @param ChildOrderProduct $v + * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) + * @throws PropelException + */ + public function setOrderProduct(ChildOrderProduct $v = null) + { + if ($v === null) { + $this->setOrderProductId(NULL); + } else { + $this->setOrderProductId($v->getId()); + } + + $this->aOrderProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildOrderProduct object, it will not be re-added. + if ($v !== null) { + $v->addOrderProductAttributeCombination($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrderProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderProduct The associated ChildOrderProduct object. + * @throws PropelException + */ + public function getOrderProduct(ConnectionInterface $con = null) + { + if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { + $this->aOrderProduct = ChildOrderProductQuery::create()->findPk($this->order_product_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aOrderProduct->addOrderProductAttributeCombinations($this); + */ + } + + return $this->aOrderProduct; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->order_product_id = null; + $this->attribute_title = null; + $this->attribute_chapo = null; + $this->attribute_description = null; + $this->attribute_postscriptum = null; + $this->attribute_av_title = null; + $this->attribute_av_chapo = null; + $this->attribute_av_description = null; + $this->attribute_av_postscriptum = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aOrderProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(OrderProductAttributeCombinationTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildOrderProductAttributeCombination The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php new file mode 100644 index 000000000..886b75c5f --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php @@ -0,0 +1,897 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildOrderProductAttributeCombination|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = OrderProductAttributeCombinationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductAttributeCombination A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, ORDER_PRODUCT_ID, ATTRIBUTE_TITLE, ATTRIBUTE_CHAPO, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_POSTSCRIPTUM, ATTRIBUTE_AV_TITLE, ATTRIBUTE_AV_CHAPO, ATTRIBUTE_AV_DESCRIPTION, ATTRIBUTE_AV_POSTSCRIPTUM, CREATED_AT, UPDATED_AT FROM order_product_attribute_combination WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderProductAttributeCombination(); + $obj->hydrate($row); + OrderProductAttributeCombinationTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductAttributeCombination|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id 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 ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the order_product_id column + * + * Example usage: + * + * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 + * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) + * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 + * + * + * @see filterByOrderProduct() + * + * @param mixed $orderProductId 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 ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByOrderProductId($orderProductId = null, $comparison = null) + { + if (is_array($orderProductId)) { + $useMinMax = false; + if (isset($orderProductId['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderProductId['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison); + } + + /** + * Filter the query on the attribute_title column + * + * Example usage: + * + * $query->filterByAttributeTitle('fooValue'); // WHERE attribute_title = 'fooValue' + * $query->filterByAttributeTitle('%fooValue%'); // WHERE attribute_title LIKE '%fooValue%' + * + * + * @param string $attributeTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeTitle($attributeTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeTitle)) { + $attributeTitle = str_replace('*', '%', $attributeTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, $attributeTitle, $comparison); + } + + /** + * Filter the query on the attribute_chapo column + * + * Example usage: + * + * $query->filterByAttributeChapo('fooValue'); // WHERE attribute_chapo = 'fooValue' + * $query->filterByAttributeChapo('%fooValue%'); // WHERE attribute_chapo LIKE '%fooValue%' + * + * + * @param string $attributeChapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeChapo($attributeChapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeChapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeChapo)) { + $attributeChapo = str_replace('*', '%', $attributeChapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $attributeChapo, $comparison); + } + + /** + * Filter the query on the attribute_description column + * + * Example usage: + * + * $query->filterByAttributeDescription('fooValue'); // WHERE attribute_description = 'fooValue' + * $query->filterByAttributeDescription('%fooValue%'); // WHERE attribute_description LIKE '%fooValue%' + * + * + * @param string $attributeDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeDescription($attributeDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeDescription)) { + $attributeDescription = str_replace('*', '%', $attributeDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $attributeDescription, $comparison); + } + + /** + * Filter the query on the attribute_postscriptum column + * + * Example usage: + * + * $query->filterByAttributePostscriptum('fooValue'); // WHERE attribute_postscriptum = 'fooValue' + * $query->filterByAttributePostscriptum('%fooValue%'); // WHERE attribute_postscriptum LIKE '%fooValue%' + * + * + * @param string $attributePostscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributePostscriptum($attributePostscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributePostscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributePostscriptum)) { + $attributePostscriptum = str_replace('*', '%', $attributePostscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM, $attributePostscriptum, $comparison); + } + + /** + * Filter the query on the attribute_av_title column + * + * Example usage: + * + * $query->filterByAttributeAvTitle('fooValue'); // WHERE attribute_av_title = 'fooValue' + * $query->filterByAttributeAvTitle('%fooValue%'); // WHERE attribute_av_title LIKE '%fooValue%' + * + * + * @param string $attributeAvTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvTitle($attributeAvTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvTitle)) { + $attributeAvTitle = str_replace('*', '%', $attributeAvTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $attributeAvTitle, $comparison); + } + + /** + * Filter the query on the attribute_av_chapo column + * + * Example usage: + * + * $query->filterByAttributeAvChapo('fooValue'); // WHERE attribute_av_chapo = 'fooValue' + * $query->filterByAttributeAvChapo('%fooValue%'); // WHERE attribute_av_chapo LIKE '%fooValue%' + * + * + * @param string $attributeAvChapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvChapo($attributeAvChapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvChapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvChapo)) { + $attributeAvChapo = str_replace('*', '%', $attributeAvChapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $attributeAvChapo, $comparison); + } + + /** + * Filter the query on the attribute_av_description column + * + * Example usage: + * + * $query->filterByAttributeAvDescription('fooValue'); // WHERE attribute_av_description = 'fooValue' + * $query->filterByAttributeAvDescription('%fooValue%'); // WHERE attribute_av_description LIKE '%fooValue%' + * + * + * @param string $attributeAvDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvDescription($attributeAvDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvDescription)) { + $attributeAvDescription = str_replace('*', '%', $attributeAvDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $attributeAvDescription, $comparison); + } + + /** + * Filter the query on the attribute_av_postscriptum column + * + * Example usage: + * + * $query->filterByAttributeAvPostscriptum('fooValue'); // WHERE attribute_av_postscriptum = 'fooValue' + * $query->filterByAttributeAvPostscriptum('%fooValue%'); // WHERE attribute_av_postscriptum LIKE '%fooValue%' + * + * + * @param string $attributeAvPostscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvPostscriptum($attributeAvPostscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvPostscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvPostscriptum)) { + $attributeAvPostscriptum = str_replace('*', '%', $attributeAvPostscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $attributeAvPostscriptum, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * 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 ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * 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 ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProduct object + * + * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByOrderProduct($orderProduct, $comparison = null) + { + if ($orderProduct instanceof \Thelia\Model\OrderProduct) { + return $this + ->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); + } elseif ($orderProduct instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProduct relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProduct'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProduct'); + } + + return $this; + } + + /** + * Use the OrderProduct relation OrderProduct object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query + */ + public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); + } + + /** + * Exclude object from result + * + * @param ChildOrderProductAttributeCombination $orderProductAttributeCombination Object to remove from the list of results + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function prune($orderProductAttributeCombination = null) + { + if ($orderProductAttributeCombination) { + $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ID, $orderProductAttributeCombination->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the order_product_attribute_combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderProductAttributeCombinationTableMap::clearInstancePool(); + OrderProductAttributeCombinationTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderProductAttributeCombination or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderProductAttributeCombination object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + OrderProductAttributeCombinationTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderProductAttributeCombinationTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductAttributeCombinationTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductAttributeCombinationTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductAttributeCombinationTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductAttributeCombinationTableMap::CREATED_AT); + } + +} // OrderProductAttributeCombinationQuery diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php index b007c89e1..f28102dfb 100644 --- a/core/lib/Thelia/Model/Base/OrderProductQuery.php +++ b/core/lib/Thelia/Model/Base/OrderProductQuery.php @@ -24,12 +24,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildOrderProductQuery orderByOrderId($order = Criteria::ASC) Order by the order_id column * @method ChildOrderProductQuery orderByProductRef($order = Criteria::ASC) Order by the product_ref column + * @method ChildOrderProductQuery orderByProductSaleElementsRef($order = Criteria::ASC) Order by the product_sale_elements_ref column * @method ChildOrderProductQuery orderByTitle($order = Criteria::ASC) Order by the title column - * @method ChildOrderProductQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildOrderProductQuery orderByChapo($order = Criteria::ASC) Order by the chapo column + * @method ChildOrderProductQuery orderByDescription($order = Criteria::ASC) Order by the description column + * @method ChildOrderProductQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column * @method ChildOrderProductQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column * @method ChildOrderProductQuery orderByPrice($order = Criteria::ASC) Order by the price column - * @method ChildOrderProductQuery orderByTax($order = Criteria::ASC) Order by the tax column + * @method ChildOrderProductQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column + * @method ChildOrderProductQuery orderByWasNew($order = Criteria::ASC) Order by the was_new column + * @method ChildOrderProductQuery orderByWasInPromo($order = Criteria::ASC) Order by the was_in_promo column + * @method ChildOrderProductQuery orderByWeight($order = Criteria::ASC) Order by the weight column + * @method ChildOrderProductQuery orderByTaxRuleTitle($order = Criteria::ASC) Order by the tax_rule_title column + * @method ChildOrderProductQuery orderByTaxRuleDescription($order = Criteria::ASC) Order by the tax_rule_description column * @method ChildOrderProductQuery orderByParent($order = Criteria::ASC) Order by the parent column * @method ChildOrderProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildOrderProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -37,12 +44,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery groupById() Group by the id column * @method ChildOrderProductQuery groupByOrderId() Group by the order_id column * @method ChildOrderProductQuery groupByProductRef() Group by the product_ref column + * @method ChildOrderProductQuery groupByProductSaleElementsRef() Group by the product_sale_elements_ref column * @method ChildOrderProductQuery groupByTitle() Group by the title column - * @method ChildOrderProductQuery groupByDescription() Group by the description column * @method ChildOrderProductQuery groupByChapo() Group by the chapo column + * @method ChildOrderProductQuery groupByDescription() Group by the description column + * @method ChildOrderProductQuery groupByPostscriptum() Group by the postscriptum column * @method ChildOrderProductQuery groupByQuantity() Group by the quantity column * @method ChildOrderProductQuery groupByPrice() Group by the price column - * @method ChildOrderProductQuery groupByTax() Group by the tax column + * @method ChildOrderProductQuery groupByPromoPrice() Group by the promo_price column + * @method ChildOrderProductQuery groupByWasNew() Group by the was_new column + * @method ChildOrderProductQuery groupByWasInPromo() Group by the was_in_promo column + * @method ChildOrderProductQuery groupByWeight() Group by the weight column + * @method ChildOrderProductQuery groupByTaxRuleTitle() Group by the tax_rule_title column + * @method ChildOrderProductQuery groupByTaxRuleDescription() Group by the tax_rule_description column * @method ChildOrderProductQuery groupByParent() Group by the parent column * @method ChildOrderProductQuery groupByCreatedAt() Group by the created_at column * @method ChildOrderProductQuery groupByUpdatedAt() Group by the updated_at column @@ -55,9 +69,13 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation * @method ChildOrderProductQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation * - * @method ChildOrderProductQuery leftJoinOrderFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderFeature relation - * @method ChildOrderProductQuery rightJoinOrderFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderFeature relation - * @method ChildOrderProductQuery innerJoinOrderFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderFeature relation + * @method ChildOrderProductQuery leftJoinOrderProductAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductAttributeCombination relation + * @method ChildOrderProductQuery rightJoinOrderProductAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductAttributeCombination relation + * @method ChildOrderProductQuery innerJoinOrderProductAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductAttributeCombination relation + * + * @method ChildOrderProductQuery leftJoinOrderProductTax($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductTax relation + * @method ChildOrderProductQuery rightJoinOrderProductTax($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductTax relation + * @method ChildOrderProductQuery innerJoinOrderProductTax($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductTax relation * * @method ChildOrderProduct findOne(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query * @method ChildOrderProduct findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query, or a new ChildOrderProduct object populated from the query conditions when no match is found @@ -65,12 +83,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProduct findOneById(int $id) Return the first ChildOrderProduct filtered by the id column * @method ChildOrderProduct findOneByOrderId(int $order_id) Return the first ChildOrderProduct filtered by the order_id column * @method ChildOrderProduct findOneByProductRef(string $product_ref) Return the first ChildOrderProduct filtered by the product_ref column + * @method ChildOrderProduct findOneByProductSaleElementsRef(string $product_sale_elements_ref) Return the first ChildOrderProduct filtered by the product_sale_elements_ref column * @method ChildOrderProduct findOneByTitle(string $title) Return the first ChildOrderProduct filtered by the title column - * @method ChildOrderProduct findOneByDescription(string $description) Return the first ChildOrderProduct filtered by the description column * @method ChildOrderProduct findOneByChapo(string $chapo) Return the first ChildOrderProduct filtered by the chapo column + * @method ChildOrderProduct findOneByDescription(string $description) Return the first ChildOrderProduct filtered by the description column + * @method ChildOrderProduct findOneByPostscriptum(string $postscriptum) Return the first ChildOrderProduct filtered by the postscriptum column * @method ChildOrderProduct findOneByQuantity(double $quantity) Return the first ChildOrderProduct filtered by the quantity column * @method ChildOrderProduct findOneByPrice(double $price) Return the first ChildOrderProduct filtered by the price column - * @method ChildOrderProduct findOneByTax(double $tax) Return the first ChildOrderProduct filtered by the tax column + * @method ChildOrderProduct findOneByPromoPrice(string $promo_price) Return the first ChildOrderProduct filtered by the promo_price column + * @method ChildOrderProduct findOneByWasNew(int $was_new) Return the first ChildOrderProduct filtered by the was_new column + * @method ChildOrderProduct findOneByWasInPromo(int $was_in_promo) Return the first ChildOrderProduct filtered by the was_in_promo column + * @method ChildOrderProduct findOneByWeight(string $weight) Return the first ChildOrderProduct filtered by the weight column + * @method ChildOrderProduct findOneByTaxRuleTitle(string $tax_rule_title) Return the first ChildOrderProduct filtered by the tax_rule_title column + * @method ChildOrderProduct findOneByTaxRuleDescription(string $tax_rule_description) Return the first ChildOrderProduct filtered by the tax_rule_description column * @method ChildOrderProduct findOneByParent(int $parent) Return the first ChildOrderProduct filtered by the parent column * @method ChildOrderProduct findOneByCreatedAt(string $created_at) Return the first ChildOrderProduct filtered by the created_at column * @method ChildOrderProduct findOneByUpdatedAt(string $updated_at) Return the first ChildOrderProduct filtered by the updated_at column @@ -78,12 +103,19 @@ use Thelia\Model\Map\OrderProductTableMap; * @method array findById(int $id) Return ChildOrderProduct objects filtered by the id column * @method array findByOrderId(int $order_id) Return ChildOrderProduct objects filtered by the order_id column * @method array findByProductRef(string $product_ref) Return ChildOrderProduct objects filtered by the product_ref column + * @method array findByProductSaleElementsRef(string $product_sale_elements_ref) Return ChildOrderProduct objects filtered by the product_sale_elements_ref column * @method array findByTitle(string $title) Return ChildOrderProduct objects filtered by the title column - * @method array findByDescription(string $description) Return ChildOrderProduct objects filtered by the description column * @method array findByChapo(string $chapo) Return ChildOrderProduct objects filtered by the chapo column + * @method array findByDescription(string $description) Return ChildOrderProduct objects filtered by the description column + * @method array findByPostscriptum(string $postscriptum) Return ChildOrderProduct objects filtered by the postscriptum column * @method array findByQuantity(double $quantity) Return ChildOrderProduct objects filtered by the quantity column * @method array findByPrice(double $price) Return ChildOrderProduct objects filtered by the price column - * @method array findByTax(double $tax) Return ChildOrderProduct objects filtered by the tax column + * @method array findByPromoPrice(string $promo_price) Return ChildOrderProduct objects filtered by the promo_price column + * @method array findByWasNew(int $was_new) Return ChildOrderProduct objects filtered by the was_new column + * @method array findByWasInPromo(int $was_in_promo) Return ChildOrderProduct objects filtered by the was_in_promo column + * @method array findByWeight(string $weight) Return ChildOrderProduct objects filtered by the weight column + * @method array findByTaxRuleTitle(string $tax_rule_title) Return ChildOrderProduct objects filtered by the tax_rule_title column + * @method array findByTaxRuleDescription(string $tax_rule_description) Return ChildOrderProduct objects filtered by the tax_rule_description column * @method array findByParent(int $parent) Return ChildOrderProduct objects filtered by the parent column * @method array findByCreatedAt(string $created_at) Return ChildOrderProduct objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildOrderProduct objects filtered by the updated_at column @@ -175,7 +207,7 @@ abstract class OrderProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, TITLE, DESCRIPTION, CHAPO, QUANTITY, PRICE, TAX, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; + $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, TAX_RULE_TITLE, TAX_RULE_DESCRIPTION, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -377,6 +409,35 @@ abstract class OrderProductQuery extends ModelCriteria return $this->addUsingAlias(OrderProductTableMap::PRODUCT_REF, $productRef, $comparison); } + /** + * Filter the query on the product_sale_elements_ref column + * + * Example usage: + * + * $query->filterByProductSaleElementsRef('fooValue'); // WHERE product_sale_elements_ref = 'fooValue' + * $query->filterByProductSaleElementsRef('%fooValue%'); // WHERE product_sale_elements_ref LIKE '%fooValue%' + * + * + * @param string $productSaleElementsRef The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByProductSaleElementsRef($productSaleElementsRef = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($productSaleElementsRef)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $productSaleElementsRef)) { + $productSaleElementsRef = str_replace('*', '%', $productSaleElementsRef); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $productSaleElementsRef, $comparison); + } + /** * Filter the query on the title column * @@ -406,6 +467,35 @@ abstract class OrderProductQuery extends ModelCriteria return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison); } + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison); + } + /** * Filter the query on the description column * @@ -436,32 +526,32 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query on the chapo column + * Filter the query on the postscriptum column * * Example usage: * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' * * - * @param string $chapo The value to use as filter. + * @param string $postscriptum The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function filterByChapo($chapo = null, $comparison = null) + public function filterByPostscriptum($postscriptum = null, $comparison = null) { if (null === $comparison) { - if (is_array($chapo)) { + if (is_array($postscriptum)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(OrderProductTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** @@ -547,16 +637,45 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query on the tax column + * Filter the query on the promo_price column * * Example usage: * - * $query->filterByTax(1234); // WHERE tax = 1234 - * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34) - * $query->filterByTax(array('min' => 12)); // WHERE tax > 12 + * $query->filterByPromoPrice('fooValue'); // WHERE promo_price = 'fooValue' + * $query->filterByPromoPrice('%fooValue%'); // WHERE promo_price LIKE '%fooValue%' * * - * @param mixed $tax The value to use as filter. + * @param string $promoPrice The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByPromoPrice($promoPrice = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($promoPrice)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $promoPrice)) { + $promoPrice = str_replace('*', '%', $promoPrice); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PROMO_PRICE, $promoPrice, $comparison); + } + + /** + * Filter the query on the was_new column + * + * Example usage: + * + * $query->filterByWasNew(1234); // WHERE was_new = 1234 + * $query->filterByWasNew(array(12, 34)); // WHERE was_new IN (12, 34) + * $query->filterByWasNew(array('min' => 12)); // WHERE was_new > 12 + * + * + * @param mixed $wasNew 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. @@ -564,16 +683,16 @@ abstract class OrderProductQuery extends ModelCriteria * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function filterByTax($tax = null, $comparison = null) + public function filterByWasNew($wasNew = null, $comparison = null) { - if (is_array($tax)) { + if (is_array($wasNew)) { $useMinMax = false; - if (isset($tax['min'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL); + if (isset($wasNew['min'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($tax['max'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL); + if (isset($wasNew['max'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -584,7 +703,135 @@ abstract class OrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison); + return $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew, $comparison); + } + + /** + * Filter the query on the was_in_promo column + * + * Example usage: + * + * $query->filterByWasInPromo(1234); // WHERE was_in_promo = 1234 + * $query->filterByWasInPromo(array(12, 34)); // WHERE was_in_promo IN (12, 34) + * $query->filterByWasInPromo(array('min' => 12)); // WHERE was_in_promo > 12 + * + * + * @param mixed $wasInPromo 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByWasInPromo($wasInPromo = null, $comparison = null) + { + if (is_array($wasInPromo)) { + $useMinMax = false; + if (isset($wasInPromo['min'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($wasInPromo['max'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo, $comparison); + } + + /** + * Filter the query on the weight column + * + * Example usage: + * + * $query->filterByWeight('fooValue'); // WHERE weight = 'fooValue' + * $query->filterByWeight('%fooValue%'); // WHERE weight LIKE '%fooValue%' + * + * + * @param string $weight The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByWeight($weight = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($weight)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $weight)) { + $weight = str_replace('*', '%', $weight); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::WEIGHT, $weight, $comparison); + } + + /** + * Filter the query on the tax_rule_title column + * + * Example usage: + * + * $query->filterByTaxRuleTitle('fooValue'); // WHERE tax_rule_title = 'fooValue' + * $query->filterByTaxRuleTitle('%fooValue%'); // WHERE tax_rule_title LIKE '%fooValue%' + * + * + * @param string $taxRuleTitle The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByTaxRuleTitle($taxRuleTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($taxRuleTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $taxRuleTitle)) { + $taxRuleTitle = str_replace('*', '%', $taxRuleTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_TITLE, $taxRuleTitle, $comparison); + } + + /** + * Filter the query on the tax_rule_description column + * + * Example usage: + * + * $query->filterByTaxRuleDescription('fooValue'); // WHERE tax_rule_description = 'fooValue' + * $query->filterByTaxRuleDescription('%fooValue%'); // WHERE tax_rule_description LIKE '%fooValue%' + * + * + * @param string $taxRuleDescription The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByTaxRuleDescription($taxRuleDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($taxRuleDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $taxRuleDescription)) { + $taxRuleDescription = str_replace('*', '%', $taxRuleDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_DESCRIPTION, $taxRuleDescription, $comparison); } /** @@ -790,40 +1037,40 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\OrderFeature object + * Filter the query by a related \Thelia\Model\OrderProductAttributeCombination object * - * @param \Thelia\Model\OrderFeature|ObjectCollection $orderFeature the related object to use as filter + * @param \Thelia\Model\OrderProductAttributeCombination|ObjectCollection $orderProductAttributeCombination the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function filterByOrderFeature($orderFeature, $comparison = null) + public function filterByOrderProductAttributeCombination($orderProductAttributeCombination, $comparison = null) { - if ($orderFeature instanceof \Thelia\Model\OrderFeature) { + if ($orderProductAttributeCombination instanceof \Thelia\Model\OrderProductAttributeCombination) { return $this - ->addUsingAlias(OrderProductTableMap::ID, $orderFeature->getOrderProductId(), $comparison); - } elseif ($orderFeature instanceof ObjectCollection) { + ->addUsingAlias(OrderProductTableMap::ID, $orderProductAttributeCombination->getOrderProductId(), $comparison); + } elseif ($orderProductAttributeCombination instanceof ObjectCollection) { return $this - ->useOrderFeatureQuery() - ->filterByPrimaryKeys($orderFeature->getPrimaryKeys()) + ->useOrderProductAttributeCombinationQuery() + ->filterByPrimaryKeys($orderProductAttributeCombination->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderFeature() only accepts arguments of type \Thelia\Model\OrderFeature or Collection'); + throw new PropelException('filterByOrderProductAttributeCombination() only accepts arguments of type \Thelia\Model\OrderProductAttributeCombination or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderFeature relation + * Adds a JOIN clause to the query using the OrderProductAttributeCombination relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinOrderProductAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderFeature'); + $relationMap = $tableMap->getRelation('OrderProductAttributeCombination'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -838,14 +1085,14 @@ abstract class OrderProductQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderFeature'); + $this->addJoinObject($join, 'OrderProductAttributeCombination'); } return $this; } /** - * Use the OrderFeature relation OrderFeature object + * Use the OrderProductAttributeCombination relation OrderProductAttributeCombination object * * @see useQuery() * @@ -853,13 +1100,86 @@ abstract class OrderProductQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\OrderFeatureQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\OrderProductAttributeCombinationQuery A secondary query class using the current class as primary query */ - public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useOrderProductAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery'); + ->joinOrderProductAttributeCombination($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProductAttributeCombination', '\Thelia\Model\OrderProductAttributeCombinationQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProductTax object + * + * @param \Thelia\Model\OrderProductTax|ObjectCollection $orderProductTax the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByOrderProductTax($orderProductTax, $comparison = null) + { + if ($orderProductTax instanceof \Thelia\Model\OrderProductTax) { + return $this + ->addUsingAlias(OrderProductTableMap::ID, $orderProductTax->getOrderProductId(), $comparison); + } elseif ($orderProductTax instanceof ObjectCollection) { + return $this + ->useOrderProductTaxQuery() + ->filterByPrimaryKeys($orderProductTax->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderProductTax() only accepts arguments of type \Thelia\Model\OrderProductTax or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProductTax relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function joinOrderProductTax($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProductTax'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProductTax'); + } + + return $this; + } + + /** + * Use the OrderProductTax relation OrderProductTax object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductTaxQuery A secondary query class using the current class as primary query + */ + public function useOrderProductTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProductTax($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProductTax', '\Thelia\Model\OrderProductTaxQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProductTax.php b/core/lib/Thelia/Model/Base/OrderProductTax.php new file mode 100644 index 000000000..91d3492e1 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductTax.php @@ -0,0 +1,1595 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderProductTax instance. If + * obj is an instance of OrderProductTax, delegates to + * equals(OrderProductTax). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderProductTax The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderProductTax The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [order_product_id] column value. + * + * @return int + */ + public function getOrderProductId() + { + + return $this->order_product_id; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [amount] column value. + * + * @return double + */ + public function getAmount() + { + + return $this->amount; + } + + /** + * Get the [promo_amount] column value. + * + * @return double + */ + public function getPromoAmount() + { + + return $this->promo_amount; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [order_product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setOrderProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_product_id !== $v) { + $this->order_product_id = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::ORDER_PRODUCT_ID; + } + + if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) { + $this->aOrderProduct = null; + } + + + return $this; + } // setOrderProductId() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [amount] column. + * + * @param double $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setAmount($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->amount !== $v) { + $this->amount = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::AMOUNT; + } + + + return $this; + } // setAmount() + + /** + * Set the value of [promo_amount] column. + * + * @param double $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setPromoAmount($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->promo_amount !== $v) { + $this->promo_amount = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::PROMO_AMOUNT; + } + + + return $this; + } // setPromoAmount() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderProductTaxTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderProductTaxTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductTaxTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductTaxTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTaxTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTaxTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTaxTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->amount = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTaxTableMap::translateFieldName('PromoAmount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo_amount = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTaxTableMap::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 ? 7 + $startcol : OrderProductTaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 8; // 8 = OrderProductTaxTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\OrderProductTax object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) { + $this->aOrderProduct = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildOrderProductTaxQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrderProduct = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see OrderProductTax::setDeleted() + * @see OrderProductTax::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildOrderProductTaxQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + OrderProductTaxTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aOrderProduct !== null) { + if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) { + $affectedRows += $this->aOrderProduct->save($con); + } + $this->setOrderProduct($this->aOrderProduct); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderProductTaxTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductTaxTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderProductTaxTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::ORDER_PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'AMOUNT'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::PROMO_AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'PROMO_AMOUNT'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO order_product_tax (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'ORDER_PRODUCT_ID': + $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'AMOUNT': + $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); + break; + case 'PROMO_AMOUNT': + $stmt->bindValue($identifier, $this->promo_amount, PDO::PARAM_STR); + 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; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductTaxTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getOrderProductId(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getAmount(); + break; + case 5: + return $this->getPromoAmount(); + break; + case 6: + return $this->getCreatedAt(); + break; + case 7: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['OrderProductTax'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['OrderProductTax'][$this->getPrimaryKey()] = true; + $keys = OrderProductTaxTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getOrderProductId(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getAmount(), + $keys[5] => $this->getPromoAmount(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aOrderProduct) { + $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductTaxTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setOrderProductId($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setAmount($value); + break; + case 5: + $this->setPromoAmount($value); + break; + case 6: + $this->setCreatedAt($value); + break; + case 7: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = OrderProductTaxTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAmount($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPromoAmount($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]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(OrderProductTaxTableMap::DATABASE_NAME); + + if ($this->isColumnModified(OrderProductTaxTableMap::ID)) $criteria->add(OrderProductTaxTableMap::ID, $this->id); + if ($this->isColumnModified(OrderProductTaxTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $this->order_product_id); + if ($this->isColumnModified(OrderProductTaxTableMap::TITLE)) $criteria->add(OrderProductTaxTableMap::TITLE, $this->title); + if ($this->isColumnModified(OrderProductTaxTableMap::DESCRIPTION)) $criteria->add(OrderProductTaxTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(OrderProductTaxTableMap::AMOUNT)) $criteria->add(OrderProductTaxTableMap::AMOUNT, $this->amount); + if ($this->isColumnModified(OrderProductTaxTableMap::PROMO_AMOUNT)) $criteria->add(OrderProductTaxTableMap::PROMO_AMOUNT, $this->promo_amount); + if ($this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) $criteria->add(OrderProductTaxTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) $criteria->add(OrderProductTaxTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(OrderProductTaxTableMap::DATABASE_NAME); + $criteria->add(OrderProductTaxTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\OrderProductTax (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setOrderProductId($this->getOrderProductId()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setAmount($this->getAmount()); + $copyObj->setPromoAmount($this->getPromoAmount()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderProductTax Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildOrderProduct object. + * + * @param ChildOrderProduct $v + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + * @throws PropelException + */ + public function setOrderProduct(ChildOrderProduct $v = null) + { + if ($v === null) { + $this->setOrderProductId(NULL); + } else { + $this->setOrderProductId($v->getId()); + } + + $this->aOrderProduct = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildOrderProduct object, it will not be re-added. + if ($v !== null) { + $v->addOrderProductTax($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrderProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderProduct The associated ChildOrderProduct object. + * @throws PropelException + */ + public function getOrderProduct(ConnectionInterface $con = null) + { + if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { + $this->aOrderProduct = ChildOrderProductQuery::create()->findPk($this->order_product_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aOrderProduct->addOrderProductTaxes($this); + */ + } + + return $this->aOrderProduct; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->order_product_id = null; + $this->title = null; + $this->description = null; + $this->amount = null; + $this->promo_amount = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aOrderProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(OrderProductTaxTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildOrderProductTax The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderProductTaxTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php b/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php new file mode 100644 index 000000000..d0153d0cd --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php @@ -0,0 +1,789 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildOrderProductTax|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = OrderProductTaxTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductTax A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, ORDER_PRODUCT_ID, TITLE, DESCRIPTION, AMOUNT, PROMO_AMOUNT, CREATED_AT, UPDATED_AT FROM order_product_tax WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderProductTax(); + $obj->hydrate($row); + OrderProductTaxTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProductTax|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(OrderProductTaxTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(OrderProductTaxTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id 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 ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the order_product_id column + * + * Example usage: + * + * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 + * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) + * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 + * + * + * @see filterByOrderProduct() + * + * @param mixed $orderProductId 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 ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByOrderProductId($orderProductId = null, $comparison = null) + { + if (is_array($orderProductId)) { + $useMinMax = false; + if (isset($orderProductId['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderProductId['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the amount column + * + * Example usage: + * + * $query->filterByAmount(1234); // WHERE amount = 1234 + * $query->filterByAmount(array(12, 34)); // WHERE amount IN (12, 34) + * $query->filterByAmount(array('min' => 12)); // WHERE amount > 12 + * + * + * @param mixed $amount 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 ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByAmount($amount = null, $comparison = null) + { + if (is_array($amount)) { + $useMinMax = false; + if (isset($amount['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::AMOUNT, $amount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($amount['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::AMOUNT, $amount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::AMOUNT, $amount, $comparison); + } + + /** + * Filter the query on the promo_amount column + * + * Example usage: + * + * $query->filterByPromoAmount(1234); // WHERE promo_amount = 1234 + * $query->filterByPromoAmount(array(12, 34)); // WHERE promo_amount IN (12, 34) + * $query->filterByPromoAmount(array('min' => 12)); // WHERE promo_amount > 12 + * + * + * @param mixed $promoAmount 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 ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByPromoAmount($promoAmount = null, $comparison = null) + { + if (is_array($promoAmount)) { + $useMinMax = false; + if (isset($promoAmount['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::PROMO_AMOUNT, $promoAmount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($promoAmount['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::PROMO_AMOUNT, $promoAmount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::PROMO_AMOUNT, $promoAmount, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * 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 ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * 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 ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProduct object + * + * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByOrderProduct($orderProduct, $comparison = null) + { + if ($orderProduct instanceof \Thelia\Model\OrderProduct) { + return $this + ->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); + } elseif ($orderProduct instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderProductTaxTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProduct relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProduct'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProduct'); + } + + return $this; + } + + /** + * Use the OrderProduct relation OrderProduct object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query + */ + public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); + } + + /** + * Exclude object from result + * + * @param ChildOrderProductTax $orderProductTax Object to remove from the list of results + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function prune($orderProductTax = null) + { + if ($orderProductTax) { + $this->addUsingAlias(OrderProductTaxTableMap::ID, $orderProductTax->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the order_product_tax table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderProductTaxTableMap::clearInstancePool(); + OrderProductTaxTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderProductTax or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderProductTax object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderProductTaxTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + OrderProductTaxTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderProductTaxTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductTaxTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductTaxTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductTaxTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductTaxTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductTaxTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductTaxTableMap::CREATED_AT); + } + +} // OrderProductTaxQuery diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php index 5771072f2..4a5e49436 100644 --- a/core/lib/Thelia/Model/Base/OrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -171,7 +171,7 @@ abstract class OrderStatus implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -229,8 +229,8 @@ abstract class OrderStatus implements ActiveRecordInterface * obj is an instance of OrderStatus, delegates to * equals(OrderStatus). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -269,8 +269,6 @@ abstract class OrderStatus implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -281,6 +279,7 @@ abstract class OrderStatus implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -291,7 +290,10 @@ abstract class OrderStatus implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -348,7 +350,9 @@ abstract class OrderStatus implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -421,7 +425,7 @@ abstract class OrderStatus implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -441,7 +445,7 @@ abstract class OrderStatus implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -993,8 +997,7 @@ abstract class OrderStatus implements ActiveRecordInterface $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php index 2946cc55b..d9f7f3b52 100644 --- a/core/lib/Thelia/Model/Base/OrderStatusI18n.php +++ b/core/lib/Thelia/Model/Base/OrderStatusI18n.php @@ -158,7 +158,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class OrderStatusI18n implements ActiveRecordInterface * obj is an instance of OrderStatusI18n, delegates to * equals(OrderStatusI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class OrderStatusI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class OrderStatusI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class OrderStatusI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 9ec203fec..77824575c 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -411,7 +411,7 @@ abstract class Product implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -469,8 +469,8 @@ abstract class Product implements ActiveRecordInterface * obj is an instance of Product, delegates to * equals(Product). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -509,8 +509,6 @@ abstract class Product implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -521,6 +519,7 @@ abstract class Product implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -531,7 +530,10 @@ abstract class Product implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -588,7 +590,9 @@ abstract class Product implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -705,7 +709,7 @@ abstract class Product implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -725,7 +729,7 @@ abstract class Product implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -756,7 +760,7 @@ abstract class Product implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1870,8 +1874,7 @@ abstract class Product implements ActiveRecordInterface $keys[10] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductAssociatedContent.php b/core/lib/Thelia/Model/Base/ProductAssociatedContent.php index bbc97d5d1..764a7370c 100644 --- a/core/lib/Thelia/Model/Base/ProductAssociatedContent.php +++ b/core/lib/Thelia/Model/Base/ProductAssociatedContent.php @@ -154,7 +154,7 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -212,8 +212,8 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface * obj is an instance of ProductAssociatedContent, delegates to * equals(ProductAssociatedContent). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -252,8 +252,6 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -264,6 +262,7 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -274,7 +273,10 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -331,7 +333,9 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -426,7 +430,7 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -446,7 +450,7 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1063,8 +1067,7 @@ abstract class ProductAssociatedContent implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php index 2c6db3184..2e00db24a 100644 --- a/core/lib/Thelia/Model/Base/ProductCategory.php +++ b/core/lib/Thelia/Model/Base/ProductCategory.php @@ -148,7 +148,7 @@ abstract class ProductCategory implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -206,8 +206,8 @@ abstract class ProductCategory implements ActiveRecordInterface * obj is an instance of ProductCategory, delegates to * equals(ProductCategory). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -246,8 +246,6 @@ abstract class ProductCategory implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -258,6 +256,7 @@ abstract class ProductCategory implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -268,7 +267,10 @@ abstract class ProductCategory implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -325,7 +327,9 @@ abstract class ProductCategory implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -409,7 +413,7 @@ abstract class ProductCategory implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -429,7 +433,7 @@ abstract class ProductCategory implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1009,8 +1013,7 @@ abstract class ProductCategory implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductDocument.php b/core/lib/Thelia/Model/Base/ProductDocument.php index 4223679c1..507539f45 100644 --- a/core/lib/Thelia/Model/Base/ProductDocument.php +++ b/core/lib/Thelia/Model/Base/ProductDocument.php @@ -176,7 +176,7 @@ abstract class ProductDocument implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class ProductDocument implements ActiveRecordInterface * obj is an instance of ProductDocument, delegates to * equals(ProductDocument). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class ProductDocument implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class ProductDocument implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class ProductDocument implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class ProductDocument implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class ProductDocument implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class ProductDocument implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class ProductDocument implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php index 1a6017966..2dff23586 100644 --- a/core/lib/Thelia/Model/Base/ProductDocumentI18n.php +++ b/core/lib/Thelia/Model/Base/ProductDocumentI18n.php @@ -158,7 +158,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface * obj is an instance of ProductDocumentI18n, delegates to * equals(ProductDocumentI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ProductDocumentI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php index 3ef14e787..cdab7349d 100644 --- a/core/lib/Thelia/Model/Base/ProductI18n.php +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -158,7 +158,7 @@ abstract class ProductI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ProductI18n implements ActiveRecordInterface * obj is an instance of ProductI18n, delegates to * equals(ProductI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ProductI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ProductI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ProductI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ProductI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ProductI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductImage.php b/core/lib/Thelia/Model/Base/ProductImage.php index a54d22cd0..873aa0ec7 100644 --- a/core/lib/Thelia/Model/Base/ProductImage.php +++ b/core/lib/Thelia/Model/Base/ProductImage.php @@ -176,7 +176,7 @@ abstract class ProductImage implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -234,8 +234,8 @@ abstract class ProductImage implements ActiveRecordInterface * obj is an instance of ProductImage, delegates to * equals(ProductImage). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -274,8 +274,6 @@ abstract class ProductImage implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -286,6 +284,7 @@ abstract class ProductImage implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -296,7 +295,10 @@ abstract class ProductImage implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -353,7 +355,9 @@ abstract class ProductImage implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -448,7 +452,7 @@ abstract class ProductImage implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -468,7 +472,7 @@ abstract class ProductImage implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1089,8 +1093,7 @@ abstract class ProductImage implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductImageI18n.php b/core/lib/Thelia/Model/Base/ProductImageI18n.php index 679ded79c..76f9b38a9 100644 --- a/core/lib/Thelia/Model/Base/ProductImageI18n.php +++ b/core/lib/Thelia/Model/Base/ProductImageI18n.php @@ -158,7 +158,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ProductImageI18n implements ActiveRecordInterface * obj is an instance of ProductImageI18n, delegates to * equals(ProductImageI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ProductImageI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ProductImageI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ProductImageI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ProductImageI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductPrice.php b/core/lib/Thelia/Model/Base/ProductPrice.php index e92ca2cfa..dc177ad1b 100644 --- a/core/lib/Thelia/Model/Base/ProductPrice.php +++ b/core/lib/Thelia/Model/Base/ProductPrice.php @@ -154,7 +154,7 @@ abstract class ProductPrice implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -212,8 +212,8 @@ abstract class ProductPrice implements ActiveRecordInterface * obj is an instance of ProductPrice, delegates to * equals(ProductPrice). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -252,8 +252,6 @@ abstract class ProductPrice implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -264,6 +262,7 @@ abstract class ProductPrice implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -274,7 +273,10 @@ abstract class ProductPrice implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -331,7 +333,9 @@ abstract class ProductPrice implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -426,7 +430,7 @@ abstract class ProductPrice implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -446,7 +450,7 @@ abstract class ProductPrice implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1052,8 +1056,7 @@ abstract class ProductPrice implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ProductSaleElements.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php index fa887dc8a..e54b13155 100644 --- a/core/lib/Thelia/Model/Base/ProductSaleElements.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php @@ -103,10 +103,18 @@ abstract class ProductSaleElements implements ActiveRecordInterface /** * The value for the weight field. + * Note: this column has a database default value of: 0 * @var double */ protected $weight; + /** + * The value for the is_default field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $is_default; + /** * The value for the created_at field. * @var string @@ -178,6 +186,8 @@ abstract class ProductSaleElements implements ActiveRecordInterface { $this->promo = 0; $this->newness = 0; + $this->weight = 0; + $this->is_default = false; } /** @@ -224,7 +234,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -282,8 +292,8 @@ abstract class ProductSaleElements implements ActiveRecordInterface * obj is an instance of ProductSaleElements, delegates to * equals(ProductSaleElements). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -322,8 +332,6 @@ abstract class ProductSaleElements implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -334,6 +342,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -344,7 +353,10 @@ abstract class ProductSaleElements implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -401,7 +413,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -513,6 +527,17 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this->weight; } + /** + * Get the [is_default] column value. + * + * @return boolean + */ + public function getIsDefault() + { + + return $this->is_default; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -529,7 +554,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -549,7 +574,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -704,6 +729,35 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this; } // setWeight() + /** + * Sets the value of the [is_default] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) + */ + public function setIsDefault($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_default !== $v) { + $this->is_default = $v; + $this->modifiedColumns[] = ProductSaleElementsTableMap::IS_DEFAULT; + } + + + return $this; + } // setIsDefault() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -764,6 +818,14 @@ abstract class ProductSaleElements implements ActiveRecordInterface return false; } + if ($this->weight !== 0) { + return false; + } + + if ($this->is_default !== false) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -812,13 +874,16 @@ abstract class ProductSaleElements implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; $this->weight = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_default = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::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 ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -831,7 +896,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 9; // 9 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 10; // 10 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $e); @@ -1145,6 +1210,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) { $modifiedColumns[':p' . $index++] = 'WEIGHT'; } + if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'IS_DEFAULT'; + } if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1183,6 +1251,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface case 'WEIGHT': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; + case 'IS_DEFAULT': + $stmt->bindValue($identifier, (int) $this->is_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; @@ -1273,9 +1344,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this->getWeight(); break; case 7: - return $this->getCreatedAt(); + return $this->getIsDefault(); break; case 8: + return $this->getCreatedAt(); + break; + case 9: return $this->getUpdatedAt(); break; default: @@ -1314,12 +1388,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface $keys[4] => $this->getPromo(), $keys[5] => $this->getNewness(), $keys[6] => $this->getWeight(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), + $keys[7] => $this->getIsDefault(), + $keys[8] => $this->getCreatedAt(), + $keys[9] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } @@ -1392,9 +1466,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->setWeight($value); break; case 7: - $this->setCreatedAt($value); + $this->setIsDefault($value); break; case 8: + $this->setCreatedAt($value); + break; + case 9: $this->setUpdatedAt($value); break; } // switch() @@ -1428,8 +1505,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface if (array_key_exists($keys[4], $arr)) $this->setPromo($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setNewness($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setWeight($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[7], $arr)) $this->setIsDefault($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); } /** @@ -1448,6 +1526,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($this->isColumnModified(ProductSaleElementsTableMap::PROMO)) $criteria->add(ProductSaleElementsTableMap::PROMO, $this->promo); if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) $criteria->add(ProductSaleElementsTableMap::NEWNESS, $this->newness); if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) $criteria->add(ProductSaleElementsTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) $criteria->add(ProductSaleElementsTableMap::IS_DEFAULT, $this->is_default); if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) $criteria->add(ProductSaleElementsTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) $criteria->add(ProductSaleElementsTableMap::UPDATED_AT, $this->updated_at); @@ -1519,6 +1598,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $copyObj->setPromo($this->getPromo()); $copyObj->setNewness($this->getNewness()); $copyObj->setWeight($this->getWeight()); + $copyObj->setIsDefault($this->getIsDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2445,6 +2525,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->promo = null; $this->newness = null; $this->weight = null; + $this->is_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php index 6e9068002..c8201ed0b 100644 --- a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php @@ -28,6 +28,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElementsQuery orderByPromo($order = Criteria::ASC) Order by the promo column * @method ChildProductSaleElementsQuery orderByNewness($order = Criteria::ASC) Order by the newness column * @method ChildProductSaleElementsQuery orderByWeight($order = Criteria::ASC) Order by the weight column + * @method ChildProductSaleElementsQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column * @method ChildProductSaleElementsQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductSaleElementsQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -38,6 +39,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElementsQuery groupByPromo() Group by the promo column * @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column * @method ChildProductSaleElementsQuery groupByWeight() Group by the weight column + * @method ChildProductSaleElementsQuery groupByIsDefault() Group by the is_default column * @method ChildProductSaleElementsQuery groupByCreatedAt() Group by the created_at column * @method ChildProductSaleElementsQuery groupByUpdatedAt() Group by the updated_at column * @@ -71,6 +73,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElements findOneByPromo(int $promo) Return the first ChildProductSaleElements filtered by the promo column * @method ChildProductSaleElements findOneByNewness(int $newness) Return the first ChildProductSaleElements filtered by the newness column * @method ChildProductSaleElements findOneByWeight(double $weight) Return the first ChildProductSaleElements filtered by the weight column + * @method ChildProductSaleElements findOneByIsDefault(boolean $is_default) Return the first ChildProductSaleElements filtered by the is_default column * @method ChildProductSaleElements findOneByCreatedAt(string $created_at) Return the first ChildProductSaleElements filtered by the created_at column * @method ChildProductSaleElements findOneByUpdatedAt(string $updated_at) Return the first ChildProductSaleElements filtered by the updated_at column * @@ -81,6 +84,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method array findByPromo(int $promo) Return ChildProductSaleElements objects filtered by the promo column * @method array findByNewness(int $newness) Return ChildProductSaleElements objects filtered by the newness column * @method array findByWeight(double $weight) Return ChildProductSaleElements objects filtered by the weight column + * @method array findByIsDefault(boolean $is_default) Return ChildProductSaleElements objects filtered by the is_default column * @method array findByCreatedAt(string $created_at) Return ChildProductSaleElements objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProductSaleElements objects filtered by the updated_at column * @@ -171,7 +175,7 @@ abstract class ProductSaleElementsQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0'; + $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -537,6 +541,33 @@ abstract class ProductSaleElementsQuery extends ModelCriteria return $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight, $comparison); } + /** + * Filter the query on the is_default column + * + * Example usage: + * + * $query->filterByIsDefault(true); // WHERE is_default = true + * $query->filterByIsDefault('yes'); // WHERE is_default = true + * + * + * @param boolean|string $isDefault The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductSaleElementsQuery The current query, for fluid interface + */ + public function filterByIsDefault($isDefault = null, $comparison = null) + { + if (is_string($isDefault)) { + $is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(ProductSaleElementsTableMap::IS_DEFAULT, $isDefault, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/ProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php index a5d22e498..f4327e4f1 100644 --- a/core/lib/Thelia/Model/Base/ProductVersion.php +++ b/core/lib/Thelia/Model/Base/ProductVersion.php @@ -192,7 +192,7 @@ abstract class ProductVersion implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -250,8 +250,8 @@ abstract class ProductVersion implements ActiveRecordInterface * obj is an instance of ProductVersion, delegates to * equals(ProductVersion). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -290,8 +290,6 @@ abstract class ProductVersion implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -302,6 +300,7 @@ abstract class ProductVersion implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -312,7 +311,10 @@ abstract class ProductVersion implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -369,7 +371,9 @@ abstract class ProductVersion implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -486,7 +490,7 @@ abstract class ProductVersion implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -506,7 +510,7 @@ abstract class ProductVersion implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -537,7 +541,7 @@ abstract class ProductVersion implements ActiveRecordInterface if ($format === null) { return $this->version_created_at; } else { - return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + return $this->version_created_at instanceof \DateTime ? $this->version_created_at->format($format) : null; } } @@ -1309,8 +1313,7 @@ abstract class ProductVersion implements ActiveRecordInterface $keys[10] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php index 5a51bdc29..59bb2766a 100644 --- a/core/lib/Thelia/Model/Base/Resource.php +++ b/core/lib/Thelia/Model/Base/Resource.php @@ -184,7 +184,7 @@ abstract class Resource implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -242,8 +242,8 @@ abstract class Resource implements ActiveRecordInterface * obj is an instance of Resource, delegates to * equals(Resource). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -282,8 +282,6 @@ abstract class Resource implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -294,6 +292,7 @@ abstract class Resource implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -304,7 +303,10 @@ abstract class Resource implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -361,7 +363,9 @@ abstract class Resource implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -434,7 +438,7 @@ abstract class Resource implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -454,7 +458,7 @@ abstract class Resource implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1034,8 +1038,7 @@ abstract class Resource implements ActiveRecordInterface $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php index ac9ca106f..bd1104a90 100644 --- a/core/lib/Thelia/Model/Base/ResourceI18n.php +++ b/core/lib/Thelia/Model/Base/ResourceI18n.php @@ -158,7 +158,7 @@ abstract class ResourceI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -216,8 +216,8 @@ abstract class ResourceI18n implements ActiveRecordInterface * obj is an instance of ResourceI18n, delegates to * equals(ResourceI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -256,8 +256,6 @@ abstract class ResourceI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -268,6 +266,7 @@ abstract class ResourceI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -278,7 +277,10 @@ abstract class ResourceI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -335,7 +337,9 @@ abstract class ResourceI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -1010,8 +1014,7 @@ abstract class ResourceI18n implements ActiveRecordInterface $keys[5] => $this->getPostscriptum(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/RewritingArgument.php b/core/lib/Thelia/Model/Base/RewritingArgument.php index 45f26c24f..e34778574 100644 --- a/core/lib/Thelia/Model/Base/RewritingArgument.php +++ b/core/lib/Thelia/Model/Base/RewritingArgument.php @@ -141,7 +141,7 @@ abstract class RewritingArgument implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -199,8 +199,8 @@ abstract class RewritingArgument implements ActiveRecordInterface * obj is an instance of RewritingArgument, delegates to * equals(RewritingArgument). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -239,8 +239,6 @@ abstract class RewritingArgument implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -251,6 +249,7 @@ abstract class RewritingArgument implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -261,7 +260,10 @@ abstract class RewritingArgument implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -318,7 +320,9 @@ abstract class RewritingArgument implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -402,7 +406,7 @@ abstract class RewritingArgument implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -422,7 +426,7 @@ abstract class RewritingArgument implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -979,8 +983,7 @@ abstract class RewritingArgument implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/RewritingUrl.php b/core/lib/Thelia/Model/Base/RewritingUrl.php index 75ee97e79..06fa093b2 100644 --- a/core/lib/Thelia/Model/Base/RewritingUrl.php +++ b/core/lib/Thelia/Model/Base/RewritingUrl.php @@ -184,7 +184,7 @@ abstract class RewritingUrl implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -242,8 +242,8 @@ abstract class RewritingUrl implements ActiveRecordInterface * obj is an instance of RewritingUrl, delegates to * equals(RewritingUrl). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -282,8 +282,6 @@ abstract class RewritingUrl implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -294,6 +292,7 @@ abstract class RewritingUrl implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -304,7 +303,10 @@ abstract class RewritingUrl implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -361,7 +363,9 @@ abstract class RewritingUrl implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -478,7 +482,7 @@ abstract class RewritingUrl implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -498,7 +502,7 @@ abstract class RewritingUrl implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1207,8 +1211,7 @@ abstract class RewritingUrl implements ActiveRecordInterface $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php index da674b5cf..2ca5a8735 100644 --- a/core/lib/Thelia/Model/Base/Tax.php +++ b/core/lib/Thelia/Model/Base/Tax.php @@ -177,7 +177,7 @@ abstract class Tax implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -235,8 +235,8 @@ abstract class Tax implements ActiveRecordInterface * obj is an instance of Tax, delegates to * equals(Tax). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -275,8 +275,6 @@ abstract class Tax implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -287,6 +285,7 @@ abstract class Tax implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -297,7 +296,10 @@ abstract class Tax implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -354,7 +356,9 @@ abstract class Tax implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -438,7 +442,7 @@ abstract class Tax implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -458,7 +462,7 @@ abstract class Tax implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1044,8 +1048,7 @@ abstract class Tax implements ActiveRecordInterface $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php index abb659135..cedf8b348 100644 --- a/core/lib/Thelia/Model/Base/TaxI18n.php +++ b/core/lib/Thelia/Model/Base/TaxI18n.php @@ -146,7 +146,7 @@ abstract class TaxI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -204,8 +204,8 @@ abstract class TaxI18n implements ActiveRecordInterface * obj is an instance of TaxI18n, delegates to * equals(TaxI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -244,8 +244,6 @@ abstract class TaxI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -256,6 +254,7 @@ abstract class TaxI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -266,7 +265,10 @@ abstract class TaxI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -323,7 +325,9 @@ abstract class TaxI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -908,8 +912,7 @@ abstract class TaxI18n implements ActiveRecordInterface $keys[3] => $this->getDescription(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php index b361567d8..7accb0df8 100644 --- a/core/lib/Thelia/Model/Base/TaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -199,7 +199,7 @@ abstract class TaxRule implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -257,8 +257,8 @@ abstract class TaxRule implements ActiveRecordInterface * obj is an instance of TaxRule, delegates to * equals(TaxRule). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -297,8 +297,6 @@ abstract class TaxRule implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -309,6 +307,7 @@ abstract class TaxRule implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -319,7 +318,10 @@ abstract class TaxRule implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -376,7 +378,9 @@ abstract class TaxRule implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -449,7 +453,7 @@ abstract class TaxRule implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -469,7 +473,7 @@ abstract class TaxRule implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1053,8 +1057,7 @@ abstract class TaxRule implements ActiveRecordInterface $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountry.php b/core/lib/Thelia/Model/Base/TaxRuleCountry.php index 0cc3e74eb..de527540c 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleCountry.php +++ b/core/lib/Thelia/Model/Base/TaxRuleCountry.php @@ -161,7 +161,7 @@ abstract class TaxRuleCountry implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -219,8 +219,8 @@ abstract class TaxRuleCountry implements ActiveRecordInterface * obj is an instance of TaxRuleCountry, delegates to * equals(TaxRuleCountry). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -259,8 +259,6 @@ abstract class TaxRuleCountry implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -271,6 +269,7 @@ abstract class TaxRuleCountry implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -281,7 +280,10 @@ abstract class TaxRuleCountry implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -338,7 +340,9 @@ abstract class TaxRuleCountry implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -433,7 +437,7 @@ abstract class TaxRuleCountry implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -453,7 +457,7 @@ abstract class TaxRuleCountry implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1074,8 +1078,7 @@ abstract class TaxRuleCountry implements ActiveRecordInterface $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php index 711dba307..535195fb7 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleI18n.php +++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php @@ -146,7 +146,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -204,8 +204,8 @@ abstract class TaxRuleI18n implements ActiveRecordInterface * obj is an instance of TaxRuleI18n, delegates to * equals(TaxRuleI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -244,8 +244,6 @@ abstract class TaxRuleI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -256,6 +254,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -266,7 +265,10 @@ abstract class TaxRuleI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -323,7 +325,9 @@ abstract class TaxRuleI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -908,8 +912,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface $keys[3] => $this->getDescription(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/Template.php b/core/lib/Thelia/Model/Base/Template.php index 08bb0f3a0..fdb767c96 100644 --- a/core/lib/Thelia/Model/Base/Template.php +++ b/core/lib/Thelia/Model/Base/Template.php @@ -219,7 +219,7 @@ abstract class Template implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -277,8 +277,8 @@ abstract class Template implements ActiveRecordInterface * obj is an instance of Template, delegates to * equals(Template). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -317,8 +317,6 @@ abstract class Template implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -329,6 +327,7 @@ abstract class Template implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -339,7 +338,10 @@ abstract class Template implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -396,7 +398,9 @@ abstract class Template implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -458,7 +462,7 @@ abstract class Template implements ActiveRecordInterface if ($format === null) { return $this->created_at; } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; } } @@ -478,7 +482,7 @@ abstract class Template implements ActiveRecordInterface if ($format === null) { return $this->updated_at; } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; } } @@ -1091,8 +1095,7 @@ abstract class Template implements ActiveRecordInterface $keys[2] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/Base/TemplateI18n.php b/core/lib/Thelia/Model/Base/TemplateI18n.php index 7c61c6983..67ec21bc5 100644 --- a/core/lib/Thelia/Model/Base/TemplateI18n.php +++ b/core/lib/Thelia/Model/Base/TemplateI18n.php @@ -140,7 +140,7 @@ abstract class TemplateI18n implements ActiveRecordInterface * be false, if the object was retrieved from storage or was created * and then saved. * - * @return true, if the object has never been persisted. + * @return boolean true, if the object has never been persisted. */ public function isNew() { @@ -198,8 +198,8 @@ abstract class TemplateI18n implements ActiveRecordInterface * obj is an instance of TemplateI18n, delegates to * equals(TemplateI18n). Otherwise, returns false. * - * @param obj The object to compare to. - * @return Whether equal to the object specified. + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. */ public function equals($obj) { @@ -238,8 +238,6 @@ abstract class TemplateI18n implements ActiveRecordInterface /** * Get the associative array of the virtual columns in this object * - * @param string $name The virtual column name - * * @return array */ public function getVirtualColumns() @@ -250,6 +248,7 @@ abstract class TemplateI18n implements ActiveRecordInterface /** * Checks the existence of a virtual column in this object * + * @param string $name The virtual column name * @return boolean */ public function hasVirtualColumn($name) @@ -260,7 +259,10 @@ abstract class TemplateI18n implements ActiveRecordInterface /** * Get the value of a virtual column in this object * + * @param string $name The virtual column name * @return mixed + * + * @throws PropelException */ public function getVirtualColumn($name) { @@ -317,7 +319,9 @@ abstract class TemplateI18n implements ActiveRecordInterface $parser = AbstractParser::getParser($parser); } - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; } /** @@ -857,8 +861,7 @@ abstract class TemplateI18n implements ActiveRecordInterface $keys[2] => $this->getName(), ); $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { + foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index a1fb3601a..25a4f44aa 100755 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -7,7 +7,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; use Thelia\Model\ConfigQuery; -use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\Cart\CartEvent; use Thelia\TaxEngine\Calculator; class CartItem extends BaseCartItem diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index 347a0f7f7..067c54fc1 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -2,7 +2,7 @@ namespace Thelia\Model; -use Thelia\Core\Event\CategoryEvent; +use Thelia\Core\Event\Category\CategoryEvent; use Thelia\Model\Base\Category as BaseCategory; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Tools\URL; @@ -106,7 +106,7 @@ class Category extends BaseCategory public function preDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY, new CategoryEvent($this)); - + $this->reorderBeforeDelete(); return true; } diff --git a/core/lib/Thelia/Model/CategoryAssociatedContent.php b/core/lib/Thelia/Model/CategoryAssociatedContent.php index 9154767bc..e5fcddc41 100644 --- a/core/lib/Thelia/Model/CategoryAssociatedContent.php +++ b/core/lib/Thelia/Model/CategoryAssociatedContent.php @@ -3,7 +3,7 @@ namespace Thelia\Model; use Thelia\Model\Base\CategoryAssociatedContent as BaseCategoryAssociatedContent; -use Thelia\Core\Event\CategoryAssociatedContentEvent; +use Thelia\Core\Event\Category\CategoryAssociatedContentEvent; use Thelia\Core\Event\TheliaEvents; use Propel\Runtime\Connection\ConnectionInterface; diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php index 5724e2df1..0917ab30c 100755 --- a/core/lib/Thelia/Model/CategoryDocument.php +++ b/core/lib/Thelia/Model/CategoryDocument.php @@ -25,4 +25,28 @@ class CategoryDocument extends BaseCategoryDocument return true; } + + /** + * Set Document parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setCategoryId($parentId); + + return $this; + } + + /** + * Get Document parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getCategoryId(); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php index 5bf964e10..17ee387b5 100755 --- a/core/lib/Thelia/Model/CategoryImage.php +++ b/core/lib/Thelia/Model/CategoryImage.php @@ -2,6 +2,8 @@ namespace Thelia\Model; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpFoundation\File\UploadedFile; use Thelia\Model\Base\CategoryImage as BaseCategoryImage; use Propel\Runtime\Connection\ConnectionInterface; @@ -25,4 +27,29 @@ class CategoryImage extends BaseCategoryImage return true; } + + /** + * Set Image parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setCategoryId($parentId); + + return $this; + } + + /** + * Get Image parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getCategoryId(); + } + } diff --git a/core/lib/Thelia/Model/Config.php b/core/lib/Thelia/Model/Config.php index cc44e5053..9b44f1981 100755 --- a/core/lib/Thelia/Model/Config.php +++ b/core/lib/Thelia/Model/Config.php @@ -26,7 +26,7 @@ namespace Thelia\Model; use Thelia\Model\Base\Config as BaseConfig; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\ConfigEvent; +use Thelia\Core\Event\Config\ConfigEvent; class Config extends BaseConfig { diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php index 10ed2afe3..6417c8b56 100755 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -2,7 +2,12 @@ namespace Thelia\Model; +use Propel\Runtime\Propel; +use Thelia\Core\Event\Content\ContentEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Content as BaseContent; +use Thelia\Model\ContentFolderQuery; +use Thelia\Model\Map\ContentTableMap; use Thelia\Tools\URL; use Propel\Runtime\Connection\ConnectionInterface; @@ -30,13 +35,119 @@ class Content extends BaseContent // and generate the position relative to this folder } - /** - * {@inheritDoc} - */ - public function preInsert(ConnectionInterface $con = null) + public function getDefaultFolderId() { - $this->setPosition($this->getNextPosition()); + // Find default folder + $default_folder = ContentFolderQuery::create() + ->filterByContentId($this->getId()) + ->filterByDefaultFolder(true) + ->findOne(); + + return $default_folder == null ? 0 : $default_folder->getFolderId(); + } + + public function setDefaultFolder($folderId) + { +/* ContentFolderQuery::create() + ->filterByContentId($this->getId) + ->update(array("DefaultFolder" => 0));*/ + + return $this; + } + + + public function updateDefaultFolder($defaultFolderId) + { + // Allow uncategorized content (NULL instead of 0, to bypass delete cascade constraint) + if ($defaultFolderId <= 0) { + $defaultFolderId = NULL; + } + + if ($defaultFolderId == $this->getDefaultFolderId()) { + return; + } + + ContentFolderQuery::create() + ->filterByContentId($this->getId()) + ->update(array('DefaultFolder' => 0)); + + $contentFolder = ContentFolderQuery::create() + ->filterByContentId($this->getId()) + ->filterByFolderId($defaultFolderId) + ->findOne(); + + if (null === $contentFolder) { + $contentFolder = new ContentFolder(); + + $contentFolder->setContentId($this->getId()) + ->setFolderId($defaultFolderId); + } + + $contentFolder->setDefaultFolder(true) + ->save(); + + } + + /** + * Create a new content. + * + * Here pre and post insert event are fired + * + * @param $defaultFolderId + * @throws \Exception + */ + public function create($defaultFolderId) + { + $con = Propel::getWriteConnection(ContentTableMap::DATABASE_NAME); + + $con->beginTransaction(); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECONTENT, new ContentEvent($this)); + + try { + $this->save($con); + + $cf = new ContentFolder(); + $cf->setContentId($this->getId()) + ->setFolderId($defaultFolderId) + ->setDefaultFolder(1) + ->save($con); + + $this->setPosition($this->getNextPosition())->save($con); + + $con->commit(); + + $this->dispatchEvent(TheliaEvents::AFTER_CREATECONTENT,new ContentEvent($this)); + } catch(\Exception $ex) { + + $con->rollback(); + + throw $ex; + } + } + + + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATECONTENT, new ContentEvent($this)); return true; } + + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATECONTENT, new ContentEvent($this)); + } + + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETECONTENT, new ContentEvent($this)); + + return true; + } + + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETECONTENT, new ContentEvent($this)); + } } diff --git a/core/lib/Thelia/Model/ContentDocument.php b/core/lib/Thelia/Model/ContentDocument.php index 8ecf3a3a9..1409b2713 100755 --- a/core/lib/Thelia/Model/ContentDocument.php +++ b/core/lib/Thelia/Model/ContentDocument.php @@ -25,4 +25,28 @@ class ContentDocument extends BaseContentDocument return true; } + + /** + * Set Document parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setContentId($parentId); + + return $this; + } + + /** + * Get Document parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getContentId(); + } } diff --git a/core/lib/Thelia/Model/ContentImage.php b/core/lib/Thelia/Model/ContentImage.php index ac1dcf755..b6a3085d4 100755 --- a/core/lib/Thelia/Model/ContentImage.php +++ b/core/lib/Thelia/Model/ContentImage.php @@ -25,4 +25,28 @@ class ContentImage extends BaseContentImage return true; } + + /** + * Set Image parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setContentId($parentId); + + return $this; + } + + /** + * Get Image parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getContentId(); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Model/Coupon.php b/core/lib/Thelia/Model/Coupon.php index 032de412a..c4f74569d 100755 --- a/core/lib/Thelia/Model/Coupon.php +++ b/core/lib/Thelia/Model/Coupon.php @@ -25,7 +25,7 @@ namespace Thelia\Model; use Propel\Runtime\Propel; use Thelia\Constraint\Rule\CouponRuleInterface; -use Thelia\Coupon\CouponRuleCollection; +use Thelia\Coupon\ConditionCollection; use Thelia\Model\Base\Coupon as BaseCoupon; use Thelia\Model\Map\CouponTableMap; @@ -54,7 +54,7 @@ class Coupon extends BaseCoupon * @param string $code Coupon Code * @param string $title Coupon title * @param float $amount Amount removed from the Total Checkout - * @param string $effect Coupon effect + * @param string $type Coupon type * @param bool $isRemovingPostage Is removing Postage * @param string $shortDescription Coupon short description * @param string $description Coupon description @@ -63,17 +63,18 @@ class Coupon extends BaseCoupon * @param boolean $isAvailableOnSpecialOffers Is available on special offers * @param boolean $isCumulative Is cumulative * @param int $maxUsage Coupon quantity + * @param string $defaultSerializedRule Serialized default rule added if none found * @param string $locale Coupon Language code ISO (ex: fr_FR) * * @throws \Exception */ - function createOrUpdate($code, $title, $amount, $effect, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null) + function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null) { $this->setCode($code) ->setTitle($title) ->setShortDescription($shortDescription) ->setDescription($description) - ->setType($effect) + ->setType($type) ->setAmount($amount) ->setIsRemovingPostage($isRemovingPostage) ->setIsEnabled($isEnabled) @@ -82,6 +83,11 @@ class Coupon extends BaseCoupon ->setIsCumulative($isCumulative) ->setMaxUsage($maxUsage); + // If no rule given, set default rule + if (null === $this->getSerializedConditions()) { + $this->setSerializedConditions($defaultSerializedRule); + } + // Set object language (i18n) if (!is_null($locale)) { $this->setLocale($locale); @@ -100,16 +106,16 @@ class Coupon extends BaseCoupon } /** - * Create or Update this coupon rule + * Create or Update this coupon condition * - * @param string $serializableRules Serialized rules ready to be saved - * @param string $locale Coupon Language code ISO (ex: fr_FR) + * @param string $serializableConditions Serialized conditions ready to be saved + * @param string $locale Coupon Language code ISO (ex: fr_FR) * * @throws \Exception */ - function createOrUpdateRules($serializableRules, $locale) + public function createOrUpdateConditions($serializableConditions, $locale) { - $this->setSerializedRules($serializableRules); + $this->setSerializedConditions($serializableConditions); // Set object language (i18n) if (!is_null($locale)) { @@ -121,13 +127,9 @@ class Coupon extends BaseCoupon try { $this->save($con); $con->commit(); - } catch(\Exception $e) { $con->rollback(); throw $e; } } - - - } diff --git a/core/lib/Thelia/Model/Currency.php b/core/lib/Thelia/Model/Currency.php index 6ec452456..c5b77fc08 100755 --- a/core/lib/Thelia/Model/Currency.php +++ b/core/lib/Thelia/Model/Currency.php @@ -6,7 +6,7 @@ use Propel\Runtime\Exception\PropelException; use Thelia\Model\Base\Currency as BaseCurrency; use Thelia\Core\Event\TheliaEvents; use Propel\Runtime\Connection\ConnectionInterface; -use Thelia\Core\Event\CurrencyEvent; +use Thelia\Core\Event\Currency\CurrencyEvent; class Currency extends BaseCurrency { diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 820928224..230023410 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -17,7 +17,7 @@ use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; use Thelia\Model\Map\CustomerTableMap; use Thelia\Core\Security\Role\Role; -use Thelia\Core\Event\CustomerEvent; +use Thelia\Core\Event\Customer\CustomerEvent; /** * Skeleton subclass for representing a row from the 'customer' table. diff --git a/core/lib/Thelia/Model/Feature.php b/core/lib/Thelia/Model/Feature.php index cf0284d2b..800ff832a 100755 --- a/core/lib/Thelia/Model/Feature.php +++ b/core/lib/Thelia/Model/Feature.php @@ -5,7 +5,7 @@ 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; +use Thelia\Core\Event\Feature\FeatureEvent; class Feature extends BaseFeature { @@ -20,7 +20,7 @@ class Feature extends BaseFeature { $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE, new FeatureEvent($this)); // Set the current position for the new object - $this->setPosition($this->getNextPosition()); + //$this->setPosition($this->getNextPosition()); return true; } diff --git a/core/lib/Thelia/Model/FeatureAv.php b/core/lib/Thelia/Model/FeatureAv.php index ae6e35087..8d21b4cb1 100755 --- a/core/lib/Thelia/Model/FeatureAv.php +++ b/core/lib/Thelia/Model/FeatureAv.php @@ -5,7 +5,7 @@ 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; +use Thelia\Core\Event\Feature\FeatureAvEvent; class FeatureAv extends BaseFeatureAv { diff --git a/core/lib/Thelia/Model/FeatureProduct.php b/core/lib/Thelia/Model/FeatureProduct.php index 35a9b2ddc..bc4440a26 100755 --- a/core/lib/Thelia/Model/FeatureProduct.php +++ b/core/lib/Thelia/Model/FeatureProduct.php @@ -3,8 +3,66 @@ namespace Thelia\Model; use Thelia\Model\Base\FeatureProduct as BaseFeatureProduct; +use Thelia\Core\Event\TheliaEvents; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\FeatureProduct\FeatureProductEvent; - class FeatureProduct extends BaseFeatureProduct +class FeatureProduct extends BaseFeatureProduct { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE_PRODUCT, new FeatureProductEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE_PRODUCT, new FeatureProductEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE_PRODUCT, new FeatureProductEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE_PRODUCT, new FeatureProductEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE_PRODUCT, new FeatureProductEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE_PRODUCT, new FeatureProductEvent($this)); + } } diff --git a/core/lib/Thelia/Model/FeatureTemplate.php b/core/lib/Thelia/Model/FeatureTemplate.php index 47a33027a..3f28a3a10 100644 --- a/core/lib/Thelia/Model/FeatureTemplate.php +++ b/core/lib/Thelia/Model/FeatureTemplate.php @@ -3,8 +3,30 @@ namespace Thelia\Model; use Thelia\Model\Base\FeatureTemplate as BaseFeatureTemplate; +use Propel\Runtime\Connection\ConnectionInterface; - class FeatureTemplate extends BaseFeatureTemplate +class FeatureTemplate extends BaseFeatureTemplate { + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * Calculate next position relative to our template + */ + protected function addCriteriaToPositionQuery($query) + { + $query->filterByTemplateId($this->getTemplateId()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + // Set the current position for the new object + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index 8cbe00ce0..4b32e7591 100755 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -2,6 +2,8 @@ namespace Thelia\Model; +use Thelia\Core\Event\Folder\FolderEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Folder as BaseFolder; use Thelia\Tools\URL; use Propel\Runtime\Connection\ConnectionInterface; @@ -44,8 +46,8 @@ class Folder extends BaseFolder foreach($children as $child) { - $contentsCount += ProductQuery::create() - ->filterByCategory($child) + $contentsCount += ContentQuery::create() + ->filterByFolder($child) ->count(); } @@ -67,6 +69,37 @@ class Folder extends BaseFolder { $this->setPosition($this->getNextPosition()); + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFOLDER, new FolderEvent($this)); + return true; } + + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEFOLDER, new FolderEvent($this)); + } + + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFOLDER, new FolderEvent($this)); + + return true; + } + + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFOLDER, new FolderEvent($this)); + } + + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFOLDER, new FolderEvent($this)); + $this->reorderBeforeDelete(); + return true; + } + + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEFOLDER, new FolderEvent($this)); + } } diff --git a/core/lib/Thelia/Model/FolderDocument.php b/core/lib/Thelia/Model/FolderDocument.php index 0a86995d2..1d84d9e55 100755 --- a/core/lib/Thelia/Model/FolderDocument.php +++ b/core/lib/Thelia/Model/FolderDocument.php @@ -25,4 +25,28 @@ class FolderDocument extends BaseFolderDocument return true; } + + /** + * Set Document parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setFolderId($parentId); + + return $this; + } + + /** + * Get Document parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getFolderId(); + } } diff --git a/core/lib/Thelia/Model/FolderImage.php b/core/lib/Thelia/Model/FolderImage.php index 58d8f928e..f9491c9a5 100755 --- a/core/lib/Thelia/Model/FolderImage.php +++ b/core/lib/Thelia/Model/FolderImage.php @@ -25,4 +25,28 @@ class FolderImage extends BaseFolderImage return true; } + + /** + * Set Image parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setFolderId($parentId); + + return $this; + } + + /** + * Get Image parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getFolderId(); + } } diff --git a/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php index 04d3a9a4a..1df6d56c1 100644 --- a/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php @@ -57,7 +57,7 @@ class AttributeTemplateTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class AttributeTemplateTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field @@ -84,6 +84,11 @@ class AttributeTemplateTableMap extends TableMap */ const TEMPLATE_ID = 'attribute_template.TEMPLATE_ID'; + /** + * the column name for the POSITION field + */ + const POSITION = 'attribute_template.POSITION'; + /** * the column name for the CREATED_AT field */ @@ -106,12 +111,12 @@ class AttributeTemplateTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'AttributeId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'templateId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID, AttributeTemplateTableMap::ATTRIBUTE_ID, AttributeTemplateTableMap::TEMPLATE_ID, AttributeTemplateTableMap::CREATED_AT, AttributeTemplateTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'attribute_id', 'template_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'AttributeId', 'TemplateId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'templateId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID, AttributeTemplateTableMap::ATTRIBUTE_ID, AttributeTemplateTableMap::TEMPLATE_ID, AttributeTemplateTableMap::POSITION, AttributeTemplateTableMap::CREATED_AT, AttributeTemplateTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'TEMPLATE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'attribute_id', 'template_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -121,12 +126,12 @@ class AttributeTemplateTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID => 0, AttributeTemplateTableMap::ATTRIBUTE_ID => 1, AttributeTemplateTableMap::TEMPLATE_ID => 2, AttributeTemplateTableMap::CREATED_AT => 3, AttributeTemplateTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'TemplateId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'templateId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID => 0, AttributeTemplateTableMap::ATTRIBUTE_ID => 1, AttributeTemplateTableMap::TEMPLATE_ID => 2, AttributeTemplateTableMap::POSITION => 3, AttributeTemplateTableMap::CREATED_AT => 4, AttributeTemplateTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'TEMPLATE_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'template_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -149,6 +154,7 @@ class AttributeTemplateTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null); $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -316,12 +322,14 @@ class AttributeTemplateTableMap extends TableMap $criteria->addSelectColumn(AttributeTemplateTableMap::ID); $criteria->addSelectColumn(AttributeTemplateTableMap::ATTRIBUTE_ID); $criteria->addSelectColumn(AttributeTemplateTableMap::TEMPLATE_ID); + $criteria->addSelectColumn(AttributeTemplateTableMap::POSITION); $criteria->addSelectColumn(AttributeTemplateTableMap::CREATED_AT); $criteria->addSelectColumn(AttributeTemplateTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php index bd9079be6..70d689a2a 100644 --- a/core/lib/Thelia/Model/Map/CouponTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponTableMap.php @@ -89,11 +89,6 @@ class CouponTableMap extends TableMap */ const AMOUNT = 'coupon.AMOUNT'; - /** - * the column name for the IS_USED field - */ - const IS_USED = 'coupon.IS_USED'; - /** * the column name for the IS_ENABLED field */ @@ -105,9 +100,9 @@ class CouponTableMap extends TableMap const EXPIRATION_DATE = 'coupon.EXPIRATION_DATE'; /** - * the column name for the SERIALIZED_RULES field + * the column name for the MAX_USAGE field */ - const SERIALIZED_RULES = 'coupon.SERIALIZED_RULES'; + const MAX_USAGE = 'coupon.MAX_USAGE'; /** * the column name for the IS_CUMULATIVE field @@ -119,16 +114,21 @@ class CouponTableMap extends TableMap */ const IS_REMOVING_POSTAGE = 'coupon.IS_REMOVING_POSTAGE'; - /** - * the column name for the MAX_USAGE field - */ - const MAX_USAGE = 'coupon.MAX_USAGE'; - /** * the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field */ const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon.IS_AVAILABLE_ON_SPECIAL_OFFERS'; + /** + * the column name for the IS_USED field + */ + const IS_USED = 'coupon.IS_USED'; + + /** + * the column name for the SERIALIZED_CONDITIONS field + */ + const SERIALIZED_CONDITIONS = 'coupon.SERIALIZED_CONDITIONS'; + /** * the column name for the CREATED_AT field */ @@ -165,11 +165,11 @@ class CouponTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ), - self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::AMOUNT, CouponTableMap::IS_USED, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::SERIALIZED_RULES, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), - self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ), + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::TYPE, CouponTableMap::AMOUNT, CouponTableMap::IS_ENABLED, CouponTableMap::EXPIRATION_DATE, CouponTableMap::MAX_USAGE, CouponTableMap::IS_CUMULATIVE, CouponTableMap::IS_REMOVING_POSTAGE, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponTableMap::IS_USED, CouponTableMap::SERIALIZED_CONDITIONS, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, CouponTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) ); @@ -180,11 +180,11 @@ class CouponTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsUsed' => 4, 'IsEnabled' => 5, 'ExpirationDate' => 6, 'SerializedRules' => 7, 'IsCumulative' => 8, 'IsRemovingPostage' => 9, 'MaxUsage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isUsed' => 4, 'isEnabled' => 5, 'expirationDate' => 6, 'serializedRules' => 7, 'isCumulative' => 8, 'isRemovingPostage' => 9, 'maxUsage' => 10, 'isAvailableOnSpecialOffers' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ), - self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::AMOUNT => 3, CouponTableMap::IS_USED => 4, CouponTableMap::IS_ENABLED => 5, CouponTableMap::EXPIRATION_DATE => 6, CouponTableMap::SERIALIZED_RULES => 7, CouponTableMap::IS_CUMULATIVE => 8, CouponTableMap::IS_REMOVING_POSTAGE => 9, CouponTableMap::MAX_USAGE => 10, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, CouponTableMap::CREATED_AT => 12, CouponTableMap::UPDATED_AT => 13, CouponTableMap::VERSION => 14, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_USED' => 4, 'IS_ENABLED' => 5, 'EXPIRATION_DATE' => 6, 'SERIALIZED_RULES' => 7, 'IS_CUMULATIVE' => 8, 'IS_REMOVING_POSTAGE' => 9, 'MAX_USAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_used' => 4, 'is_enabled' => 5, 'expiration_date' => 6, 'serialized_rules' => 7, 'is_cumulative' => 8, 'is_removing_postage' => 9, 'max_usage' => 10, 'is_available_on_special_offers' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ), + self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::TYPE => 2, CouponTableMap::AMOUNT => 3, CouponTableMap::IS_ENABLED => 4, CouponTableMap::EXPIRATION_DATE => 5, CouponTableMap::MAX_USAGE => 6, CouponTableMap::IS_CUMULATIVE => 7, CouponTableMap::IS_REMOVING_POSTAGE => 8, CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponTableMap::IS_USED => 10, CouponTableMap::SERIALIZED_CONDITIONS => 11, CouponTableMap::CREATED_AT => 12, CouponTableMap::UPDATED_AT => 13, CouponTableMap::VERSION => 14, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) ); @@ -208,14 +208,14 @@ class CouponTableMap extends TableMap $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null); $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); - $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); - $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); + $this->addColumn('IS_ENABLED', 'IsEnabled', 'BOOLEAN', true, 1, null); $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); - $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); - $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); - $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); $this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null); + $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'BOOLEAN', true, 1, null); + $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'BOOLEAN', true, 1, null); $this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null); + $this->addColumn('IS_USED', 'IsUsed', 'BOOLEAN', true, 1, null); + $this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', 'LONGVARCHAR', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0); @@ -397,14 +397,14 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn(CouponTableMap::CODE); $criteria->addSelectColumn(CouponTableMap::TYPE); $criteria->addSelectColumn(CouponTableMap::AMOUNT); - $criteria->addSelectColumn(CouponTableMap::IS_USED); $criteria->addSelectColumn(CouponTableMap::IS_ENABLED); $criteria->addSelectColumn(CouponTableMap::EXPIRATION_DATE); - $criteria->addSelectColumn(CouponTableMap::SERIALIZED_RULES); + $criteria->addSelectColumn(CouponTableMap::MAX_USAGE); $criteria->addSelectColumn(CouponTableMap::IS_CUMULATIVE); $criteria->addSelectColumn(CouponTableMap::IS_REMOVING_POSTAGE); - $criteria->addSelectColumn(CouponTableMap::MAX_USAGE); $criteria->addSelectColumn(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS); + $criteria->addSelectColumn(CouponTableMap::IS_USED); + $criteria->addSelectColumn(CouponTableMap::SERIALIZED_CONDITIONS); $criteria->addSelectColumn(CouponTableMap::CREATED_AT); $criteria->addSelectColumn(CouponTableMap::UPDATED_AT); $criteria->addSelectColumn(CouponTableMap::VERSION); @@ -413,14 +413,14 @@ class CouponTableMap extends TableMap $criteria->addSelectColumn($alias . '.CODE'); $criteria->addSelectColumn($alias . '.TYPE'); $criteria->addSelectColumn($alias . '.AMOUNT'); - $criteria->addSelectColumn($alias . '.IS_USED'); $criteria->addSelectColumn($alias . '.IS_ENABLED'); $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); - $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); + $criteria->addSelectColumn($alias . '.MAX_USAGE'); $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); - $criteria->addSelectColumn($alias . '.MAX_USAGE'); $criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS'); + $criteria->addSelectColumn($alias . '.IS_USED'); + $criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php index 30ce279b8..91e774912 100644 --- a/core/lib/Thelia/Model/Map/CouponVersionTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponVersionTableMap.php @@ -89,11 +89,6 @@ class CouponVersionTableMap extends TableMap */ const AMOUNT = 'coupon_version.AMOUNT'; - /** - * the column name for the IS_USED field - */ - const IS_USED = 'coupon_version.IS_USED'; - /** * the column name for the IS_ENABLED field */ @@ -105,9 +100,9 @@ class CouponVersionTableMap extends TableMap const EXPIRATION_DATE = 'coupon_version.EXPIRATION_DATE'; /** - * the column name for the SERIALIZED_RULES field + * the column name for the MAX_USAGE field */ - const SERIALIZED_RULES = 'coupon_version.SERIALIZED_RULES'; + const MAX_USAGE = 'coupon_version.MAX_USAGE'; /** * the column name for the IS_CUMULATIVE field @@ -119,16 +114,21 @@ class CouponVersionTableMap extends TableMap */ const IS_REMOVING_POSTAGE = 'coupon_version.IS_REMOVING_POSTAGE'; - /** - * the column name for the MAX_USAGE field - */ - const MAX_USAGE = 'coupon_version.MAX_USAGE'; - /** * the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field */ const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'coupon_version.IS_AVAILABLE_ON_SPECIAL_OFFERS'; + /** + * the column name for the IS_USED field + */ + const IS_USED = 'coupon_version.IS_USED'; + + /** + * the column name for the SERIALIZED_CONDITIONS field + */ + const SERIALIZED_CONDITIONS = 'coupon_version.SERIALIZED_CONDITIONS'; + /** * the column name for the CREATED_AT field */ @@ -156,11 +156,11 @@ class CouponVersionTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsUsed', 'IsEnabled', 'ExpirationDate', 'SerializedRules', 'IsCumulative', 'IsRemovingPostage', 'MaxUsage', 'IsAvailableOnSpecialOffers', 'CreatedAt', 'UpdatedAt', 'Version', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isUsed', 'isEnabled', 'expirationDate', 'serializedRules', 'isCumulative', 'isRemovingPostage', 'maxUsage', 'isAvailableOnSpecialOffers', 'createdAt', 'updatedAt', 'version', ), - self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_USED, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::SERIALIZED_RULES, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_USED', 'IS_ENABLED', 'EXPIRATION_DATE', 'SERIALIZED_RULES', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'MAX_USAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), - self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_used', 'is_enabled', 'expiration_date', 'serialized_rules', 'is_cumulative', 'is_removing_postage', 'max_usage', 'is_available_on_special_offers', 'created_at', 'updated_at', 'version', ), + self::TYPE_PHPNAME => array('Id', 'Code', 'Type', 'Amount', 'IsEnabled', 'ExpirationDate', 'MaxUsage', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'IsUsed', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', 'Version', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'amount', 'isEnabled', 'expirationDate', 'maxUsage', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'isUsed', 'serializedConditions', 'createdAt', 'updatedAt', 'version', ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID, CouponVersionTableMap::CODE, CouponVersionTableMap::TYPE, CouponVersionTableMap::AMOUNT, CouponVersionTableMap::IS_ENABLED, CouponVersionTableMap::EXPIRATION_DATE, CouponVersionTableMap::MAX_USAGE, CouponVersionTableMap::IS_CUMULATIVE, CouponVersionTableMap::IS_REMOVING_POSTAGE, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, CouponVersionTableMap::IS_USED, CouponVersionTableMap::SERIALIZED_CONDITIONS, CouponVersionTableMap::CREATED_AT, CouponVersionTableMap::UPDATED_AT, CouponVersionTableMap::VERSION, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'AMOUNT', 'IS_ENABLED', 'EXPIRATION_DATE', 'MAX_USAGE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IS_USED', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', 'VERSION', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'amount', 'is_enabled', 'expiration_date', 'max_usage', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'is_used', 'serialized_conditions', 'created_at', 'updated_at', 'version', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) ); @@ -171,11 +171,11 @@ class CouponVersionTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsUsed' => 4, 'IsEnabled' => 5, 'ExpirationDate' => 6, 'SerializedRules' => 7, 'IsCumulative' => 8, 'IsRemovingPostage' => 9, 'MaxUsage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isUsed' => 4, 'isEnabled' => 5, 'expirationDate' => 6, 'serializedRules' => 7, 'isCumulative' => 8, 'isRemovingPostage' => 9, 'maxUsage' => 10, 'isAvailableOnSpecialOffers' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ), - self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::AMOUNT => 3, CouponVersionTableMap::IS_USED => 4, CouponVersionTableMap::IS_ENABLED => 5, CouponVersionTableMap::EXPIRATION_DATE => 6, CouponVersionTableMap::SERIALIZED_RULES => 7, CouponVersionTableMap::IS_CUMULATIVE => 8, CouponVersionTableMap::IS_REMOVING_POSTAGE => 9, CouponVersionTableMap::MAX_USAGE => 10, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, CouponVersionTableMap::CREATED_AT => 12, CouponVersionTableMap::UPDATED_AT => 13, CouponVersionTableMap::VERSION => 14, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_USED' => 4, 'IS_ENABLED' => 5, 'EXPIRATION_DATE' => 6, 'SERIALIZED_RULES' => 7, 'IS_CUMULATIVE' => 8, 'IS_REMOVING_POSTAGE' => 9, 'MAX_USAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_used' => 4, 'is_enabled' => 5, 'expiration_date' => 6, 'serialized_rules' => 7, 'is_cumulative' => 8, 'is_removing_postage' => 9, 'max_usage' => 10, 'is_available_on_special_offers' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Amount' => 3, 'IsEnabled' => 4, 'ExpirationDate' => 5, 'MaxUsage' => 6, 'IsCumulative' => 7, 'IsRemovingPostage' => 8, 'IsAvailableOnSpecialOffers' => 9, 'IsUsed' => 10, 'SerializedConditions' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'isEnabled' => 4, 'expirationDate' => 5, 'maxUsage' => 6, 'isCumulative' => 7, 'isRemovingPostage' => 8, 'isAvailableOnSpecialOffers' => 9, 'isUsed' => 10, 'serializedConditions' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, ), + self::TYPE_COLNAME => array(CouponVersionTableMap::ID => 0, CouponVersionTableMap::CODE => 1, CouponVersionTableMap::TYPE => 2, CouponVersionTableMap::AMOUNT => 3, CouponVersionTableMap::IS_ENABLED => 4, CouponVersionTableMap::EXPIRATION_DATE => 5, CouponVersionTableMap::MAX_USAGE => 6, CouponVersionTableMap::IS_CUMULATIVE => 7, CouponVersionTableMap::IS_REMOVING_POSTAGE => 8, CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 9, CouponVersionTableMap::IS_USED => 10, CouponVersionTableMap::SERIALIZED_CONDITIONS => 11, CouponVersionTableMap::CREATED_AT => 12, CouponVersionTableMap::UPDATED_AT => 13, CouponVersionTableMap::VERSION => 14, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'AMOUNT' => 3, 'IS_ENABLED' => 4, 'EXPIRATION_DATE' => 5, 'MAX_USAGE' => 6, 'IS_CUMULATIVE' => 7, 'IS_REMOVING_POSTAGE' => 8, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 9, 'IS_USED' => 10, 'SERIALIZED_CONDITIONS' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'amount' => 3, 'is_enabled' => 4, 'expiration_date' => 5, 'max_usage' => 6, 'is_cumulative' => 7, 'is_removing_postage' => 8, 'is_available_on_special_offers' => 9, 'is_used' => 10, 'serialized_conditions' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) ); @@ -199,14 +199,14 @@ class CouponVersionTableMap extends TableMap $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null); $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); - $this->addColumn('IS_USED', 'IsUsed', 'TINYINT', true, null, null); - $this->addColumn('IS_ENABLED', 'IsEnabled', 'TINYINT', true, null, null); + $this->addColumn('IS_ENABLED', 'IsEnabled', 'BOOLEAN', true, 1, null); $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); - $this->addColumn('SERIALIZED_RULES', 'SerializedRules', 'LONGVARCHAR', true, null, null); - $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'TINYINT', true, null, null); - $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'TINYINT', true, null, null); $this->addColumn('MAX_USAGE', 'MaxUsage', 'INTEGER', true, null, null); + $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'BOOLEAN', true, 1, null); + $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'BOOLEAN', true, 1, null); $this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null); + $this->addColumn('IS_USED', 'IsUsed', 'BOOLEAN', true, 1, null); + $this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', 'LONGVARCHAR', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0); @@ -411,14 +411,14 @@ class CouponVersionTableMap extends TableMap $criteria->addSelectColumn(CouponVersionTableMap::CODE); $criteria->addSelectColumn(CouponVersionTableMap::TYPE); $criteria->addSelectColumn(CouponVersionTableMap::AMOUNT); - $criteria->addSelectColumn(CouponVersionTableMap::IS_USED); $criteria->addSelectColumn(CouponVersionTableMap::IS_ENABLED); $criteria->addSelectColumn(CouponVersionTableMap::EXPIRATION_DATE); - $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_RULES); + $criteria->addSelectColumn(CouponVersionTableMap::MAX_USAGE); $criteria->addSelectColumn(CouponVersionTableMap::IS_CUMULATIVE); $criteria->addSelectColumn(CouponVersionTableMap::IS_REMOVING_POSTAGE); - $criteria->addSelectColumn(CouponVersionTableMap::MAX_USAGE); $criteria->addSelectColumn(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS); + $criteria->addSelectColumn(CouponVersionTableMap::IS_USED); + $criteria->addSelectColumn(CouponVersionTableMap::SERIALIZED_CONDITIONS); $criteria->addSelectColumn(CouponVersionTableMap::CREATED_AT); $criteria->addSelectColumn(CouponVersionTableMap::UPDATED_AT); $criteria->addSelectColumn(CouponVersionTableMap::VERSION); @@ -427,14 +427,14 @@ class CouponVersionTableMap extends TableMap $criteria->addSelectColumn($alias . '.CODE'); $criteria->addSelectColumn($alias . '.TYPE'); $criteria->addSelectColumn($alias . '.AMOUNT'); - $criteria->addSelectColumn($alias . '.IS_USED'); $criteria->addSelectColumn($alias . '.IS_ENABLED'); $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); - $criteria->addSelectColumn($alias . '.SERIALIZED_RULES'); + $criteria->addSelectColumn($alias . '.MAX_USAGE'); $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); - $criteria->addSelectColumn($alias . '.MAX_USAGE'); $criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS'); + $criteria->addSelectColumn($alias . '.IS_USED'); + $criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.VERSION'); diff --git a/core/lib/Thelia/Model/Map/FeatureProductTableMap.php b/core/lib/Thelia/Model/Map/FeatureProductTableMap.php index f0263b47c..9db4ec441 100644 --- a/core/lib/Thelia/Model/Map/FeatureProductTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureProductTableMap.php @@ -90,9 +90,9 @@ class FeatureProductTableMap extends TableMap const FEATURE_AV_ID = 'feature_product.FEATURE_AV_ID'; /** - * the column name for the BY_DEFAULT field + * the column name for the FREE_TEXT_VALUE field */ - const BY_DEFAULT = 'feature_product.BY_DEFAULT'; + const FREE_TEXT_VALUE = 'feature_product.FREE_TEXT_VALUE'; /** * the column name for the POSITION field @@ -121,11 +121,11 @@ class FeatureProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'byDefault', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(FeatureProductTableMap::ID, FeatureProductTableMap::PRODUCT_ID, FeatureProductTableMap::FEATURE_ID, FeatureProductTableMap::FEATURE_AV_ID, FeatureProductTableMap::BY_DEFAULT, FeatureProductTableMap::POSITION, FeatureProductTableMap::CREATED_AT, FeatureProductTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'by_default', 'position', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'FreeTextValue', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'freeTextValue', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureProductTableMap::ID, FeatureProductTableMap::PRODUCT_ID, FeatureProductTableMap::FEATURE_ID, FeatureProductTableMap::FEATURE_AV_ID, FeatureProductTableMap::FREE_TEXT_VALUE, FeatureProductTableMap::POSITION, FeatureProductTableMap::CREATED_AT, FeatureProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'FREE_TEXT_VALUE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'free_text_value', 'position', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -136,11 +136,11 @@ class FeatureProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - self::TYPE_COLNAME => array(FeatureProductTableMap::ID => 0, FeatureProductTableMap::PRODUCT_ID => 1, FeatureProductTableMap::FEATURE_ID => 2, FeatureProductTableMap::FEATURE_AV_ID => 3, FeatureProductTableMap::BY_DEFAULT => 4, FeatureProductTableMap::POSITION => 5, FeatureProductTableMap::CREATED_AT => 6, FeatureProductTableMap::UPDATED_AT => 7, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'BY_DEFAULT' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'by_default' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'FreeTextValue' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'freeTextValue' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(FeatureProductTableMap::ID => 0, FeatureProductTableMap::PRODUCT_ID => 1, FeatureProductTableMap::FEATURE_ID => 2, FeatureProductTableMap::FEATURE_AV_ID => 3, FeatureProductTableMap::FREE_TEXT_VALUE => 4, FeatureProductTableMap::POSITION => 5, FeatureProductTableMap::CREATED_AT => 6, FeatureProductTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'FREE_TEXT_VALUE' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'free_text_value' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -164,7 +164,7 @@ class FeatureProductTableMap extends TableMap $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); $this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', false, null, null); - $this->addColumn('BY_DEFAULT', 'ByDefault', 'VARCHAR', false, 255, null); + $this->addColumn('FREE_TEXT_VALUE', 'FreeTextValue', 'LONGVARCHAR', false, null, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -335,7 +335,7 @@ class FeatureProductTableMap extends TableMap $criteria->addSelectColumn(FeatureProductTableMap::PRODUCT_ID); $criteria->addSelectColumn(FeatureProductTableMap::FEATURE_ID); $criteria->addSelectColumn(FeatureProductTableMap::FEATURE_AV_ID); - $criteria->addSelectColumn(FeatureProductTableMap::BY_DEFAULT); + $criteria->addSelectColumn(FeatureProductTableMap::FREE_TEXT_VALUE); $criteria->addSelectColumn(FeatureProductTableMap::POSITION); $criteria->addSelectColumn(FeatureProductTableMap::CREATED_AT); $criteria->addSelectColumn(FeatureProductTableMap::UPDATED_AT); @@ -344,7 +344,7 @@ class FeatureProductTableMap extends TableMap $criteria->addSelectColumn($alias . '.PRODUCT_ID'); $criteria->addSelectColumn($alias . '.FEATURE_ID'); $criteria->addSelectColumn($alias . '.FEATURE_AV_ID'); - $criteria->addSelectColumn($alias . '.BY_DEFAULT'); + $criteria->addSelectColumn($alias . '.FREE_TEXT_VALUE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php index 067a242a3..c6a29e2f4 100644 --- a/core/lib/Thelia/Model/Map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -156,7 +156,7 @@ class FeatureTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('VISIBLE', 'Visible', 'INTEGER', false, null, 0); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php index abb1a98b7..68f3b9a24 100644 --- a/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php @@ -57,7 +57,7 @@ class FeatureTemplateTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class FeatureTemplateTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field @@ -84,6 +84,11 @@ class FeatureTemplateTableMap extends TableMap */ const TEMPLATE_ID = 'feature_template.TEMPLATE_ID'; + /** + * the column name for the POSITION field + */ + const POSITION = 'feature_template.POSITION'; + /** * the column name for the CREATED_AT field */ @@ -106,12 +111,12 @@ class FeatureTemplateTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'FeatureId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'templateId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID, FeatureTemplateTableMap::FEATURE_ID, FeatureTemplateTableMap::TEMPLATE_ID, FeatureTemplateTableMap::CREATED_AT, FeatureTemplateTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'feature_id', 'template_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'FeatureId', 'TemplateId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'templateId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID, FeatureTemplateTableMap::FEATURE_ID, FeatureTemplateTableMap::TEMPLATE_ID, FeatureTemplateTableMap::POSITION, FeatureTemplateTableMap::CREATED_AT, FeatureTemplateTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'TEMPLATE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'feature_id', 'template_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -121,12 +126,12 @@ class FeatureTemplateTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID => 0, FeatureTemplateTableMap::FEATURE_ID => 1, FeatureTemplateTableMap::TEMPLATE_ID => 2, FeatureTemplateTableMap::CREATED_AT => 3, FeatureTemplateTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'TemplateId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'templateId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID => 0, FeatureTemplateTableMap::FEATURE_ID => 1, FeatureTemplateTableMap::TEMPLATE_ID => 2, FeatureTemplateTableMap::POSITION => 3, FeatureTemplateTableMap::CREATED_AT => 4, FeatureTemplateTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'TEMPLATE_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'template_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -149,6 +154,7 @@ class FeatureTemplateTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -316,12 +322,14 @@ class FeatureTemplateTableMap extends TableMap $criteria->addSelectColumn(FeatureTemplateTableMap::ID); $criteria->addSelectColumn(FeatureTemplateTableMap::FEATURE_ID); $criteria->addSelectColumn(FeatureTemplateTableMap::TEMPLATE_ID); + $criteria->addSelectColumn(FeatureTemplateTableMap::POSITION); $criteria->addSelectColumn(FeatureTemplateTableMap::CREATED_AT); $criteria->addSelectColumn(FeatureTemplateTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.FEATURE_ID'); $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php new file mode 100644 index 000000000..3c3aee2f9 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php @@ -0,0 +1,503 @@ + array('Id', 'OrderProductId', 'AttributeTitle', 'AttributeChapo', 'AttributeDescription', 'AttributePostscriptum', 'AttributeAvTitle', 'AttributeAvChapo', 'AttributeAvDescription', 'AttributeAvPostscriptum', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'attributeTitle', 'attributeChapo', 'attributeDescription', 'attributePostscriptum', 'attributeAvTitle', 'attributeAvChapo', 'attributeAvDescription', 'attributeAvPostscriptum', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, OrderProductAttributeCombinationTableMap::CREATED_AT, OrderProductAttributeCombinationTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'ATTRIBUTE_TITLE', 'ATTRIBUTE_CHAPO', 'ATTRIBUTE_DESCRIPTION', 'ATTRIBUTE_POSTSCRIPTUM', 'ATTRIBUTE_AV_TITLE', 'ATTRIBUTE_AV_CHAPO', 'ATTRIBUTE_AV_DESCRIPTION', 'ATTRIBUTE_AV_POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'attribute_title', 'attribute_chapo', 'attribute_description', 'attribute_postscriptum', 'attribute_av_title', 'attribute_av_chapo', 'attribute_av_description', 'attribute_av_postscriptum', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'AttributeTitle' => 2, 'AttributeChapo' => 3, 'AttributeDescription' => 4, 'AttributePostscriptum' => 5, 'AttributeAvTitle' => 6, 'AttributeAvChapo' => 7, 'AttributeAvDescription' => 8, 'AttributeAvPostscriptum' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'attributeTitle' => 2, 'attributeChapo' => 3, 'attributeDescription' => 4, 'attributePostscriptum' => 5, 'attributeAvTitle' => 6, 'attributeAvChapo' => 7, 'attributeAvDescription' => 8, 'attributeAvPostscriptum' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), + self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID => 0, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID => 1, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE => 2, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO => 3, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION => 4, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM => 5, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE => 6, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO => 7, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION => 8, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM => 9, OrderProductAttributeCombinationTableMap::CREATED_AT => 10, OrderProductAttributeCombinationTableMap::UPDATED_AT => 11, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'ATTRIBUTE_TITLE' => 2, 'ATTRIBUTE_CHAPO' => 3, 'ATTRIBUTE_DESCRIPTION' => 4, 'ATTRIBUTE_POSTSCRIPTUM' => 5, 'ATTRIBUTE_AV_TITLE' => 6, 'ATTRIBUTE_AV_CHAPO' => 7, 'ATTRIBUTE_AV_DESCRIPTION' => 8, 'ATTRIBUTE_AV_POSTSCRIPTUM' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'attribute_title' => 2, 'attribute_chapo' => 3, 'attribute_description' => 4, 'attribute_postscriptum' => 5, 'attribute_av_title' => 6, 'attribute_av_chapo' => 7, 'attribute_av_description' => 8, 'attribute_av_postscriptum' => 9, 'created_at' => 10, 'updated_at' => 11, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('order_product_attribute_combination'); + $this->setPhpName('OrderProductAttributeCombination'); + $this->setClassName('\\Thelia\\Model\\OrderProductAttributeCombination'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null); + $this->addColumn('ATTRIBUTE_TITLE', 'AttributeTitle', 'VARCHAR', true, 255, null); + $this->addColumn('ATTRIBUTE_CHAPO', 'AttributeChapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_DESCRIPTION', 'AttributeDescription', 'CLOB', false, null, null); + $this->addColumn('ATTRIBUTE_POSTSCRIPTUM', 'AttributePostscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_AV_TITLE', 'AttributeAvTitle', 'VARCHAR', true, 255, null); + $this->addColumn('ATTRIBUTE_AV_CHAPO', 'AttributeAvChapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_AV_DESCRIPTION', 'AttributeAvDescription', 'CLOB', false, null, null); + $this->addColumn('ATTRIBUTE_AV_POSTSCRIPTUM', 'AttributeAvPostscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderProductAttributeCombinationTableMap::CLASS_DEFAULT : OrderProductAttributeCombinationTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (OrderProductAttributeCombination object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderProductAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderProductAttributeCombinationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderProductAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderProductAttributeCombinationTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderProductAttributeCombinationTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderProductAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderProductAttributeCombinationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + OrderProductAttributeCombinationTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ID); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_TITLE'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_CHAPO'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_TITLE'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_CHAPO'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(OrderProductAttributeCombinationTableMap::DATABASE_NAME)->getTable(OrderProductAttributeCombinationTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderProductAttributeCombinationTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderProductAttributeCombinationTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a OrderProductAttributeCombination or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or OrderProductAttributeCombination object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderProductAttributeCombination) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + $criteria->add(OrderProductAttributeCombinationTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderProductAttributeCombinationQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderProductAttributeCombinationTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderProductAttributeCombinationTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_product_attribute_combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderProductAttributeCombinationQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderProductAttributeCombination or Criteria object. + * + * @param mixed $criteria Criteria or OrderProductAttributeCombination object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductAttributeCombinationTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderProductAttributeCombination object + } + + if ($criteria->containsKey(OrderProductAttributeCombinationTableMap::ID) && $criteria->keyContainsValue(OrderProductAttributeCombinationTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductAttributeCombinationTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderProductAttributeCombinationQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderProductAttributeCombinationTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderProductAttributeCombinationTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php index 038d12863..8144f23a7 100644 --- a/core/lib/Thelia/Model/Map/OrderProductTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php @@ -57,7 +57,7 @@ class OrderProductTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 12; + const NUM_COLUMNS = 19; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class OrderProductTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 12; + const NUM_HYDRATE_COLUMNS = 19; /** * the column name for the ID field @@ -84,20 +84,30 @@ class OrderProductTableMap extends TableMap */ const PRODUCT_REF = 'order_product.PRODUCT_REF'; + /** + * the column name for the PRODUCT_SALE_ELEMENTS_REF field + */ + const PRODUCT_SALE_ELEMENTS_REF = 'order_product.PRODUCT_SALE_ELEMENTS_REF'; + /** * the column name for the TITLE field */ const TITLE = 'order_product.TITLE'; + /** + * the column name for the CHAPO field + */ + const CHAPO = 'order_product.CHAPO'; + /** * the column name for the DESCRIPTION field */ const DESCRIPTION = 'order_product.DESCRIPTION'; /** - * the column name for the CHAPO field + * the column name for the POSTSCRIPTUM field */ - const CHAPO = 'order_product.CHAPO'; + const POSTSCRIPTUM = 'order_product.POSTSCRIPTUM'; /** * the column name for the QUANTITY field @@ -110,9 +120,34 @@ class OrderProductTableMap extends TableMap const PRICE = 'order_product.PRICE'; /** - * the column name for the TAX field + * the column name for the PROMO_PRICE field */ - const TAX = 'order_product.TAX'; + const PROMO_PRICE = 'order_product.PROMO_PRICE'; + + /** + * the column name for the WAS_NEW field + */ + const WAS_NEW = 'order_product.WAS_NEW'; + + /** + * the column name for the WAS_IN_PROMO field + */ + const WAS_IN_PROMO = 'order_product.WAS_IN_PROMO'; + + /** + * the column name for the WEIGHT field + */ + const WEIGHT = 'order_product.WEIGHT'; + + /** + * the column name for the TAX_RULE_TITLE field + */ + const TAX_RULE_TITLE = 'order_product.TAX_RULE_TITLE'; + + /** + * the column name for the TAX_RULE_DESCRIPTION field + */ + const TAX_RULE_DESCRIPTION = 'order_product.TAX_RULE_DESCRIPTION'; /** * the column name for the PARENT field @@ -141,12 +176,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::TITLE, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::CHAPO, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'TaxRuleTitle', 'TaxRuleDescription', 'Parent', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'taxRuleTitle', 'taxRuleDescription', 'parent', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX_RULE_TITLE, OrderProductTableMap::TAX_RULE_DESCRIPTION, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX_RULE_TITLE', 'TAX_RULE_DESCRIPTION', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax_rule_title', 'tax_rule_description', 'parent', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) ); /** @@ -156,12 +191,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::TITLE => 3, OrderProductTableMap::DESCRIPTION => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::QUANTITY => 6, OrderProductTableMap::PRICE => 7, OrderProductTableMap::TAX => 8, OrderProductTableMap::PARENT => 9, OrderProductTableMap::CREATED_AT => 10, OrderProductTableMap::UPDATED_AT => 11, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'TaxRuleTitle' => 14, 'TaxRuleDescription' => 15, 'Parent' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'taxRuleTitle' => 14, 'taxRuleDescription' => 15, 'parent' => 16, 'createdAt' => 17, 'updatedAt' => 18, ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX_RULE_TITLE => 14, OrderProductTableMap::TAX_RULE_DESCRIPTION => 15, OrderProductTableMap::PARENT => 16, OrderProductTableMap::CREATED_AT => 17, OrderProductTableMap::UPDATED_AT => 18, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX_RULE_TITLE' => 14, 'TAX_RULE_DESCRIPTION' => 15, 'PARENT' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax_rule_title' => 14, 'tax_rule_description' => 15, 'parent' => 16, 'created_at' => 17, 'updated_at' => 18, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) ); /** @@ -182,13 +217,20 @@ class OrderProductTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null); + $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', true, 255, null); + $this->addColumn('PRODUCT_SALE_ELEMENTS_REF', 'ProductSaleElementsRef', 'VARCHAR', true, 255, null); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); - $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null); + $this->addColumn('PROMO_PRICE', 'PromoPrice', 'VARCHAR', false, 45, null); + $this->addColumn('WAS_NEW', 'WasNew', 'TINYINT', true, null, null); + $this->addColumn('WAS_IN_PROMO', 'WasInPromo', 'TINYINT', true, null, null); + $this->addColumn('WEIGHT', 'Weight', 'VARCHAR', false, 45, null); + $this->addColumn('TAX_RULE_TITLE', 'TaxRuleTitle', 'VARCHAR', false, 255, null); + $this->addColumn('TAX_RULE_DESCRIPTION', 'TaxRuleDescription', 'CLOB', false, null, null); $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -200,7 +242,8 @@ class OrderProductTableMap extends TableMap public function buildRelations() { $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderFeature', '\\Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures'); + $this->addRelation('OrderProductAttributeCombination', '\\Thelia\\Model\\OrderProductAttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductAttributeCombinations'); + $this->addRelation('OrderProductTax', '\\Thelia\\Model\\OrderProductTax', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductTaxes'); } // buildRelations() /** @@ -222,7 +265,8 @@ class OrderProductTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderFeatureTableMap::clearInstancePool(); + OrderProductAttributeCombinationTableMap::clearInstancePool(); + OrderProductTaxTableMap::clearInstancePool(); } /** @@ -366,12 +410,19 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn(OrderProductTableMap::ID); $criteria->addSelectColumn(OrderProductTableMap::ORDER_ID); $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF); + $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF); $criteria->addSelectColumn(OrderProductTableMap::TITLE); - $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION); $criteria->addSelectColumn(OrderProductTableMap::CHAPO); + $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION); + $criteria->addSelectColumn(OrderProductTableMap::POSTSCRIPTUM); $criteria->addSelectColumn(OrderProductTableMap::QUANTITY); $criteria->addSelectColumn(OrderProductTableMap::PRICE); - $criteria->addSelectColumn(OrderProductTableMap::TAX); + $criteria->addSelectColumn(OrderProductTableMap::PROMO_PRICE); + $criteria->addSelectColumn(OrderProductTableMap::WAS_NEW); + $criteria->addSelectColumn(OrderProductTableMap::WAS_IN_PROMO); + $criteria->addSelectColumn(OrderProductTableMap::WEIGHT); + $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_TITLE); + $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_DESCRIPTION); $criteria->addSelectColumn(OrderProductTableMap::PARENT); $criteria->addSelectColumn(OrderProductTableMap::CREATED_AT); $criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT); @@ -379,12 +430,19 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ORDER_ID'); $criteria->addSelectColumn($alias . '.PRODUCT_REF'); + $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_REF'); $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); $criteria->addSelectColumn($alias . '.QUANTITY'); $criteria->addSelectColumn($alias . '.PRICE'); - $criteria->addSelectColumn($alias . '.TAX'); + $criteria->addSelectColumn($alias . '.PROMO_PRICE'); + $criteria->addSelectColumn($alias . '.WAS_NEW'); + $criteria->addSelectColumn($alias . '.WAS_IN_PROMO'); + $criteria->addSelectColumn($alias . '.WEIGHT'); + $criteria->addSelectColumn($alias . '.TAX_RULE_TITLE'); + $criteria->addSelectColumn($alias . '.TAX_RULE_DESCRIPTION'); $criteria->addSelectColumn($alias . '.PARENT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php new file mode 100644 index 000000000..98994c6e4 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php @@ -0,0 +1,471 @@ + array('Id', 'OrderProductId', 'Title', 'Description', 'Amount', 'PromoAmount', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'title', 'description', 'amount', 'promoAmount', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID, OrderProductTaxTableMap::ORDER_PRODUCT_ID, OrderProductTaxTableMap::TITLE, OrderProductTaxTableMap::DESCRIPTION, OrderProductTaxTableMap::AMOUNT, OrderProductTaxTableMap::PROMO_AMOUNT, OrderProductTaxTableMap::CREATED_AT, OrderProductTaxTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'TITLE', 'DESCRIPTION', 'AMOUNT', 'PROMO_AMOUNT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'title', 'description', 'amount', 'promo_amount', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'Title' => 2, 'Description' => 3, 'Amount' => 4, 'PromoAmount' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'promoAmount' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID => 0, OrderProductTaxTableMap::ORDER_PRODUCT_ID => 1, OrderProductTaxTableMap::TITLE => 2, OrderProductTaxTableMap::DESCRIPTION => 3, OrderProductTaxTableMap::AMOUNT => 4, OrderProductTaxTableMap::PROMO_AMOUNT => 5, OrderProductTaxTableMap::CREATED_AT => 6, OrderProductTaxTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'AMOUNT' => 4, 'PROMO_AMOUNT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'promo_amount' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('order_product_tax'); + $this->setPhpName('OrderProductTax'); + $this->setClassName('\\Thelia\\Model\\OrderProductTax'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); + $this->addColumn('PROMO_AMOUNT', 'PromoAmount', 'FLOAT', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderProductTaxTableMap::CLASS_DEFAULT : OrderProductTaxTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (OrderProductTax object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderProductTaxTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderProductTaxTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderProductTaxTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderProductTaxTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderProductTaxTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderProductTaxTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderProductTaxTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + OrderProductTaxTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(OrderProductTaxTableMap::ID); + $criteria->addSelectColumn(OrderProductTaxTableMap::ORDER_PRODUCT_ID); + $criteria->addSelectColumn(OrderProductTaxTableMap::TITLE); + $criteria->addSelectColumn(OrderProductTaxTableMap::DESCRIPTION); + $criteria->addSelectColumn(OrderProductTaxTableMap::AMOUNT); + $criteria->addSelectColumn(OrderProductTaxTableMap::PROMO_AMOUNT); + $criteria->addSelectColumn(OrderProductTaxTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderProductTaxTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.AMOUNT'); + $criteria->addSelectColumn($alias . '.PROMO_AMOUNT'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(OrderProductTaxTableMap::DATABASE_NAME)->getTable(OrderProductTaxTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductTaxTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderProductTaxTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderProductTaxTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a OrderProductTax or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or OrderProductTax object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderProductTax) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderProductTaxTableMap::DATABASE_NAME); + $criteria->add(OrderProductTaxTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderProductTaxQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderProductTaxTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderProductTaxTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_product_tax table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderProductTaxQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderProductTax or Criteria object. + * + * @param mixed $criteria Criteria or OrderProductTax object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTaxTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderProductTax object + } + + if ($criteria->containsKey(OrderProductTaxTableMap::ID) && $criteria->keyContainsValue(OrderProductTaxTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductTaxTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderProductTaxQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderProductTaxTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderProductTaxTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php index fc23ae569..1e894ef24 100644 --- a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php @@ -57,7 +57,7 @@ class ProductSaleElementsTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 10; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductSaleElementsTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 9; + const NUM_HYDRATE_COLUMNS = 10; /** * the column name for the ID field @@ -104,6 +104,11 @@ class ProductSaleElementsTableMap extends TableMap */ const WEIGHT = 'product_sale_elements.WEIGHT'; + /** + * the column name for the IS_DEFAULT field + */ + const IS_DEFAULT = 'product_sale_elements.IS_DEFAULT'; + /** * the column name for the CREATED_AT field */ @@ -126,12 +131,12 @@ class ProductSaleElementsTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'isDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::IS_DEFAULT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'is_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -141,12 +146,12 @@ class ProductSaleElementsTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::CREATED_AT => 7, ProductSaleElementsTableMap::UPDATED_AT => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'created_at' => 7, 'updated_at' => 8, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'IsDefault' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'isDefault' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::IS_DEFAULT => 7, ProductSaleElementsTableMap::CREATED_AT => 8, ProductSaleElementsTableMap::UPDATED_AT => 9, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'IS_DEFAULT' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'is_default' => 7, 'created_at' => 8, 'updated_at' => 9, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -167,11 +172,12 @@ class ProductSaleElementsTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', true, 45, null); + $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0); $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0); - $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null); + $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, 0); + $this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', false, 1, false); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -355,6 +361,7 @@ class ProductSaleElementsTableMap extends TableMap $criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO); $criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS); $criteria->addSelectColumn(ProductSaleElementsTableMap::WEIGHT); + $criteria->addSelectColumn(ProductSaleElementsTableMap::IS_DEFAULT); $criteria->addSelectColumn(ProductSaleElementsTableMap::CREATED_AT); $criteria->addSelectColumn(ProductSaleElementsTableMap::UPDATED_AT); } else { @@ -365,6 +372,7 @@ class ProductSaleElementsTableMap extends TableMap $criteria->addSelectColumn($alias . '.PROMO'); $criteria->addSelectColumn($alias . '.NEWNESS'); $criteria->addSelectColumn($alias . '.WEIGHT'); + $criteria->addSelectColumn($alias . '.IS_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php index a06230c37..c50a30c90 100644 --- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -143,7 +143,7 @@ class TaxI18nTableMap extends TableMap $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php index 012ad2e72..24f8a41d7 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -143,7 +143,7 @@ class TaxRuleI18nTableMap extends TableMap $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); } // initialize() /** diff --git a/core/lib/Thelia/Model/Message.php b/core/lib/Thelia/Model/Message.php index aa6481ab8..4163e6d6b 100755 --- a/core/lib/Thelia/Model/Message.php +++ b/core/lib/Thelia/Model/Message.php @@ -5,7 +5,7 @@ namespace Thelia\Model; use Thelia\Model\Base\Message as BaseMessage; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\MessageEvent; +use Thelia\Core\Event\Message\MessageEvent; class Message extends BaseMessage { diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index c5d03b7e7..4033e5bfb 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -2,10 +2,17 @@ namespace Thelia\Model; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Connection\ConnectionInterface; -use Thelia\Core\Event\OrderEvent; +use Propel\Runtime\Propel; +use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Order as BaseOrder; +use Thelia\Model\Base\OrderProductTaxQuery; +use Thelia\Model\Map\OrderProductTaxTableMap; +use Thelia\Model\OrderProductQuery; +use Thelia\Model\Map\OrderTableMap; +use \PDO; class Order extends BaseOrder { @@ -19,20 +26,223 @@ class Order extends BaseOrder */ public function preInsert(ConnectionInterface $con = null) { - $this->dispatchEvent(TheliaEvents::ORDER_SET_REFERENCE, new OrderEvent($this)); + $this->setRef($this->generateRef()); + + $this->dispatchEvent(TheliaEvents::ORDER_BEFORE_CREATE, new OrderEvent($this)); return true; } + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this)); + } + + public function generateRef() + { + /* order addresses are unique */ + return uniqid('ORD', true); + } + /** * calculate the total amount * - * @TODO create body method + * @param int $tax * - * @return int + * @return int|string|Base\double */ - public function getTotalAmount() + public function getTotalAmount(&$tax = 0) { - return 2; + $amount = 0; + $tax = 0; + + /* browse all products */ + $orderProductIds = array(); + foreach($this->getOrderProducts() as $orderProduct) { + $taxAmountQuery = OrderProductTaxQuery::create(); + + if($orderProduct->getWasInPromo() == 1) { + $taxAmountQuery->withColumn('SUM(' . OrderProductTaxTableMap::PROMO_AMOUNT . ')', 'total_tax'); + } else { + $taxAmountQuery->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax'); + } + + $taxAmount = $taxAmountQuery->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL) + ->findOne(); + $amount += ($orderProduct->getWasInPromo() == 1 ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) * $orderProduct->getQuantity(); + $tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity(); + } + + return $amount + $tax + $this->getPostage(); // @todo : manage discount + } + + /** + * PROPEL SHOULD FIX IT + * + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; + } + if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_DATE'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_ID'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE'; + } + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) { + $modifiedColumns[':p' . $index++] = 'TRANSACTION_REF'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_REF'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_REF'; + } + if ($this->isColumnModified(OrderTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; + } + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::STATUS_ID)) { + $modifiedColumns[':p' . $index++] = 'STATUS_ID'; + } + if ($this->isColumnModified(OrderTableMap::LANG_ID)) { + $modifiedColumns[':p' . $index++] = 'LANG_ID'; + } + if ($this->isColumnModified(OrderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $db = Propel::getServiceContainer()->getAdapter(OrderTableMap::DATABASE_NAME); + + if ($db->useQuoteIdentifier()) { + $tableName = $db->quoteIdentifierTable(OrderTableMap::TABLE_NAME); + } else { + $tableName = OrderTableMap::TABLE_NAME; + } + + $sql = sprintf( + 'INSERT INTO %s (%s) VALUES (%s)', + $tableName, + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'REF': + $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); + break; + case 'CUSTOMER_ID': + $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); + break; + case 'INVOICE_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT); + break; + case 'DELIVERY_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT); + break; + case 'INVOICE_DATE': + $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'CURRENCY_ID': + $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); + break; + case 'CURRENCY_RATE': + $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); + break; + case 'TRANSACTION_REF': + $stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR); + break; + case 'DELIVERY_REF': + $stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR); + break; + case 'INVOICE_REF': + $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR); + break; + case 'POSTAGE': + $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); + break; + case 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); + break; + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT); + break; + case 'STATUS_ID': + $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); + break; + case 'LANG_ID': + $stmt->bindValue($identifier, $this->lang_id, 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; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); } } diff --git a/core/lib/Thelia/Model/OrderProduct.php b/core/lib/Thelia/Model/OrderProduct.php old mode 100755 new mode 100644 index 2c0e189aa..b73ef9852 --- a/core/lib/Thelia/Model/OrderProduct.php +++ b/core/lib/Thelia/Model/OrderProduct.php @@ -2,8 +2,30 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\Order\OrderEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\OrderProduct as BaseOrderProduct; -class OrderProduct extends BaseOrderProduct { +class OrderProduct extends BaseOrderProduct +{ + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_BEFORE_CREATE, new OrderEvent($this->getOrder())); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_AFTER_CREATE, new OrderEvent($this->getOrder())); + } } diff --git a/core/lib/Thelia/Model/OrderProductAttributeCombination.php b/core/lib/Thelia/Model/OrderProductAttributeCombination.php new file mode 100644 index 000000000..1f9cee13d --- /dev/null +++ b/core/lib/Thelia/Model/OrderProductAttributeCombination.php @@ -0,0 +1,10 @@ +prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (\Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new Order(); + $obj->hydrate($row); + OrderTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + return $obj; + } } // OrderQuery diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index cbb6c0051..f48f9e75e 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -8,7 +8,7 @@ use Thelia\Tools\URL; use Thelia\TaxEngine\Calculator; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\ProductEvent; +use Thelia\Core\Event\Product\ProductEvent; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Propel; use Thelia\Model\Map\ProductTableMap; @@ -87,12 +87,46 @@ class Product extends BaseProduct return $this; } + public function updateDefaultCategory($defaultCategoryId) { + + // Allow uncategorized products (NULL instead of 0, to bypass delete cascade constraint) + if ($defaultCategoryId <= 0) $defaultCategoryId = NULL; + + // Update the default category + $productCategory = ProductCategoryQuery::create() + ->filterByProductId($this->getId()) + ->filterByDefaultCategory(true) + ->findOne() + ; + + if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) { + exit; + // Delete the old default category + if ($productCategory !== null) $productCategory->delete(); + + // Add the new default category + $productCategory = new ProductCategory(); + + $productCategory + ->setProduct($this) + ->setCategoryId($defaultCategoryId) + ->setDefaultCategory(true) + ->save() + ; + } + } + /** * Create a new product, along with the default category ID * * @param int $defaultCategoryId the default category ID of this product + * @param float $basePrice the product base price + * @param int $priceCurrencyId the price currency Id + * @param int $taxRuleId the product tax rule ID + * @param float $baseWeight base weight in Kg */ - public function create($defaultCategoryId) { + + public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) { $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME); @@ -105,18 +139,13 @@ class Product extends BaseProduct $this->save($con); // Add the default category - $pc = new ProductCategory(); - - $pc - ->setProduct($this) - ->setCategoryId($defaultCategoryId) - ->setDefaultCategory(true) - ->save($con) - ; + $this->updateDefaultCategory($defaultCategoryId); // Set the position $this->setPosition($this->getNextPosition())->save($con); + $this->setTaxRuleId($taxRuleId); + // Create an empty product sale element $sale_elements = new ProductSaleElements(); @@ -125,7 +154,8 @@ class Product extends BaseProduct ->setRef($this->getRef()) ->setPromo(0) ->setNewness(0) - ->setWeight(0) + ->setWeight($baseWeight) + ->setIsDefault(true) ->save($con) ; @@ -134,9 +164,9 @@ class Product extends BaseProduct $product_price ->setProductSaleElements($sale_elements) - ->setPromoPrice(0) - ->setPrice(0) - ->setCurrency(CurrencyQuery::create()->findOneByByDefault(true)) + ->setPromoPrice($basePrice) + ->setPrice($basePrice) + ->setCurrencyId($priceCurrencyId) ->save($con) ; diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php index e07ee2cd6..12be080fc 100644 --- a/core/lib/Thelia/Model/ProductAssociatedContent.php +++ b/core/lib/Thelia/Model/ProductAssociatedContent.php @@ -4,18 +4,29 @@ namespace Thelia\Model; use Thelia\Model\Base\ProductAssociatedContent as BaseProductAssociatedContent; use Propel\Runtime\Connection\ConnectionInterface; -use Thelia\Core\Event\ProductAssociatedContentEvent; +use Thelia\Core\Event\Product\ProductAssociatedContentEvent; use Thelia\Core\Event\TheliaEvents; class ProductAssociatedContent extends BaseProductAssociatedContent { use \Thelia\Model\Tools\ModelEventDispatcherTrait; + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * Calculate next position relative to our product + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByProductId($this->getProductId()); + } + /** * {@inheritDoc} */ public function preInsert(ConnectionInterface $con = null) { + $this->setPosition($this->getNextPosition()); + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); return true; diff --git a/core/lib/Thelia/Model/ProductDocument.php b/core/lib/Thelia/Model/ProductDocument.php index 53515ff3c..b0f8032da 100755 --- a/core/lib/Thelia/Model/ProductDocument.php +++ b/core/lib/Thelia/Model/ProductDocument.php @@ -26,4 +26,28 @@ class ProductDocument extends BaseProductDocument return true; } + /** + * Set Document parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setProductId($parentId); + + return $this; + } + + /** + * Get Document parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getProductId(); + } + } diff --git a/core/lib/Thelia/Model/ProductImage.php b/core/lib/Thelia/Model/ProductImage.php index 4bf0c40a6..6cc3ddd8c 100755 --- a/core/lib/Thelia/Model/ProductImage.php +++ b/core/lib/Thelia/Model/ProductImage.php @@ -25,4 +25,28 @@ class ProductImage extends BaseProductImage return true; } + + /** + * Set Image parent id + * + * @param int $parentId parent id + * + * @return $this + */ + public function setParentId($parentId) + { + $this->setProductId($parentId); + + return $this; + } + + /** + * Get Image parent id + * + * @return int parent id + */ + public function getParentId() + { + return $this->getProductId(); + } } diff --git a/core/lib/Thelia/Model/TaxRule.php b/core/lib/Thelia/Model/TaxRule.php index 36f80a044..e66e013d0 100755 --- a/core/lib/Thelia/Model/TaxRule.php +++ b/core/lib/Thelia/Model/TaxRule.php @@ -3,7 +3,32 @@ namespace Thelia\Model; use Thelia\Model\Base\TaxRule as BaseTaxRule; +use Thelia\TaxEngine\Calculator; +use Thelia\TaxEngine\OrderProductTaxCollection; -class TaxRule extends BaseTaxRule { +class TaxRule extends BaseTaxRule +{ + /** + * @param Country $country + * @param $untaxedAmount + * @param $untaxedPromoAmount + * @param null $askedLocale + * + * @return OrderProductTaxCollection + */ + public function getTaxDetail(Country $country, $untaxedAmount, $untaxedPromoAmount, $askedLocale = null) + { + $taxCalculator = new Calculator(); + $taxCollection = new OrderProductTaxCollection(); + $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale); + $promoTaxCollection = new OrderProductTaxCollection(); + $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedPromoAmount, $promoTaxCollection, $askedLocale); + + foreach($taxCollection as $index => $tax) { + $tax->setPromoAmount($promoTaxCollection->getKey($index)->getAmount()); + } + + return $taxCollection; + } } diff --git a/core/lib/Thelia/Model/TaxRuleQuery.php b/core/lib/Thelia/Model/TaxRuleQuery.php index d5ce47546..572500003 100755 --- a/core/lib/Thelia/Model/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/TaxRuleQuery.php @@ -21,13 +21,19 @@ class TaxRuleQuery extends BaseTaxRuleQuery { const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition'; - public function getTaxCalculatorCollection(Product $product, Country $country) + /** + * @param TaxRule $taxRule + * @param Country $country + * + * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection + */ + public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country) { $search = TaxQuery::create() ->filterByTaxRuleCountry( TaxRuleCountryQuery::create() ->filterByCountry($country, Criteria::EQUAL) - ->filterByTaxRuleId($product->getTaxRuleId()) + ->filterByTaxRuleId($taxRule->getId()) ->orderByPosition() ->find() ) diff --git a/core/lib/Thelia/Model/Template.php b/core/lib/Thelia/Model/Template.php index 881187573..1772421bb 100644 --- a/core/lib/Thelia/Model/Template.php +++ b/core/lib/Thelia/Model/Template.php @@ -4,7 +4,7 @@ namespace Thelia\Model; use Thelia\Model\Base\Template as BaseTemplate; use Propel\Runtime\Connection\ConnectionInterface; -use Thelia\Core\Event\TemplateEvent; +use Thelia\Core\Event\Template\TemplateEvent; use Thelia\Core\Event\TheliaEvents; class Template extends BaseTemplate diff --git a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php index 70da830ac..edbbad62b 100644 --- a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php +++ b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php @@ -126,7 +126,8 @@ trait PositionManagementTrait { $result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save(); $cnx->commit(); - } catch (Exception $e) { + } + catch (Exception $e) { $cnx->rollback(); } } @@ -179,7 +180,10 @@ trait PositionManagementTrait { try { foreach ($results as $result) { - $result->setDispatcher($this->getDispatcher())->setPosition($result->getPosition() + $delta)->save($cnx); + + $objNewPosition = $result->getPosition() + $delta; + + $result->setDispatcher($this->getDispatcher())->setPosition($objNewPosition)->save($cnx); } $this @@ -188,9 +192,26 @@ trait PositionManagementTrait { ; $cnx->commit(); - } catch (Exception $e) { + } + catch (Exception $e) { $cnx->rollback(); } } } + + protected function reorderBeforeDelete() + { + // Find DATABASE_NAME constant + $mapClassName = self::TABLE_MAP; + + $sql = sprintf("UPDATE `%s` SET position=(position-1) WHERE parent=:parent AND position>:position", $mapClassName::TABLE_NAME); + + $con = Propel::getConnection($mapClassName::DATABASE_NAME); + $statement = $con->prepare($sql); + + $statement->execute(array( + ':parent' => $this->getParent(), + ':position' => $this->getPosition() + )); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php index 19947efa6..0a8af40c8 100644 --- a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php +++ b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php @@ -44,8 +44,11 @@ trait UrlRewritingTrait { * * @param string $locale a valid locale (e.g. en_US) */ - public function getUrl($locale) + public function getUrl($locale = null) { + if(null === $locale) { + $locale = $this->getLocale(); + } return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString(); } diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index f559c1fd5..37c40c953 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -25,7 +25,9 @@ namespace Thelia\Module; use Symfony\Component\DependencyInjection\ContainerAware; +use Thelia\Model\ModuleI18nQuery; use Thelia\Model\Map\ModuleImageTableMap; +use Thelia\Model\ModuleI18n; use Thelia\Tools\Image; use Thelia\Exception\ModuleException; use Thelia\Model\Module; @@ -49,12 +51,12 @@ abstract class BaseModule extends ContainerAware public function activate() { $moduleModel = $this->getModuleModel(); - if($moduleModel->getActivate() == self::IS_NOT_ACTIVATED) { + if ($moduleModel->getActivate() == self::IS_NOT_ACTIVATED) { $moduleModel->setActivate(self::IS_ACTIVATED); $moduleModel->save(); try { $this->afterActivation(); - } catch(\Exception $e) { + } catch (\Exception $e) { $moduleModel->setActivate(self::IS_NOT_ACTIVATED); $moduleModel->save(); throw $e; @@ -76,11 +78,32 @@ abstract class BaseModule extends ContainerAware return $this->container; } + public function setTitle(Module $module, $titles) + { + if (is_array($titles)) { + foreach ($titles as $locale => $title) { + $moduleI18n = ModuleI18nQuery::create()->filterById($module->getId())->filterByLocale($locale)->findOne(); + if (null === $moduleI18n) { + $moduleI18n = new ModuleI18n(); + $moduleI18n + ->setId($module->getId()) + ->setLocale($locale) + ->setTitle($title) + ; + $moduleI18n->save(); + } else { + $moduleI18n->setTitle($title); + $moduleI18n->save(); + } + } + } + } + public function deployImageFolder(Module $module, $folderPath) { try { $directoryBrowser = new \DirectoryIterator($folderPath); - } catch(\UnexpectedValueException $e) { + } catch (\UnexpectedValueException $e) { throw $e; } @@ -90,7 +113,7 @@ abstract class BaseModule extends ContainerAware /* browse the directory */ $imagePosition = 1; - foreach($directoryBrowser as $directoryContent) { + foreach ($directoryBrowser as $directoryContent) { /* is it a file ? */ if ($directoryContent->isFile()) { @@ -98,7 +121,7 @@ abstract class BaseModule extends ContainerAware $filePath = $directoryContent->getPathName(); /* is it a picture ? */ - if( Image::isImage($filePath) ) { + if ( Image::isImage($filePath) ) { $con->beginTransaction(); @@ -111,7 +134,7 @@ abstract class BaseModule extends ContainerAware $imageFileName = sprintf("%s-%d-%s", $module->getCode(), $image->getId(), $fileName); $increment = 0; - while(file_exists($imageDirectory . '/' . $imageFileName)) { + while (file_exists($imageDirectory . '/' . $imageFileName)) { $imageFileName = sprintf("%s-%d-%d-%s", $module->getCode(), $image->getId(), $increment, $fileName); $increment++; } @@ -119,13 +142,13 @@ abstract class BaseModule extends ContainerAware $imagePath = sprintf('%s/%s', $imageDirectory, $imageFileName); if (! is_dir($imageDirectory)) { - if(! @mkdir($imageDirectory, 0777, true)) { + if (! @mkdir($imageDirectory, 0777, true)) { $con->rollBack(); throw new ModuleException(sprintf("Cannot create directory : %s", $imageDirectory), ModuleException::CODE_NOT_FOUND); } } - if(! @copy($filePath, $imagePath)) { + if (! @copy($filePath, $imagePath)) { $con->rollBack(); throw new ModuleException(sprintf("Cannot copy file : %s to : %s", $filePath, $imagePath), ModuleException::CODE_NOT_FOUND); } @@ -148,7 +171,7 @@ abstract class BaseModule extends ContainerAware { $moduleModel = ModuleQuery::create()->findOneByCode($this->getCode()); - if(null === $moduleModel) { + if (null === $moduleModel) { throw new ModuleException(sprintf("Module Code `%s` not found", $this->getCode()), ModuleException::CODE_NOT_FOUND); } diff --git a/core/lib/Thelia/Module/PaymentModuleInterface.php b/core/lib/Thelia/Module/PaymentModuleInterface.php index d864ae50a..90f8ea0a9 100644 --- a/core/lib/Thelia/Module/PaymentModuleInterface.php +++ b/core/lib/Thelia/Module/PaymentModuleInterface.php @@ -23,8 +23,6 @@ namespace Thelia\Module; -use Thelia\Model\Country; - interface PaymentModuleInterface extends BaseModuleInterface { /** diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php index b5a2f995e..8039dec39 100755 --- a/core/lib/Thelia/TaxEngine/Calculator.php +++ b/core/lib/Thelia/TaxEngine/Calculator.php @@ -24,8 +24,11 @@ namespace Thelia\TaxEngine; use Thelia\Exception\TaxEngineException; use Thelia\Model\Country; +use Thelia\Model\OrderProductTax; use Thelia\Model\Product; +use Thelia\Model\TaxRule; use Thelia\Model\TaxRuleQuery; +use Thelia\Tools\I18n; /** * Class Calculator @@ -68,14 +71,34 @@ class Calculator $this->product = $product; $this->country = $country; - $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product, $country); + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product->getTaxRule(), $country); return $this; } - public function getTaxAmountFromUntaxedPrice($untaxedPrice) + public function loadTaxRule(TaxRule $taxRule, Country $country) { - return $this->getTaxedPrice($untaxedPrice) - $untaxedPrice; + $this->product = null; + $this->country = null; + $this->taxRulesCollection = null; + + if($taxRule->getId() === null) { + throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); + } + if($country->getId() === null) { + throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); + } + + $this->country = $country; + + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country); + + return $this; + } + + public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null) + { + return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice; } public function getTaxAmountFromTaxedPrice($taxedPrice) @@ -83,7 +106,15 @@ class Calculator return $taxedPrice - $this->getUntaxedPrice($taxedPrice); } - public function getTaxedPrice($untaxedPrice) + /** + * @param $untaxedPrice + * @param null $taxCollection returns OrderProductTaxCollection + * @param null $askedLocale + * + * @return int + * @throws \Thelia\Exception\TaxEngineException + */ + public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null) { if(null === $this->taxRulesCollection) { throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION); @@ -97,6 +128,9 @@ class Calculator $currentPosition = 1; $currentTax = 0; + if(null !== $taxCollection) { + $taxCollection = new OrderProductTaxCollection(); + } foreach($this->taxRulesCollection as $taxRule) { $position = (int)$taxRule->getTaxRuleCountryPosition(); @@ -109,7 +143,17 @@ class Calculator $currentPosition = $position; } - $currentTax += $taxType->calculate($taxedPrice); + $taxAmount = round($taxType->calculate($taxedPrice), 2); + $currentTax += $taxAmount; + + if(null !== $taxCollection) { + $taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId()); + $orderProductTax = new OrderProductTax(); + $orderProductTax->setTitle($taxI18n->getTitle()); + $orderProductTax->setDescription($taxI18n->getDescription()); + $orderProductTax->setAmount($taxAmount); + $taxCollection->addTax($orderProductTax); + } } $taxedPrice += $currentTax; diff --git a/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php new file mode 100755 index 000000000..5c4ac2022 --- /dev/null +++ b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php @@ -0,0 +1,126 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\TaxEngine; + +use Thelia\Model\OrderProductTax; + +/** + * + * @author Etienne Roudeix + * + */ +class OrderProductTaxCollection implements \Iterator +{ + private $position; + protected $taxes = array(); + + public function __construct() + { + foreach (func_get_args() as $tax) { + $this->addTax($tax); + } + } + + public function isEmpty() + { + return count($this->taxes) == 0; + } + + /** + * @param OrderProductTax $tax + * + * @return OrderProductTaxCollection + */ + public function addTax(OrderProductTax $tax) + { + $this->taxes[] = $tax; + + return $this; + } + + public function getCount() + { + return count($this->taxes); + } + + /** + * (PHP 5 >= 5.0.0)
+ * Return the current element + * @link http://php.net/manual/en/iterator.current.php + * @return OrderProductTax + */ + public function current() + { + return $this->taxes[$this->position]; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Move forward to next element + * @link http://php.net/manual/en/iterator.next.php + * @return void Any returned value is ignored. + */ + public function next() + { + $this->position++; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Return the key of the current element + * @link http://php.net/manual/en/iterator.key.php + * @return mixed scalar on success, or null on failure. + */ + public function key() + { + return $this->position; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Checks if current position is valid + * @link http://php.net/manual/en/iterator.valid.php + * @return boolean The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. + */ + public function valid() + { + return isset($this->taxes[$this->position]); + } + + /** + * (PHP 5 >= 5.0.0)
+ * Rewind the Iterator to the first element + * @link http://php.net/manual/en/iterator.rewind.php + * @return void Any returned value is ignored. + */ + public function rewind() + { + $this->position = 0; + } + + public function getKey($key) + { + return isset($this->taxes[$key]) ? $this->taxes[$key] : null; + } +} diff --git a/core/lib/Thelia/Tests/Action/AddressTest.php b/core/lib/Thelia/Tests/Action/AddressTest.php index 69f5b5329..9c4198c06 100644 --- a/core/lib/Thelia/Tests/Action/AddressTest.php +++ b/core/lib/Thelia/Tests/Action/AddressTest.php @@ -22,9 +22,11 @@ /*************************************************************************************/ namespace Thelia\Tests\Action; + use Thelia\Action\Address; -use Thelia\Core\Event\AddressCreateOrUpdateEvent; +use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent; use Thelia\Model\Base\CustomerQuery; +use Thelia\Tests\Action\BaseAction; /** * @@ -34,20 +36,9 @@ use Thelia\Model\Base\CustomerQuery; * @package Thelia\Tests\Action * @author Manuel Raynaud */ -class AddressTest extends \PHPUnit_Framework_TestCase +class AddressTest extends BaseAction { - public function getContainer() - { - $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); - - $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); - - $container->set("event_dispatcher", $dispatcher); - - return $container; - } - public function testCreatedAddress() { $customer = CustomerQuery::create()->findOne(); diff --git a/core/lib/Thelia/Tests/Action/BaseAction.php b/core/lib/Thelia/Tests/Action/BaseAction.php new file mode 100644 index 000000000..f0027fd21 --- /dev/null +++ b/core/lib/Thelia/Tests/Action/BaseAction.php @@ -0,0 +1,44 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action; + + +/** + * Class BaseAction + * @package Thelia\Tests\Action\ImageTest + * @author Manuel Raynaud + */ +class BaseAction extends \PHPUnit_Framework_TestCase +{ + public function getContainer() + { + $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); + + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + + $container->set("event_dispatcher", $dispatcher); + + return $container; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Action/ContentTest.php b/core/lib/Thelia/Tests/Action/ContentTest.php new file mode 100644 index 000000000..7aa819346 --- /dev/null +++ b/core/lib/Thelia/Tests/Action/ContentTest.php @@ -0,0 +1,276 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Action\Content; +use Thelia\Core\Event\Content\ContentAddFolderEvent; +use Thelia\Core\Event\Content\ContentCreateEvent; +use Thelia\Core\Event\Content\ContentDeleteEvent; +use Thelia\Core\Event\Content\ContentRemoveFolderEvent; +use Thelia\Core\Event\Content\ContentToggleVisibilityEvent; +use Thelia\Core\Event\Content\ContentUpdateEvent; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\ContentFolder; +use Thelia\Model\ContentFolderQuery; +use Thelia\Model\ContentQuery; +use Thelia\Model\FolderQuery; + + +/** + * Class ContentTest + * @package Thelia\Tests\Action + * @author Manuel Raynaud + */ +class ContentTest extends BaseAction +{ + public function testCreateContent() + { + $folder = $this->getRandomFolder(); + + $event = new ContentCreateEvent(); + $event + ->setVisible(1) + ->setLocale('en_US') + ->setTitle('test create content') + ->setDefaultFolder($folder->getId()) + ; + + $contentAction = new Content($this->getContainer()); + $contentAction->create($event); + + $createdContent = $event->getContent(); + + $this->assertInstanceOf('Thelia\Model\Content', $createdContent); + $this->assertEquals(1, $createdContent->getVisible()); + $this->assertEquals('test create content', $createdContent->getTitle()); + $this->assertEquals($folder->getId(), $createdContent->getDefaultFolderId()); + + } + + public function testUpdateContent() + { + $content = $this->getRandomContent(); + $folder = $this->getRandomFolder(); + + $event = new ContentUpdateEvent($content->getId()); + $event + ->setVisible(1) + ->setLocale('en_US') + ->setTitle('test update content title') + ->setChapo('test update content short description') + ->setDescription('test update content description') + ->setPostscriptum('test update content postscriptum') + ->setDefaultFolder($folder->getId()) + ; + + $contentAction = new Content($this->getContainer()); + $contentAction->update($event); + + $updatedContent = $event->getContent(); + + $this->assertInstanceOf('Thelia\Model\Content', $updatedContent); + $this->assertEquals(1, $updatedContent->getVisible()); + $this->assertEquals('test update content title', $updatedContent->getTitle()); + $this->assertEquals('test update content short description', $updatedContent->getChapo()); + $this->assertEquals('test update content description', $updatedContent->getDescription()); + $this->assertEquals('test update content postscriptum', $updatedContent->getPostscriptum()); + $this->assertEquals($folder->getId(), $updatedContent->getDefaultFolderId()); + } + + public function testDeleteContent() + { + $content = $this->getRandomContent(); + + $event = new ContentDeleteEvent($content->getId()); + + $contentAction = new Content($this->getContainer()); + $contentAction->delete($event); + + $deletedContent = $event->getContent(); + + $this->assertInstanceOf('Thelia\Model\Content', $deletedContent); + $this->assertTrue($deletedContent->isDeleted()); + + } + + public function testContentToggleVisibility() + { + $content = $this->getRandomContent(); + + $visibility = $content->getVisible(); + + $event = new ContentToggleVisibilityEvent($content); + + $contentAction = new Content($this->getContainer()); + $contentAction->toggleVisibility($event); + + $updatedContent = $event->getContent(); + + $this->assertInstanceOf('Thelia\Model\Content', $updatedContent); + $this->assertEquals(!$visibility, $updatedContent->getVisible()); + } + + public function testUpdatePositionUp() + { + $content = ContentQuery::create() + ->filterByPosition(1, Criteria::GREATER_THAN) + ->findOne(); + + if (null === $content) { + $this->fail('use fixtures before launching test, there is no content in database'); + } + + $newPosition = $content->getPosition()-1; + + $event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_UP); + + $contentAction = new Content($this->getContainer()); + $contentAction->updatePosition($event); + + $updatedContent = ContentQuery::create()->findPk($content->getId()); + + $this->assertEquals($newPosition, $updatedContent->getPosition(),sprintf("new position is %d, new position expected is %d for content %d", $newPosition, $updatedContent->getPosition(), $updatedContent->getId())); + } + + public function testUpdatePositionDown() + { + $content = ContentQuery::create() + ->filterByPosition(1) + ->findOne(); + + if (null === $content) { + $this->fail('use fixtures before launching test, there is no content in database'); + } + + $newPosition = $content->getPosition()+1; + + $event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_DOWN); + + $contentAction = new Content($this->getContainer()); + $contentAction->updatePosition($event); + + $updatedContent = ContentQuery::create()->findPk($content->getId()); + + $this->assertEquals($newPosition, $updatedContent->getPosition(),sprintf("new position is %d, new position expected is %d for content %d", $newPosition, $updatedContent->getPosition(), $updatedContent->getId())); + } + + public function testUpdatePositionWithSpecificPosition() + { + $content = ContentQuery::create() + ->filterByPosition(1, Criteria::GREATER_THAN) + ->findOne(); + + if (null === $content) { + $this->fail('use fixtures before launching test, there is no content in database'); + } + + $event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, 1); + + $contentAction = new Content($this->getContainer()); + $contentAction->updatePosition($event); + + $updatedContent = ContentQuery::create()->findPk($content->getId()); + + $this->assertEquals(1, $updatedContent->getPosition(),sprintf("new position is 1, new position expected is %d for content %d", $updatedContent->getPosition(), $updatedContent->getId())); + } + + public function testAddFolderToContent() + { + $content = $this->getRandomContent(); + + do { + $folder = $this->getRandomFolder(); + + $test = ContentFolderQuery::create() + ->filterByContent($content) + ->filterByFolder($folder); + } while($test->count() > 0); + + $event = new ContentAddFolderEvent($content, $folder->getId()); + + $contentAction = new Content($this->getContainer()); + $contentAction->addFolder($event); + + $testAddFolder = ContentFolderQuery::create() + ->filterByContent($content) + ->filterByFolder($folder) + ->findOne() + ; + + $this->assertNotNull($testAddFolder); + $this->assertEquals($content->getId(), $testAddFolder->getContentId(), 'check if content id are equals'); + $this->assertEquals($folder->getId(), $testAddFolder->getFolderId(), 'check if folder id are equals'); + + return $testAddFolder; + } + + /** + * @depends testAddFolderToContent + */ + public function testRemoveFolder(ContentFolder $association) + { + $event = new ContentRemoveFolderEvent($association->getContent(), $association->getFolder()->getId()); + + $contentAction = new Content($this->getContainer()); + $contentAction->removeFolder($event); + + $testAssociation = ContentFolderQuery::create() + ->filterByContent($association->getContent()) + ->filterByFolder($association->getFolder()) + ->findOne(); + + $this->assertNull($testAssociation); + } + /** + * @return \Thelia\Model\Content + */ + protected function getRandomContent() + { + $content = ContentQuery::create() + ->addAscendingOrderByColumn('RAND()') + ->findOne(); + + if (null === $content) { + $this->fail('use fixtures before launching test, there is no content in database'); + } + + return $content; + } + + /** + * @return \Thelia\Model\Folder + */ + protected function getRandomFolder() + { + $folder = FolderQuery::create() + ->addAscendingOrderByColumn('RAND()') + ->findOne(); + + if(null === $folder) { + $this->fail('use fixtures before launching test, there is no folder in database'); + } + + return $folder; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Action/CustomerTest.php b/core/lib/Thelia/Tests/Action/CustomerTest.php index 10ba01587..50ef4fde6 100644 --- a/core/lib/Thelia/Tests/Action/CustomerTest.php +++ b/core/lib/Thelia/Tests/Action/CustomerTest.php @@ -23,8 +23,7 @@ namespace Thelia\Tests\Action\ImageTest; use Thelia\Action\Customer; -use Thelia\Core\Event\CustomerCreateOrUpdateEvent; - +use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; /** * Class CustomerTest @@ -101,4 +100,4 @@ class CustomerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($customerCreateEvent->getCellphone(), $addressCreated->getCellphone()); $this->assertEquals($customerCreateEvent->getCompany(), $addressCreated->getCompany()); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Action/DocumentTest.php b/core/lib/Thelia/Tests/Action/DocumentTest.php index 39aece1f4..17a841d94 100644 --- a/core/lib/Thelia/Tests/Action/DocumentTest.php +++ b/core/lib/Thelia/Tests/Action/DocumentTest.php @@ -21,14 +21,14 @@ /* */ /*************************************************************************************/ -namespace Thelia\Tests\Action\DocumentTest; +namespace Thelia\Tests\Action; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Action\Document; -use Thelia\Core\Event\DocumentEvent; +use Thelia\Core\Event\Document\DocumentEvent; use Thelia\Model\ConfigQuery; /** diff --git a/core/lib/Thelia/Tests/Action/FolderTest.php b/core/lib/Thelia/Tests/Action/FolderTest.php new file mode 100644 index 000000000..903e1b77b --- /dev/null +++ b/core/lib/Thelia/Tests/Action/FolderTest.php @@ -0,0 +1,224 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Action\Folder; +use Thelia\Core\Event\Folder\FolderCreateEvent; +use Thelia\Core\Event\Folder\FolderDeleteEvent; +use Thelia\Core\Event\Folder\FolderToggleVisibilityEvent; +use Thelia\Core\Event\Folder\FolderUpdateEvent; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Model\FolderQuery; + + +/** + * Class FolderTest + * @package Thelia\Tests\Action\ImageTest + * @author Manuel Raynaud + */ +class FolderTest extends BaseAction +{ + /** + * test folder creation + * @covers Thelia\Action\Folder::create + */ + public function testCreateFolder() + { + + $event = new FolderCreateEvent(); + $event + ->setParent(0) + ->setVisible(1) + ->setLocale('en_US') + ->setTitle('folder creation test'); + + $folderAction = new Folder($this->getContainer()); + + $folderAction->create($event); + + $folder = $event->getFolder(); + + $this->assertInstanceOf('Thelia\Model\Folder', $folder); + $this->assertEquals('folder creation test', $folder->getTitle()); + $this->assertEquals(1, $folder->getVisible()); + $this->assertEquals(0, $folder->getParent()); + } + + /** + * test update creation + * @covers Thelia\Action\Folder::update + */ + public function testUpdateFolder() + { + $folder = $this->getRandomFolder(); + + + + $visible = !$folder->getVisible(); + $event = new FolderUpdateEvent($folder->getId()); + + $event + ->setLocale('en_US') + ->setTitle('test update folder') + ->setVisible($visible) + ->setChapo('test folder update chapo') + ->setDescription('update folder description') + ->setPostscriptum('update folder postscriptum') + ->setParent(0) + ; + + $folderAction = new Folder($this->getContainer()); + $folderAction->update($event); + + $updatedFolder = $event->getFolder(); + + $this->assertInstanceOf('Thelia\Model\Folder', $updatedFolder); + $this->assertEquals('test update folder', $updatedFolder->getTitle()); + $this->assertEquals('test folder update chapo', $updatedFolder->getChapo()); + $this->assertEquals('update folder description', $updatedFolder->getDescription()); + $this->assertEquals('update folder postscriptum', $updatedFolder->getPostscriptum()); + $this->assertEquals(0, $updatedFolder->getParent()); + $this->assertEquals($visible, $updatedFolder->getVisible()); + } + + /** + * test folder removal + * @covers Thelia\Action\Folder::delete + */ + public function testDeleteFolder() + { + $folder = $this->getRandomFolder(); + + $event = new FolderDeleteEvent($folder->getId()); + + $folderAction = new Folder($this->getContainer()); + $folderAction->delete($event); + + $deletedFolder = $event->getFolder(); + + $this->assertInstanceOf('Thelia\Model\Folder', $deletedFolder); + $this->assertTrue($deletedFolder->isDeleted()); + } + + /** + * test folder toggle visibility + * @covers Thelia\Action\Folder::toggleVisibility + */ + public function testToggleVisibility() + { + $folder = $this->getRandomFolder(); + $visible = $folder->getVisible(); + + $event = new FolderToggleVisibilityEvent($folder); + + $folderAction = new Folder($this->getContainer()); + $folderAction->toggleVisibility($event); + + $updatedFolder = $event->getFolder(); + + $this->assertInstanceOf('Thelia\Model\Folder', $updatedFolder); + $this->assertEquals(!$visible, $updatedFolder->getVisible()); + } + + public function testUpdatePositionUp() + { + $folder = FolderQuery::create() + ->filterByPosition(1, Criteria::GREATER_THAN) + ->findOne(); + + if(null === $folder) { + $this->fail('use fixtures before launching test, there is no folder in database'); + } + + $newPosition = $folder->getPosition()-1; + + $event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_UP); + + $folderAction = new Folder($this->getContainer()); + $folderAction->updatePosition($event); + + $updatedFolder = FolderQuery::create()->findPk($folder->getId()); + + $this->assertEquals($newPosition, $updatedFolder->getPosition(),sprintf("new position is %d, new position expected is %d for folder %d", $newPosition, $updatedFolder->getPosition(), $updatedFolder->getId())); + } + + public function testUpdatePositionDown() + { + $folder = FolderQuery::create() + ->filterByPosition(1) + ->findOne(); + + if(null === $folder) { + $this->fail('use fixtures before launching test, there is no folder in database'); + } + + $newPosition = $folder->getPosition()+1; + + $event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_DOWN); + + $folderAction = new Folder($this->getContainer()); + $folderAction->updatePosition($event); + + $updatedFolder = FolderQuery::create()->findPk($folder->getId()); + + $this->assertEquals($newPosition, $updatedFolder->getPosition(),sprintf("new position is %d, new position expected is %d for folder %d", $newPosition, $updatedFolder->getPosition(), $updatedFolder->getId())); + } + + public function testUpdatePositionWithSpecificPosition() + { + $folder = FolderQuery::create() + ->filterByPosition(1, Criteria::GREATER_THAN) + ->findOne(); + + if(null === $folder) { + $this->fail('use fixtures before launching test, there is no folder in database'); + } + + $event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, 1); + + $folderAction = new Folder($this->getContainer()); + $folderAction->updatePosition($event); + + $updatedFolder = FolderQuery::create()->findPk($folder->getId()); + + $this->assertEquals(1, $updatedFolder->getPosition(),sprintf("new position is 1, new position expected is %d for folder %d", $updatedFolder->getPosition(), $updatedFolder->getId())); + + } + + /** + * @return \Thelia\Model\Folder + */ + protected function getRandomFolder() + { + $folder = FolderQuery::create() + ->addAscendingOrderByColumn('RAND()') + ->findOne(); + + if(null === $folder) { + $this->fail('use fixtures before launching test, there is no folder in database'); + } + + return $folder; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Action/ImageTest.php b/core/lib/Thelia/Tests/Action/ImageTest.php index f08da25b9..1b718f096 100755 --- a/core/lib/Thelia/Tests/Action/ImageTest.php +++ b/core/lib/Thelia/Tests/Action/ImageTest.php @@ -21,14 +21,14 @@ /* */ /*************************************************************************************/ -namespace Thelia\Tests\Action\ImageTest; +namespace Thelia\Tests\Action; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Action\Image; -use Thelia\Core\Event\ImageEvent; +use Thelia\Core\Event\Image\ImageEvent; use Thelia\Model\ConfigQuery; /** diff --git a/core/lib/Thelia/Tests/Action/OrderTest.php b/core/lib/Thelia/Tests/Action/OrderTest.php new file mode 100644 index 000000000..67628e718 --- /dev/null +++ b/core/lib/Thelia/Tests/Action/OrderTest.php @@ -0,0 +1,451 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action; +use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; +use Thelia\Core\Event\Order\OrderAddressEvent; +use Thelia\Core\Event\Order\OrderEvent; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\HttpFoundation\Session\Session; +use Thelia\Core\Security\SecurityContext; +use Thelia\Model\AddressQuery; +use Thelia\Model\Base\OrderAddressQuery; +use Thelia\Model\Base\OrderProductQuery; +use Thelia\Model\Base\OrderQuery; +use Thelia\Model\OrderAddress; +use Thelia\Model\OrderStatus; +use Thelia\Model\ProductSaleElementsQuery; +use Thelia\Model\Cart; +use Thelia\Model\CartItem; +use Thelia\Model\CurrencyQuery; +use Thelia\Model\CustomerQuery; +use Thelia\Model\ModuleQuery; +use Thelia\Model\Order as OrderModel; +use Thelia\Model\Customer as CustomerModel; +use Thelia\Action\Order; +use Thelia\Model\ProductQuery; +use Thelia\Module\BaseModule; + +/** + * Class CustomerTest + * @package Thelia\Tests\Action + * @author Etienne Roudeix + */ +class OrderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ContainerBuilder $container + */ + protected $container; + + /** + * @var Order $orderAction + */ + protected $orderAction; + + /** + * @var \Thelia\Core\Event\Order\OrderEvent $orderEvent + */ + protected $orderEvent; + + /** + * @var CustomerModel $customer + */ + protected $customer; + + /** + * @var Cart $customer + */ + protected $cart; + + /** + * @var CartItem[] + */ + protected $cartItems; + + public function setUp() + { + $container = new ContainerBuilder(); + + $session = new Session(new MockArraySessionStorage()); + $request = new Request(); + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + + $request->setSession($session); + + $container->set("event_dispatcher", $dispatcher); + $container->set('request', $request); + $container->set('thelia.securityContext', new SecurityContext($request)); + + $this->container = $container; + + $this->orderEvent = new OrderEvent(new OrderModel()); + + $this->orderAction = new Order($this->container); + + /* load customer */ + $this->customer = $this->loadCustomer(); + if (null === $this->customer) { + return; + } + + /* fill cart */ + $this->cart = $this->fillCart(); + + } + + public function loadCustomer() + { + $customer = CustomerQuery::create()->findOne(); + if (null === $customer) { + return null; + } + + $this->container->get('thelia.securityContext')->setCustomerUser($customer); + + return $customer; + } + + public function fillCart() + { + $currency = CurrencyQuery::create()->findOne(); + + //create a fake cart in database; + $cart = new Cart(); + $cart->setToken(uniqid("createorder", true)) + ->setCustomer($this->customer) + ->setCurrency($currency) + ->save(); + + /* add 3 items */ + $productList = array(); + for ($i=0; $i<3; $i++) { + $pse = ProductSaleElementsQuery::create() + ->filterByProduct( + ProductQuery::create() + ->filterByVisible(1) + ->filterById($productList, Criteria::NOT_IN) + ->find() + ) + ->filterByQuantity(5, Criteria::GREATER_EQUAL) + ->joinProductPrice('pp', Criteria::INNER_JOIN) + ->addJoinCondition('pp', 'currency_id = ?', $currency->getId(), null, \PDO::PARAM_INT) + ->withColumn('`pp`.price', 'price_PRICE') + ->withColumn('`pp`.promo_price', 'price_PROMO_PRICE') + ->findOne(); + + $productList[] = $pse->getProductId(); + + $cartItem = new CartItem(); + $cartItem + ->setCart($cart) + ->setProduct($pse->getProduct()) + ->setProductSaleElements($pse) + ->setQuantity($i+1) + ->setPrice($pse->getPrice()) + ->setPromoPrice($pse->getPromoPrice()) + ->setPromo($pse->getPromo()) + ->setPriceEndOfLife(time() + 60*60*24*30) + ->save(); + $this->cartItems[] = $cartItem; + } + + $this->container->get('request')->getSession()->setCart($cart->getId()); + + return $cart; + } + + public function testSetDeliveryAddress() + { + //$validAddressId = AddressQuery::create()->findOneByCustomerId($this->customer->getId()); + + $this->orderEvent->setDeliveryAddress(321); + + $this->orderAction->setDeliveryAddress($this->orderEvent); + + $this->assertEquals( + 321, + $this->orderEvent->getOrder()->chosenDeliveryAddress + ); + } + + public function testSetinvoiceAddress() + { + $this->orderEvent->setInvoiceAddress(654); + + $this->orderAction->setInvoiceAddress($this->orderEvent); + + $this->assertEquals( + 654, + $this->orderEvent->getOrder()->chosenInvoiceAddress + ); + } + + public function testSetDeliveryModule() + { + $this->orderEvent->setDeliveryModule(123); + + $this->orderAction->setDeliveryModule($this->orderEvent); + + $this->assertEquals( + 123, + $this->orderEvent->getOrder()->getDeliveryModuleId() + ); + } + + public function testSetPaymentModule() + { + $this->orderEvent->setPaymentModule(456); + + $this->orderAction->setPaymentModule($this->orderEvent); + + $this->assertEquals( + 456, + $this->orderEvent->getOrder()->getPaymentModuleId() + ); + } + + public function testCreate() + { + $validDeliveryAddress = AddressQuery::create()->findOneByCustomerId($this->customer->getId()); + $validInvoiceAddress = AddressQuery::create()->filterById($validDeliveryAddress->getId(), Criteria::NOT_EQUAL)->findOneByCustomerId($this->customer->getId()); + + $deliveryModule = ModuleQuery::create() + ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) + ->filterByActivate(1) + ->findOne(); + + if (null === $deliveryModule) { + throw new \Exception('No Delivery Module fixture found'); + } + + $paymentModule = ModuleQuery::create() + ->filterByType(BaseModule::PAYMENT_MODULE_TYPE) + ->filterByActivate(1) + ->findOne(); + + if (null === $paymentModule) { + throw new \Exception('No Payment Module fixture found'); + } + + $this->orderEvent->getOrder()->chosenDeliveryAddress = $validDeliveryAddress->getId(); + $this->orderEvent->getOrder()->chosenInvoiceAddress = $validInvoiceAddress->getId(); + $this->orderEvent->getOrder()->setDeliveryModuleId($deliveryModule->getId()); + $this->orderEvent->getOrder()->setPostage(20); + $this->orderEvent->getOrder()->setPaymentModuleId($paymentModule->getId()); + + /* memorize current stocks */ + $itemsStock = array(); + foreach ($this->cartItems as $index => $cartItem) { + $itemsStock[$index] = $cartItem->getProductSaleElements()->getQuantity(); + } + + $this->orderAction->create($this->orderEvent); + + $placedOrder = $this->orderEvent->getPlacedOrder(); + + $this->assertNotNull($placedOrder); + $this->assertNotNull($placedOrder->getId()); + + /* check customer */ + $this->assertEquals($this->customer->getId(), $placedOrder->getCustomerId(), 'customer i does not match'); + + /* check delivery address */ + $deliveryOrderAddress = $placedOrder->getOrderAddressRelatedByDeliveryOrderAddressId(); + $this->assertEquals($validDeliveryAddress->getCustomerTitle()->getId(), $deliveryOrderAddress->getCustomerTitleId(), 'delivery address title does not match'); + $this->assertEquals($validDeliveryAddress->getCompany(), $deliveryOrderAddress->getCompany(), 'delivery address company does not match'); + $this->assertEquals($validDeliveryAddress->getFirstname(), $deliveryOrderAddress->getFirstname(), 'delivery address fistname does not match'); + $this->assertEquals($validDeliveryAddress->getLastname(), $deliveryOrderAddress->getLastname(), 'delivery address lastname does not match'); + $this->assertEquals($validDeliveryAddress->getAddress1(), $deliveryOrderAddress->getAddress1(), 'delivery address address1 does not match'); + $this->assertEquals($validDeliveryAddress->getAddress2(), $deliveryOrderAddress->getAddress2(), 'delivery address address2 does not match'); + $this->assertEquals($validDeliveryAddress->getAddress3(), $deliveryOrderAddress->getAddress3(), 'delivery address address3 does not match'); + $this->assertEquals($validDeliveryAddress->getZipcode(), $deliveryOrderAddress->getZipcode(), 'delivery address zipcode does not match'); + $this->assertEquals($validDeliveryAddress->getCity(), $deliveryOrderAddress->getCity(), 'delivery address city does not match'); + $this->assertEquals($validDeliveryAddress->getPhone(), $deliveryOrderAddress->getPhone(), 'delivery address phone does not match'); + $this->assertEquals($validDeliveryAddress->getCountryId(), $deliveryOrderAddress->getCountryId(), 'delivery address country does not match'); + + /* check invoice address */ + $invoiceOrderAddress = $placedOrder->getOrderAddressRelatedByInvoiceOrderAddressId(); + $this->assertEquals($validInvoiceAddress->getCustomerTitle()->getId(), $invoiceOrderAddress->getCustomerTitleId(), 'invoice address title does not match'); + $this->assertEquals($validInvoiceAddress->getCompany(), $invoiceOrderAddress->getCompany(), 'invoice address company does not match'); + $this->assertEquals($validInvoiceAddress->getFirstname(), $invoiceOrderAddress->getFirstname(), 'invoice address fistname does not match'); + $this->assertEquals($validInvoiceAddress->getLastname(), $invoiceOrderAddress->getLastname(), 'invoice address lastname does not match'); + $this->assertEquals($validInvoiceAddress->getAddress1(), $invoiceOrderAddress->getAddress1(), 'invoice address address1 does not match'); + $this->assertEquals($validInvoiceAddress->getAddress2(), $invoiceOrderAddress->getAddress2(), 'invoice address address2 does not match'); + $this->assertEquals($validInvoiceAddress->getAddress3(), $invoiceOrderAddress->getAddress3(), 'invoice address address3 does not match'); + $this->assertEquals($validInvoiceAddress->getZipcode(), $invoiceOrderAddress->getZipcode(), 'invoice address zipcode does not match'); + $this->assertEquals($validInvoiceAddress->getCity(), $invoiceOrderAddress->getCity(), 'invoice address city does not match'); + $this->assertEquals($validInvoiceAddress->getPhone(), $invoiceOrderAddress->getPhone(), 'invoice address phone does not match'); + $this->assertEquals($validInvoiceAddress->getCountryId(), $invoiceOrderAddress->getCountryId(), 'invoice address country does not match'); + + /* check currency */ + $this->assertEquals($this->cart->getCurrencyId(), $placedOrder->getCurrencyId(), 'currency id does not match'); + $this->assertEquals($this->cart->getCurrency()->getRate(), $placedOrder->getCurrencyRate(), 'currency rate does not match'); + + /* check delivery module */ + $this->assertEquals(20, $placedOrder->getPostage(), 'postage does not match'); + $this->assertEquals($deliveryModule->getId(), $placedOrder->getDeliveryModuleId(), 'delivery module does not match'); + + /* check payment module */ + $this->assertEquals($paymentModule->getId(), $placedOrder->getPaymentModuleId(), 'payment module does not match'); + + /* check status */ + $this->assertEquals(OrderStatus::CODE_NOT_PAID, $placedOrder->getOrderStatus()->getCode(), 'status does not match'); + + /* check lang */ + $this->assertEquals($this->container->get('request')->getSession()->getLang()->getId(), $placedOrder->getLangId(), 'lang does not match'); + + /* check ordered product */ + foreach ($this->cartItems as $index => $cartItem) { + $orderProduct = OrderProductQuery::create() + ->filterByOrderId($placedOrder->getId()) + ->filterByProductRef($cartItem->getProduct()->getRef()) + ->filterByProductSaleElementsRef($cartItem->getProductSaleElements()->getRef()) + ->filterByQuantity($cartItem->getQuantity()) + ->filterByPrice($cartItem->getPrice(), Criteria::LIKE) + ->filterByPromoPrice($cartItem->getPromoPrice(), Criteria::LIKE) + ->filterByWasNew($cartItem->getProductSaleElements()->getNewness()) + ->filterByWasInPromo($cartItem->getPromo()) + ->filterByWeight($cartItem->getProductSaleElements()->getWeight()) + ->findOne(); + + $this->assertNotNull($orderProduct); + + /* check attribute combinations */ + $this->assertEquals( + $cartItem->getProductSaleElements()->getAttributeCombinations()->count(), + $orderProduct->getOrderProductAttributeCombinations()->count() + ); + + /* check stock decrease */ + $this->assertEquals( + $itemsStock[$index] - $orderProduct->getQuantity(), + $cartItem->getProductSaleElements()->getQuantity() + ); + + /* check tax */ + $orderProductTaxList = $orderProduct->getOrderProductTaxes(); + foreach ($cartItem->getProduct()->getTaxRule()->getTaxDetail($validDeliveryAddress->getCountry(), $cartItem->getPrice(), $cartItem->getPromoPrice()) as $index => $tax) { + $orderProductTax = $orderProductTaxList[$index]; + $this->assertEquals($tax->getAmount(), $orderProductTax->getAmount()); + $this->assertEquals($tax->getPromoAmount(), $orderProductTax->getPromoAmount()); + } + } + + return $placedOrder; + } + + /** + * @depends testCreate + * + * @param OrderModel $order + */ + public function testUpdateStatus(OrderModel $order) + { + $newStatus = $order->getStatusId() == 5 ? 1 : 5; + $this->orderEvent->setStatus($newStatus); + $this->orderEvent->setOrder($order); + + $this->orderAction->updateStatus($this->orderEvent); + + $this->assertEquals( + $newStatus, + $this->orderEvent->getOrder()->getStatusId() + ); + $this->assertEquals( + $newStatus, + OrderQuery::create()->findPk($order->getId())->getStatusId() + ); + } + + /** + * @depends testCreate + * + * @param OrderModel $order + */ + public function testUpdateDeliveryRef(OrderModel $order) + { + $deliveryRef = uniqid('DELREF'); + $this->orderEvent->setDeliveryRef($deliveryRef); + $this->orderEvent->setOrder($order); + + $this->orderAction->updateDeliveryRef($this->orderEvent); + + $this->assertEquals( + $deliveryRef, + $this->orderEvent->getOrder()->getDeliveryRef() + ); + $this->assertEquals( + $deliveryRef, + OrderQuery::create()->findPk($order->getId())->getDeliveryRef() + ); + } + + /** + * @depends testCreate + * + * @param OrderModel $order + */ + public function testUpdateAddress(OrderModel $order) + { + $deliveryRef = uniqid('DELREF'); + $orderAddress = OrderAddressQuery::create()->findPk($order->getDeliveryOrderAddressId()); + $title = $orderAddress->getCustomerTitleId() == 3 ? 1 : 3; + $country = $orderAddress->getCountryId() == 64 ? 1 : 64; + $orderAddressEvent = new OrderAddressEvent( + $title, 'B', 'C', 'D', 'E', 'F', 'G', 'H', $country, 'J', 'K' + ); + $orderAddressEvent->setOrderAddress($orderAddress); + $orderAddressEvent->setOrder($order); + + $this->orderAction->updateAddress($orderAddressEvent); + + $newOrderAddress = OrderAddressQuery::create()->findPk($orderAddress->getId()); + + $this->assertEquals($title, $orderAddressEvent->getOrderAddress()->getCustomerTitleId()); + $this->assertEquals('B', $orderAddressEvent->getOrderAddress()->getFirstname()); + $this->assertEquals('C', $orderAddressEvent->getOrderAddress()->getLastname()); + $this->assertEquals('D', $orderAddressEvent->getOrderAddress()->getAddress1()); + $this->assertEquals('E', $orderAddressEvent->getOrderAddress()->getAddress2()); + $this->assertEquals('F', $orderAddressEvent->getOrderAddress()->getAddress3()); + $this->assertEquals('G', $orderAddressEvent->getOrderAddress()->getZipcode()); + $this->assertEquals('H', $orderAddressEvent->getOrderAddress()->getCity()); + $this->assertEquals($country, $orderAddressEvent->getOrderAddress()->getCountryId()); + $this->assertEquals('J', $orderAddressEvent->getOrderAddress()->getPhone()); + $this->assertEquals('K', $orderAddressEvent->getOrderAddress()->getCompany()); + + $this->assertEquals($title, $newOrderAddress->getCustomerTitleId()); + $this->assertEquals('B', $newOrderAddress->getFirstname()); + $this->assertEquals('C', $newOrderAddress->getLastname()); + $this->assertEquals('D', $newOrderAddress->getAddress1()); + $this->assertEquals('E', $newOrderAddress->getAddress2()); + $this->assertEquals('F', $newOrderAddress->getAddress3()); + $this->assertEquals('G', $newOrderAddress->getZipcode()); + $this->assertEquals('H', $newOrderAddress->getCity()); + $this->assertEquals($country, $newOrderAddress->getCountryId()); + $this->assertEquals('J', $newOrderAddress->getPhone()); + $this->assertEquals('K', $newOrderAddress->getCompany()); + } +} diff --git a/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php b/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php index 1d6d08e92..680a487aa 100755 --- a/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php +++ b/core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php @@ -40,7 +40,7 @@ class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase { $module = ModuleQuery::create()->findOne(); - if(null !== $module) { + if (null !== $module) { $application = new Application($this->getKernel()); $module->setActivate(BaseModule::IS_NOT_ACTIVATED); @@ -70,10 +70,9 @@ class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase { $testedModule = ModuleQuery::create()->findOneByCode('Letshopethismoduledoesnotexists'); - if(null == $testedModule) { + if (null == $testedModule) { $application = new Application($this->getKernel()); - $moduleActivate = new ModuleActivateCommand(); $moduleActivate->setContainer($this->getContainer()); diff --git a/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php new file mode 100644 index 000000000..6e54417e3 --- /dev/null +++ b/core/lib/Thelia/Tests/Condition/ConditionEvaluatorTest.php @@ -0,0 +1,460 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition\Implementation; + +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\Operators; +use Thelia\Coupon\AdapterInterface; +use Thelia\Coupon\ConditionCollection; +use Thelia\Model\CurrencyQuery; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test ConditionEvaluator Class + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class ConditionEvaluatorTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + public function setUp() + { + } + + public function testTestSuccess1Rules() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + + $stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager') + ->disableOriginalConstructor() + ->getMock(); + $stubMatchForTotalAmountManager->expects($this->any()) + ->method('isMatching') + ->will($this->returnValue(true)); + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue($stubMatchForTotalAmountManager)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(401.00)); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => '>', + MatchForTotalAmountManager::INPUT2 => '==' + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + + $conditionEvaluator = new ConditionEvaluator(); + $isValid = $conditionEvaluator->isMatching($conditions); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + public function testTestFail1Rules() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + + $stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager') + ->disableOriginalConstructor() + ->getMock(); + $stubMatchForTotalAmountManager->expects($this->any()) + ->method('isMatching') + ->will($this->returnValue(true)); + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue($stubMatchForTotalAmountManager)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(400.00)); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => '>', + MatchForTotalAmountManager::INPUT2 => '==' + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + + $conditionEvaluator = new ConditionEvaluator(); + $isValid = $conditionEvaluator->isMatching($conditions); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual, 'Conditions evaluator always think Customer is matching conditions'); + } + + public function testTestSuccess2Rules() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + + $stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager') + ->disableOriginalConstructor() + ->getMock(); + $stubMatchForTotalAmountManager->expects($this->any()) + ->method('isMatching') + ->will($this->returnValue(true)); + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue($stubMatchForTotalAmountManager)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(401.00)); + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(5)); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => '>', + MatchForTotalAmountManager::INPUT2 => '==' + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => '>' + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + + $conditionEvaluator = new ConditionEvaluator(); + $isValid = $conditionEvaluator->isMatching($conditions); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + public function testTestFail2Rules() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + + $stubMatchForTotalAmountManager = $this->getMockBuilder('\Thelia\Condition\Implementation\MatchForTotalAmountManager') + ->disableOriginalConstructor() + ->getMock(); + $stubMatchForTotalAmountManager->expects($this->any()) + ->method('isMatching') + ->will($this->returnValue(true)); + + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue($stubMatchForTotalAmountManager)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(400.00)); + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(5)); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => '>', + MatchForTotalAmountManager::INPUT2 => '==' + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => '>' + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + + $conditionEvaluator = new ConditionEvaluator(); + $isValid = $conditionEvaluator->isMatching($conditions); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual, 'Conditions evaluator always think Customer is matching conditions'); + } + + public function testVariableOpComparisonSuccess() + { + $conditionEvaluator = new ConditionEvaluator(); + $expected = true; + $actual = $conditionEvaluator->variableOpComparison(1, Operators::EQUAL, 1); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::DIFFERENT, 2); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::SUPERIOR, 0); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::INFERIOR, 2); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::INFERIOR_OR_EQUAL, 1); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::INFERIOR_OR_EQUAL, 2); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::SUPERIOR_OR_EQUAL, 1); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::SUPERIOR_OR_EQUAL, 0); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::IN, array(1, 2, 3)); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(1, Operators::OUT, array(0, 2, 3)); + $this->assertEquals($expected, $actual); + + } + + public function testVariableOpComparisonFail() + { + $conditionEvaluator = new ConditionEvaluator(); + $expected = false; + $actual = $conditionEvaluator->variableOpComparison(2, Operators::EQUAL, 1); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(2, Operators::DIFFERENT, 2); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(0, Operators::SUPERIOR, 0); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(3, Operators::INFERIOR, 2); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(2, Operators::INFERIOR_OR_EQUAL, 1); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(3, Operators::SUPERIOR_OR_EQUAL, 4); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(0, Operators::IN, array(1, 2, 3)); + $this->assertEquals($expected, $actual); + + $actual = $conditionEvaluator->variableOpComparison(2, Operators::OUT, array(0, 2, 3)); + $this->assertEquals($expected, $actual); + + } + + /** + * @expectedException \Exception + */ + public function testVariableOpComparisonException() + { + $conditionEvaluator = new ConditionEvaluator(); + $expected = true; + $actual = $conditionEvaluator->variableOpComparison(1, 'bad', 1); + $this->assertEquals($expected, $actual); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } +} diff --git a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php new file mode 100644 index 000000000..295d9a308 --- /dev/null +++ b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php @@ -0,0 +1,397 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition\Implementation; + +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\ConditionFactory; +use Thelia\Condition\Operators; +use Thelia\Coupon\AdapterInterface; +use Thelia\Coupon\ConditionCollection; +use Thelia\Model\CurrencyQuery; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test ConditionFactory Class + * + * @package Condition + * @author Guillaume MOREL + * + */ +class ConditionFactoryTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + public function setUp() + { + } + + /** + * Check the Rules serialization module + */ + public function testBuild() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue(new MatchForTotalAmountManager($stubAdapter))); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 40.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $conditionFactory = new ConditionFactory($stubContainer); + $ruleManager1 = $conditionFactory->build($condition1->getServiceId(), $operators, $values); + + $expected = $condition1; + $actual = $ruleManager1; + + $this->assertEquals($expected, $actual); + $this->assertEquals($condition1->getServiceId(), $ruleManager1->getServiceId()); + $this->assertEquals($condition1->getValidators(), $ruleManager1->getValidators()); + } + + /** + * Check the Rules serialization module + */ + public function testBuildFail() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue(new MatchForTotalAmountManager($stubAdapter))); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValueMap(array('unset.service', false))); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 40.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $conditionFactory = new ConditionFactory($stubContainer); + $conditionManager1 = $conditionFactory->build('unset.service', $operators, $values); + + $expected = false; + $actual = $conditionManager1; + + $this->assertEquals($expected, $actual); + } + + /** + * Check the Rules serialization module + */ + public function testRuleSerialisation() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue(new MatchForTotalAmountManager($stubAdapter))); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 40.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $condition2 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' + ); + $condition2->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + + $conditionFactory = new ConditionFactory($stubContainer); + + $serializedConditions = $conditionFactory->serializeConditionCollection($conditions); + $unserializedConditions = $conditionFactory->unserializeConditionCollection($serializedConditions); + + $expected = (string) $conditions; + $actual = (string) $unserializedConditions; + + $this->assertEquals($expected, $actual); + } + + /** + * Check the getInputs method + */ + public function testGetInputs() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue($condition1)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(true)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 40.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + + $conditionFactory = new ConditionFactory($stubContainer); + + $expected = $condition1->getValidators(); + $actual = $conditionFactory->getInputs('thelia.condition.match_for_x_articles'); + + $this->assertEquals($expected, $actual); + + } + + /** + * Check the getInputs method + */ + public function testGetInputsFalse() + { + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getTranslator') + ->will($this->returnValue($stubTranslator)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currencies = CurrencyQuery::create(); + $currencies = $currencies->find(); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue($currencies)); + + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValue($condition1)); + + $stubContainer->expects($this->any()) + ->method('has') + ->will($this->returnValue(false)); + + $stubAdapter->expects($this->any()) + ->method('getContainer') + ->will($this->returnValue($stubContainer)); + + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 40.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $conditions = new ConditionCollection(); + $conditions->add($condition1); + + $conditionFactory = new ConditionFactory($stubContainer); + + $expected = false; + $actual = $conditionFactory->getInputs('thelia.condition.unknown'); + + $this->assertEquals($expected, $actual); + + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } +} diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php new file mode 100644 index 000000000..726ed4988 --- /dev/null +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneManagerTest.php @@ -0,0 +1,127 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition\Implementation; + +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\Operators; +use Thelia\Coupon\AdapterInterface; +use Thelia\Model\Currency; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test MatchForEveryoneManager Class + * + * @package Condition + * @author Guillaume MOREL + * + */ +class MatchForEveryoneManagerTest extends \PHPUnit_Framework_TestCase +{ + /** @var AdapterInterface $stubTheliaAdapter */ + protected $stubTheliaAdapter = null; + + /** + * Generate adapter stub + * + * @param int $cartTotalPrice Cart total price + * @param string $checkoutCurrency Checkout currency + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR') + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue($checkoutCurrency)); + + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currency1 = new Currency(); + $currency1->setCode('EUR'); + $currency2 = new Currency(); + $currency2->setCode('USD'); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue(array($currency1, $currency2))); + + return $stubAdapter; + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::setValidators + * + */ + public function testValidBackOfficeInputOperator() + { + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + /** @var AdapterInterface $stubAdapter */ + $condition1 = new MatchForEveryoneManager($stubAdapter); + $operators = array(); + $values = array(); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if condition is always matching + * + * @covers Thelia\Condition\Implementation\MatchForEveryoneManager::isMatching + * + */ + public function testIsMatching() + { + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + /** @var AdapterInterface $stubAdapter */ + $condition1 = new MatchForEveryoneManager($stubAdapter); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual = $isValid; + $this->assertEquals($expected, $actual); + } + +} diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php new file mode 100644 index 000000000..cc142ac38 --- /dev/null +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountManagerTest.php @@ -0,0 +1,610 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition\Implementation; + +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\Operators; +use Thelia\Coupon\AdapterInterface; +use Thelia\Exception\InvalidConditionValueException; +use Thelia\Model\Currency; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test MatchForTotalAmountManager Class + * + * @package Condition + * @author Guillaume MOREL + * + */ +class MatchForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase +{ + /** @var AdapterInterface $stubTheliaAdapter */ + protected $stubTheliaAdapter = null; + + /** + * Generate adapter stub + * + * @param int $cartTotalPrice Cart total price + * @param string $checkoutCurrency Checkout currency + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR') + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue($checkoutCurrency)); + + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $currency1 = new Currency(); + $currency1->setCode('EUR'); + $currency2 = new Currency(); + $currency2->setCode('USD'); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue(array($currency1, $currency2))); + + return $stubAdapter; + } + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidConditionOperatorException + * + */ + public function testInValidBackOfficeInputOperator() + { + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + /** @var AdapterInterface $stubAdapter */ + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::IN, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => '400', + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidConditionOperatorException + * + */ + public function testInValidBackOfficeInputOperator2() + { + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + /** @var AdapterInterface $stubAdapter */ + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::INFERIOR + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => '400', + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidConditionValueException + * + */ + public function testInValidBackOfficeInputValue() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 'X', + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidConditionValueException + * + */ + public function testInValidBackOfficeInputValue2() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400, + MatchForTotalAmountManager::INPUT2 => 'FLA'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionInferior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testNotMatchingConditionInferior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionInferiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionInferiorEquals2() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testNotMatchingConditionInferiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test equals operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionEqual() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test equals operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testNotMatchingConditionEqual() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionSuperiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionSuperiorEquals2() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testNotMatchingConditionSuperiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionSuperior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testNotMatchingConditionSuperior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check currency is checked + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testMatchingConditionCurrency() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check currency is checked + * + * @covers Thelia\Condition\Implementation\MatchForTotalAmountManager::isMatching + * + */ + public function testNotMatchingConditionCurrency() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->generateAdapterStub(400.00, 'EUR'); + + $condition1 = new MatchForTotalAmountManager($stubAdapter); + $operators = array( + MatchForTotalAmountManager::INPUT1 => Operators::EQUAL, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'USD'); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php new file mode 100644 index 000000000..4243b1082 --- /dev/null +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForXArticlesManagerTest.php @@ -0,0 +1,670 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition\Implementation; + +use Thelia\Condition\ConditionEvaluator; +use Thelia\Condition\Operators; +use Thelia\Condition\SerializableCondition; +use Thelia\Coupon\AdapterInterface; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test MatchForXArticlesManager Class + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class MatchForXArticlesManagerTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::setValidators + * @expectedException \Thelia\Exception\InvalidConditionOperatorException + */ + public function testInValidBackOfficeInputOperator() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + /** @var AdapterInterface $stubAdapter */ + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::IN + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 5 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::setValidators + * @expectedException \Thelia\Exception\InvalidConditionValueException + */ + public function testInValidBackOfficeInputValue() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 'X' + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testMatchingRuleInferior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::INFERIOR + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 5 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testNotMatchingRuleInferior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::INFERIOR + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4, + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testMatchingRuleInferiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL, + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 5, + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testMatchingRuleInferiorEquals2() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test inferior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testNotMatchingRuleInferiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::INFERIOR_OR_EQUAL + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 3 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test equals operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testMatchingRuleEqual() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::EQUAL + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test equals operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testNotMatchingRuleEqual() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::EQUAL + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 5 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testMatchingRuleSuperiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testMatchingRuleSuperiorEquals2() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 3 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testNotMatchingRuleSuperiorEquals() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR_OR_EQUAL + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 5 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testMatchingRuleSuperior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 3 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if test superior operator is working + * + * @covers Thelia\Condition\Implementation\MatchForXArticlesManager::isMatching + * + */ + public function testNotMatchingRuleSuperior() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $isValid = $condition1->isMatching(); + + $expected = false; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + public function testGetSerializableRule() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $serializableRule = $condition1->getSerializableCondition(); + + $expected = new SerializableCondition(); + $expected->conditionServiceId = $condition1->getServiceId(); + $expected->operators = $operators; + $expected->values = $values; + + $actual = $serializableRule; + + $this->assertEquals($expected, $actual); + + } + + public function testGetAvailableOperators() + { + /** @var AdapterInterface $stubAdapter */ + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConditionEvaluator') + ->will($this->returnValue(new ConditionEvaluator())); + + $condition1 = new MatchForXArticlesManager($stubAdapter); + $operators = array( + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR + ); + $values = array( + MatchForXArticlesManager::INPUT1 => 4 + ); + $condition1->setValidatorsFromForm($operators, $values); + + $expected = array( + MatchForXArticlesManager::INPUT1 => array( + Operators::INFERIOR, + Operators::INFERIOR_OR_EQUAL, + Operators::EQUAL, + Operators::SUPERIOR_OR_EQUAL, + Operators::SUPERIOR + ) + ); + $actual = $condition1->getAvailableOperators(); + + $this->assertEquals($expected, $actual); + + } + +// public function testGetValidators() +// { +// $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\BaseAdapter') +// ->disableOriginalConstructor() +// ->getMock(); +// +// $stubAdapter->expects($this->any()) +// ->method('getNbArticlesInCart') +// ->will($this->returnValue(4)); +// +// $condition1 = new MatchForXArticlesManager($stubAdapter); +// $operators = array( +// MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR +// ); +// $values = array( +// MatchForXArticlesManager::INPUT1 => 4 +// ); +// $condition1->setValidatorsFromForm($operators, $values); +// +// $expected = array( +// $operators, +// $values +// ); +// $actual = $condition1->getValidators(); +// +// $this->assertEquals($expected, $actual); +// +// } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + +} diff --git a/core/lib/Thelia/Tests/Condition/OperatorsTest.php b/core/lib/Thelia/Tests/Condition/OperatorsTest.php new file mode 100644 index 000000000..5d673e80b --- /dev/null +++ b/core/lib/Thelia/Tests/Condition/OperatorsTest.php @@ -0,0 +1,112 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition; + +use Thelia\Core\Translation\Translator; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Unit Test Operators Class + * + * @package Condition + * @author Guillaume MOREL + * + */ +class OperatorsTest extends \PHPUnit_Framework_TestCase +{ + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + } + + public function testOperatorI18n() + { + /** @var Translator $stubTranslator */ + $stubTranslator = $this->getMockBuilder('\Thelia\Core\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); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + public function callbackI18n() + { + $args = func_get_args(); + + return $args[0]; + } +} diff --git a/core/lib/Thelia/Tests/Constraint/ConstraintFactoryTest.php b/core/lib/Thelia/Tests/Constraint/ConstraintFactoryTest.php deleted file mode 100644 index ccc04fbfc..000000000 --- a/core/lib/Thelia/Tests/Constraint/ConstraintFactoryTest.php +++ /dev/null @@ -1,228 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; -use Thelia\Constraint\Rule\AvailableForXArticlesManager; -use Thelia\Constraint\Rule\Operators; -use Thelia\Coupon\CouponBaseAdapter; -use Thelia\Coupon\CouponRuleCollection; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test ConstraintManager Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class ConstraintFactoryTest extends \PHPUnit_Framework_TestCase -{ - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - public function setUp() - { - } - - /** - * Check the Rules serialization module - */ - public function testBuild() - { - $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getTranslator') - ->will($this->returnValue($stubTranslator)); - - $rule1 = new AvailableForTotalAmountManager($stubAdapter); - $operators = array( - AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 40.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR' - ); - $rule1->setValidatorsFromForm($operators, $values); - - /** @var ConstraintManager $constraintManager */ - $constraintFactory = new ConstraintFactory($this->getContainer()); - $ruleManager1 = $constraintFactory->build($rule1->getServiceId(), $operators, $values); - - $expected = $rule1; - $actual = $ruleManager1; - - $this->assertEquals($expected, $actual); - $this->assertEquals($rule1->getServiceId(), $ruleManager1->getServiceId()); - $this->assertEquals($rule1->getValidators(), $ruleManager1->getValidators()); - } - - /** - * Check the Rules serialization module - */ - public function testBuildFail() - { - $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getTranslator') - ->will($this->returnValue($stubTranslator)); - - $rule1 = new AvailableForTotalAmountManager($stubAdapter); - $operators = array( - AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 40.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR' - ); - $rule1->setValidatorsFromForm($operators, $values); - - /** @var ConstraintManager $constraintManager */ - $constraintFactory = new ConstraintFactory($this->getContainer()); - $ruleManager1 = $constraintFactory->build('unset.service', $operators, $values); - - $expected = false; - $actual = $ruleManager1; - - $this->assertEquals($expected, $actual); - } - - /** - * Check the Rules serialization module - */ - public function testRuleSerialisation() - { - $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getTranslator') - ->will($this->returnValue($stubTranslator)); - - $rule1 = new AvailableForTotalAmountManager($stubAdapter); - $operators = array( - AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 40.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR' - ); - $rule1->setValidatorsFromForm($operators, $values); - - $rule2 = new AvailableForTotalAmountManager($stubAdapter); - $operators = array( - AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR' - ); - $rule2->setValidatorsFromForm($operators, $values); - - $rules = new CouponRuleCollection(); - $rules->add($rule1); - $rules->add($rule2); - - /** @var ConstraintManager $constraintManager */ - $constraintFactory = new ConstraintFactory($this->getContainer()); - - $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); - $unserializedRules = $constraintFactory->unserializeCouponRuleCollection($serializedRules); - - $expected = (string) $rules; - $actual = (string) $unserializedRules; - - $this->assertEquals($expected, $actual); - } - - /** - * Get Mocked Container with 2 Rules - * - * @return ContainerBuilder - */ - public function getContainer() - { - $container = new ContainerBuilder(); - - $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getTranslator') - ->will($this->returnValue($stubTranslator)); - - $rule1 = new AvailableForTotalAmountManager($stubAdapter); - $rule2 = new AvailableForXArticlesManager($stubAdapter); - - $adapter = new CouponBaseAdapter($container); - - $container->set('thelia.constraint.rule.available_for_total_amount', $rule1); - $container->set('thelia.constraint.rule.available_for_x_articles', $rule2); - $container->set('thelia.adapter', $adapter); - - return $container; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } -} diff --git a/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php b/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php deleted file mode 100644 index 68818a092..000000000 --- a/core/lib/Thelia/Tests/Constraint/ConstraintValidatorTest.php +++ /dev/null @@ -1,346 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; -use Thelia\Constraint\Rule\AvailableForXArticlesManager; -use Thelia\Constraint\Rule\Operators; -use Thelia\Coupon\CouponBaseAdapter; -use Thelia\Coupon\CouponRuleCollection; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test ConstraintValidator Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class ConstraintValidatorTest extends \PHPUnit_Framework_TestCase -{ - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - public function setUp() - { - } - - public function testTestSuccess1Rules() - { - $ConstraintValidator = new ConstraintValidator(); - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $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( - AvailableForTotalAmountManager::INPUT1 => '>', - AvailableForTotalAmountManager::INPUT2 => '==' - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $rules = new CouponRuleCollection(); - $rules->add($rule1); - - $isValid = $ConstraintValidator->isMatching($rules); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - public function testTestFail1Rules() - { - $ConstraintValidator = new ConstraintValidator(); - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $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( - AvailableForTotalAmountManager::INPUT1 => '>', - AvailableForTotalAmountManager::INPUT2 => '==' - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $rules = new CouponRuleCollection(); - $rules->add($rule1); - - $isValid = $ConstraintValidator->isMatching($rules); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual, 'Constraints validator always think Customer is matching rules'); - } - - public function testTestSuccess2Rules() - { - $ConstraintValidator = new ConstraintValidator(); - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $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( - AvailableForTotalAmountManager::INPUT1 => '>', - AvailableForTotalAmountManager::INPUT2 => '==' - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $rule2 = new AvailableForXArticlesManager($stubAdapter); - $operators = array( - AvailableForXArticlesManager::INPUT1 => '>' - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 4 - ); - $rule2->setValidatorsFromForm($operators, $values); - - $rules = new CouponRuleCollection(); - $rules->add($rule1); - $rules->add($rule2); - - $isValid = $ConstraintValidator->isMatching($rules); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - public function testTestFail2Rules() - { - $ConstraintValidator = new ConstraintValidator(); - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $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( - AvailableForTotalAmountManager::INPUT1 => '>', - AvailableForTotalAmountManager::INPUT2 => '==' - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $rule2 = new AvailableForXArticlesManager($stubAdapter); - $operators = array( - AvailableForXArticlesManager::INPUT1 => '>' - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 4 - ); - $rule2->setValidatorsFromForm($operators, $values); - - $rules = new CouponRuleCollection(); - $rules->add($rule1); - $rules->add($rule2); - - $isValid = $ConstraintValidator->isMatching($rules); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual, 'Constraints validator always think Customer is matching rules'); - } - - public function testVariableOpComparisonSuccess() - { - $ConstraintValidator = new ConstraintValidator(); - $expected = true; - $actual = $ConstraintValidator->variableOpComparison(1, Operators::EQUAL, 1); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::DIFFERENT, 2); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::SUPERIOR, 0); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::INFERIOR, 2); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::INFERIOR_OR_EQUAL, 1); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::INFERIOR_OR_EQUAL, 2); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::SUPERIOR_OR_EQUAL, 1); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::SUPERIOR_OR_EQUAL, 0); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::IN, array(1, 2, 3)); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(1, Operators::OUT, array(0, 2, 3)); - $this->assertEquals($expected, $actual); - - } - - public function testVariableOpComparisonFail() - { - $ConstraintValidator = new ConstraintValidator(); - $expected = false; - $actual = $ConstraintValidator->variableOpComparison(2, Operators::EQUAL, 1); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(2, Operators::DIFFERENT, 2); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(0, Operators::SUPERIOR, 0); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(3, Operators::INFERIOR, 2); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(2, Operators::INFERIOR_OR_EQUAL, 1); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(3, Operators::SUPERIOR_OR_EQUAL, 4); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(0, Operators::IN, array(1, 2, 3)); - $this->assertEquals($expected, $actual); - - $actual = $ConstraintValidator->variableOpComparison(2, Operators::OUT, array(0, 2, 3)); - $this->assertEquals($expected, $actual); - - } - - /** - * @expectedException \Exception - */ - public function testVariableOpComparisonException() - { - $ConstraintValidator = new ConstraintValidator(); - $expected = true; - $actual = $ConstraintValidator->variableOpComparison(1, 'bad', 1); - $this->assertEquals($expected, $actual); - } - - /** - * Get Mocked Container with 2 Rules - * - * @return ContainerBuilder - */ - public function getContainer() - { - $container = new ContainerBuilder(); - - $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getTranslator') - ->will($this->returnValue($stubTranslator)); - - $rule1 = new AvailableForTotalAmountManager($stubAdapter); - $rule2 = new AvailableForXArticlesManager($stubAdapter); - - $adapter = new CouponBaseAdapter($container); - - $container->set('thelia.constraint.rule.available_for_total_amount', $rule1); - $container->set('thelia.constraint.rule.available_for_x_articles', $rule2); - $container->set('thelia.adapter', $adapter); - - return $container; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } -} diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php deleted file mode 100644 index c3f7249df..000000000 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php +++ /dev/null @@ -1,709 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use Thelia\Constraint\ConstraintValidator; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; -use Thelia\Constraint\Rule\Operators; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test AvailableForTotalAmount Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase -{ - /** @var CouponAdapterInterface $stubTheliaAdapter */ - protected $stubTheliaAdapter = null; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - 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\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); -// } - -// /** -// * 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); -// } - -// /** -// * 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); -// } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleInferior() - { - $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::INFERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testNotMatchingRuleInferior() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $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::INFERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleInferiorEquals() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $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::INFERIOR_OR_EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleInferiorEquals2() - { - $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::INFERIOR_OR_EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testNotMatchingRuleInferiorEquals() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $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::INFERIOR_OR_EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test equals operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleEqual() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $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::EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test equals operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testNotMatchingRuleEqual() - { - $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::EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleSuperiorEquals() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $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_OR_EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleSuperiorEquals2() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $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_OR_EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testNotMatchingRuleSuperiorEquals() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399.00)); - $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_OR_EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleSuperior() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $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.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testNotMatchingRuleSuperior() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399.00)); - $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.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check currency is checked - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testMatchingRuleCurrency() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400.00)); - $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::EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check currency is checked - * - * @covers Thelia\Constraint\Rule\AvailableForTotalAmountManager::isMatching - * - */ - public function testNotMatchingRuleCurrency() - { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400.00)); - $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::EQUAL, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL - ); - $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'USD'); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php deleted file mode 100644 index 4ecbcb8ac..000000000 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php +++ /dev/null @@ -1,710 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use Thelia\Constraint\ConstraintValidator; -use Thelia\Constraint\Rule\AvailableForXArticlesManager; -use Thelia\Constraint\Rule\Operators; -use Thelia\Constraint\Rule\SerializableRule; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test AvailableForXArticles Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase -{ - -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// protected $stubTheliaAdapter = null; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - 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\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); -// } - -// /** -// * 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); -// } - -// /** -// * 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); -// } - -// /** -// * 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); -// } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testMatchingRuleInferior() - { - $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::INFERIOR - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 5 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testNotMatchingRuleInferior() - { - $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::INFERIOR - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 4, - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testMatchingRuleInferiorEquals() - { - $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::INFERIOR_OR_EQUAL, - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 5, - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testMatchingRuleInferiorEquals2() - { - $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::INFERIOR_OR_EQUAL - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 4 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test inferior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testNotMatchingRuleInferiorEquals() - { - $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::INFERIOR_OR_EQUAL - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 3 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test equals operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testMatchingRuleEqual() - { - $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::EQUAL - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 4 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test equals operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testNotMatchingRuleEqual() - { - $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::EQUAL - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 5 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testMatchingRuleSuperiorEquals() - { - $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_OR_EQUAL - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 4 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testMatchingRuleSuperiorEquals2() - { - $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_OR_EQUAL - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 3 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testNotMatchingRuleSuperiorEquals() - { - $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_OR_EQUAL - ); - $values = array( - AvailableForXArticlesManager::INPUT1 => 5 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testMatchingRuleSuperior() - { - $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 => 3 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = true; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - /** - * Check if test superior operator is working - * - * @covers Thelia\Constraint\Rule\AvailableForXArticlesManager::isMatching - * - */ - public function testNotMatchingRuleSuperior() - { - $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 => 4 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $isValid = $rule1->isMatching(); - - $expected = false; - $actual =$isValid; - $this->assertEquals($expected, $actual); - } - - public function testGetSerializableRule() - { - $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 => 4 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $serializableRule = $rule1->getSerializableRule(); - - $expected = new SerializableRule(); - $expected->ruleServiceId = $rule1->getServiceId(); - $expected->operators = $operators; - $expected->values = $values; - - $actual = $serializableRule; - - $this->assertEquals($expected, $actual); - - } - - public function testGetAvailableOperators() - { - $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 => 4 - ); - $rule1->setValidatorsFromForm($operators, $values); - - $expected = array( - AvailableForXArticlesManager::INPUT1 => array( - Operators::INFERIOR, - Operators::INFERIOR_OR_EQUAL, - Operators::EQUAL, - Operators::SUPERIOR_OR_EQUAL, - Operators::SUPERIOR - ) - ); - $actual = $rule1->getAvailableOperators(); - - $this->assertEquals($expected, $actual); - - } - -// public function testGetValidators() -// { -// $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') -// ->disableOriginalConstructor() -// ->getMock(); -// -// $stubAdapter->expects($this->any()) -// ->method('getNbArticlesInCart') -// ->will($this->returnValue(4)); -// -// $rule1 = new AvailableForXArticlesManager($stubAdapter); -// $operators = array( -// AvailableForXArticlesManager::INPUT1 => Operators::SUPERIOR -// ); -// $values = array( -// AvailableForXArticlesManager::INPUT1 => 4 -// ); -// $rule1->setValidatorsFromForm($operators, $values); -// -// $expected = array( -// $operators, -// $values -// ); -// $actual = $rule1->getValidators(); -// -// $this->assertEquals($expected, $actual); -// -// } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php deleted file mode 100644 index 0b29baa62..000000000 --- a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php +++ /dev/null @@ -1,427 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use Thelia\Constraint\Validator\QuantityParam; -use Thelia\Constraint\Rule\Operators; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test Operators Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class OperatorsTest extends \PHPUnit_Framework_TestCase -{ - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - } - - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorInferiorValidBefore() -// { -// $adapter = new CouponBaseAdapter(); -// // Given -// $a = 11; -// $operator = Operators::INFERIOR; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorInferiorInvalidEquals() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 12; -// $operator = Operators::INFERIOR; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorInferiorInvalidAfter() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 13; -// $operator = Operators::INFERIOR; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorInferiorOrEqualValidEqual() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 11; -// $operator = Operators::INFERIOR_OR_EQUAL; -// $b = new QuantityParam($adapter, 11); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorInferiorOrEqualValidBefore() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 10; -// $operator = Operators::INFERIOR_OR_EQUAL; -// $b = new QuantityParam($adapter, 11); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorInferiorOrEqualInValidAfter() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 12; -// $operator = Operators::INFERIOR_OR_EQUAL; -// $b = new QuantityParam($adapter, 11); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorEqualValidEqual() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 12; -// $operator = Operators::EQUAL; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorEqualInValidBefore() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 11; -// $operator = Operators::EQUAL; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorEqualInValidAfter() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 13; -// $operator = Operators::EQUAL; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorSuperiorOrEqualValidEqual() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 13; -// $operator = Operators::SUPERIOR_OR_EQUAL; -// $b = new QuantityParam($adapter, 13); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorSuperiorOrEqualAfter() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 14; -// $operator = Operators::SUPERIOR_OR_EQUAL; -// $b = new QuantityParam($adapter, 13); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorSuperiorOrEqualInvalidBefore() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 12; -// $operator = Operators::SUPERIOR_OR_EQUAL; -// $b = new QuantityParam($adapter, 13); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorSuperiorValidAfter() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 13; -// $operator = Operators::SUPERIOR; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorSuperiorInvalidEqual() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 12; -// $operator = Operators::SUPERIOR; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorSuperiorInvalidBefore() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 11; -// $operator = Operators::SUPERIOR; -// $b = new QuantityParam($adapter, 12); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorDifferentValid() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 12; -// $operator = Operators::DIFFERENT; -// $b = new QuantityParam($adapter, 11); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertTrue($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorDifferentInvalidEquals() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 11; -// $operator = Operators::DIFFERENT; -// $b = new QuantityParam($adapter, 11); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator -// * -// */ -// public function testOperatorInValid() -// { -// // Given -// $adapter = new CouponBaseAdapter(); -// $a = 12; -// $operator = 'X'; -// $b = new QuantityParam($adapter, 11); -// -// // When -// $actual = Operators::isValid($a, $operator, $b); -// -// // Then -// $this->assertFalse($actual); -// } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php deleted file mode 100644 index db281bcc5..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/CustomerParamTest.php +++ /dev/null @@ -1,168 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use InvalidArgumentException; -use Thelia\Constraint\Validator\CustomerParam; -use Thelia\Constraint\Validator\QuantityParam; -use Thelia\Model\Customer; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test CustomerParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class CustomerParamTest extends \PHPUnit_Framework_TestCase -{ - - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// protected $stubTheliaAdapter = null; -// -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); -// } -// -// /** -// * Generate valid CouponBaseAdapter -// * -// * @param int $customerId Customer id -// * -// * @return CouponAdapterInterface -// */ -// protected function generateValidCouponBaseAdapterMock($customerId = 4521) -// { -// $customer = new Customer(); -// $customer->setId($customerId); -// $customer->setFirstname('Firstname'); -// $customer->setLastname('Lastname'); -// $customer->setEmail('em@il.com'); -// -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $stubTheliaAdapter = $this->getMock( -// 'Thelia\Coupon\CouponBaseAdapter', -// array('getCustomer'), -// array() -// ); -// $stubTheliaAdapter->expects($this->any()) -// ->method('getCustomer') -// ->will($this->returnValue($customer)); -// -// return $stubTheliaAdapter; -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -// * -// */ -// public function testCanUseCoupon() -// { -// $customerId = 4521; -// $couponValidForCustomerId = 4521; -// -// $adapter = $this->generateValidCouponBaseAdapterMock($customerId); -// -// $customerParam = new CustomerParam($adapter, $couponValidForCustomerId); -// -// $expected = 0; -// $actual = $customerParam->compareTo($customerId); -// $this->assertEquals($expected, $actual); -// } -// -//// /** -//// * -//// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -//// * -//// */ -//// public function testCanNotUseCouponTest() -//// { -//// -//// } -//// -//// /** -//// * -//// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -//// * @expectedException InvalidArgumentException -//// * -//// */ -//// public function testCanNotUseCouponCustomerNotFoundTest() -//// { -//// -//// } -// -// -// -// -//// /** -//// * Test is the object is serializable -//// * If no data is lost during the process -//// */ -//// public function isSerializableTest() -//// { -//// $adapter = new CouponBaseAdapter(); -//// $intValidator = 42; -//// $intToValidate = -1; -//// -//// $param = new QuantityParam($adapter, $intValidator); -//// -//// $serialized = base64_encode(serialize($param)); -//// /** @var QuantityParam $unserialized */ -//// $unserialized = base64_decode(serialize($serialized)); -//// -//// $this->assertEquals($param->getValue(), $unserialized->getValue()); -//// $this->assertEquals($param->getInteger(), $unserialized->getInteger()); -//// -//// $new = new QuantityParam($adapter, $unserialized->getInteger()); -//// $this->assertEquals($param->getInteger(), $new->getInteger()); -//// } -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php deleted file mode 100644 index 53a5c70eb..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/DateParamTest.php +++ /dev/null @@ -1,158 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use InvalidArgumentException; -use Thelia\Constraint\Validator\DateParam; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test DateParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class DateParamTest extends \PHPUnit_Framework_TestCase -{ - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\DateParam::compareTo -// * -// */ -// public function testInferiorDate() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-07"); -// -// $dateParam = new DateParam($adapter, $dateValidator); -// -// $expected = 1; -// $actual = $dateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\DateParam::compareTo -// * -// */ -// public function testEqualsDate() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-08"); -// -// $dateParam = new DateParam($adapter, $dateValidator); -// -// $expected = 0; -// $actual = $dateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\DateParam::compareTo -// * -// */ -// public function testSuperiorDate() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-09"); -// -// $dateParam = new DateParam($adapter, $dateValidator); -// -// $expected = -1; -// $actual = $dateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\DateParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = 1377012588; -// -// $dateParam = new DateParam($adapter, $dateValidator); -// -// $dateParam->compareTo($dateToValidate); -// } -// -// /** -// * Test is the object is serializable -// * If no data is lost during the process -// */ -// public function isSerializableTest() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidator = new \DateTime("2012-07-08"); -// -// $param = new DateParam($adapter, $dateValidator); -// -// $serialized = base64_encode(serialize($param)); -// /** @var DateParam $unserialized */ -// $unserialized = base64_decode(serialize($serialized)); -// -// $this->assertEquals($param->getValue(), $unserialized->getValue()); -// $this->assertEquals($param->getDateTime(), $unserialized->getDateTime()); -// -// $new = new DateParam($adapter, $unserialized->getDateTime()); -// $this->assertEquals($param->getDateTime(), $new->getDateTime()); -// } -// -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php deleted file mode 100644 index edf71b138..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/IntegerParamTest.php +++ /dev/null @@ -1,159 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use InvalidArgumentException; -use Thelia\Constraint\Validator\IntegerParam; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test IntegerParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class IntegerParamTest extends \PHPUnit_Framework_TestCase -{ - - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo -// * -// */ -// public function testInferiorInteger() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = 41; -// -// $integerParam = new IntegerParam($adapter, $intValidator); -// -// $expected = 1; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo -// * -// */ -// public function testEqualsInteger() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = 42; -// -// $integerParam = new IntegerParam($adapter, $intValidator); -// -// $expected = 0; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo -// * -// */ -// public function testSuperiorInteger() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = 43; -// -// $integerParam = new IntegerParam($adapter, $intValidator); -// -// $expected = -1; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\IntegerParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = '42'; -// -// $integerParam = new IntegerParam($adapter, $intValidator); -// -// $expected = 0; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * Test is the object is serializable -// * If no data is lost during the process -// */ -// public function isSerializableTest() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// -// $param = new IntegerParam($adapter, $intValidator); -// -// $serialized = base64_encode(serialize($param)); -// /** @var IntegerParam $unserialized */ -// $unserialized = base64_decode(serialize($serialized)); -// -// $this->assertEquals($param->getValue(), $unserialized->getValue()); -// $this->assertEquals($param->getInteger(), $unserialized->getInteger()); -// -// $new = new IntegerParam($adapter, $unserialized->getInteger()); -// $this->assertEquals($param->getInteger(), $new->getInteger()); -// } -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php deleted file mode 100644 index e98c5f719..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/IntervalParamTest.php +++ /dev/null @@ -1,184 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use InvalidArgumentException; -use Thelia\Constraint\Validator\IntervalParam; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test IntervalParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class IntervalParamTest extends \PHPUnit_Framework_TestCase -{ - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\IntervalParam::compareTo -// * -// */ -// public function testInferiorDate() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidatorStart = new \DateTime("2012-07-08"); -// $dateValidatorInterval = new \DateInterval("P1M"); //1month -// $dateToValidate = new \DateTime("2012-07-07"); -// -// $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); -// -// $expected = 1; -// $actual = $dateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\IntervalParam::compareTo -// * -// */ -// public function testEqualsDate() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidatorStart = new \DateTime("2012-07-08"); -// $dateValidatorInterval = new \DateInterval("P1M"); //1month -// $dateToValidate = new \DateTime("2012-07-08"); -// -// echo '1 ' . date_format($dateValidatorStart, 'g:ia \o\n l jS F Y') . "\n"; -// echo '2 ' . date_format($dateToValidate, 'g:ia \o\n l jS F Y') . "\n"; -// -// $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); -// -// $expected = 0; -// $actual = $dateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\IntervalParam::compareTo -// * -// */ -// public function testEqualsDate2() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidatorStart = new \DateTime("2012-07-08"); -// $dateValidatorInterval = new \DateInterval("P1M"); //1month -// $dateToValidate = new \DateTime("2012-08-08"); -// -// $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); -// -// $expected = 0; -// $actual = $dateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\IntervalParam::compareTo -// * -// */ -// public function testSuperiorDate() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidatorStart = new \DateTime("2012-07-08"); -// $dateValidatorInterval = new \DateInterval("P1M"); //1month -// $dateToValidate = new \DateTime("2012-08-09"); -// -// $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); -// -// $expected = -1; -// $actual = $dateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\DateParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidatorStart = new \DateTime("2012-07-08"); -// $dateValidatorInterval = new \DateInterval("P1M"); //1month -// $dateToValidate = 1377012588; -// -// $dateParam = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); -// -// $dateParam->compareTo($dateToValidate); -// } -// -// /** -// * Test is the object is serializable -// * If no data is lost during the process -// */ -// public function isSerializableTest() -// { -// $adapter = new CouponBaseAdapter(); -// $dateValidatorStart = new \DateTime("2012-07-08"); -// $dateValidatorInterval = new \DateInterval("P1M"); //1month -// -// $param = new IntervalParam($adapter, $dateValidatorStart, $dateValidatorInterval); -// -// $serialized = base64_encode(serialize($param)); -// /** @var IntervalParam $unserialized */ -// $unserialized = base64_decode(serialize($serialized)); -// -// $this->assertEquals($param->getValue(), $unserialized->getValue()); -// $this->assertEquals($param->getDatePeriod(), $unserialized->getDatePeriod()); -// -// $new = new IntervalParam($adapter, $unserialized->getStart(), $unserialized->getInterval()); -// $this->assertEquals($param->getDatePeriod(), $new->getDatePeriod()); -// } -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php deleted file mode 100644 index 4eb04a77e..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/PriceParamTest.php +++ /dev/null @@ -1,237 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use InvalidArgumentException; -use Thelia\Constraint\Validator\PriceParam; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test PriceParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class PriceParamTest extends \PHPUnit_Framework_TestCase -{ - - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * -// */ -// public function testInferiorPrice() -// { -// $adapter = new CouponBaseAdapter(); -// -// $priceValidator = 42.50; -// $priceToValidate = 1.00; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); -// -// $expected = 1; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * -// */ -// public function testInferiorPrice2() -// { -// $adapter = new CouponBaseAdapter(); -// -// $priceValidator = 42.50; -// $priceToValidate = 42.49; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); -// -// $expected = 1; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * -// */ -// public function testEqualsPrice() -// { -// $adapter = new CouponBaseAdapter(); -// -// $priceValidator = 42.50; -// $priceToValidate = 42.50; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); -// -// $expected = 0; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * -// */ -// public function testSuperiorPrice() -// { -// $adapter = new CouponBaseAdapter(); -// -// $priceValidator = 42.50; -// $priceToValidate = 42.51; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); -// -// $expected = -1; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException() -// { -// $adapter = new CouponBaseAdapter(); -// -// $priceValidator = 42.50; -// $priceToValidate = '42.50'; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); -// -// $expected = 0; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException2() -// { -// $adapter = new CouponBaseAdapter(); -// -// $priceValidator = 42.50; -// $priceToValidate = -1; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); -// -// $expected = 0; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException3() -// { -// $adapter = new CouponBaseAdapter(); -// -// $priceValidator = 42.50; -// $priceToValidate = 0; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'EUR'); -// -// $expected = 0; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\PriceParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException4() -// { -// $adapter = new CouponBaseAdapter(); -// $priceValidator = 42.50; -// $priceToValidate = 1; -// -// $integerParam = new PriceParam($adapter, $priceValidator, 'GBP'); -// -// $expected = 0; -// $actual = $integerParam->compareTo($priceToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * Test is the object is serializable -// * If no data is lost during the process -// */ -// public function isSerializableTest() -// { -// $adapter = new CouponBaseAdapter(); -// $priceValidator = 42.50; -// -// $param = new PriceParam($adapter, $priceValidator, 'GBP'); -// -// $serialized = base64_encode(serialize($param)); -// /** @var PriceParam $unserialized */ -// $unserialized = base64_decode(serialize($serialized)); -// -// $this->assertEquals($param->getValue(), $unserialized->getValue()); -// $this->assertEquals($param->getPrice(), $unserialized->getPrice()); -// $this->assertEquals($param->getCurrency(), $unserialized->getCurrency()); -// -// $new = new PriceParam($adapter, $unserialized->getPrice(), $unserialized->getCurrency()); -// $this->assertEquals($param->getPrice(), $new->getPrice()); -// $this->assertEquals($param->getCurrency(), $new->getCurrency()); -// } -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php deleted file mode 100644 index 806cedf8d..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/QuantityParamTest.php +++ /dev/null @@ -1,195 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use InvalidArgumentException; -use Thelia\Constraint\Validator\QuantityParam; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test QuantityParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class QuantityParamTest extends \PHPUnit_Framework_TestCase -{ - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -// * -// */ -// public function testInferiorQuantity() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = 0; -// -// $integerParam = new QuantityParam($adapter, $intValidator); -// -// $expected = 1; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -// * -// */ -// public function testInferiorQuantity2() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = 41; -// -// $integerParam = new QuantityParam($adapter, $intValidator); -// -// $expected = 1; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -// * -// */ -// public function testEqualsQuantity() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = 42; -// -// $integerParam = new QuantityParam($adapter, $intValidator); -// -// $expected = 0; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -// * -// */ -// public function testSuperiorQuantity() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = 43; -// -// $integerParam = new QuantityParam($adapter, $intValidator); -// -// $expected = -1; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = '42'; -// -// $integerParam = new QuantityParam($adapter, $intValidator); -// -// $expected = 0; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\QuantityParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException2() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = -1; -// -// $integerParam = new QuantityParam($adapter, $intValidator); -// -// $expected = 0; -// $actual = $integerParam->compareTo($intToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * Test is the object is serializable -// * If no data is lost during the process -// */ -// public function isSerializableTest() -// { -// $adapter = new CouponBaseAdapter(); -// $intValidator = 42; -// $intToValidate = -1; -// -// $param = new QuantityParam($adapter, $intValidator); -// -// $serialized = base64_encode(serialize($param)); -// /** @var QuantityParam $unserialized */ -// $unserialized = base64_decode(serialize($serialized)); -// -// $this->assertEquals($param->getValue(), $unserialized->getValue()); -// $this->assertEquals($param->getInteger(), $unserialized->getInteger()); -// -// $new = new QuantityParam($adapter, $unserialized->getInteger()); -// $this->assertEquals($param->getInteger(), $new->getInteger()); -// } -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php deleted file mode 100644 index be03743d3..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedDateParamTest.php +++ /dev/null @@ -1,309 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use InvalidArgumentException; -use Thelia\Constraint\Validator\RepeatedDateParam; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test RepeatedDateParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class RepeatedDateParamTest extends \PHPUnit_Framework_TestCase -{ - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testInferiorDate() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-07"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(); -// -// $expected = -1; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriod() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(); -// -// $expected = 0; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriod() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-08-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(1, 1); -// -// $expected = 0; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthTenTimesThirdPeriod() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-09-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(1, 10); -// -// $expected = 0; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthTenTimesTensPeriod() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2013-05-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(1, 10); -// -// $expected = 0; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryFourMonthTwoTimesSecondPeriod() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-11-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(4, 2); -// -// $expected = 0; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryFourMonthTwoTimesLastPeriod() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2013-03-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(4, 2); -// -// $expected = 0; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testNotEqualsDateRepeatEveryFourMonthTwoTimes1() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-08-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(4, 2); -// -// $expected = -1; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testNotEqualsDateRepeatEveryFourMonthTwoTimes2() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-12-08"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(4, 2); -// -// $expected = -1; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedDateParam::compareTo -// * -// */ -// public function testSuperiorDateRepeatEveryFourMonthTwoTimes() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2013-03-09"); -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(4, 2); -// -// $expected = -1; -// $actual = $repeatedDateParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\DateParam::compareTo -// * @expectedException InvalidArgumentException -// */ -// public function testInvalidArgumentException() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = 1377012588; -// -// $repeatedDateParam = new RepeatedDateParam($adapter); -// $repeatedDateParam->setFrom($startDateValidator); -// $repeatedDateParam->repeatEveryMonth(4, 2); -// -// $repeatedDateParam->compareTo($dateToValidate); -// } -// -// /** -// * Test is the object is serializable -// * If no data is lost during the process -// */ -// public function isSerializableTest() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// -// $param = new RepeatedDateParam($adapter); -// $param->setFrom($startDateValidator); -// $param->repeatEveryMonth(4, 2); -// -// $serialized = base64_encode(serialize($param)); -// /** @var RepeatedDateParam $unserialized */ -// $unserialized = base64_decode(serialize($serialized)); -// -// $this->assertEquals($param->getValue(), $unserialized->getValue()); -// $this->assertEquals($param->getDatePeriod(), $unserialized->getDatePeriod()); -// -// $new = new RepeatedDateParam($adapter); -// $new->setFrom($unserialized->getFrom()); -// $new->repeatEveryMonth($unserialized->getFrequency(), $unserialized->getNbRepetition()); -// $this->assertEquals($param->getDatePeriod(), $new->getDatePeriod()); -// } -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php b/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php deleted file mode 100644 index c5565a322..000000000 --- a/core/lib/Thelia/Tests/Constraint/Validator/RepeatedIntervalParamTest.php +++ /dev/null @@ -1,426 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Coupon; - -use Thelia\Constraint\Validator\RepeatedIntervalParam; - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Unit Test RepeatedIntervalParam Class - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class RepeatedIntervalParamTest extends \PHPUnit_Framework_TestCase -{ - - public function testSomething() - { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -// /** -// * Sets up the fixture, for example, opens a network connection. -// * This method is called before a test is executed. -// */ -// protected function setUp() -// { -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testInferiorDate() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-07"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// -// $RepeatedIntervalParam->repeatEveryMonth(); -// -// $expected = -1; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodBeginning() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-08"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodMiddle() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-13"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeFirstPeriodEnding() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-07-18"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodBeginning() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-08-08"); -// $dateToValidate = new \DateTime("2012-08-08"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodMiddle() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-08-08"); -// $dateToValidate = new \DateTime("2012-08-13"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthOneTimeSecondPeriodEnding() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-08-08"); -// $dateToValidate = new \DateTime("2012-08-18"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodBeginning() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-10-08"); -// $dateToValidate = new \DateTime("2012-10-08"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 4); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodMiddle() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-10-08"); -// $dateToValidate = new \DateTime("2012-10-13"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 4); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testEqualsDateRepeatEveryMonthFourTimeLastPeriodEnding() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-10-08"); -// $dateToValidate = new \DateTime("2012-10-18"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 4); -// -// $expected = 0; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testNotEqualsDateRepeatEveryMonthFourTimeInTheBeginning() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-10-08"); -// $dateToValidate = new \DateTime("2012-07-19"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 4); -// -// $expected = -1; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testNotEqualsDateRepeatEveryMonthFourTimeInTheMiddle() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-10-08"); -// $dateToValidate = new \DateTime("2012-08-01"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 4); -// -// $expected = -1; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testNotEqualsDateRepeatEveryMonthFourTimeInTheEnd() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-10-08"); -// $dateToValidate = new \DateTime("2012-08-07"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 4); -// -// $expected = -1; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// -// -// /** -// * -// * @covers Thelia\Coupon\Parameter\RepeatedIntervalParam::compareTo -// * -// */ -// public function testSuperiorDateRepeatEveryMonthFourTime() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = new \DateTime("2012-10-19"); -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 0); -// -// $expected = -1; -// $actual = $RepeatedIntervalParam->compareTo($dateToValidate); -// $this->assertEquals($expected, $actual); -// } -// -// /** -// * @covers Thelia\Coupon\Parameter\DateParam::compareTo -// * @expectedException \InvalidArgumentException -// */ -// public function testInvalidArgumentException() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = 1377012588; -// $duration = 10; -// -// $RepeatedIntervalParam = new RepeatedIntervalParam($adapter); -// $RepeatedIntervalParam->setFrom($startDateValidator); -// $RepeatedIntervalParam->setDurationInDays($duration); -// $RepeatedIntervalParam->repeatEveryMonth(1, 4); -// -// $RepeatedIntervalParam->compareTo($dateToValidate); -// } -// -// /** -// * Test is the object is serializable -// * If no data is lost during the process -// */ -// public function isSerializableTest() -// { -// $adapter = new CouponBaseAdapter(); -// $startDateValidator = new \DateTime("2012-07-08"); -// $dateToValidate = 1377012588; -// $duration = 10; -// -// $param = new RepeatedIntervalParam($adapter); -// $param->setFrom($startDateValidator); -// $param->setDurationInDays($duration); -// $param->repeatEveryMonth(1, 4); -// -// $serialized = base64_encode(serialize($param)); -// /** @var RepeatedIntervalParam $unserialized */ -// $unserialized = base64_decode(serialize($serialized)); -// -// $this->assertEquals($param->getValue(), $unserialized->getValue()); -// $this->assertEquals($param->getDatePeriod(), $unserialized->getDatePeriod()); -// -// $new = new RepeatedIntervalParam($adapter); -// $new->setFrom($unserialized->getFrom()); -// $new->repeatEveryMonth($unserialized->getFrequency(), $unserialized->getNbRepetition()); -// $new->setDurationInDays($unserialized->getDurationInDays()); -// $this->assertEquals($param->getDatePeriod(), $new->getDatePeriod()); -// } -// -// /** -// * Tears down the fixture, for example, closes a network connection. -// * This method is called after a test is executed. -// */ -// protected function tearDown() -// { -// } - -} diff --git a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php index eb271d4c1..056a14927 100755 --- a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php +++ b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php @@ -103,7 +103,6 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase $stubRequestContext )); - $this->container->set('request', $request); $this->container->set('event_dispatcher', new EventDispatcher()); $this->container->set('thelia.securityContext', new SecurityContext($request)); diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php index 2b7019879..cd3a47df0 100644 --- a/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php @@ -23,7 +23,6 @@ namespace Thelia\Tests\Core\Template\Loop; -use Thelia\Model\DocumentQuery; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; use Thelia\Core\Template\Loop\Document; diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php index ba4bfadc5..8c4906293 100644 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php @@ -23,7 +23,6 @@ namespace Thelia\Tests\Core\Template\Loop; -use Thelia\Model\ImageQuery; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; use Thelia\Core\Template\Loop\Image; diff --git a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php index 45f097a77..438a025de 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponBaseAdapterTest.php @@ -28,7 +28,7 @@ namespace Thelia\Coupon; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test CouponBaseAdapter Class + * Unit Test BaseAdapter Class * * @package Coupon * @author Guillaume MOREL @@ -44,7 +44,7 @@ class CouponBaseAdapterTest extends \PHPUnit_Framework_TestCase ); } // /** -// * @var CouponBaseAdapter +// * @var BaseAdapter // */ // protected $object; // @@ -54,7 +54,7 @@ class CouponBaseAdapterTest extends \PHPUnit_Framework_TestCase // */ // protected function setUp() // { -// $this->object = new CouponBaseAdapter; +// $this->object = new BaseAdapter; // } // // /** @@ -66,7 +66,7 @@ class CouponBaseAdapterTest extends \PHPUnit_Framework_TestCase // } // // /** -// * @covers Thelia\Coupon\CouponBaseAdapter::getCart +// * @covers Thelia\Coupon\BaseAdapter::getCart // * @todo Implement testGetCart(). // */ // public function testGetCart() @@ -78,7 +78,7 @@ class CouponBaseAdapterTest extends \PHPUnit_Framework_TestCase // } // // /** -// * @covers Thelia\Coupon\CouponBaseAdapter::getDeliveryAddress +// * @covers Thelia\Coupon\BaseAdapter::getDeliveryAddress // * @todo Implement testGetDeliveryAddress(). // */ // public function testGetDeliveryAddress() @@ -90,7 +90,7 @@ class CouponBaseAdapterTest extends \PHPUnit_Framework_TestCase // } // // /** -// * @covers Thelia\Coupon\CouponBaseAdapter::getCustomer +// * @covers Thelia\Coupon\BaseAdapter::getCustomer // * @todo Implement testGetCustomer(). // */ // public function testGetCustomer() diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index 261f0e100..21a0cfa4b 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -74,7 +74,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // * @param bool $isUsed If Coupon has been used yet // * @param bool $isEnabled If Coupon is enabled // * @param \DateTime $expirationDate When Coupon expires -// * @param CouponRuleCollection $rules Coupon rules +// * @param ConditionCollection $rules Coupon rules // * @param bool $isCumulative If Coupon is cumulative // * @param bool $isRemovingPostage If Coupon is removing postage // * @@ -109,9 +109,9 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // $isRemovingPostage // ); // -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->getMock( -// 'Thelia\Coupon\CouponBaseAdapter', +// 'Thelia\Coupon\BaseAdapter', // array('findOneCouponByCode'), // array() // ); @@ -135,7 +135,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // $date = new \DateTime(); // $date->setTimestamp(strtotime("today - 2 months")); // -// /** @var CouponAdapterInterface $mockAdapter */ +// /** @var AdapterInterface $mockAdapter */ // $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, $date); // $couponFactory = new CouponFactory($mockAdapter); // $coupon = $couponFactory->buildCouponFromCode('XMAS1'); @@ -151,7 +151,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // { // $date = new \DateTime(); // -// /** @var CouponAdapterInterface $mockAdapter */ +// /** @var AdapterInterface $mockAdapter */ // $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, $date); // $couponFactory = new CouponFactory($mockAdapter); // $coupon = $couponFactory->buildCouponFromCode('XMAS1'); @@ -161,12 +161,12 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // * Test if an expired Coupon is build or not (equal) // * // * @covers Thelia\Coupon\CouponFactory::buildCouponFromCode -// * @expectedException \Thelia\Exception\InvalidRuleException +// * @expectedException \Thelia\Exception\InvalidConditionException // */ // public function testBuildCouponFromCodeWithoutRule() // { -// /** @var CouponAdapterInterface $mockAdapter */ -// $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, null, new CouponRuleCollection(array())); +// /** @var AdapterInterface $mockAdapter */ +// $mockAdapter = $this->generateCouponModelMock(null, null, null, null, null, null, null, null, null, new ConditionCollection(array())); // $couponFactory = new CouponFactory($mockAdapter); // $coupon = $couponFactory->buildCouponFromCode('XMAS1'); // } @@ -178,7 +178,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // */ // public function testBuildCouponFromCode() // { -// /** @var CouponAdapterInterface $mockAdapter */ +// /** @var AdapterInterface $mockAdapter */ // $mockAdapter = $this->generateCouponModelMock(); // $couponFactory = new CouponFactory($mockAdapter); // /** @var CouponInterface $coupon */ @@ -206,7 +206,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // /** // * Generate valid CouponRuleInterfaces // * -// * @return CouponRuleCollection Set of CouponRuleInterface +// * @return ConditionCollection Set of ConditionManagerInterface // */ // protected function generateValidRules() // { @@ -230,7 +230,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase //// ) //// ) //// ); -//// $rules = new CouponRuleCollection(array($rule1, $rule2)); +//// $rules = new ConditionCollection(array($rule1, $rule2)); //// //// return $rules; // } @@ -247,7 +247,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // * @param bool $isUsed If Coupon has been used yet // * @param bool $isEnabled If Coupon is enabled // * @param \DateTime $expirationDate When Coupon expires -// * @param CouponRuleCollection $rules Coupon rules +// * @param ConditionCollection $rules Coupon rules // * @param bool $isCumulative If Coupon is cumulative // * @param bool $isRemovingPostage If Coupon is removing postage // * @@ -327,7 +327,7 @@ class CouponFactoryTest extends \PHPUnit_Framework_TestCase // $rules = $this->generateValidRules(); // } // -// $coupon->setSerializedRules(base64_encode(serialize($rules))); +// $coupon->setSerializedConditions(base64_encode(serialize($rules))); // // $coupon->setIsCumulative($isCumulative); // $coupon->setIsRemovingPostage($isRemovingPostage); diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index d0662442a..1d1ba7c72 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -88,7 +88,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // /** @var CouponInterface $coupon */ // $coupon = self::generateValidCoupon(); // -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice); // // $couponManager = new CouponManager($stubCouponBaseAdapter); @@ -108,7 +108,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // */ // public function testGetDiscountTwoCoupon() // { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $cartTotalPrice = 100.00; // $checkoutTotalPrice = 120.00; // @@ -124,11 +124,11 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // ) // ) // ); -// $rules = new CouponRuleCollection(array($rule1)); +// $rules = new ConditionCollection(array($rule1)); // /** @var CouponInterface $coupon2 */ // $coupon2 = $this->generateValidCoupon('XMAS2', null, null, null, 15.00, null, null, $rules); // -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon1, $coupon2), $cartTotalPrice, $checkoutTotalPrice); // // $couponManager = new CouponManager($stubCouponBaseAdapter); @@ -148,7 +148,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // */ // public function testGetDiscountAlwaysInferiorToPrice() // { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $cartTotalPrice = 21.00; // $checkoutTotalPrice = 26.00; // @@ -162,11 +162,11 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // ) // ) // ); -// $rules = new CouponRuleCollection(array($rule1)); +// $rules = new ConditionCollection(array($rule1)); // /** @var CouponInterface $coupon */ // $coupon = $this->generateValidCoupon('XMAS2', null, null, null, 30.00, null, null, $rules); // -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice); // // $couponManager = new CouponManager($stubCouponBaseAdapter); @@ -185,7 +185,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // */ // public function testIsCouponRemovingPostage() // { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $cartTotalPrice = 21.00; // $checkoutTotalPrice = 27.00; // @@ -199,11 +199,11 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // ) // ) // ); -// $rules = new CouponRuleCollection(array($rule1)); +// $rules = new ConditionCollection(array($rule1)); // /** @var CouponInterface $coupon */ // $coupon = $this->generateValidCoupon('XMAS2', null, null, null, 30.00, null, null, $rules, null, true); // -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter(array($coupon), $cartTotalPrice, $checkoutTotalPrice); // // $couponManager = new CouponManager($stubCouponBaseAdapter); @@ -231,7 +231,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // // $coupons = array($couponCumulative1); // -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -264,7 +264,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative1 = $this->generateValidCoupon(null, null, null, null, null, null, null, null, true); // // $coupons = array($couponCumulative1); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -299,7 +299,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); // // $coupons = array($couponCumulative1, $couponCumulative2); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -334,7 +334,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, false); // // $coupons = array($couponCumulative1, $couponCumulative2); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -369,7 +369,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); // // $coupons = array($couponCumulative1, $couponCumulative2); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -404,7 +404,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, false); // // $coupons = array($couponCumulative1, $couponCumulative2); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -437,7 +437,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative1 = $this->generateValidCoupon('XMAS1', null, null, null, null, null, new \DateTime(), null, true); // // $coupons = array($couponCumulative1); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -472,7 +472,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, new \DateTime(), null, true); // // $coupons = array($couponCumulative1, $couponCumulative2); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -507,7 +507,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, null, null, true); // // $coupons = array($couponCumulative1, $couponCumulative2); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -542,7 +542,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative2 = $this->generateValidCoupon('XMAS2', null, null, null, null, null, new \DateTime(), null, true); // // $coupons = array($couponCumulative1, $couponCumulative2); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -581,7 +581,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative4 = $this->generateValidCoupon('XMAS4', null, null, null, null, null, null, null, true); // // $coupons = array($couponCumulative1, $couponCumulative2, $couponCumulative3, $couponCumulative4); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -620,7 +620,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $couponCumulative4 = $this->generateValidCoupon('XMAS4', null, null, null, null, null, null, null, false); // // $coupons = array($couponCumulative1, $couponCumulative2, $couponCumulative3, $couponCumulative4); -// /** @var CouponAdapterInterface $stubCouponBaseAdapter */ +// /** @var AdapterInterface $stubCouponBaseAdapter */ // $stubCouponBaseAdapter = $this->generateFakeAdapter($coupons, $cartTotalPrice, $checkoutTotalPrice); // // // When @@ -641,11 +641,11 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // /** // * Generate valid CouponRuleInterfaces // * -// * @return array Array of CouponRuleInterface +// * @return array Array of ConditionManagerInterface // */ // public static function generateValidRules() // { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $rule1 = new AvailableForTotalAmount( // $adapter, array( // AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( @@ -666,7 +666,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // ) // ) // ); -// $rules = new CouponRuleCollection(array($rule1, $rule2)); +// $rules = new ConditionCollection(array($rule1, $rule2)); // // return $rules; // } @@ -692,7 +692,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // public function generateFakeAdapter(array $coupons, $cartTotalPrice, $checkoutTotalPrice, $postagePrice = 6.00) // { // $stubCouponBaseAdapter = $this->getMock( -// 'Thelia\Coupon\CouponBaseAdapter', +// 'Thelia\Coupon\BaseAdapter', // array( // 'getCurrentCoupons', // 'getCartTotalPrice', @@ -734,7 +734,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // * @param float $amount Coupon discount // * @param bool $isEnabled Is Coupon enabled // * @param \DateTime $expirationDate Coupon expiration date -// * @param CouponRuleCollection $rules Coupon rules +// * @param ConditionCollection $rules Coupon rules // * @param bool $isCumulative If is cumulative // * @param bool $isRemovingPostage If is removing postage // * @param bool $isAvailableOnSpecialOffers If is available on @@ -758,7 +758,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase // $isAvailableOnSpecialOffers = null, // $maxUsage = null // ) { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // if ($code === null) { // $code = self::VALID_CODE; // } diff --git a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php index 803000779..2b19ba130 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponRuleCollectionTest.php @@ -33,7 +33,7 @@ use Thelia\Constraint\Rule\Operators; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test CouponRuleCollection Class + * Unit Test ConditionCollection Class * * @package Coupon * @author Guillaume MOREL @@ -73,7 +73,7 @@ class CouponRuleCollectionTest extends \PHPUnit_Framework_TestCase //// ) //// ) //// ); -//// $rules = new CouponRuleCollection(array($rule1, $rule2)); +//// $rules = new ConditionCollection(array($rule1, $rule2)); //// //// $serializedRules = base64_encode(serialize($rules)); //// $unserializedRules = unserialize(base64_decode($serializedRules)); diff --git a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php index 3300cb19b..d13184a8c 100644 --- a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php +++ b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon; +use Thelia\Coupon\RuleOrganizer; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -47,7 +48,7 @@ class RuleOrganizerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = new RuleOrganizer; + $this->object = new RuleOrganizer(); } /** diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php index 990309f28..de739bf90 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXAmountTest.php @@ -153,7 +153,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // */ // public function testGetEffect() // { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // $expected = 10; @@ -186,7 +186,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); +// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2))); // // // Then // $expected = 3; @@ -197,7 +197,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // * Test Coupon rule setter // * // * @covers Thelia\Coupon\type\RemoveXAmountManager::setRules -// * @expectedException \Thelia\Exception\InvalidRuleException +// * @expectedException \Thelia\Exception\InvalidConditionException // * // */ // public function testSetRulesInvalid() @@ -216,7 +216,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); +// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2))); // } // // /** @@ -228,7 +228,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // public function testGetEffectIfTotalAmountInferiorTo400Valid() // { // // Given -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( // Operators::INFERIOR, // 400.00 @@ -236,7 +236,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 10.00; @@ -253,7 +253,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // public function testGetEffectIfTotalAmountInferiorOrEqualTo400Valid() // { // // Given -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( // Operators::INFERIOR_OR_EQUAL, // 400.00 @@ -261,7 +261,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 10.00; @@ -278,7 +278,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // public function testGetEffectIfTotalAmountEqualTo400Valid() // { // // Given -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( // Operators::EQUAL, // 400.00 @@ -286,7 +286,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 10.00; @@ -303,7 +303,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // public function testGetEffectIfTotalAmountSuperiorOrEqualTo400Valid() // { // // Given -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( // Operators::SUPERIOR_OR_EQUAL, // 400.00 @@ -311,7 +311,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 10.00; @@ -328,7 +328,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // public function testGetEffectIfTotalAmountSuperiorTo400Valid() // { // // Given -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $rule0 = $this->generateValidRuleAvailableForTotalAmountOperatorTo( // Operators::SUPERIOR, // 400.00 @@ -336,7 +336,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // $coupon = CouponManagerTest::generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 10.00; @@ -365,7 +365,7 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase // */ // protected function generateValidRuleAvailableForTotalAmountOperatorTo($operator, $amount) // { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $validators = array( // AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( // $operator, diff --git a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php index b5d6529b1..b1b012fb3 100644 --- a/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php +++ b/core/lib/Thelia/Tests/Coupon/Type/RemoveXPercentTest.php @@ -158,7 +158,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); +// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2))); // // // Then // $expected = 3; @@ -169,7 +169,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // * Test Coupon rule setter // * // * @covers Thelia\Coupon\type\RemoveXPercentManager::setRules -// * @expectedException \Thelia\Exception\InvalidRuleException +// * @expectedException \Thelia\Exception\InvalidConditionException // * // */ // public function testSetRulesInvalid() @@ -188,7 +188,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0, $rule1, $rule2))); +// $coupon->setRules(new ConditionCollection(array($rule0, $rule1, $rule2))); // } // // /** @@ -207,7 +207,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 24.50; @@ -231,7 +231,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 24.50; @@ -255,7 +255,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 24.50; @@ -279,7 +279,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 24.50; @@ -303,7 +303,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // $coupon = $this->generateValidCoupon(null, null, null, null, null, null, null, null, false, false); // // // When -// $coupon->setRules(new CouponRuleCollection(array($rule0))); +// $coupon->setRules(new ConditionCollection(array($rule0))); // // // Then // $expected = 24.50; @@ -322,7 +322,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // * @param float $amount Coupon discount // * @param bool $isEnabled Is Coupon enabled // * @param \DateTime $expirationDate Coupon expiration date -// * @param CouponRuleCollection $rules Coupon rules +// * @param ConditionCollection $rules Coupon rules // * @param bool $isCumulative If is cumulative // * @param bool $isRemovingPostage If is removing postage // * @param bool $isAvailableOnSpecialOffers If is available on @@ -407,7 +407,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // */ // protected function generateValidRuleAvailableForTotalAmountOperatorTo($operator, $amount) // { -// $adapter = new CouponBaseAdapter(); +// $adapter = new BaseAdapter(); // $validators = array( // AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( // $operator, @@ -432,7 +432,7 @@ class RemoveXPercentTest extends \PHPUnit_Framework_TestCase // public function generateFakeAdapter($cartTotalPrice) // { // $stubCouponBaseAdapter = $this->getMock( -// 'Thelia\Coupon\CouponBaseAdapter', +// 'Thelia\Coupon\BaseAdapter', // array( // 'getCartTotalPrice' // ), diff --git a/core/lib/Thelia/Tests/Form/OrderDeliveryTest.php b/core/lib/Thelia/Tests/Form/OrderDeliveryTest.php new file mode 100755 index 000000000..980c17d88 --- /dev/null +++ b/core/lib/Thelia/Tests/Form/OrderDeliveryTest.php @@ -0,0 +1,32 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Tests\Form; + +class OrderDeliveryTest extends \PHPUnit_Framework_TestCase +{ + + public function testOrderDelivery() + { + + } +} diff --git a/core/lib/Thelia/Tests/Module/BaseModuleTestor.php b/core/lib/Thelia/Tests/Module/BaseModuleTestor.php index ce70cd4ad..1a8de083a 100644 --- a/core/lib/Thelia/Tests/Module/BaseModuleTestor.php +++ b/core/lib/Thelia/Tests/Module/BaseModuleTestor.php @@ -23,7 +23,6 @@ namespace Thelia\Tests\Module; - /** * * @author Etienne Roudeix @@ -50,4 +49,3 @@ abstract class BaseModuleTestor extends \PHPUnit_Framework_TestCase $this->instance = $this->getTestedInstance(); } } - diff --git a/core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php b/core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php index 449a9162d..16b8e2f28 100644 --- a/core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php +++ b/core/lib/Thelia/Tests/Rewriting/BaseRewritingObject.php @@ -23,7 +23,6 @@ namespace Thelia\Tests\Rewriting; - /** * Class BaseRewritingObject * @package Thelia\Tests\Rewriting @@ -35,7 +34,7 @@ abstract class BaseRewritingObject extends \PHPUnit_Framework_TestCase /** * @return mixed an instance of Product, Folder, Content or Category Model */ - abstract function getObject(); + abstract public function getObject(); /** * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl @@ -105,4 +104,4 @@ abstract class BaseRewritingObject extends \PHPUnit_Framework_TestCase $object->generateRewrittenUrl('fr_FR'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php b/core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php index 247fdc8a9..f5ff56685 100644 --- a/core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php +++ b/core/lib/Thelia/Tests/Rewriting/CategoryRewritingTest.php @@ -24,7 +24,6 @@ namespace Thelia\Tests\Rewriting; use Thelia\Model\Category; - /** * Class CategoryRewritingTest * @package Thelia\Tests\Rewriting @@ -36,8 +35,8 @@ class CategoryRewritingTest extends BaseRewritingObject /** * @return \Thelia\Model\Category */ - function getObject() + public function getObject() { return new Category(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php b/core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php index e06ff62b2..97dd10bee 100644 --- a/core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php +++ b/core/lib/Thelia/Tests/Rewriting/ContentRewritingTest.php @@ -24,7 +24,6 @@ namespace Thelia\Tests\Rewriting; use Thelia\Model\Content; - /** * Class ContentRewritingTest * @package Thelia\Tests\Rewriting @@ -36,8 +35,8 @@ class ContentRewritingTest extends BaseRewritingObject /** * @return \Thelia\Model\Content */ - function getObject() + public function getObject() { return new Content(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php b/core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php index db0dbc897..81e4154a2 100644 --- a/core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php +++ b/core/lib/Thelia/Tests/Rewriting/FolderRewritingTest.php @@ -24,7 +24,6 @@ namespace Thelia\Tests\Rewriting; use Thelia\Model\Folder; - /** * Class FolderRewritingTest * @package Thelia\Tests\Rewriting @@ -36,8 +35,8 @@ class FolderRewritingTest extends BaseRewritingObject /** * @return mixed an instance of Product, Folder, Content or Category Model */ - function getObject() + public function getObject() { return new Folder(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php index 2bff1bf5c..0a74587d5 100644 --- a/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php +++ b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php @@ -23,8 +23,6 @@ namespace Thelia\Tests\Rewriting; use Thelia\Model\Product; -use Thelia\Model\ProductQuery; - /** * Class ProductRewriteTest @@ -37,8 +35,8 @@ class ProductRewriteTest extends BaseRewritingObject /** * @return mixed an instance of Product, Folder, Content or Category Model */ - function getObject() + public function getObject() { return new Product(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php index 502b14c7e..f8c6ec6c0 100755 --- a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php +++ b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php @@ -86,7 +86,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRuleQuery = $this->getMock('\Thelia\Model\TaxRuleQuery', array('getTaxCalculatorCollection')); $taxRuleQuery->expects($this->once()) ->method('getTaxCalculatorCollection') - ->with($productQuery, $countryQuery) + ->with($productQuery->getTaxRule(), $countryQuery) ->will($this->returnValue('foo')); $rewritingUrlQuery = $this->getProperty('taxRuleQuery'); diff --git a/core/lib/Thelia/Tests/Tools/FileManagerTest.php b/core/lib/Thelia/Tests/Tools/FileManagerTest.php new file mode 100644 index 000000000..1228867a7 --- /dev/null +++ b/core/lib/Thelia/Tests/Tools/FileManagerTest.php @@ -0,0 +1,895 @@ + + */ + +namespace Thelia\Tests\Tools; + +use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; +use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; +use Thelia\Core\Translation\Translator; +use Thelia\Exception\ImageException; +use Thelia\Model\Admin; +use Thelia\Tools\FileManager; + +/** + * Class FileManagerTest + * + * @package Thelia\Tests\Tools + */ +class FileManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Thelia\Tools\FileManager::copyUploadedFile + */ + public function testCopyUploadedFile() + { + $this->markTestIncomplete( + 'Mock issue' + ); + + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + $stubTranslator->expects($this->any()) + ->method('trans') + ->will($this->returnValue('translated')); + + $stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request') + ->disableOriginalConstructor() + ->getMock(); + + $stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext') + ->disableOriginalConstructor() + ->getMock(); + $stubSecurity->expects($this->any()) + ->method('getAdminUser') + ->will($this->returnValue(new Admin())); + + // Create a map of arguments to return values. + $map = array( + array('thelia.translator', $stubTranslator), + array('request', $stubRequest), + array('thelia.securityContext', $stubSecurity) + ); + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValueMap($map)); + + $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage') + ->disableOriginalConstructor() + ->getMock(); + $stubProductImage->expects($this->any()) + ->method('getUploadDir') + ->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product')); + $stubProductImage->expects($this->any()) + ->method('getId') + ->will($this->returnValue(42)); + $stubProductImage->expects($this->any()) + ->method('setFile') + ->will($this->returnValue(true)); + $stubProductImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(0)); + + $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile') + ->disableOriginalConstructor() + ->getMock(); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalName') + ->will($this->returnValue('goodName')); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalExtension') + ->will($this->returnValue('png')); + $stubUploadedFile->expects($this->any()) + ->method('move') + ->will($this->returnValue($stubUploadedFile)); + + $fileManager = new FileManager($stubContainer); + + $newUploadedFiles = array(); + + $actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_IMAGES); + + $this->assertCount(1, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::copyUploadedFile + * @expectedException \Thelia\Exception\ImageException + */ + public function testCopyUploadedFileExceptionImageException() + { + $this->markTestIncomplete( + 'Mock issue' + ); + + $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + $stubTranslator->expects($this->any()) + ->method('trans') + ->will($this->returnValue('translated')); + + $stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request') + ->disableOriginalConstructor() + ->getMock(); + + $stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext') + ->disableOriginalConstructor() + ->getMock(); + $stubSecurity->expects($this->any()) + ->method('getAdminUser') + ->will($this->returnValue(new Admin())); + + // Create a map of arguments to return values. + $map = array( + array('thelia.translator', $stubTranslator), + array('request', $stubRequest), + array('thelia.securityContext', $stubSecurity) + ); + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + $stubContainer->expects($this->any()) + ->method('get') + ->will($this->returnValueMap($map)); + + $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage') + ->disableOriginalConstructor() + ->getMock(); + $stubProductImage->expects($this->any()) + ->method('getUploadDir') + ->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product')); + $stubProductImage->expects($this->any()) + ->method('getId') + ->will($this->returnValue(42)); + $stubProductImage->expects($this->any()) + ->method('setFile') + ->will($this->returnValue(true)); + $stubProductImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(0)); + + $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile') + ->disableOriginalConstructor() + ->getMock(); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalName') + ->will($this->returnValue('goodName')); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalExtension') + ->will($this->returnValue('png')); + $stubUploadedFile->expects($this->any()) + ->method('move') + ->will($this->returnValue($stubUploadedFile)); + + $fileManager = new FileManager($stubContainer); + + $newUploadedFiles = array(); + + $actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_DOCUMENTS); + + } + + /** + * @covers Thelia\Tools\FileManager::saveImage + */ + public function testSaveImageProductImage() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage') + ->disableOriginalConstructor() + ->getMock(); + $stubProductImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubProductImage->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24); + + $expected = 10; + $actual = $fileManager->saveImage($event, $stubProductImage); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveDocument + */ + public function testSaveDocumentProductDocument() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument') + ->disableOriginalConstructor() + ->getMock(); + $stubProductDocument->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubProductDocument->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24); + + $expected = 10; + $actual = $fileManager->saveDocument($event, $stubProductDocument); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveImage + */ + public function testSaveImageCategoryImage() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubCategoryImage = $this->getMockBuilder('\Thelia\Model\CategoryImage') + ->disableOriginalConstructor() + ->getMock(); + $stubCategoryImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubCategoryImage->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24); + + $expected = 10; + $actual = $fileManager->saveImage($event, $stubCategoryImage); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveDocument + */ + public function testSaveDocumentCategoryDocument() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubCategoryDocument = $this->getMockBuilder('\Thelia\Model\CategoryDocument') + ->disableOriginalConstructor() + ->getMock(); + $stubCategoryDocument->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubCategoryDocument->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24); + + $expected = 10; + $actual = $fileManager->saveDocument($event, $stubCategoryDocument); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveImage + */ + public function testSaveImageFolderImage() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubFolderImage = $this->getMockBuilder('\Thelia\Model\FolderImage') + ->disableOriginalConstructor() + ->getMock(); + $stubFolderImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubFolderImage->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24); + + $expected = 10; + $actual = $fileManager->saveImage($event, $stubFolderImage); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveDocument + */ + public function testSaveDocumentFolderDocument() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubFolderDocument = $this->getMockBuilder('\Thelia\Model\FolderDocument') + ->disableOriginalConstructor() + ->getMock(); + $stubFolderDocument->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubFolderDocument->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24); + + $expected = 10; + $actual = $fileManager->saveDocument($event, $stubFolderDocument); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveImage + */ + public function testSaveImageContentImage() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubContentImage = $this->getMockBuilder('\Thelia\Model\ContentImage') + ->disableOriginalConstructor() + ->getMock(); + $stubContentImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubContentImage->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24); + + $expected = 10; + $actual = $fileManager->saveImage($event, $stubContentImage); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveDocument + */ + public function testSaveDocumentContentDocument() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubContentDocument = $this->getMockBuilder('\Thelia\Model\ContentDocument') + ->disableOriginalConstructor() + ->getMock(); + $stubContentDocument->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubContentDocument->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $fileManager = new FileManager($stubContainer); + + $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24); + + $expected = 10; + $actual = $fileManager->saveDocument($event, $stubContentDocument); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::saveImage + * @expectedException \Thelia\Exception\ImageException + */ + public function testSaveImageExceptionImageException() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + $fileManager = new FileManager($stubContainer); + + $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage') + ->disableOriginalConstructor() + ->getMock(); + $stubProductImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubProductImage->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $event = new ImageCreateOrUpdateEvent('bad', 24); + + $fileManager->saveImage($event, $stubProductImage); + } + + /** + * @covers Thelia\Tools\FileManager::saveDocument + * @expectedException \Thelia\Model\Exception\InvalidArgumentException + */ + public function testSaveDocumentExceptionDocumentException() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + $fileManager = new FileManager($stubContainer); + + $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument') + ->disableOriginalConstructor() + ->getMock(); + $stubProductDocument->expects($this->any()) + ->method('save') + ->will($this->returnValue(10)); + $stubProductDocument->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $event = new DocumentCreateOrUpdateEvent('bad', 24); + + $fileManager->saveDocument($event, $stubProductDocument); + } + + /** + * @covers Thelia\Tools\FileManager::saveImage + * @expectedException \Thelia\Exception\ImageException + */ + public function testSaveImageExceptionImageException2() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + $fileManager = new FileManager($stubContainer); + + $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage') + ->disableOriginalConstructor() + ->getMock(); + $stubProductImage->expects($this->any()) + ->method('save') + ->will($this->returnValue(0)); + $stubProductImage->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24); + + $fileManager->saveImage($event, $stubProductImage); + } + + /** + * @covers Thelia\Tools\FileManager::saveDocument + * @expectedException \Thelia\Model\Exception\InvalidArgumentException + */ + public function testSaveDocumentExceptionDocumentException2() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + $fileManager = new FileManager($stubContainer); + + $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument') + ->disableOriginalConstructor() + ->getMock(); + $stubProductDocument->expects($this->any()) + ->method('save') + ->will($this->returnValue(0)); + $stubProductDocument->expects($this->any()) + ->method('getFile') + ->will($this->returnValue('file')); + + $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24); + + $fileManager->saveDocument($event, $stubProductDocument); + } + + /** + * @covers Thelia\Tools\FileManager::sanitizeFileName + */ + public function testSanitizeFileName() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + $badFileName = 'a/ze\érà~çè§^"$*+-_°)(&é<>@#ty2/[\/:*?"<>|]/fi?.fUPPERile.exel../e*'; + + $expected = 'azer-_ty2fi.fupperile.exel..e'; + $actual = $fileManager->sanitizeFileName($badFileName); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::getImageModel + */ + public function testGetImageModel() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + $actual = $fileManager->getImageModel(FileManager::TYPE_PRODUCT); + $this->assertInstanceOf('\Thelia\Model\ProductImage', $actual); + $actual = $fileManager->getImageModel(FileManager::TYPE_CATEGORY); + $this->assertInstanceOf('\Thelia\Model\CategoryImage', $actual); + $actual = $fileManager->getImageModel(FileManager::TYPE_CONTENT); + $this->assertInstanceOf('\Thelia\Model\ContentImage', $actual); + $actual = $fileManager->getImageModel(FileManager::TYPE_FOLDER); + $this->assertInstanceOf('\Thelia\Model\FolderImage', $actual); + $actual = $fileManager->getImageModel('bad'); + $this->assertNull($actual); + } + + /** + * @covers Thelia\Tools\FileManager::getDocumentModel + */ + public function testGetDocumentModel() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + $actual = $fileManager->getDocumentModel(FileManager::TYPE_PRODUCT); + $this->assertInstanceOf('\Thelia\Model\ProductDocument', $actual); + $actual = $fileManager->getDocumentModel(FileManager::TYPE_CATEGORY); + $this->assertInstanceOf('\Thelia\Model\CategoryDocument', $actual); + $actual = $fileManager->getDocumentModel(FileManager::TYPE_CONTENT); + $this->assertInstanceOf('\Thelia\Model\ContentDocument', $actual); + $actual = $fileManager->getDocumentModel(FileManager::TYPE_FOLDER); + $this->assertInstanceOf('\Thelia\Model\FolderDocument', $actual); + $actual = $fileManager->getDocumentModel('bad'); + $this->assertNull($actual); + } + + /** + * @covers Thelia\Tools\FileManager::getImageModelQuery + */ + public function testGetImageModelQuery() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + $actual = $fileManager->getImageModelQuery(FileManager::TYPE_PRODUCT); + $this->assertInstanceOf('\Thelia\Model\ProductImageQuery', $actual); + $actual = $fileManager->getImageModelQuery(FileManager::TYPE_CATEGORY); + $this->assertInstanceOf('\Thelia\Model\CategoryImageQuery', $actual); + $actual = $fileManager->getImageModelQuery(FileManager::TYPE_CONTENT); + $this->assertInstanceOf('\Thelia\Model\ContentImageQuery', $actual); + $actual = $fileManager->getImageModelQuery(FileManager::TYPE_FOLDER); + $this->assertInstanceOf('\Thelia\Model\FolderImageQuery', $actual); + $actual = $fileManager->getImageModelQuery('bad'); + $this->assertNull($actual); + } + + /** + * @covers Thelia\Tools\FileManager::getDocumentModelQuery + */ + public function testGetDocumentModelQuery() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_PRODUCT); + $this->assertInstanceOf('\Thelia\Model\ProductDocumentQuery', $actual); + $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CATEGORY); + $this->assertInstanceOf('\Thelia\Model\CategoryDocumentQuery', $actual); + $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CONTENT); + $this->assertInstanceOf('\Thelia\Model\ContentDocumentQuery', $actual); + $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_FOLDER); + $this->assertInstanceOf('\Thelia\Model\FolderDocumentQuery', $actual); + $actual = $fileManager->getDocumentModelQuery('bad'); + $this->assertNull($actual); + } + + /** + * @covers Thelia\Tools\FileManager::getParentFileModel + */ + public function testGetParentFileModel() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_PRODUCT, 1); + $this->assertInstanceOf('\Thelia\Model\Product', $actual); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_CATEGORY, 1); + $this->assertInstanceOf('\Thelia\Model\Category', $actual); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_CONTENT, 1); + $this->assertInstanceOf('\Thelia\Model\Content', $actual); + $actual = $fileManager->getParentFileModel(FileManager::TYPE_FOLDER, 1); + $this->assertInstanceOf('\Thelia\Model\Folder', $actual, 1); + $actual = $fileManager->getParentFileModel('bad', 1); + $this->assertNull($actual); + } + + /** + * @covers Thelia\Tools\FileManager::getImageForm + */ + public function testGetImageForm() + { + // Mock issue + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + /** + * @covers Thelia\Tools\FileManager::getDocumentForm + */ + public function testGetDocumentForm() + { + // Mock issue + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Thelia\Tools\FileManager::getUploadDir + */ + public function testGetUploadDir() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + + $actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/product', $actual); + $actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/category', $actual); + $actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/content', $actual); + $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/folder', $actual); + $actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_IMAGES); + $this->assertEquals(false, $actual); + + $actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/product', $actual); + $actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/category', $actual); + $actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/content', $actual); + $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/folder', $actual); + $actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals(false, $actual); + + $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, 'bad'); + $this->assertEquals(false, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::getRedirectionUrl + */ + public function testGetRedirectionUrl() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('/admin/products/update?product_id=1¤t_tab=images', $actual); + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('/admin/categories/update?category_id=1¤t_tab=images', $actual); + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('/admin/content/update/1?current_tab=images', $actual); + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('/admin/folders/update/1?current_tab=images', $actual); + $actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals(false, $actual); + + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('/admin/products/update?product_id=1¤t_tab=documents', $actual); + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('/admin/categories/update?category_id=1¤t_tab=documents', $actual); + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('/admin/content/update/1?current_tab=documents', $actual); + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('/admin/folders/update/1?current_tab=documents', $actual); + $actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals(false, $actual); + + $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, 'bad'); + $this->assertEquals(false, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::getFormId + */ + public function testGetFormId() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + + $actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('thelia.admin.product.image.modification', $actual); + $actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('thelia.admin.category.image.modification', $actual); + $actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('thelia.admin.content.image.modification', $actual); + $actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES); + $this->assertEquals('thelia.admin.folder.image.modification', $actual); + $actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_IMAGES); + $this->assertEquals(false, $actual); + + $actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('thelia.admin.product.document.modification', $actual); + $actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('thelia.admin.category.document.modification', $actual); + $actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('thelia.admin.content.document.modification', $actual); + $actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals('thelia.admin.folder.document.modification', $actual); + $actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_DOCUMENTS); + $this->assertEquals(false, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::renameFile + */ + public function testRenameFile() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile') + ->disableOriginalConstructor() + ->getMock(); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalExtension') + ->will($this->returnValue('yml')); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalName') + ->will($this->returnValue('or1-g_n?al*/&é"filen@me#')); + + $fileManager = new FileManager($stubContainer); + + $expected = 'or1-g_nalfilenme-1.yml'; + $actual = $fileManager->renameFile(1, $stubUploadedFile); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::renameFile + */ + public function testRenameFileWithoutExtension() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile') + ->disableOriginalConstructor() + ->getMock(); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalExtension') + ->will($this->returnValue('')); + $stubUploadedFile->expects($this->any()) + ->method('getClientOriginalName') + ->will($this->returnValue('or1-g_n?al*/&é"filen@me#')); + + $fileManager = new FileManager($stubContainer); + + $expected = 'or1-g_nalfilenme-1'; + $actual = $fileManager->renameFile(1, $stubUploadedFile); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::isImage + */ + public function testIsImage() + { + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fileManager = new FileManager($stubContainer); + + $actual = $fileManager->isImage('image/jpeg'); + $this->assertTrue($actual); + $actual = $fileManager->isImage('image/png'); + $this->assertTrue($actual); + $actual = $fileManager->isImage('image/gif'); + $this->assertTrue($actual); + + $actual = $fileManager->isImage('bad'); + $this->assertFalse($actual); + $actual = $fileManager->isImage('image/jpg'); + $this->assertFalse($actual); + $actual = $fileManager->isImage('application/x-msdownload'); + $this->assertFalse($actual); + $actual = $fileManager->isImage('application/x-sh'); + $this->assertFalse($actual); + + } + + /** + * @covers Thelia\Tools\FileManager::getAvailableTypes + */ + public function testGetAvailableTypes() + { + $expected = array( + FileManager::TYPE_CATEGORY, + FileManager::TYPE_CONTENT, + FileManager::TYPE_FOLDER, + FileManager::TYPE_PRODUCT, + FileManager::TYPE_MODULE, + ); + $actual = FileManager::getAvailableTypes(); + + $this->assertEquals($expected, $actual); + } + + /** + * @covers Thelia\Tools\FileManager::adminLogAppend + */ + public function testAdminLogAppend() + { + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers Thelia\Tools\FileManager::deleteFile + */ + public function testDeleteFile() + { + // @todo see http://tech.vg.no/2011/03/09/mocking-the-file-system-using-phpunit-and-vfsstream/ + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/core/lib/Thelia/Tools/FileManager.php b/core/lib/Thelia/Tools/FileManager.php new file mode 100644 index 000000000..a795bcd5e --- /dev/null +++ b/core/lib/Thelia/Tools/FileManager.php @@ -0,0 +1,724 @@ +. */ +/* */ +/**********************************************************************************/ +namespace Thelia\Tools; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\File\UploadedFile; +use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; +use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\Translation\Translator; +use Thelia\Exception\ImageException; +use Thelia\Form\CategoryDocumentModification; +use Thelia\Form\CategoryImageModification; +use Thelia\Form\ContentDocumentModification; +use Thelia\Form\ContentImageModification; +use Thelia\Form\FolderDocumentModification; +use Thelia\Form\FolderImageModification; +use Thelia\Form\ProductDocumentModification; +use Thelia\Form\ProductImageModification; +use Thelia\Model\AdminLog; +use Thelia\Model\CategoryDocument; +use Thelia\Model\CategoryDocumentQuery; +use Thelia\Model\CategoryImage; +use Thelia\Model\CategoryImageQuery; +use Thelia\Model\CategoryQuery; +use Thelia\Model\ContentDocument; +use Thelia\Model\ContentDocumentQuery; +use Thelia\Model\ContentImage; +use Thelia\Model\ContentImageQuery; +use Thelia\Model\ContentQuery; +use Thelia\Model\Exception\InvalidArgumentException; +use Thelia\Model\FolderDocument; +use Thelia\Model\FolderDocumentQuery; +use Thelia\Model\FolderImage; +use Thelia\Model\FolderImageQuery; +use Thelia\Model\FolderQuery; +use Thelia\Model\ProductDocument; +use Thelia\Model\ProductDocumentQuery; +use Thelia\Model\ProductImage; +use Thelia\Model\ProductImageQuery; +use Thelia\Model\ProductQuery; + +/** + * Created by JetBrains PhpStorm. + * Date: 9/19/13 + * Time: 3:24 PM + * + * File Manager + * + * @package File + * @author Guillaume MOREL + * + */ +class FileManager +{ + CONST TYPE_PRODUCT = 'product'; + CONST TYPE_CATEGORY = 'category'; + CONST TYPE_CONTENT = 'content'; + CONST TYPE_FOLDER = 'folder'; + CONST TYPE_MODULE = 'module'; + + CONST FILE_TYPE_IMAGES = 'images'; + CONST FILE_TYPE_DOCUMENTS = 'documents'; + + /** @var ContainerInterface Service Container */ + protected $container = null; + + /** @var Translator Service Translator */ + protected $translator = null; + + /** + * Constructor + * + * @param ContainerInterface $container Service container + */ + public function __construct(ContainerInterface $container) + { + $this->container = $container; + $this->translator = $this->container->get('thelia.translator'); + } + + /** + * Copy UploadedFile into the server storage directory + * + * @param int $parentId Parent id + * @param string $parentType Image type + * @param FolderImage|ContentImage|CategoryImage|ProductImage|FolderDocument|ContentDocument|CategoryDocument|ProductDocument $model Model saved + * @param UploadedFile $uploadedFile Ready to be uploaded file + * @param string $fileType File type ex FileManager::FILE_TYPE_IMAGES + * + * @throws \Thelia\Exception\ImageException + * @return UploadedFile + */ + public function copyUploadedFile($parentId, $parentType, $model, $uploadedFile, $fileType) + { + $newUploadedFile = null; + if ($uploadedFile !== null) { + $directory = $this->getUploadDir($parentType, $fileType); + $fileName = $this->renameFile($model->getId(), $uploadedFile); + + $this->adminLogAppend( + $this->translator->trans( + 'Uploading %type% %fileName% to %directory% for parent_id %parentId% (%parentType%)', + array( + '%type%' => $fileType, + '%fileName%' => $uploadedFile->getClientOriginalName(), + '%directory%' => $directory . '/' . $fileName, + '%parentId%' => $parentId, + '%parentType%' => $parentType + ), + 'image' + ) + ); + + $newUploadedFile = $uploadedFile->move($directory, $fileName); + $model->setFile($fileName); + + if (!$model->save()) { + throw new ImageException( + sprintf( + '%s %s (%s) failed to be saved (image file)', + ucfirst($parentType), + $model->getFile(), + $fileType + ) + ); + } + } + + return $newUploadedFile; + } + + /** + * Save image into the database + * + * @param ImageCreateOrUpdateEvent $event Image event + * @param FolderImage|ContentImage|CategoryImage|ProductImage $modelImage Image to save + * + * @return int Nb lines modified + * @throws \Thelia\Exception\ImageException + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function saveImage(ImageCreateOrUpdateEvent $event, $modelImage) + { + $nbModifiedLines = 0; + + if ($modelImage->getFile() !== null) { + switch ($event->getImageType()) { + case self::TYPE_PRODUCT: + /** @var ProductImage $modelImage */ + $modelImage->setProductId($event->getParentId()); + break; + case self::TYPE_CATEGORY: + /** @var CategoryImage $modelImage */ + $modelImage->setCategoryId($event->getParentId()); + break; + case self::TYPE_CONTENT: + /** @var ContentImage $modelImage */ + $modelImage->setContentId($event->getParentId()); + break; + case self::TYPE_FOLDER: + /** @var FolderImage $modelImage */ + $modelImage->setFolderId($event->getParentId()); + break; + default: + throw new ImageException( + sprintf( + 'Picture parent type is unknown (available types : %s)', + implode( + ',', + self::getAvailableTypes() + ) + ) + ); + } + + $nbModifiedLines = $modelImage->save(); + if (!$nbModifiedLines) { + throw new ImageException( + sprintf( + 'Image %s failed to be saved (image content)', + $modelImage->getFile() + ) + ); + } + } + + return $nbModifiedLines; + } + + /** + * Save document into the database + * + * @param DocumentCreateOrUpdateEvent $event Image event + * @param FolderDocument|ContentDocument|CategoryDocument|ProductDocument $modelDocument Document to save + * + * @throws \Thelia\Model\Exception\InvalidArgumentException + * @return int Nb lines modified + * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action + */ + public function saveDocument(DocumentCreateOrUpdateEvent $event, $modelDocument) + { + $nbModifiedLines = 0; + + if ($modelDocument->getFile() !== null) { + switch ($event->getDocumentType()) { + case self::TYPE_PRODUCT: + /** @var ProductImage $modelImage */ + $modelDocument->setProductId($event->getParentId()); + break; + case self::TYPE_CATEGORY: + /** @var CategoryImage $modelImage */ + $modelDocument->setCategoryId($event->getParentId()); + break; + case self::TYPE_CONTENT: + /** @var ContentImage $modelImage */ + $modelDocument->setContentId($event->getParentId()); + break; + case self::TYPE_FOLDER: + /** @var FolderImage $modelImage */ + $modelDocument->setFolderId($event->getParentId()); + break; + default: + throw new InvalidArgumentException( + sprintf( + 'Document parent type is unknown (available types : %s)', + implode( + ',', + self::getAvailableTypes() + ) + ) + ); + } + + $nbModifiedLines = $modelDocument->save(); + if (!$nbModifiedLines) { + throw new InvalidArgumentException( + sprintf( + 'Document %s failed to be saved (document content)', + $modelDocument->getFile() + ) + ); + } + } + + return $nbModifiedLines; + } + + /** + * Sanitizes a filename replacing whitespace with dashes + * + * Removes special characters that are illegal in filenames on certain + * operating systems and special characters requiring special escaping + * to manipulate at the command line. + * + * @param string $string The filename to be sanitized + * + * @return string The sanitized filename + */ + public function sanitizeFileName($string) + { + return strtolower(preg_replace('/[^a-zA-Z0-9-_\.]/', '', $string)); + } + + /** + * Helper to append a message to the admin log. + * + * @param string $message + */ + public function adminLogAppend($message) + { + AdminLog::append( + $message, + $this->container->get('request'), + $this->container->get('thelia.securityContext')->getAdminUser() + ); + } + + /** + * Delete image from file storage and database + * + * @param CategoryImage|ProductImage|ContentImage|FolderImage|CategoryDocument|ProductDocument|ContentDocument|FolderDocument $model File being deleted + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * @param string $fileType File type ex FileManager::FILE_TYPE_DOCUMENTS + * + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function deleteFile($model, $parentType, $fileType) + { + $url = $this->getUploadDir($parentType, $fileType) . '/' . $model->getFile(); + unlink(str_replace('..', '', $url)); + $model->delete(); + } + + /** + * Get image model from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * + * @return null|\Thelia\Model\CategoryImage|\Thelia\Model\ContentImage|\Thelia\Model\FolderImage|\Thelia\Model\ProductImage + * + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function getImageModel($parentType) + { + switch ($parentType) { + case self::TYPE_PRODUCT: + $model = new ProductImage(); + break; + case self::TYPE_CATEGORY: + $model = new CategoryImage(); + break; + case self::TYPE_CONTENT: + $model = new ContentImage(); + break; + case self::TYPE_FOLDER: + $model = new FolderImage(); + break; + default: + $model = null; + } + + return $model; + } + + /** + * Get document model from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * + * @return null|ProductDocument|CategoryDocument|ContentDocument|FolderDocument + * + * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action + */ + public function getDocumentModel($parentType) + { + switch ($parentType) { + case self::TYPE_PRODUCT: + $model = new ProductDocument(); + break; + case self::TYPE_CATEGORY: + $model = new CategoryDocument(); + break; + case self::TYPE_CONTENT: + $model = new ContentDocument(); + break; + case self::TYPE_FOLDER: + $model = new FolderDocument(); + break; + default: + $model = null; + } + + return $model; + } + + /** + * Get image model query from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * + * @return null|\Thelia\Model\CategoryImageQuery|\Thelia\Model\ContentImageQuery|\Thelia\Model\FolderImageQuery|\Thelia\Model\ProductImageQuery + * + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function getImageModelQuery($parentType) + { + switch ($parentType) { + case self::TYPE_PRODUCT: + $model = new ProductImageQuery(); + break; + case self::TYPE_CATEGORY: + $model = new CategoryImageQuery(); + break; + case self::TYPE_CONTENT: + $model = new ContentImageQuery(); + break; + case self::TYPE_FOLDER: + $model = new FolderImageQuery(); + break; + default: + $model = null; + } + + return $model; + } + + /** + * Get document model query from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * + * @return null|ProductDocumentQuery|CategoryDocumentQuery|ContentDocumentQuery|FolderDocumentQuery + * + * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action + */ + public function getDocumentModelQuery($parentType) + { + switch ($parentType) { + case self::TYPE_PRODUCT: + $model = new ProductDocumentQuery(); + break; + case self::TYPE_CATEGORY: + $model = new CategoryDocumentQuery(); + break; + case self::TYPE_CONTENT: + $model = new ContentDocumentQuery(); + break; + case self::TYPE_FOLDER: + $model = new FolderDocumentQuery(); + break; + default: + $model = null; + } + + return $model; + } + + /** + * Get form service id from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * @param string $fileType Parent id + * + * @return string + * + * @todo refactor make all documents using propel inheritance and factorise image behaviour into one single clean action + */ + public function getFormId($parentType, $fileType) + { + switch ($fileType) { + case self::FILE_TYPE_IMAGES: + $type = 'image'; + break; + case self::FILE_TYPE_DOCUMENTS: + $type = 'document'; + break; + default: + return false; + } + + switch ($parentType) { + case self::TYPE_PRODUCT: + $formId = 'thelia.admin.product.' . $type . '.modification'; + break; + case self::TYPE_CATEGORY: + $formId = 'thelia.admin.category.' . $type . '.modification'; + break; + case self::TYPE_CONTENT: + $formId = 'thelia.admin.content.' . $type . '.modification'; + break; + case self::TYPE_FOLDER: + $formId = 'thelia.admin.folder.' . $type . '.modification'; + break; + default: + $formId = false; + } + + return $formId; + } + + /** + * Get image parent model from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * @param int $parentId Parent Id + * + * @return null|\Thelia\Model\Category|\Thelia\Model\Content|\Thelia\Model\Folder|\Thelia\Model\Product + * + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + */ + public function getParentFileModel($parentType, $parentId) + { + switch ($parentType) { + case self::TYPE_PRODUCT: + $model = ProductQuery::create()->findPk($parentId); + break; + case self::TYPE_CATEGORY: + $model = CategoryQuery::create()->findPk($parentId); + break; + case self::TYPE_CONTENT: + $model = ContentQuery::create()->findPk($parentId); + break; + case self::TYPE_FOLDER: + $model = FolderQuery::create()->findPk($parentId); + break; + default: + $model = null; + } + + return $model; + } + + /** + * Get image parent model from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * @param Request $request Request service + * + * @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action + * @return ProductImageModification|CategoryImageModification|ContentImageModification|FolderImageModification + */ + public function getImageForm($parentType, Request $request) + { + switch ($parentType) { + case self::TYPE_PRODUCT: + $form = new ProductImageModification($request); + break; + case self::TYPE_CATEGORY: + $form = new CategoryImageModification($request); + break; + case self::TYPE_CONTENT: + $form = new ContentImageModification($request); + break; + case self::TYPE_FOLDER: + $form = new FolderImageModification($request); + break; + default: + $form = null; + } + + return $form; + + } + + /** + * Get document parent model from type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * @param Request $request Request service + * + * @todo refactor make all document using propel inheritance and factorise image behaviour into one single clean action + * @return ProductDocumentModification|CategoryDocumentModification|ContentDocumentModification|FolderDocumentModification + */ + public function getDocumentForm($parentType, Request $request) + { + switch ($parentType) { + case self::TYPE_PRODUCT: + $form = new ProductDocumentModification($request); + break; + case self::TYPE_CATEGORY: + $form = new CategoryDocumentModification($request); + break; + case self::TYPE_CONTENT: + $form = new ContentDocumentModification($request); + break; + case self::TYPE_FOLDER: + $form = new FolderDocumentModification($request); + break; + default: + $form = null; + } + + return $form; + + } + + /** + * Get image upload dir + * + * @param string $parentType Parent type ex FileManager::TYPE_PRODUCT + * @param string $fileType File type ex : self::FILE_TYPE_DOCUMENTS + * + * @return string Uri + */ + public function getUploadDir($parentType, $fileType) + { + if (!in_array($fileType, self::$availableFileType)) { + return false; + } + + switch ($parentType) { + case self::TYPE_PRODUCT: + $uri = THELIA_LOCAL_DIR . 'media/' . $fileType . '/' . self::TYPE_PRODUCT; + break; + case self::TYPE_CATEGORY: + $uri = THELIA_LOCAL_DIR . 'media/' . $fileType . '/' . self::TYPE_CATEGORY; + break; + case self::TYPE_CONTENT: + $uri = THELIA_LOCAL_DIR . 'media/' . $fileType . '/' . self::TYPE_CONTENT; + break; + case self::TYPE_FOLDER: + $uri = THELIA_LOCAL_DIR . 'media/' . $fileType . '/' . self::TYPE_FOLDER; + break; + default: + $uri = false; + } + + return $uri; + + } + + /** + * Deduce image redirecting URL from parent type + * + * @param string $parentType Parent type ex : self::TYPE_PRODUCT + * @param int $parentId Parent id + * @param string $fileType File type ex : self::FILE_TYPE_DOCUMENTS + * + * @return string + */ + public function getRedirectionUrl($parentType, $parentId, $fileType) + { + if (!in_array($fileType, self::$availableFileType)) { + return false; + } + + switch ($parentType) { + case self::TYPE_PRODUCT: + $uri = '/admin/products/update?product_id=' . $parentId . '¤t_tab=' . $fileType; + break; + case self::TYPE_CATEGORY: + $uri = '/admin/categories/update?category_id=' . $parentId . '¤t_tab=' . $fileType; + break; + case self::TYPE_CONTENT: + $uri = '/admin/content/update/' . $parentId . '?current_tab=' . $fileType; + break; + case self::TYPE_FOLDER: + $uri = '/admin/folders/update/' . $parentId . '?current_tab=' . $fileType; + break; + default: + $uri = false; + } + + return $uri; + + } + + /** @var array Available file parent type */ + public static $availableType = array( + self::TYPE_PRODUCT, + self::TYPE_CATEGORY, + self::TYPE_CONTENT, + self::TYPE_FOLDER, + self::TYPE_MODULE + ); + + /** @var array Available file type type */ + public static $availableFileType = array( + self::FILE_TYPE_DOCUMENTS, + self::FILE_TYPE_IMAGES + ); + + /** + * Rename file with image model id + * + * @param int $modelId Model id + * @param UploadedFile $uploadedFile File being saved + * + * @return string + */ + public function renameFile($modelId, $uploadedFile) + { + $extension = $uploadedFile->getClientOriginalExtension(); + if (!empty($extension)) { + $extension = '.' . strtolower($extension); + } + $fileName = $this->sanitizeFileName( + str_replace( + $extension, + '', + $uploadedFile->getClientOriginalName() + ) . '-' . $modelId . $extension + ); + + return $fileName; + } + + /** + * Check if a file is an image + * Check based on mime type + * + * @param string $mimeType File mime type + * + * @return bool + */ + public function isImage($mimeType) + { + $isValid = false; + + $allowedType = array('image/jpeg' , 'image/png' ,'image/gif'); + if (in_array($mimeType, $allowedType)) { + $isValid = true; + } + + return $isValid; + } + + /** + * Return all document and image types + * + * @return array + */ + public static function getAvailableTypes() + { + return array( + self::TYPE_CATEGORY, + self::TYPE_CONTENT, + self::TYPE_FOLDER, + self::TYPE_PRODUCT, + self::TYPE_MODULE, + ); + } +} diff --git a/core/lib/Thelia/Tools/I18n.php b/core/lib/Thelia/Tools/I18n.php index 1f3ff57dd..9931f4087 100644 --- a/core/lib/Thelia/Tools/I18n.php +++ b/core/lib/Thelia/Tools/I18n.php @@ -54,4 +54,39 @@ class I18n return \DateTime::createFromFormat($currentDateFormat, $date); } + + public static function forceI18nRetrieving($askedLocale, $modelName, $id, $needed = array('Title')) + { + $i18nQueryClass = sprintf("\\Thelia\\Model\\%sI18nQuery", $modelName); + $i18nClass = sprintf("\\Thelia\\Model\\%sI18n", $modelName); + + /* get customer language translation */ + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + $askedLocale + )->findOne(); + /* or default translation */ + if (null === $i18n) { + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + Lang::getDefaultLanguage()->getLocale() + )->findOne(); + } + if (null === $i18n) { // @todo something else ? + $i18n = new $i18nClass();; + $i18n->setId($id); + foreach ($needed as $need) { + $method = sprintf('set%s', $need); + if (method_exists($i18n, $method)) { + $i18n->$method('DEFAULT ' . strtoupper($need)); + } else { + // @todo throw sg ? + } + } + } + + return $i18n; + } } diff --git a/core/lib/Thelia/Tools/Image.php b/core/lib/Thelia/Tools/Image.php index 5fa4d3c6c..2558c9bd4 100755 --- a/core/lib/Thelia/Tools/Image.php +++ b/core/lib/Thelia/Tools/Image.php @@ -25,17 +25,16 @@ namespace Thelia\Tools; class Image { - static public function isImage($filePath, $allowedImageTypes = null) + public static function isImage($filePath, $allowedImageTypes = null) { $imageFile = getimagesize($filePath); $imageType = $imageFile[2]; - if(!is_array($allowedImageTypes) && $imageType != IMAGETYPE_UNKNOWN) { + if (!is_array($allowedImageTypes) && $imageType != IMAGETYPE_UNKNOWN) { return true; } - if(in_array($imageType , $allowedImageTypes)) - { + if (in_array($imageType , $allowedImageTypes)) { return true; } diff --git a/core/lib/Thelia/Tools/Rest/ResponseRest.php b/core/lib/Thelia/Tools/Rest/ResponseRest.php index 75d511d78..0c9186436 100644 --- a/core/lib/Thelia/Tools/Rest/ResponseRest.php +++ b/core/lib/Thelia/Tools/Rest/ResponseRest.php @@ -26,7 +26,7 @@ class ResponseRest extends Response * Constructor. * * @param array $data Array to be serialized - * @param string $format serialization format, xml or json available + * @param string $format serialization format, text, xml or json available * @param integer $status The response status code * @param array $headers An array of response headers * @@ -38,14 +38,22 @@ class ResponseRest extends Response { parent::__construct('', $status, $headers); - $this->format = $format; - $serializer = $this->getSerializer(); + if ($format == 'text') { + if (isset($data)) { + $this->setContent($data); + } - if (isset($data)) { - $this->setContent($serializer->serialize($data, $this->format)); + $this->headers->set('Content-Type', 'text/plain'); + } else { + $this->format = $format; + $serializer = $this->getSerializer(); + + if (isset($data)) { + $this->setContent($serializer->serialize($data, $this->format)); + } + + $this->headers->set('Content-Type', 'application/' . $this->format); } - - $this->headers->set('Content-Type', 'application/' . $this->format); } /** diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 363860064..83469f602 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -91,6 +91,7 @@ class URL $schemeAuthority = "$scheme://$host"."$port"; } + return $schemeAuthority.$this->requestContext->getBaseUrl(); } @@ -240,7 +241,7 @@ class URL } else { $allParametersWithoutView = $request->query->all(); $view = $request->attributes->get('_view'); - if(isset($allOtherParameters['view'])) { + if (isset($allOtherParameters['view'])) { unset($allOtherParameters['view']); } $this->retriever->rewrittenUrl = null; diff --git a/core/lib/Thelia/Type/FloatToFloatArrayType.php b/core/lib/Thelia/Type/FloatToFloatArrayType.php index 5a70dba91..682ddebdd 100755 --- a/core/lib/Thelia/Type/FloatToFloatArrayType.php +++ b/core/lib/Thelia/Type/FloatToFloatArrayType.php @@ -38,10 +38,11 @@ class FloatToFloatArrayType implements TypeInterface public function isValid($value) { if(!is_array($value)) + return false; - foreach($value as $key => $value) { - if( filter_var($key, FILTER_VALIDATE_FLOAT) === false || filter_var($value, FILTER_VALIDATE_FLOAT) === false ) { + foreach ($value as $key => $value) { + if ( filter_var($key, FILTER_VALIDATE_FLOAT) === false || filter_var($value, FILTER_VALIDATE_FLOAT) === false ) { return false; } } diff --git a/core/lib/Thelia/Type/ModelType.php b/core/lib/Thelia/Type/ModelType.php index 38df857e4..9eacef094 100755 --- a/core/lib/Thelia/Type/ModelType.php +++ b/core/lib/Thelia/Type/ModelType.php @@ -42,7 +42,7 @@ class ModelType implements TypeInterface { $class = '\\Thelia\\Model\\' . $expectedModelActiveRecord; - if(!(class_exists($class) && new $class instanceof ActiveRecordInterface)) { + if (!(class_exists($class) && new $class instanceof ActiveRecordInterface)) { throw new TypeException('MODEL NOT FOUND', TypeException::MODEL_NOT_FOUND); } diff --git a/install/faker.php b/install/faker.php index eed6db11a..86b401aee 100755 --- a/install/faker.php +++ b/install/faker.php @@ -1,9 +1,12 @@ execute(); - echo "Creating customer\n"; + echo "Creating customers\n"; //customer $customer = new Thelia\Model\Customer(); @@ -160,6 +163,24 @@ try { "test@thelia.net", "azerty" ); + for ($j = 0; $j <= 3; $j++) { + $address = new Thelia\Model\Address(); + $address->setLabel($faker->text(20)) + ->setTitleId(rand(1,3)) + ->setFirstname($faker->firstname) + ->setLastname($faker->lastname) + ->setAddress1($faker->streetAddress) + ->setAddress2($faker->streetAddress) + ->setAddress3($faker->streetAddress) + ->setCellphone($faker->phoneNumber) + ->setPhone($faker->phoneNumber) + ->setZipcode($faker->postcode) + ->setCity($faker->city) + ->setCountryId(64) + ->setCustomer($customer) + ->save() + ; + } for($i = 0; $i < 50; $i++) { $customer = new Thelia\Model\Customer(); @@ -273,7 +294,7 @@ try { ->save(); } - echo "Creating folders and content\n"; + echo "Creating folders and contents\n"; //folders and contents $contentIdList = array(); @@ -404,6 +425,7 @@ try { $stock->setPromo($faker->randomNumber(0,1)); $stock->setNewness($faker->randomNumber(0,1)); $stock->setWeight($faker->randomFloat(2, 100,10000)); + $stock->setIsDefault($i == 0); $stock->save(); $productPrice = new \Thelia\Model\ProductPrice(); @@ -442,7 +464,7 @@ try { $featureAvId[array_rand($featureAvId, 1)] ); } else { //no av - $featureProduct->setByDefault($faker->text(10)); + $featureProduct->setFreeTextValue($faker->text(10)); } $featureProduct->save(); @@ -618,9 +640,11 @@ function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description' /** * Generate Coupon fixtures */ -function generateCouponFixtures($thelia) +function generateCouponFixtures(\Thelia\Core\Thelia $thelia) { + /** @var $container ContainerInterface Service Container */ $container = $thelia->getContainer(); + /** @var AdapterInterface $adapter */ $adapter = $container->get('thelia.adapter'); // Coupons @@ -639,57 +663,48 @@ Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentes Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); $coupon1->setAmount(10.00); - $coupon1->setIsUsed(1); - $coupon1->setIsEnabled(1); + $coupon1->setIsUsed(true); + $coupon1->setIsEnabled(true); $date = new \DateTime(); - $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months"))); - $rule1 = new AvailableForTotalAmountManager($adapter); + $condition1 = new MatchForTotalAmountManager($adapter); $operators = array( - AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL ); $values = array( - AvailableForTotalAmountManager::INPUT1 => 40.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmountManager::INPUT1 => 40.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' ); - $rule1->setValidatorsFromForm($operators, $values); + $condition1->setValidatorsFromForm($operators, $values); - $rule2 = new AvailableForTotalAmountManager($adapter); + $condition2 = new MatchForTotalAmountManager($adapter); $operators = array( - AvailableForTotalAmountManager::INPUT1 => Operators::INFERIOR, - AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + MatchForTotalAmountManager::INPUT1 => Operators::INFERIOR, + MatchForTotalAmountManager::INPUT2 => Operators::EQUAL ); $values = array( - AvailableForTotalAmountManager::INPUT1 => 400.00, - AvailableForTotalAmountManager::INPUT2 => 'EUR' + MatchForTotalAmountManager::INPUT1 => 400.00, + MatchForTotalAmountManager::INPUT2 => 'EUR' ); - $rule2->setValidatorsFromForm($operators, $values); + $condition2->setValidatorsFromForm($operators, $values); - $rules = new CouponRuleCollection(); - $rules->add($rule1); - $rules->add($rule2); - - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $container->get('thelia.constraint.factory'); - - $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); - $coupon1->setSerializedRules($serializedRules); + $conditions = new ConditionCollection(); + $conditions->add($condition1); + $conditions->add($condition2); + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $container->get('thelia.condition.factory'); + $serializedConditions = $conditionFactory->serializeConditionCollection($conditions); + $coupon1->setSerializedConditions($serializedConditions); $coupon1->setMaxUsage(40); - $coupon1->setIsCumulative(1); - $coupon1->setIsRemovingPostage(0); - $coupon1->setIsAvailableOnSpecialOffers(1); - + $coupon1->setIsCumulative(true); + $coupon1->setIsRemovingPostage(false); + $coupon1->setIsAvailableOnSpecialOffers(true); $coupon1->save(); - - - - - - // Coupons $coupon2 = new Thelia\Model\Coupon(); $coupon2->setCode('SPRINGBREAK'); @@ -706,33 +721,70 @@ Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentes Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); $coupon2->setAmount(10.00); - $coupon2->setIsUsed(1); - $coupon2->setIsEnabled(1); + $coupon2->setIsUsed(true); + $coupon2->setIsEnabled(true); $date = new \DateTime(); - $coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + $coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 1 months"))); - $rule1 = new AvailableForXArticlesManager($adapter); + $condition1 = new MatchForXArticlesManager($adapter); $operators = array( - AvailableForXArticlesManager::INPUT1 => Operators::SUPERIOR, + MatchForXArticlesManager::INPUT1 => Operators::SUPERIOR, ); $values = array( - AvailableForXArticlesManager::INPUT1 => 4, + MatchForXArticlesManager::INPUT1 => 4, ); - $rule1->setValidatorsFromForm($operators, $values); + $condition1->setValidatorsFromForm($operators, $values); + $conditions = new ConditionCollection(); + $conditions->add($condition1); - $rules = new CouponRuleCollection(); - $rules->add($rule1); - - /** @var ConstraintFactory $constraintFactory */ - $constraintFactory = $container->get('thelia.constraint.factory'); - - $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); - $coupon2->setSerializedRules($serializedRules); + /** @var ConditionFactory $conditionFactory */ + $conditionFactory = $container->get('thelia.condition.factory'); + $serializedConditions = $conditionFactory->serializeConditionCollection($conditions); + $coupon2->setSerializedConditions($serializedConditions); $coupon2->setMaxUsage(-1); - $coupon2->setIsCumulative(0); - $coupon2->setIsRemovingPostage(1); - $coupon2->setIsAvailableOnSpecialOffers(1); - + $coupon2->setIsCumulative(false); + $coupon2->setIsRemovingPostage(true); + $coupon2->setIsAvailableOnSpecialOffers(true); $coupon2->save(); + + + // Coupons + $coupon3 = new Thelia\Model\Coupon(); + $coupon3->setCode('OLD'); + $coupon3->setType('thelia.coupon.type.remove_x_percent'); + $coupon3->setTitle('Old coupon'); + $coupon3->setShortDescription('Coupon for Springbreak removing 10% if you have more than 4 articles in your cart'); + $coupon3->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + +Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + +Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + +Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + +Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); + $coupon3->setAmount(10.00); + $coupon3->setIsUsed(false); + $coupon3->setIsEnabled(false); + $date = new \DateTime(); + $coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + + $condition1 = new MatchForEveryoneManager($adapter); + $operators = array(); + $values = array(); + $condition1->setValidatorsFromForm($operators, $values); + $conditions = new ConditionCollection(); + $conditions->add($condition1); + + /** @var ConditionFactory $constraintCondition */ + $constraintCondition = $container->get('thelia.condition.factory'); + + $serializedConditions = $constraintCondition->serializeConditionCollection($conditions); + $coupon3->setSerializedConditions($serializedConditions); + $coupon3->setMaxUsage(-1); + $coupon3->setIsCumulative(true); + $coupon3->setIsRemovingPostage(false); + $coupon3->setIsAvailableOnSpecialOffers(false); + $coupon3->save(); } diff --git a/install/import.php b/install/import.php index c5fa3572a..ab1cba486 100644 --- a/install/import.php +++ b/install/import.php @@ -21,11 +21,8 @@ /* */ /*************************************************************************************/ -use Thelia\Constraint\ConstraintFactory; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; -use Thelia\Constraint\Rule\AvailableForXArticlesManager; -use Thelia\Constraint\Rule\Operators; -use Thelia\Coupon\CouponRuleCollection; +use Thelia\Condition\Implementation\MatchForTotalAmountManager; +use Thelia\Condition\Implementation\MatchForXArticlesManager; require __DIR__ . '/../core/bootstrap.php'; @@ -44,14 +41,14 @@ $con->beginTransaction(); try { $stmt = $con->prepare("SET foreign_key_checks = 0"); $stmt->execute(); - clearTables(); + clearTables($con); $stmt = $con->prepare("SET foreign_key_checks = 1"); $stmt->execute(); - $categories = createCategories(); - $color = createColors(); - $brand = createBrand(); + $categories = createCategories($con); + $color = createColors($con); + $brand = createBrand($con); echo "creating templates\n"; $template = new \Thelia\Model\Template(); @@ -60,24 +57,24 @@ try { ->setName('template de démo') ->setLocale('en_US') ->setName('demo template') - ->save(); + ->save($con); $at = new Thelia\Model\AttributeTemplate(); $at ->setTemplate($template) ->setAttribute($color) - ->save(); + ->save($con); $ft = new Thelia\Model\FeatureTemplate(); $ft ->setTemplate($template) ->setFeature($brand) - ->save(); + ->save($con); echo "end creating templates\n"; - createProduct($faker, $categories, $template, $color, $brand); + createProduct($faker, $categories, $template, $color, $brand, $con); @@ -87,7 +84,7 @@ try { $con->rollBack(); } -function createProduct($faker, $categories, $template, $attribute, $feature) +function createProduct($faker, $categories, $template, $attribute, $feature, $con) { echo "start creating products\n"; $fileSystem = new \Symfony\Component\Filesystem\Filesystem(); @@ -124,11 +121,11 @@ function createProduct($faker, $categories, $template, $attribute, $feature) ->setChapo($data[3]) ->setDescription($data[5]) ->setPostscriptum($data[7]) - ->save(); + ->save($con); $productCategories = $product->getProductCategories()->getFirst(); $productCategories->setDefaultCategory(true) - ->save(); + ->save($con); // Set the position $product->setPosition($product->getNextPosition())->save(); @@ -142,7 +139,7 @@ function createProduct($faker, $categories, $template, $attribute, $feature) $productImage ->setProduct($product) ->setFile($image) - ->save(); + ->save($con); $fileSystem->copy(THELIA_ROOT . 'install/import/images/'.$image, THELIA_ROOT . 'local/media/images/product/'.$image, true); } @@ -163,39 +160,42 @@ function createProduct($faker, $categories, $template, $attribute, $feature) $stock->setNewness($faker->randomNumber(0,1)); $stock->setWeight($faker->randomFloat(2, 100,10000)); - $stock->save(); + $stock->save($con); $productPrice = new \Thelia\Model\ProductPrice(); $productPrice->setProductSaleElements($stock); $productPrice->setCurrencyId(1); $productPrice->setPrice($data[8]); $productPrice->setPromoPrice($data[9]); - $productPrice->save(); + $productPrice->save($con); $attributeAv = \Thelia\Model\AttributeAvI18nQuery::create() ->filterByLocale('en_US') ->filterByTitle($pse) - ->findOne(); + ->findOne($con); $attributeCombination = new \Thelia\Model\AttributeCombination(); $attributeCombination ->setAttributeId($attribute->getId()) ->setAttributeAvId($attributeAv->getId()) ->setProductSaleElements($stock) - ->save(); + ->save($con); } + $productSaleElements = $product->getProductSaleElementss()->getFirst(); + $productSaleElements->setIsDefault(1)->save($con); + $brand = $data[11]; $featurAv = \Thelia\Model\FeatureAvI18nQuery::create() ->filterByLocale('en_US') ->filterByTitle($brand) - ->findOne(); + ->findOne($con); $featureProduct = new Thelia\Model\FeatureProduct(); $featureProduct->setProduct($product) ->setFeatureId($feature->getId()) ->setFeatureAvId($featurAv->getId()) - ->save() + ->save($con) ; @@ -205,7 +205,7 @@ function createProduct($faker, $categories, $template, $attribute, $feature) echo "end creating products\n"; } -function createBrand() +function createBrand($con) { echo "start creating brands feature\n"; if (($handle = fopen(THELIA_ROOT . '/install/import/brand.csv', "r")) !== FALSE) { @@ -229,7 +229,7 @@ function createBrand() $feature->addFeatureAv($featureAv); } - $feature->save(); + $feature->save($con); fclose($handle); } echo "brands feature created successfully\n"; @@ -237,7 +237,7 @@ function createBrand() return $feature; } -function createCategories() +function createCategories($con) { echo "start creating categories\n"; $categories = array(); @@ -255,7 +255,7 @@ function createCategories() ->setTitle(trim($data[0])) ->setLocale('en_US') ->setTitle(trim($data[1])) - ->save(); + ->save($con); $categories[trim($data[1])] = $category; } fclose($handle); @@ -264,7 +264,7 @@ function createCategories() return $categories; } -function createColors() +function createColors($con) { echo "start creating colors attributes\n"; if (($handle = fopen(THELIA_ROOT . '/install/import/colors.csv', "r")) !== FALSE) { @@ -289,91 +289,91 @@ function createColors() $attribute->addAttributeAv($attributeAv); } - $attribute->save(); + $attribute->save($con); fclose($handle); } echo "colors attributes created with success\n"; return $attribute; } -function clearTables() +function clearTables($con) { $productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create() - ->find(); - $productAssociatedContent->delete(); + ->find($con); + $productAssociatedContent->delete($con); $categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create() - ->find(); - $categoryAssociatedContent->delete(); + ->find($con); + $categoryAssociatedContent->delete($con); $featureProduct = Thelia\Model\FeatureProductQuery::create() - ->find(); - $featureProduct->delete(); + ->find($con); + $featureProduct->delete($con); $attributeCombination = Thelia\Model\AttributeCombinationQuery::create() - ->find(); - $attributeCombination->delete(); + ->find($con); + $attributeCombination->delete($con); $feature = Thelia\Model\FeatureQuery::create() - ->find(); - $feature->delete(); + ->find($con); + $feature->delete($con); $feature = Thelia\Model\FeatureI18nQuery::create() - ->find(); - $feature->delete(); + ->find($con); + $feature->delete($con); $featureAv = Thelia\Model\FeatureAvQuery::create() - ->find(); - $featureAv->delete(); + ->find($con); + $featureAv->delete($con); $featureAv = Thelia\Model\FeatureAvI18nQuery::create() - ->find(); - $featureAv->delete(); + ->find($con); + $featureAv->delete($con); $attribute = Thelia\Model\AttributeQuery::create() - ->find(); - $attribute->delete(); + ->find($con); + $attribute->delete($con); $attribute = Thelia\Model\AttributeI18nQuery::create() - ->find(); - $attribute->delete(); + ->find($con); + $attribute->delete($con); $attributeAv = Thelia\Model\AttributeAvQuery::create() - ->find(); - $attributeAv->delete(); + ->find($con); + $attributeAv->delete($con); $attributeAv = Thelia\Model\AttributeAvI18nQuery::create() - ->find(); - $attributeAv->delete(); + ->find($con); + $attributeAv->delete($con); $category = Thelia\Model\CategoryQuery::create() - ->find(); - $category->delete(); + ->find($con); + $category->delete($con); $category = Thelia\Model\CategoryI18nQuery::create() - ->find(); - $category->delete(); + ->find($con); + $category->delete($con); $product = Thelia\Model\ProductQuery::create() - ->find(); - $product->delete(); + ->find($con); + $product->delete($con); $product = Thelia\Model\ProductI18nQuery::create() - ->find(); - $product->delete(); + ->find($con); + $product->delete($con); $accessory = Thelia\Model\AccessoryQuery::create() - ->find(); - $accessory->delete(); + ->find($con); + $accessory->delete($con); $stock = \Thelia\Model\ProductSaleElementsQuery::create() - ->find(); - $stock->delete(); + ->find($con); + $stock->delete($con); $productPrice = \Thelia\Model\ProductPriceQuery::create() - ->find(); - $productPrice->delete(); + ->find($con); + $productPrice->delete($con); - \Thelia\Model\ProductImageQuery::create()->find()->delete(); + \Thelia\Model\ProductImageQuery::create()->find($con)->delete($con); } \ No newline at end of file diff --git a/install/import/products.csv b/install/import/products.csv index d2d84fb53..b085feee2 100644 --- a/install/import/products.csv +++ b/install/import/products.csv @@ -18,7 +18,7 @@ Swivel feature for added function. ";"Zoe est un fauteuil contemporain qui combi "PROD013";"Violet";"A beautifull classic";"Une beauté classique";"A new edition of a classic. Beneath a beautiful colorfull leather, a strong walnut wood frame. You will appreciate the luxurious stylish details of the ''Violet'' armless chair. ";"La réédition d'un classique. Sous un superbe cuir aux couleurs chatoyantes, une solide structure en noyer. Vous apprécierez les détails stylistiques luxueux de notre chaise Violet. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm";98;;"PROD013-1.jpg";"MAGIS";"Gray";"Chairs" "PROD014";"Sally";"Contemporary atypical chair";"Chaise contemporaine hors normes";"Contemporary atypical chair. The atypical sitting of the ''Sally '' chair will nestled you in confort. Play with the vibrant colours range to create a unique dining room. ";"Chaise contemporaine hors normes. L'assise surprenante de la chaise Sally vous enveloppera de confort. Amusez vous avec l'éventail de couleurs lumineuses pour créer une salle à manger unique. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 31''";"Dimensions : Larg. 50 cm – Prof.60 cm – Haut. 80 cm";112;;"PROD014-1.jpg;PROD014-2.jpg;PROD014-3.jpg;PROD014-4.jpg";"PARRY";"blue;purple;orange;yellow";"Chairs" "PROD015";"Oliver";"Comfort & Design";"Confort et Design";"Surround yourself in ultra modern luxury with the ''Oliver'' armchair and get a look at the future ! Eye-catching, this unique combination of comfort and design is a must-have for today's book nook. ";"Abandonnez vous à un univers de luxe ultra moderne avec le fauteuil Oliver et voyagez dans le futur ! Cette combinaison unique de confort et de design est spectaculaire. Un élément incontournable pour votre bibliothèque. ";"Dimensions : Width : 30'' – Depth : 27'' – height : 31''";"Dimensions : Larg. 75 cm – Prof. 69 cm – Haut. 80 cm";340;;"PROD015-1.jpg;PROD015-2.jpg;";"MAGIS";"white;black";"Armchairs;Chairs" -"PROD016";"Lexie";"A modern style";"Un style moderne";"Demonstrate your flair for modern style with our ''Lexie'' chair in your dining room. A rectangular cushioned back offers a contemporary feel, while the comfortable seat provides complete comfort. ";"Montrez que vous avez le sens de la modernité en choisissant la chaise ''Lexie'' pour votre salle à manger. Le coussin rectangulaire sur le dossier apporte une touche contemporaine. L'assise généreuse apporte un confort complet. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 40''";"Dimensions : larg. 50 cm – Prof. 60 cm – Haut. 100 cm";159;;"PROD016-1.jpg";"PLINK";;"Chairs" +"PROD016";"Lexie";"A modern style";"Un style moderne";"Demonstrate your flair for modern style with our ''Lexie'' chair in your dining room. A rectangular cushioned back offers a contemporary feel, while the comfortable seat provides complete comfort. ";"Montrez que vous avez le sens de la modernité en choisissant la chaise ''Lexie'' pour votre salle à manger. Le coussin rectangulaire sur le dossier apporte une touche contemporaine. L'assise généreuse apporte un confort complet. ";"Dimensions : Width : 19'' – Depth : 23'' – Height : 40''";"Dimensions : larg. 50 cm – Prof. 60 cm – Haut. 100 cm";159;;"PROD016-1.jpg";"PLINK";"Beige";"Chairs" "PROD017";"Flynn";"A touch of retro vibe";"Un petit air rétro";"If your destination is up-to-date décor with a touch of retro vibe, look no further than our ''Flynn'' sofa. Sleek, low track arms and high tapering legs give this piece a mid-century flavor. The vibrant tones of the woven upholstery will easily blend with any interior décor. ";"Si vous recherchez une décoration actuelle avec une touche rétro, n'allez pas plus loin et opter pour notre canapé ''Flynn''. Ce canapé a un petit air des années 50 grâce à ses accoudoirs bas, ses pieds allongés et ses lignes pures. Les couleurs chatoyantes de son revêtement en laine lui permettent de se fondre dans tous les intérieurs. ";"Dimensions : Width : 89'' – Depth : 37'' – Height : 36''";"Dimensions : Larg. 225 cm – Prof. 95 cm – Haut. 90 cm";1299;;"PROD017-1.jpg;PROD017-2.jpg;PROD017-3.jpg;PROD017-4.jpg";"OFFUS";"blue;green;red;purple";"Sofas" "PROD018";"Emily";"A old-world feel";"Une touche d'histoire";"Our ''Emily'' armlesschair adds a touch of a old-world feel to your space. Perfect for when defining the seating space in a larger room. A medium wood finish sets off the delicate embellishments at the base, while the luxurous upholstery keeps the look fresh. The cushions guarantee that this is a chair worth relaxing in, not just admiring from afar. ";"La chaise ''Emily'' apporte une touche d'histoire à votre intérieur. Elle est parfaite pour structurer votre espace, notamment dans une grande pièce. Les finitions bois font la part belle à de délicates arabesques, tandis que le luxueux revêtement apporte un look frais. Cette chaise n'est pas destinée à la figuration grâce à la mousse confortable de l'assise. ";"Dimensions : Width : 33'' – Depth : 27'' – Height : 40''";"Dimensions : Larg. 85 cm – Prof. 69 cm – Haut. 100 cm";690;;"PROD018-1.jpg";"PARRY";"red";"Armchairs" "PROD019";"Edgar";"A special spot";"Un endroit à part";"A special spot for reading, lounging or chatting, our '' Edgar '' armchair has no reservations when it comes to style. The design starts with mid-century modern elements like lean arms, while the brushed stainless steel base ensures stability. Swivel feature for added function. ";"Un endroit spécial où lire, rêver ou discuter, notre fauteuil ''Edgar'' n'a pas de limite quand il s'agit de style. Son design part d'éléments contemporains comme ses accoudoirs bas et fins, tandis que sa base en inox brossé assure la stabilité de l'ensemble. Siège pivotant. ";"Dimensions : Width : 33'' – Depth : 27'' – Height : 40''";"Dimensions: Larg. 85 cm – Prof. 69 cm – Haut. 100 cm";275;;"PROD019-1.jpg;PROD019-2.jpg;PROD019-3.jpg;PROD019-4.jpg;PROD019-5.jpg";"TOKO";"blue;yellow;orange;pink;purple";"Armchairs" diff --git a/install/insert.sql b/install/insert.sql index aa7573d12..ec4e1b02b 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1153,7 +1153,7 @@ INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `upda INSERT INTO `tax_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'French 19.6% VAT'); INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) VALUES @@ -1162,7 +1162,7 @@ INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'French 19.6% VAT'); INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`) VALUES diff --git a/install/tax_faker.php b/install/tax_faker.php index 5d534e2ef..85e274c98 100755 --- a/install/tax_faker.php +++ b/install/tax_faker.php @@ -1,16 +1,6 @@ - + @@ -55,7 +55,7 @@ - + @@ -101,7 +101,7 @@ - + @@ -110,7 +110,7 @@
- + @@ -145,11 +145,11 @@
- + @@ -179,7 +179,7 @@ - + @@ -205,6 +205,7 @@ + @@ -221,11 +222,11 @@
- + @@ -277,11 +278,12 @@
- + - + + @@ -297,6 +299,7 @@ + @@ -595,14 +598,21 @@
- + + - + + - - + + + + + + + @@ -626,15 +636,21 @@
- +
- - - + + + + + + + + + - + @@ -828,18 +844,18 @@ + + - - - - - - + + + + @@ -1224,4 +1240,19 @@
+ + + + + + + + + + + + + + +
diff --git a/local/modules/Cheque/Cheque.php b/local/modules/Cheque/Cheque.php index f4438db4e..4516c84f3 100755 --- a/local/modules/Cheque/Cheque.php +++ b/local/modules/Cheque/Cheque.php @@ -71,6 +71,15 @@ class Cheque extends BaseModule implements PaymentModuleInterface if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Cheque", + "fr_FR" => "Cheque", + ) + ); } public function destroy() diff --git a/local/modules/Cheque/images/cheque.png b/local/modules/Cheque/images/cheque.png old mode 100644 new mode 100755 diff --git a/local/modules/FakeCB/FakeCB.php b/local/modules/FakeCB/FakeCB.php index 7b304420c..ca682fab3 100755 --- a/local/modules/FakeCB/FakeCB.php +++ b/local/modules/FakeCB/FakeCB.php @@ -71,6 +71,15 @@ class FakeCB extends BaseModule implements PaymentModuleInterface if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Credit Card", + "fr_FR" => "Carte de crédit", + ) + ); } public function destroy() diff --git a/local/modules/FakeCB/images/mastercard.png b/local/modules/FakeCB/images/mastercard.png old mode 100644 new mode 100755 diff --git a/local/modules/FakeCB/images/visa.png b/local/modules/FakeCB/images/visa.png old mode 100644 new mode 100755 diff --git a/local/modules/TheliaDebugBar/DataCollector/PropelCollector.php b/local/modules/TheliaDebugBar/DataCollector/PropelCollector.php index 2605e07dd..00d99f9d2 100755 --- a/local/modules/TheliaDebugBar/DataCollector/PropelCollector.php +++ b/local/modules/TheliaDebugBar/DataCollector/PropelCollector.php @@ -47,10 +47,9 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa public function __construct(LoggerInterface $alternativeLogger = null) { - $serviceContainer = Propel::getServiceContainer(); - $serviceContainer->setLogger('defaultLogger', $this); + $con = Propel::getServiceContainer()->getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); + $con->setLogger($this); - $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); $con->setLogMethods(array( 'exec', 'query', diff --git a/reset_install.sh b/reset_install.sh index 8280173d9..a91a2dc1c 100755 --- a/reset_install.sh +++ b/reset_install.sh @@ -9,6 +9,9 @@ read test echo -e "\n\033[01;34m[INFO] Clearing caches\033[00m\n" php Thelia cache:clear +echo -e "\n\033[01;34m[INFO] Self-updating Composer\033[00m\n" +composer self-update + echo -e "\n\033[01;34m[INFO] Downloading vendors\033[00m\n" composer install --prefer-dist --optimize-autoloader diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index bf2e1c1ee..692c25119 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -4,6 +4,9 @@ {check_auth roles="ADMIN" permissions="{block name="check-permissions"}{/block}" login_tpl="/admin/login"} {/block} +{* -- Define some stuff for Smarty ----------------------------------------- *} +{config_load file='variables.conf'} + @@ -53,7 +56,7 @@
{intl l='Version %ver' ver="{$THELIA_VERSION}"}
- +
@@ -86,7 +89,7 @@
+ + + + + {* Check if a product template is defined *} + +
+
+ +
+ + + + + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + + page_url = "{url path='/admin/products/update' product_id=$ID}" + close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" + } + + {* -- Begin attributes management ------------------------------- *} + +
+
+
+
+

{intl l='Product Attributes'}

+ +

+ {if $TEMPLATE} + {intl + l="You can change template attributes and their positions in the template configuration page." + tpl_mgmt_url={url path='/admin/configuration/templates/update' template_id=$TEMPLATE} + } + {else} + {intl + l="You can change attributes and their positions in the attributes configuration page." + tpl_mgmt_url={url path='/admin/configuration/attributes'} + } + {/if} +

+ +
+ + + + + + + {module_include location='product_attributes_table_header'} + + + + + {loop name="product-attributes" type="attribute" order="manual" product=$product_id backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='product_features_table_row'} + + {/loop} + + {elseloop rel="product-attributes"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Attribute Name'}
{$ID}{$TITLE}
+
+ {intl l="This product template does not contains any features"} +
+
+
+
+
+
+
+ + {* -- Begin features management ---------------------------------- *} + +
+
+
+
+

{intl l='Product Features'}

+ +

+ {if $TEMPLATE} + {intl + l="You can change templates features and their positions in the template configuration page." + tpl_mgmt_url={url path='/admin/configuration/templates/update' template_id=$TEMPLATE} + } + {else} + {intl + l="You can change feature and their positions in the features configuration page." + tpl_mgmt_url={url path='/admin/configuration/features'} + } + {/if} +

+ +
+ + + + + + + + {module_include location='product_features_table_header'} + + + + + + {loop name="product-features" type="feature" order="manual" product=$product_id backend_context="1" lang="$edit_language_id"} + + + + + + + + {module_include location='product_features_table_row'} + + + {/loop} + + {elseloop rel="product-features"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Feature Name'}{intl l='Feature value for this product'}
{$ID}{$TITLE} + {* Multiple values *} + + {ifloop rel="product-features-av"} + + {* load all selected values in an array to speed up things a little *} + + {$selected = array()} + + {loop name="free-text-value" exclude_free_text="true" type="feature_value" product=$product_id feature=$ID backend_context="1" lang="$edit_language_id"} + {$selected[] = $FEATURE_AV_ID} + {/loop} + + {capture "select_options"} + {loop name="product-features-av" type="feature-availability" feature=$ID order="manual" backend_context="1" lang="$edit_language_id"} + + + {$options_count = $LOOP_COUNT} {* LOOP_COUNT is only available inside the loop ! *} + {/loop} + {/capture} + +
+ +
+ + + {intl l='Use Ctrl+click to select more than one value. You can also clear selected values.' id=$ID} + + {/ifloop} + + {* Free text *} + + {elseloop rel="product-features-av"} + {* Get the free text value *} + + {loop name="free-text-value" exclude_feature_availability="1" type="feature_value" product=$product_id feature=$ID backend_context="1" lang="$edit_language_id"} + {$feature_value=$FREE_TEXT_VALUE} + {/loop} + + + {/elseloop} +
+
+ {intl l="This product template does not contains any features"} +
+
+
+
+
+
+
+
+
+
+ + +{/loop} + + diff --git a/templates/admin/default/ajax/product-related-tab.html b/templates/admin/default/ajax/product-related-tab.html new file mode 100644 index 000000000..3c909b390 --- /dev/null +++ b/templates/admin/default/ajax/product-related-tab.html @@ -0,0 +1,576 @@ +{loop name="product_edit" type="product" visible="*" id=$product_id backend_context="1" lang=$edit_language_id} +
+ + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = true + + page_url = "{url path='/admin/products/update' product_id=$ID}" + close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" + } + +
+ + {* -- Begin related content management ------------------------------ *} + +
+
+
+ +
+ +
+ + + + + + + + + + {module_include location='product_contents_table_header'} + + + + + + + {loop name="assigned_contents" type="associated_content" product="$product_id" backend_context="1" lang="$edit_language_id"} + + + + + + + + {module_include location='product_contents_table_row'} + + + + {/loop} + + {elseloop rel="assigned_contents"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Content title'}{intl l='Position'}{intl l="Actions"}
{$ID} + {$TITLE} + + {admin_position_block + permission="admin.products.edit" + path={url path='/admin/product/update-content-position' product_id=$product_id current_tab="related"} + url_parameter="content_id" + in_place_edit_class="contentPositionChange" + position=$POSITION + id=$ID + } + +
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.product.content.delete"} + + + + {/loop} +
+
+
+ {intl l="This product contains no contents"} +
+
+
+
+
+ + {* -- End related content management -------------------------------- *} + + {* -- Begin accessories management ---------------------------------- *} + +
+
+
+
+ +

{intl l='Product accessories'}

+

{intl l='Define here this product\'s accessories'}

+ + + + + {ifloop rel="categories"} +
+ + + {intl l='Select a category to get its products'} +
+ +
+
+ + + + +
+ + {intl l='Select a product and click (+) to add it as an accessory'} +
+ +
+
+ {intl l="No available product in this category"} +
+
+ + {/ifloop} + + {elseloop rel="categories"} +
{intl l="No categories found"}
+ {/elseloop} + +
+
+ +
+ + + + + + + + + + {module_include location='product_accessories_table_header'} + + + + + + + {loop name="assigned_accessories" order="accessory" type="accessory" product="$product_id" backend_context="1" lang="$edit_language_id"} + + + + + + + + {module_include location='product_accessories_table_row'} + + + + {/loop} + + {elseloop rel="assigned_accessories"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Accessory title'}{intl l='Position'}{intl l="Actions"}
{$ID} + {$TITLE} + + {admin_position_block + permission="admin.products.edit" + path={url path='/admin/product/update-accessory-position' product_id=$product_id current_tab="related"} + url_parameter="accessory_id" + in_place_edit_class="accessoryPositionChange" + position=$POSITION + id=$ID + } + +
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.product.accessory.delete"} + + + + {/loop} +
+
+
+ {intl l="This product contains no accessories"} +
+
+
+
+
+ + {* -- End accessories management ------------------------------------ *} + +
+ +
+ + {* -- Begin categories management ----------------------------------- *} + +
+
+
+ +
+ +
+ + + + + + + + {module_include location='product_categories_table_header'} + + + + + + + {loop name="additional_categories" type="category" product=$product_id exclude=$DEFAULT_CATEGORY backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='product_categories_table_row'} + + + + {/loop} + + {elseloop rel="additional_categories"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Category title'}{intl l="Actions"}
{$ID} + {$TITLE} + +
+ {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.category.delete"} + + + + {/loop} +
+
+
+ {intl l="This product doesn't belong to any additional category."} +
+
+
+
+
+ {* -- End categories management ------------------------------------- *} +
+ +
+ +{* Delete related content confirmation dialog *} + +{capture "delete_content_dialog"} + + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_content_dialog" + dialog_title = {intl l="Remove related content"} + dialog_message = {intl l="Do you really want to remove this related content from the product ?"} + + form_action = {url path='/admin/products/content/delete'} + form_content = {$smarty.capture.delete_content_dialog nofilter} +} + +{* Delete accessory confirmation dialog *} + +{capture "delete_accessory_dialog"} + + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_accessory_dialog" + dialog_title = {intl l="Remove an accessory"} + dialog_message = {intl l="Do you really want to remove this accessory from the product ?"} + + form_action = {url path='/admin/products/accessory/delete'} + form_content = {$smarty.capture.delete_accessory_dialog nofilter} +} + +{* Delete category confirmation dialog *} + +{capture "delete_category_dialog"} + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_category_dialog" + dialog_title = {intl l="Remove from category"} + dialog_message = {intl l="Do you really want to remove the product from this category ?"} + + form_action = {url path='/admin/products/category/delete'} + form_content = {$smarty.capture.delete_category_dialog nofilter} +} + + +{/loop} \ No newline at end of file diff --git a/templates/admin/default/ajax/template-attribute-list.html b/templates/admin/default/ajax/template-attribute-list.html index a630aaa61..7c0c2fdb9 100644 --- a/templates/admin/default/ajax/template-attribute-list.html +++ b/templates/admin/default/ajax/template-attribute-list.html @@ -1,12 +1,12 @@
{ifloop rel="free_attributes"} -
+
"; + fields = Dropzone.createElement(fieldsString); + if (this.element.tagName !== "FORM") { + form = Dropzone.createElement(""); + form.appendChild(fields); + } else { + this.element.setAttribute("enctype", "multipart/form-data"); + this.element.setAttribute("method", this.options.method); + } + return form != null ? form : fields; + }; + + Dropzone.prototype.getExistingFallback = function() { + var fallback, getFallback, tagName, _i, _len, _ref; + getFallback = function(elements) { + var el, _i, _len; + for (_i = 0, _len = elements.length; _i < _len; _i++) { + el = elements[_i]; + if (/(^| )fallback($| )/.test(el.className)) { + return el; + } + } + }; + _ref = ["div", "form"]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + tagName = _ref[_i]; + if (fallback = getFallback(this.element.getElementsByTagName(tagName))) { + return fallback; + } + } + }; + + Dropzone.prototype.setupEventListeners = function() { + var elementListeners, event, listener, _i, _len, _ref, _results; + _ref = this.listeners; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elementListeners = _ref[_i]; + _results.push((function() { + var _ref1, _results1; + _ref1 = elementListeners.events; + _results1 = []; + for (event in _ref1) { + listener = _ref1[event]; + _results1.push(elementListeners.element.addEventListener(event, listener, false)); + } + return _results1; + })()); + } + return _results; + }; + + Dropzone.prototype.removeEventListeners = function() { + var elementListeners, event, listener, _i, _len, _ref, _results; + _ref = this.listeners; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elementListeners = _ref[_i]; + _results.push((function() { + var _ref1, _results1; + _ref1 = elementListeners.events; + _results1 = []; + for (event in _ref1) { + listener = _ref1[event]; + _results1.push(elementListeners.element.removeEventListener(event, listener, false)); + } + return _results1; + })()); + } + return _results; + }; + + Dropzone.prototype.disable = function() { + var file, _i, _len, _ref, _results; + this.clickableElements.forEach(function(element) { + return element.classList.remove("dz-clickable"); + }); + this.removeEventListeners(); + _ref = this.files; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + file = _ref[_i]; + _results.push(this.cancelUpload(file)); + } + return _results; + }; + + Dropzone.prototype.enable = function() { + this.clickableElements.forEach(function(element) { + return element.classList.add("dz-clickable"); + }); + return this.setupEventListeners(); + }; + + Dropzone.prototype.filesize = function(size) { + var string; + if (size >= 100000000000) { + size = size / 100000000000; + string = "TB"; + } else if (size >= 100000000) { + size = size / 100000000; + string = "GB"; + } else if (size >= 100000) { + size = size / 100000; + string = "MB"; + } else if (size >= 100) { + size = size / 100; + string = "KB"; + } else { + size = size * 10; + string = "b"; + } + return "" + (Math.round(size) / 10) + " " + string; + }; + + Dropzone.prototype._updateMaxFilesReachedClass = function() { + if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) { + return this.element.classList.add("dz-max-files-reached"); + } else { + return this.element.classList.remove("dz-max-files-reached"); + } + }; + + Dropzone.prototype.drop = function(e) { + var files, items; + if (!e.dataTransfer) { + return; + } + this.emit("drop", e); + files = e.dataTransfer.files; + this.emit("selectedfiles", files); + if (files.length) { + items = e.dataTransfer.items; + if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) { + this.handleItems(items); + } else { + this.handleFiles(files); + } + } + }; + + Dropzone.prototype.handleFiles = function(files) { + var file, _i, _len, _results; + _results = []; + for (_i = 0, _len = files.length; _i < _len; _i++) { + file = files[_i]; + _results.push(this.addFile(file)); + } + return _results; + }; + + Dropzone.prototype.handleItems = function(items) { + var entry, item, _i, _len; + for (_i = 0, _len = items.length; _i < _len; _i++) { + item = items[_i]; + if (item.webkitGetAsEntry != null) { + entry = item.webkitGetAsEntry(); + if (entry.isFile) { + this.addFile(item.getAsFile()); + } else if (entry.isDirectory) { + this.addDirectory(entry, entry.name); + } + } else { + this.addFile(item.getAsFile()); + } + } + }; + + Dropzone.prototype.accept = function(file, done) { + if (file.size > this.options.maxFilesize * 1024 * 1024) { + return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize)); + } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) { + return done(this.options.dictInvalidFileType); + } else if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) { + done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles)); + return this.emit("maxfilesexceeded", file); + } else { + return this.options.accept.call(this, file, done); + } + }; + + Dropzone.prototype.addFile = function(file) { + var _this = this; + file.upload = { + progress: 0, + total: file.size, + bytesSent: 0 + }; + this.files.push(file); + file.status = Dropzone.ADDED; + this.emit("addedfile", file); + if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) { + this.createThumbnail(file); + } + return this.accept(file, function(error) { + if (error) { + file.accepted = false; + return _this._errorProcessing([file], error); + } else { + return _this.enqueueFile(file); + } + }); + }; + + Dropzone.prototype.enqueueFiles = function(files) { + var file, _i, _len; + for (_i = 0, _len = files.length; _i < _len; _i++) { + file = files[_i]; + this.enqueueFile(file); + } + return null; + }; + + Dropzone.prototype.enqueueFile = function(file) { + var _this = this; + file.accepted = true; + if (file.status === Dropzone.ADDED) { + file.status = Dropzone.QUEUED; + if (this.options.autoProcessQueue) { + return setTimeout((function() { + return _this.processQueue(); + }), 1); + } + } else { + throw new Error("This file can't be queued because it has already been processed or was rejected."); + } + }; + + Dropzone.prototype.addDirectory = function(entry, path) { + var dirReader, entriesReader, + _this = this; + dirReader = entry.createReader(); + entriesReader = function(entries) { + var _i, _len; + for (_i = 0, _len = entries.length; _i < _len; _i++) { + entry = entries[_i]; + if (entry.isFile) { + entry.file(function(file) { + if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') { + return; + } + file.fullPath = "" + path + "/" + file.name; + return _this.addFile(file); + }); + } else if (entry.isDirectory) { + _this.addDirectory(entry, "" + path + "/" + entry.name); + } + } + }; + return dirReader.readEntries(entriesReader, function(error) { + return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0; + }); + }; + + Dropzone.prototype.removeFile = function(file) { + if (file.status === Dropzone.UPLOADING) { + this.cancelUpload(file); + } + this.files = without(this.files, file); + this.emit("removedfile", file); + if (this.files.length === 0) { + return this.emit("reset"); + } + }; + + Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) { + var file, _i, _len, _ref; + if (cancelIfNecessary == null) { + cancelIfNecessary = false; + } + _ref = this.files.slice(); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + file = _ref[_i]; + if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) { + this.removeFile(file); + } + } + return null; + }; + + Dropzone.prototype.createThumbnail = function(file) { + var fileReader, + _this = this; + fileReader = new FileReader; + fileReader.onload = function() { + var img; + img = new Image; + img.onload = function() { + var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3; + file.width = img.width; + file.height = img.height; + resizeInfo = _this.options.resize.call(_this, file); + if (resizeInfo.trgWidth == null) { + resizeInfo.trgWidth = _this.options.thumbnailWidth; + } + if (resizeInfo.trgHeight == null) { + resizeInfo.trgHeight = _this.options.thumbnailHeight; + } + canvas = document.createElement("canvas"); + ctx = canvas.getContext("2d"); + canvas.width = resizeInfo.trgWidth; + canvas.height = resizeInfo.trgHeight; + ctx.drawImage(img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight); + thumbnail = canvas.toDataURL("image/png"); + return _this.emit("thumbnail", file, thumbnail); + }; + return img.src = fileReader.result; + }; + return fileReader.readAsDataURL(file); + }; + + Dropzone.prototype.processQueue = function() { + var i, parallelUploads, processingLength, queuedFiles; + parallelUploads = this.options.parallelUploads; + processingLength = this.getUploadingFiles().length; + i = processingLength; + if (processingLength >= parallelUploads) { + return; + } + queuedFiles = this.getQueuedFiles(); + if (!(queuedFiles.length > 0)) { + return; + } + if (this.options.uploadMultiple) { + return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength)); + } else { + while (i < parallelUploads) { + if (!queuedFiles.length) { + return; + } + this.processFile(queuedFiles.shift()); + i++; + } + } + }; + + Dropzone.prototype.processFile = function(file) { + return this.processFiles([file]); + }; + + Dropzone.prototype.processFiles = function(files) { + var file, _i, _len; + for (_i = 0, _len = files.length; _i < _len; _i++) { + file = files[_i]; + file.processing = true; + file.status = Dropzone.UPLOADING; + this.emit("processing", file); + } + if (this.options.uploadMultiple) { + this.emit("processingmultiple", files); + } + return this.uploadFiles(files); + }; + + Dropzone.prototype._getFilesWithXhr = function(xhr) { + var file, files; + return files = (function() { + var _i, _len, _ref, _results; + _ref = this.files; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + file = _ref[_i]; + if (file.xhr === xhr) { + _results.push(file); + } + } + return _results; + }).call(this); + }; + + Dropzone.prototype.cancelUpload = function(file) { + var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref; + if (file.status === Dropzone.UPLOADING) { + groupedFiles = this._getFilesWithXhr(file.xhr); + for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) { + groupedFile = groupedFiles[_i]; + groupedFile.status = Dropzone.CANCELED; + } + file.xhr.abort(); + for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) { + groupedFile = groupedFiles[_j]; + this.emit("canceled", groupedFile); + } + if (this.options.uploadMultiple) { + this.emit("canceledmultiple", groupedFiles); + } + } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) { + file.status = Dropzone.CANCELED; + this.emit("canceled", file); + if (this.options.uploadMultiple) { + this.emit("canceledmultiple", [file]); + } + } + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + }; + + Dropzone.prototype.uploadFile = function(file) { + return this.uploadFiles([file]); + }; + + Dropzone.prototype.uploadFiles = function(files) { + var file, formData, handleError, headerName, headerValue, headers, input, inputName, inputType, key, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, + _this = this; + xhr = new XMLHttpRequest(); + for (_i = 0, _len = files.length; _i < _len; _i++) { + file = files[_i]; + file.xhr = xhr; + } + xhr.open(this.options.method, this.options.url, true); + xhr.withCredentials = !!this.options.withCredentials; + response = null; + handleError = function() { + var _j, _len1, _results; + _results = []; + for (_j = 0, _len1 = files.length; _j < _len1; _j++) { + file = files[_j]; + _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr)); + } + return _results; + }; + updateProgress = function(e) { + var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results; + if (e != null) { + progress = 100 * e.loaded / e.total; + for (_j = 0, _len1 = files.length; _j < _len1; _j++) { + file = files[_j]; + file.upload = { + progress: progress, + total: e.total, + bytesSent: e.loaded + }; + } + } else { + allFilesFinished = true; + progress = 100; + for (_k = 0, _len2 = files.length; _k < _len2; _k++) { + file = files[_k]; + if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) { + allFilesFinished = false; + } + file.upload.progress = progress; + file.upload.bytesSent = file.upload.total; + } + if (allFilesFinished) { + return; + } + } + _results = []; + for (_l = 0, _len3 = files.length; _l < _len3; _l++) { + file = files[_l]; + _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent)); + } + return _results; + }; + xhr.onload = function(e) { + var _ref; + if (files[0].status === Dropzone.CANCELED) { + return; + } + if (xhr.readyState !== 4) { + return; + } + response = xhr.responseText; + if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { + try { + response = JSON.parse(response); + } catch (_error) { + e = _error; + response = "Invalid JSON response from server."; + } + } + updateProgress(); + if (!((200 <= (_ref = xhr.status) && _ref < 300))) { + return handleError(); + } else { + return _this._finished(files, response, e); + } + }; + xhr.onerror = function() { + if (files[0].status === Dropzone.CANCELED) { + return; + } + return handleError(); + }; + progressObj = (_ref = xhr.upload) != null ? _ref : xhr; + progressObj.onprogress = updateProgress; + headers = { + "Accept": "application/json", + "Cache-Control": "no-cache", + "X-Requested-With": "XMLHttpRequest" + }; + if (this.options.headers) { + extend(headers, this.options.headers); + } + for (headerName in headers) { + headerValue = headers[headerName]; + xhr.setRequestHeader(headerName, headerValue); + } + formData = new FormData(); + if (this.options.params) { + _ref1 = this.options.params; + for (key in _ref1) { + value = _ref1[key]; + formData.append(key, value); + } + } + for (_j = 0, _len1 = files.length; _j < _len1; _j++) { + file = files[_j]; + this.emit("sending", file, xhr, formData); + } + if (this.options.uploadMultiple) { + this.emit("sendingmultiple", files, xhr, formData); + } + if (this.element.tagName === "FORM") { + _ref2 = this.element.querySelectorAll("input, textarea, select, button"); + for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { + input = _ref2[_k]; + inputName = input.getAttribute("name"); + inputType = input.getAttribute("type"); + if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) { + formData.append(inputName, input.value); + } + } + } + for (_l = 0, _len3 = files.length; _l < _len3; _l++) { + file = files[_l]; + formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name); + } + return xhr.send(formData); + }; + + Dropzone.prototype._finished = function(files, responseText, e) { + var file, _i, _len; + for (_i = 0, _len = files.length; _i < _len; _i++) { + file = files[_i]; + file.status = Dropzone.SUCCESS; + this.emit("success", file, responseText, e); + this.emit("complete", file); + } + if (this.options.uploadMultiple) { + this.emit("successmultiple", files, responseText, e); + this.emit("completemultiple", files); + } + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + }; + + Dropzone.prototype._errorProcessing = function(files, message, xhr) { + var file, _i, _len; + for (_i = 0, _len = files.length; _i < _len; _i++) { + file = files[_i]; + file.status = Dropzone.ERROR; + this.emit("error", file, message, xhr); + this.emit("complete", file); + } + if (this.options.uploadMultiple) { + this.emit("errormultiple", files, message, xhr); + this.emit("completemultiple", files); + } + if (this.options.autoProcessQueue) { + return this.processQueue(); + } + }; + + return Dropzone; + + })(Em); + + Dropzone.version = "3.7.1"; + + Dropzone.options = {}; + + Dropzone.optionsForElement = function(element) { + if (element.id) { + return Dropzone.options[camelize(element.id)]; + } else { + return void 0; + } + }; + + Dropzone.instances = []; + + Dropzone.forElement = function(element) { + if (typeof element === "string") { + element = document.querySelector(element); + } + if ((element != null ? element.dropzone : void 0) == null) { + throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone."); + } + return element.dropzone; + }; + + Dropzone.autoDiscover = true; + + Dropzone.discover = function() { + var checkElements, dropzone, dropzones, _i, _len, _results; + if (document.querySelectorAll) { + dropzones = document.querySelectorAll(".dropzone"); + } else { + dropzones = []; + checkElements = function(elements) { + var el, _i, _len, _results; + _results = []; + for (_i = 0, _len = elements.length; _i < _len; _i++) { + el = elements[_i]; + if (/(^| )dropzone($| )/.test(el.className)) { + _results.push(dropzones.push(el)); + } else { + _results.push(void 0); + } + } + return _results; + }; + checkElements(document.getElementsByTagName("div")); + checkElements(document.getElementsByTagName("form")); + } + _results = []; + for (_i = 0, _len = dropzones.length; _i < _len; _i++) { + dropzone = dropzones[_i]; + if (Dropzone.optionsForElement(dropzone) !== false) { + _results.push(new Dropzone(dropzone)); + } else { + _results.push(void 0); + } + } + return _results; + }; + + Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i]; + + Dropzone.isBrowserSupported = function() { + var capableBrowser, regex, _i, _len, _ref; + capableBrowser = true; + if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) { + if (!("classList" in document.createElement("a"))) { + capableBrowser = false; + } else { + _ref = Dropzone.blacklistedBrowsers; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + regex = _ref[_i]; + if (regex.test(navigator.userAgent)) { + capableBrowser = false; + continue; + } + } + } + } else { + capableBrowser = false; + } + return capableBrowser; + }; + + without = function(list, rejectedItem) { + var item, _i, _len, _results; + _results = []; + for (_i = 0, _len = list.length; _i < _len; _i++) { + item = list[_i]; + if (item !== rejectedItem) { + _results.push(item); + } + } + return _results; + }; + + camelize = function(str) { + return str.replace(/[\-_](\w)/g, function(match) { + return match[1].toUpperCase(); + }); + }; + + Dropzone.createElement = function(string) { + var div; + div = document.createElement("div"); + div.innerHTML = string; + return div.childNodes[0]; + }; + + Dropzone.elementInside = function(element, container) { + if (element === container) { + return true; + } + while (element = element.parentNode) { + if (element === container) { + return true; + } + } + return false; + }; + + Dropzone.getElement = function(el, name) { + var element; + if (typeof el === "string") { + element = document.querySelector(el); + } else if (el.nodeType != null) { + element = el; + } + if (element == null) { + throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element."); + } + return element; + }; + + Dropzone.getElements = function(els, name) { + var e, el, elements, _i, _j, _len, _len1, _ref; + if (els instanceof Array) { + elements = []; + try { + for (_i = 0, _len = els.length; _i < _len; _i++) { + el = els[_i]; + elements.push(this.getElement(el, name)); + } + } catch (_error) { + e = _error; + elements = null; + } + } else if (typeof els === "string") { + elements = []; + _ref = document.querySelectorAll(els); + for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { + el = _ref[_j]; + elements.push(el); + } + } else if (els.nodeType != null) { + elements = [els]; + } + if (!((elements != null) && elements.length)) { + throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."); + } + return elements; + }; + + Dropzone.confirm = function(question, accepted, rejected) { + if (window.confirm(question)) { + return accepted(); + } else if (rejected != null) { + return rejected(); + } + }; + + Dropzone.isValidFile = function(file, acceptedFiles) { + var baseMimeType, mimeType, validType, _i, _len; + if (!acceptedFiles) { + return true; + } + acceptedFiles = acceptedFiles.split(","); + mimeType = file.type; + baseMimeType = mimeType.replace(/\/.*$/, ""); + for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) { + validType = acceptedFiles[_i]; + validType = validType.trim(); + if (validType.charAt(0) === ".") { + if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) { + return true; + } + } else if (/\/\*$/.test(validType)) { + if (baseMimeType === validType.replace(/\/.*$/, "")) { + return true; + } + } else { + if (mimeType === validType) { + return true; + } + } + } + return false; + }; + + if (typeof jQuery !== "undefined" && jQuery !== null) { + jQuery.fn.dropzone = function(options) { + return this.each(function() { + return new Dropzone(this, options); + }); + }; + } + + if (typeof module !== "undefined" && module !== null) { + module.exports = Dropzone; + } else { + window.Dropzone = Dropzone; + } + + Dropzone.ADDED = "added"; + + Dropzone.QUEUED = "queued"; + + Dropzone.ACCEPTED = Dropzone.QUEUED; + + Dropzone.UPLOADING = "uploading"; + + Dropzone.PROCESSING = Dropzone.UPLOADING; + + Dropzone.CANCELED = "canceled"; + + Dropzone.ERROR = "error"; + + Dropzone.SUCCESS = "success"; + + /* + # contentloaded.js + # + # Author: Diego Perini (diego.perini at gmail.com) + # Summary: cross-browser wrapper for DOMContentLoaded + # Updated: 20101020 + # License: MIT + # Version: 1.2 + # + # URL: + # http://javascript.nwbox.com/ContentLoaded/ + # http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE + */ + + + contentLoaded = function(win, fn) { + var add, doc, done, init, poll, pre, rem, root, top; + done = false; + top = true; + doc = win.document; + root = doc.documentElement; + add = (doc.addEventListener ? "addEventListener" : "attachEvent"); + rem = (doc.addEventListener ? "removeEventListener" : "detachEvent"); + pre = (doc.addEventListener ? "" : "on"); + init = function(e) { + if (e.type === "readystatechange" && doc.readyState !== "complete") { + return; + } + (e.type === "load" ? win : doc)[rem](pre + e.type, init, false); + if (!done && (done = true)) { + return fn.call(win, e.type || e); + } + }; + poll = function() { + var e; + try { + root.doScroll("left"); + } catch (_error) { + e = _error; + setTimeout(poll, 50); + return; + } + return init("poll"); + }; + if (doc.readyState !== "complete") { + if (doc.createEventObject && root.doScroll) { + try { + top = !win.frameElement; + } catch (_error) {} + if (top) { + poll(); + } + } + doc[add](pre + "DOMContentLoaded", init, false); + doc[add](pre + "readystatechange", init, false); + return win[add](pre + "load", init, false); + } + }; + + Dropzone._autoDiscoverFunction = function() { + if (Dropzone.autoDiscover) { + return Dropzone.discover(); + } + }; + + contentLoaded(window, Dropzone._autoDiscoverFunction); + + }).call(this); + + }); + require.alias("component-emitter/index.js", "dropzone/deps/emitter/index.js"); + require.alias("component-emitter/index.js", "emitter/index.js"); + if (typeof exports == "object") { + module.exports = require("dropzone"); + } else if (typeof define == "function" && define.amd) { + define(function(){ return require("dropzone"); }); + } else { + this["Dropzone"] = require("dropzone"); + }})(); \ No newline at end of file diff --git a/templates/admin/default/assets/js/image-upload.js b/templates/admin/default/assets/js/image-upload.js new file mode 100644 index 000000000..c1414c73b --- /dev/null +++ b/templates/admin/default/assets/js/image-upload.js @@ -0,0 +1,102 @@ +$(function($){ + // Manage picture upload + $.imageUploadManager = {}; + + Dropzone.autoDiscover = false; + + + + // Remove image on click + $.imageUploadManager.initImageDropZone = function() { + $.imageUploadManager.onClickDeleteImage(); + + var imageDropzone = new Dropzone("#images-dropzone", { + dictDefaultMessage : $('.btn-browse').html(), + uploadMultiple: false, + maxFilesize: 8, + acceptedFiles: 'image/png, image/gif, image/jpeg' + }); + + var totalFiles = 0, + completedFiles = 0; + + imageDropzone.on("addedfile", function(file){ + totalFiles += 1; + + if(totalFiles == 1){ + $('.dz-message').hide(); + } + }); + + imageDropzone.on("complete", function(file){ + completedFiles += 1; + + if (completedFiles === totalFiles){ + $('.dz-message').slideDown(); + } + }); + + imageDropzone.on("success", function(file) { + imageDropzone.removeFile(file); + $.imageUploadManager.updateImageListAjax(); + $.imageUploadManager.onClickDeleteImage(); + }); + + + + }; + + // Update picture list via AJAX call + $.imageUploadManager.updateImageListAjax = function() { + var $imageListArea = $(".image-manager .existing-image"); + $imageListArea.html('
'); + $.ajax({ + type: "POST", + url: imageListUrl, + statusCode: { + 404: function() { + $imageListArea.html( + imageListErrorMessage + ); + } + } + }).done(function(data) { + $imageListArea.html( + data + ); + $.imageUploadManager.onClickDeleteImage(); + }); + }; + + // Remove image on click + $.imageUploadManager.onClickDeleteImage = function() { + $('.image-manager .image-delete-btn').on('click', function (e) { + e.preventDefault(); + var $this = $(this); + var $parent = $this.parent(); + var $greatParent = $parent.parent(); + + $greatParent.append('
'); + $greatParent.find('.btn-group').remove(); + var $url = $this.attr("href"); + var errorMessage = $this.attr("data-error-message"); + $.ajax({ + type: "POST", + url: $url, + statusCode: { + 404: function() { + $(".image-manager .message").html( + errorMessage + ); + } + } + }).done(function(data) { + $greatParent.remove(); + $(".image-manager .message").html( + data + ); + }); + return false; + }); + }; +}); diff --git a/templates/admin/default/assets/js/libs/jquery.js b/templates/admin/default/assets/js/libs/jquery.js new file mode 100644 index 000000000..e01079755 --- /dev/null +++ b/templates/admin/default/assets/js/libs/jquery.js @@ -0,0 +1,6 @@ +/*! jQuery v1.10.1 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license + +*/ +(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.1",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=lt(),k=lt(),E=lt(),S=!1,A=function(){return 0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=bt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+xt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return At(e.replace(z,"$1"),t,n,i)}function st(e){return K.test(e+"")}function lt(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function ut(e){return e[b]=!0,e}function ct(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function pt(e,t,n){e=e.split("|");var r,i=e.length,a=n?null:t;while(i--)(r=o.attrHandle[e[i]])&&r!==t||(o.attrHandle[e[i]]=a)}function ft(e,t){var n=e.getAttributeNode(t);return n&&n.specified?n.value:e[t]===!0?t.toLowerCase():null}function dt(e,t){return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}function ht(e){return"input"===e.nodeName.toLowerCase()?e.defaultValue:t}function gt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function mt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function yt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function vt(e){return ut(function(t){return t=+t,ut(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.parentWindow;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.frameElement&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ct(function(e){return e.innerHTML="",pt("type|href|height|width",dt,"#"===e.firstChild.getAttribute("href")),pt(B,ft,null==e.getAttribute("disabled")),e.className="i",!e.getAttribute("className")}),r.input=ct(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")}),pt("value",ht,r.attributes&&r.input),r.getElementsByTagName=ct(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ct(function(e){return e.innerHTML="
",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ct(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=st(n.querySelectorAll))&&(ct(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ct(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=st(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ct(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=st(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},r.sortDetached=ct(function(e){return 1&e.compareDocumentPosition(n.createElement("div"))}),A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return gt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?gt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:ut,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=bt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?ut(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ut(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?ut(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ut(function(e){return function(t){return at(e,t).length>0}}),contains:ut(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:ut(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:vt(function(){return[0]}),last:vt(function(e,t){return[t-1]}),eq:vt(function(e,t,n){return[0>n?n+t:n]}),even:vt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:vt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:vt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:vt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=mt(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=yt(n);function bt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function xt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function wt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function Tt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function Ct(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function Nt(e,t,n,r,i,o){return r&&!r[b]&&(r=Nt(r)),i&&!i[b]&&(i=Nt(i,o)),ut(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||St(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:Ct(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=Ct(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=Ct(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function kt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=wt(function(e){return e===t},s,!0),p=wt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[wt(Tt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return Nt(l>1&&Tt(f),l>1&&xt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&kt(e.slice(l,r)),i>r&&kt(e=e.slice(r)),i>r&&xt(e))}f.push(n)}return Tt(f)}function Et(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=Ct(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?ut(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=bt(e)),n=t.length;while(n--)o=kt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Et(i,r))}return o};function St(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function At(e,t,n,i){var a,s,u,c,p,f=bt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&xt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}o.pseudos.nth=o.pseudos.eq;function jt(){}jt.prototype=o.filters=o.pseudos,o.setFilters=new jt,r.sortStable=b.split("").sort(A).join("")===b,p(),[0,0].sort(A),r.detectDuplicates=S,x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!l||i&&!u||(n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="
a",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="
t
",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="
",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null) +}),n=s=l=u=r=o=null,t}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=x(this),l=t,u=e.match(T)||[];while(o=u[a++])l=r?l:!s.hasClass(o),s[l?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/\s*$/g,At={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?""!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle); +u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("