diff --git a/.gitignore b/.gitignore index 3063f9a02..8cf78452c 100755 --- a/.gitignore +++ b/.gitignore @@ -19,10 +19,9 @@ local/media/documents/* local/media/images/* web/assets/* web/cache/* -web/.htaccess phpdoc*.log php-cs xhprof/ phpunit.phar .DS_Store -phpmyadmin \ No newline at end of file +phpmyadmin diff --git a/Readme.md b/Readme.md index 791b61d1e..ac0862dae 100755 --- a/Readme.md +++ b/Readme.md @@ -12,14 +12,33 @@ Here is the most recent developed code for the next major version (v2). You can Most part of the code can possibly change, a large part will be refactor soon, graphical setup does not exist yet. +Requirements +------------ + +* php 5.4 +* apache 2 +* mysql 5 + +If you use Mac OSX, it still doesn't use php 5.4 as default php version... There are many solutions for you : + +* use linux (the best one) +* use last MAMP version and put the php bin directory in your path : + +```bash +export PATH=/Applications/MAMP/bin/php/php5.4.x/bin/:$PATH +``` + +* configure a complete development environment : http://php-osx.liip.ch/ +* use a virtual machine with vagrant and puppet : https://puphpet.com/ + Installation ------------ ``` bash $ git clone --recursive https://github.com/thelia/thelia.git $ cd thelia -$ wget http://getcomposer.org/composer.phar -$ php composer.phar install +$ curl -sS https://getcomposer.org/installer | php +$ php composer.phar install --optimize-autoloader ``` Finish the installation using cli tools : diff --git a/composer.json b/composer.json index 2d315bd3a..4a3798384 100755 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "simplepie/simplepie": "dev-master", "imagine/imagine": "dev-master", - "symfony/icu": "1.0" + "symfony/icu": "1.0", + "swiftmailer/swiftmailer": "5.0.*" }, "require-dev" : { "phpunit/phpunit": "3.7.*", @@ -53,9 +54,5 @@ "": "local/modules/", "Thelia" : "core/lib/" } - }, - "scripts" : { - "post-update-cmd": "composer dump-autoload -o", - "post-install-cmd": "composer dump-autoload -o" } } diff --git a/composer.lock b/composer.lock index 61160ea49..b0310c075 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": "28dfdc7a840f9e70df422581f82a871f", + "hash": "a40be01c82e68ba0c446dc204d2667da", "packages": [ { "name": "imagine/imagine", @@ -445,6 +445,55 @@ ], "time": "2013-07-02 16:38:47" }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.0.2", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/f3917ecef35a4e4d98b303eb9fee463bc983f379", + "reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Chris Corbyn" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "mail", + "mailer" + ], + "time": "2013-08-30 12:35:21" + }, { "name": "symfony-cmf/routing", "version": "1.0.0", diff --git a/core/lib/Thelia/Action/BaseCachedFile.php b/core/lib/Thelia/Action/BaseCachedFile.php new file mode 100644 index 000000000..b66496e07 --- /dev/null +++ b/core/lib/Thelia/Action/BaseCachedFile.php @@ -0,0 +1,178 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Core\Event\CachedFileEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Tools\URL; + +/** + * + * Cached file management actions. This class handles file caching in the web space + * + * Basically, files are stored outside the web space (by default in local/media/), + * and cached in the web space (by default in web/local/). + * + * In the file cache directory, a subdirectory for files categories (eg. product, category, folder, etc.) is + * automatically created, and the cached file is created here. Plugin may use their own subdirectory as required. + * + * A copy (or symbolic link, by default) of the original file is created in the cache. + * + * @package Thelia\Action + * @author Franck Allimant + * + */ +abstract class BaseCachedFile extends BaseAction +{ + /** + * @return string root of the file cache directory in web space + */ + protected abstract function getCacheDirFromWebRoot(); + + /** + * Clear the file cache. Is a subdirectory is specified, only this directory is cleared. + * If no directory is specified, the whole cache is cleared. + * Only files are deleted, directories will remain. + * + * @param CachedFileEvent $event + */ + public function clearCache(CachedFileEvent $event) + { + $path = $this->getCachePath($event->getCacheSubdirectory(), false); + + $this->clearDirectory($path); + } + + /** + * Recursively clears the specified directory. + * + * @param string $path the directory path + */ + protected function clearDirectory($path) + { + $iterator = new \DirectoryIterator($path); + + foreach ($iterator as $fileinfo) { + + if ($fileinfo->isDot()) continue; + + if ($fileinfo->isFile() || $fileinfo->isLink()) { + @unlink($fileinfo->getPathname()); + } elseif ($fileinfo->isDir()) { + $this->clearDirectory($fileinfo->getPathname()); + } + } + } + + /** + * Return the absolute URL to the cached file + * + * @param string $subdir the subdirectory related to cache base + * @param string $filename the safe filename, as returned by getCacheFilePath() + * @return string the absolute URL to the cached file + */ + protected function getCacheFileURL($subdir, $safe_filename) + { + $path = $this->getCachePathFromWebRoot($subdir); + + return URL::getInstance()->absoluteUrl(sprintf("%s/%s", $path, $safe_filename), null, URL::PATH_TO_FILE); + } + + /** + * 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 boolean $forceOriginalDocument if true, the original file path in the cache dir is returned. + * @return string the cache directory path relative to Web Root + */ + protected function getCacheFilePath($subdir, $filename, $forceOriginalFile = false, $hashed_options = null) + { + $path = $this->getCachePath($subdir); + + $safe_filename = preg_replace("[^:alnum:\-\._]", "-", strtolower(basename($filename))); + + // Keep original safe name if no tranformations are applied + if ($forceOriginalFile || $hashed_options == null) + return sprintf("%s/%s", $path, $safe_filename); + else + return sprintf("%s/%s-%s", $path, $hashed_options, $safe_filename); + } + + /** + * Return the cache directory path relative to Web Root + * + * @param string $subdir the subdirectory related to cache base, or null to get the cache directory only. + * @return string the cache directory path relative to Web Root + */ + protected function getCachePathFromWebRoot($subdir = null) + { + $cache_dir_from_web_root = $this->getCacheDirFromWebRoot(); + + if ($subdir != null) { + $safe_subdir = basename($subdir); + + $path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir); + } else + $path = $cache_dir_from_web_root; + + // Check if path is valid, e.g. in the cache dir + return $path; + } + + /** + * Return the absolute cache directory path + * + * @param string $subdir the subdirectory related to cache base, or null to get the cache base directory. + * @throws \RuntimeException if cache directory cannot be created + * @return string the absolute cache directory path + */ + protected function getCachePath($subdir = null, $create_if_not_exists = true) + { + $cache_base = $this->getCachePathFromWebRoot($subdir); + + $web_root = rtrim(THELIA_WEB_DIR, '/'); + + $path = sprintf("%s/%s", $web_root, $cache_base); + + // Create directory (recursively) if it does not exists. + if ($create_if_not_exists && !is_dir($path)) { + if (!@mkdir($path, 0777, true)) { + throw new \RuntimeException(sprintf("Failed to create %s/%s file in cache directory", $cache_base)); + } + } + + // Check if path is valid, e.g. in the cache dir + $cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot())); + + if (strpos(realpath($path), $cache_base) !== 0) { + throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir)); + } + + return $path; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 297cd64da..64254d734 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -24,52 +24,92 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Thelia\Core\Event\TheliaEvents; -use Thelia\Model\Category as CategoryModel; + use Thelia\Model\CategoryQuery; +use Thelia\Model\Category as CategoryModel; -use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\Propel; -use Thelia\Model\Map\CategoryTableMap; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CategoryUpdateEvent; use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Core\Event\CategoryDeleteEvent; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\CategoryToggleVisibilityEvent; -use Thelia\Core\Event\CategoryChangePositionEvent; +use Thelia\Core\Event\CategoryAddContentEvent; +use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery; class Category extends BaseAction implements EventSubscriberInterface { + /** + * Create a new category entry + * + * @param CategoryCreateEvent $event + */ public function create(CategoryCreateEvent $event) { $category = new CategoryModel(); $category ->setDispatcher($this->getDispatcher()) - ->create( - $event->getTitle(), - $event->getParent(), - $event->getLocale() - ); + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save() + ; $event->setCategory($category); } - public function update(CategoryChangeEvent $event) + /** + * Change a category + * + * @param CategoryUpdateEvent $event + */ + public function update(CategoryUpdateEvent $event) { + $search = CategoryQuery::create(); + + if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { + + $category + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save(); + + $event->setCategory($category); + } } /** - * Delete a category + * Delete a category entry * - * @param ActionEvent $event + * @param CategoryDeleteEvent $event */ public function delete(CategoryDeleteEvent $event) { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); + if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { - if ($category !== null) { + $category + ->setDispatcher($this->getDispatcher()) + ->delete() + ; - $category->setDispatcher($this->getDispatcher())->delete(); + $event->setCategory($category); } } @@ -80,178 +120,80 @@ class Category extends BaseAction implements EventSubscriberInterface */ public function toggleVisibility(CategoryToggleVisibilityEvent $event) { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); + $category = $event->getCategory(); - if ($category !== null) { + $category + ->setDispatcher($this->getDispatcher()) + ->setVisible($category->getVisible() ? false : true) + ->save() + ; + } - $category - ->setDispatcher($this->getDispatcher()) - ->setVisible($category->getVisible() ? false : true) + /** + * Changes position, selecting absolute ou relative change. + * + * @param CategoryChangePositionEvent $event + */ + public function updatePosition(UpdatePositionEvent $event) + { + if (null !== $category = CategoryQuery::create()->findPk($event->getObjectId())) { + + $category->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $category->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $category->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $category->movePositionDown(); + } + } + + public function addContent(CategoryAddContentEvent $event) { + + if (CategoryAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByCategory($event->getCategory())->count() <= 0) { + + $content = new CategoryAssociatedContent(); + + $content + ->setCategory($event->getCategory()) + ->setContentId($event->getContentId()) ->save() ; - } + } } - /** - * Changes category position, selecting absolute ou relative change. - * - * @param CategoryChangePositionEvent $event - */ - public function changePosition(CategoryChangePositionEvent $event) - { - if ($event->getMode() == CategoryChangePositionEvent::POSITION_ABSOLUTE) - return $this->changeAbsolutePosition($event); - else - return $this->exchangePosition($event); + public function removeContent(CategoryDeleteContentEvent $event) { + + $content = CategoryAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByCategory($event->getCategory())->findOne() + ; + + if ($content !== null) $content->delete(); } - /** - * Move up or down a category - * - * @param CategoryChangePositionEvent $event - */ - protected function exchangePosition(CategoryChangePositionEvent $event) - { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); - - if ($category !== null) { - - // The current position of the category - $my_position = $category->getPosition(); - - // Find category to exchange position with - $search = CategoryQuery::create() - ->filterByParent($category->getParent()); - - // Up or down ? - if ($event->getMode() == CategoryChangePositionEvent::POSITION_UP) { - // Find the category immediately before me - $search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC); - } elseif ($event->getMode() == CategoryChangePositionEvent::POSITION_DOWN) { - // Find the category immediately after me - $search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC); - } else - - return; - - $result = $search->findOne(); - - // If we found the proper category, exchange their positions - if ($result) { - - $cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); - - $cnx->beginTransaction(); - - try { - $category - ->setDispatcher($this->getDispatcher()) - ->setPosition($result->getPosition()) - ->save() - ; - - $result->setPosition($my_position)->save(); - - $cnx->commit(); - } catch (Exception $e) { - $cnx->rollback(); - } - } - } - } /** - * Changes category position - * - * @param CategoryChangePositionEvent $event - */ - protected function changeAbsolutePosition(CategoryChangePositionEvent $event) - { - $category = CategoryQuery::create()->findPk($event->getCategoryId()); - - if ($category !== null) { - - // The required position - $new_position = $event->getPosition(); - - // The current position - $current_position = $category->getPosition(); - - if ($new_position != null && $new_position > 0 && $new_position != $current_position) { - - // Find categories to offset - $search = CategoryQuery::create()->filterByParent($category->getParent()); - - if ($new_position > $current_position) { - // The new position is after the current position -> we will offset + 1 all categories located between us and the new position - $search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position)); - - $delta = -1; - } else { - // The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position - $search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1)); - - $delta = 1; - } - - $results = $search->find(); - - $cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME); - - $cnx->beginTransaction(); - - try { - foreach ($results as $result) { - $result->setPosition($result->getPosition() + $delta)->save($cnx); - } - - $category - ->setDispatcher($this->getDispatcher()) - ->setPosition($new_position) - ->save($cnx) - ; - - $cnx->commit(); - } catch (Exception $e) { - $cnx->rollback(); - } - } - } - } - - /** - * Returns an array of event names this subscriber listens to. - * - * The array keys are event names and the value can be: - * - * * The method name to call (priority defaults to 0) - * * An array composed of the method name to call and the priority - * * An array of arrays composed of the method names to call and respective - * priorities, or 0 if unset - * - * For instance: - * - * * array('eventName' => 'methodName') - * * array('eventName' => array('methodName', $priority)) - * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) - * - * @return array The event names to listen to - * - * @api + * {@inheritDoc} */ public static function getSubscribedEvents() { return array( - TheliaEvents::CATEGORY_CREATE => array("create", 128), - TheliaEvents::CATEGORY_UPDATE => array("update", 128), - TheliaEvents::CATEGORY_DELETE => array("delete", 128), - + TheliaEvents::CATEGORY_CREATE => array("create", 128), + TheliaEvents::CATEGORY_UPDATE => array("update", 128), + TheliaEvents::CATEGORY_DELETE => array("delete", 128), TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128), - TheliaEvents::CATEGORY_CHANGE_POSITION => array("changePosition", 128), - "action.updateCategoryPositionU" => array("changePositionUp", 128), - "action.updateCategoryPositionDown" => array("changePositionDown", 128), - "action.updateCategoryPosition" => array("changePosition", 128), + TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128), + + TheliaEvents::CATEGORY_ADD_CONTENT => array("addContent", 128), + TheliaEvents::CATEGORY_REMOVE_CONTENT => array("removeContent", 128), + ); } } diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php index 83df28524..f8a7c027c 100644 --- a/core/lib/Thelia/Action/Config.php +++ b/core/lib/Thelia/Action/Config.php @@ -22,7 +22,6 @@ /*************************************************************************************/ namespace Thelia\Action; - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Model\ConfigQuery; @@ -45,18 +44,9 @@ class Config extends BaseAction implements EventSubscriberInterface { $config = new ConfigModel(); - $config - ->setDispatcher($this->getDispatcher()) - - ->setName($event->getEventName()) - ->setValue($event->getValue()) - ->setLocale($event->getLocale()) - ->setTitle($event->getTitle()) - ->setHidden($event->getHidden()) - ->setSecured($event->getSecured()) - - ->save() - ; + $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue()) + ->setLocale($event->getLocale())->setTitle($event->getTitle())->setHidden($event->getHidden()) + ->setSecured($event->getSecured())->save(); $event->setConfig($config); } @@ -70,18 +60,13 @@ class Config extends BaseAction implements EventSubscriberInterface { $search = ConfigQuery::create(); - if (null !== $config = $search->findOneById($event->getConfigId())) { + if (null !== $config = $search->findPk($event->getConfigId())) { if ($event->getValue() !== $config->getValue()) { - $config - ->setDispatcher($this->getDispatcher()) + $config->setDispatcher($this->getDispatcher())->setValue($event->getValue())->save(); - ->setValue($event->getValue()) - ->save() - ; - - $event->setConfig($config); + $event->setConfig($config); } } } @@ -95,23 +80,12 @@ class Config extends BaseAction implements EventSubscriberInterface { $search = ConfigQuery::create(); - if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) { + if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) { - $config - ->setDispatcher($this->getDispatcher()) - - ->setName($event->getEventName()) - ->setValue($event->getValue()) - ->setHidden($event->getHidden()) - ->setSecured($event->getSecured()) - - ->setLocale($event->getLocale()) - ->setTitle($event->getTitle()) - ->setDescription($event->getDescription()) - ->setChapo($event->getChapo()) - ->setPostscriptum($event->getPostscriptum()) - - ->save(); + $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue()) + ->setHidden($event->getHidden())->setSecured($event->getSecured())->setLocale($event->getLocale()) + ->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum())->save(); $event->setConfig($config); } @@ -125,14 +99,11 @@ class Config extends BaseAction implements EventSubscriberInterface public function delete(ConfigDeleteEvent $event) { - if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) { + if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) { - if (! $config->getSecured()) { + if (!$config->getSecured()) { - $config - ->setDispatcher($this->getDispatcher()) - ->delete() - ; + $config->setDispatcher($this->getDispatcher())->delete(); $event->setConfig($config); } @@ -145,10 +116,15 @@ class Config extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - TheliaEvents::CONFIG_CREATE => array("create", 128), - TheliaEvents::CONFIG_SETVALUE => array("setValue", 128), - TheliaEvents::CONFIG_UPDATE => array("modify", 128), - TheliaEvents::CONFIG_DELETE => array("delete", 128), + TheliaEvents::CONFIG_CREATE => array( + "create", 128 + ), TheliaEvents::CONFIG_SETVALUE => array( + "setValue", 128 + ), TheliaEvents::CONFIG_UPDATE => array( + "modify", 128 + ), TheliaEvents::CONFIG_DELETE => array( + "delete", 128 + ), ); } } diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 7908d1f0d..946fee375 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -71,7 +71,7 @@ class Currency extends BaseAction implements EventSubscriberInterface { $search = CurrencyQuery::create(); - if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) { + if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { $currency ->setDispatcher($this->getDispatcher()) @@ -97,7 +97,7 @@ class Currency extends BaseAction implements EventSubscriberInterface { $search = CurrencyQuery::create(); - if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) { + if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { if ($currency->getByDefault() != $event->getIsDefault()) { @@ -123,7 +123,7 @@ class Currency extends BaseAction implements EventSubscriberInterface public function delete(CurrencyDeleteEvent $event) { - if (null !== ($currency = CurrencyQuery::create()->findOneById($event->getCurrencyId()))) { + if (null !== ($currency = CurrencyQuery::create()->findPk($event->getCurrencyId()))) { $currency ->setDispatcher($this->getDispatcher()) diff --git a/core/lib/Thelia/Action/Document.php b/core/lib/Thelia/Action/Document.php new file mode 100644 index 000000000..86fc51ac5 --- /dev/null +++ b/core/lib/Thelia/Action/Document.php @@ -0,0 +1,139 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Core\Event\DocumentEvent; +use Thelia\Model\ConfigQuery; +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; + +/** + * + * Document management actions. This class handles document processing an caching. + * + * Basically, documents are stored outside the web space (by default in local/media/documents), + * and cached in the web space (by default in web/local/documents). + * + * In the documents caches directory, a subdirectory for documents categories (eg. product, category, folder, etc.) is + * automatically created, and the cached document is created here. Plugin may use their own subdirectory as required. + * + * The cached document name contains a hash of the processing options, and the original (normalized) name of the document. + * + * A copy (or symbolic link, by default) of the original document is always created in the cache, so that the full + * resolution document is always available. + * + * Various document processing options are available : + * + * - resizing, with border, crop, or by keeping document aspect ratio + * - rotation, in degrees, positive or negative + * - background color, applyed to empty background when creating borders or rotating + * - effects. The effects are applied in the specified order. The following effects are available: + * - gamma:value : change the document Gamma to the specified value. Example: gamma:0.7 + * - grayscale or greyscale: switch document to grayscale + * - colorize:color : apply a color mask to the document. Exemple: colorize:#ff2244 + * - negative : transform the document in its negative equivalent + * - vflip or vertical_flip : vertical flip + * - hflip or horizontal_flip : horizontal flip + * + * If a problem occurs, an DocumentException may be thrown. + * + * @package Thelia\Action + * @author Franck Allimant + * + */ +class Document extends BaseCachedFile implements EventSubscriberInterface +{ + /** + * @return string root of the document cache directory in web space + */ + protected function getCacheDirFromWebRoot() { + return ConfigQuery::read('document_cache_dir_from_web_root', 'cache'); + } + + /** + * Process document and write the result in the document cache. + * + * When the original document is required, create either a symbolic link with the + * original document in the cache dir, or copy it in the cache dir if it's not already done. + * + * This method updates the cache_file_path and file_url attributes of the event + * + * @param DocumentEvent $event + * @throws \InvalidArgumentException, DocumentException + */ + public function processDocument(DocumentEvent $event) + { + $subdir = $event->getCacheSubdirectory(); + $source_file = $event->getSourceFilepath(); + + if (null == $subdir || null == $source_file) { + throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null"); + } + + $originalDocumentPathInCache = $this->getCacheFilePath($subdir, $source_file, true); + + if (! file_exists($originalDocumentPathInCache)) { + + if (! file_exists($source_file)) { + throw new DocumentException(sprintf("Source document file %s does not exists.", $source_file)); + } + + $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)); + } + } 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)); + } + } + } + + // Compute the document URL + $document_url = $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)); + } + + public static function getSubscribedEvents() + { + return array( + TheliaEvents::DOCUMENT_PROCESS => array("processDocument", 128), + TheliaEvents::DOCUMENT_CLEAR_CACHE => array("clearCache", 128), + ); + } +} diff --git a/core/lib/Thelia/Action/Image.php b/core/lib/Thelia/Action/Image.php index 66baffdbb..4660f93b8 100755 --- a/core/lib/Thelia/Action/Image.php +++ b/core/lib/Thelia/Action/Image.php @@ -71,7 +71,7 @@ use Thelia\Core\Event\TheliaEvents; * @author Franck Allimant * */ -class Image extends BaseAction implements EventSubscriberInterface +class Image extends BaseCachedFile implements EventSubscriberInterface { // Resize mode constants const EXACT_RATIO_WITH_BORDERS = 1; @@ -79,38 +79,10 @@ class Image extends BaseAction implements EventSubscriberInterface const KEEP_IMAGE_RATIO = 3; /** - * Clear the image cache. Is a subdirectory is specified, only this directory is cleared. - * If no directory is specified, the whole cache is cleared. - * Only files are deleted, directories will remain. - * - * @param ImageEvent $event + * @return string root of the image cache directory in web space */ - public function clearCache(ImageEvent $event) - { - $path = $this->getCachePath($event->getCacheSubdirectory(), false); - - $this->clearDirectory($path); - } - - /** - * Recursively clears the specified directory. - * - * @param string $path the directory path - */ - protected function clearDirectory($path) - { - $iterator = new \DirectoryIterator($path); - - foreach ($iterator as $fileinfo) { - - if ($fileinfo->isDot()) continue; - - if ($fileinfo->isFile() || $fileinfo->isLink()) { - @unlink($fileinfo->getPathname()); - } elseif ($fileinfo->isDir()) { - $this->clearDirectory($fileinfo->getPathname()); - } - } + protected function getCacheDirFromWebRoot() { + return ConfigQuery::read('image_cache_dir_from_web_root', 'cache'); } /** @@ -138,9 +110,9 @@ class Image extends BaseAction implements EventSubscriberInterface // echo basename($source_file).": "; // Find cached file path - $cacheFilePath = $this->getCacheFilePath($subdir, $source_file, $event); + $cacheFilePath = $this->getCacheFilePath($subdir, $source_file, $event->isOriginalImage(), $event->getOptionsHash()); - $originalImagePathInCache = $this->getCacheFilePath($subdir, $source_file, $event, true); + $originalImagePathInCache = $this->getCacheFilePath($subdir, $source_file, true); if (! file_exists($cacheFilePath)) { @@ -359,94 +331,6 @@ class Image extends BaseAction implements EventSubscriberInterface return $image; } - /** - * Return the absolute URL to the cached image - * - * @param string $subdir the subdirectory related to cache base - * @param string $filename the safe filename, as returned by getCacheFilePath() - * @return string the absolute URL to the cached image - */ - protected function getCacheFileURL($subdir, $safe_filename) - { - $path = $this->getCachePathFromWebRoot($subdir); - - return URL::getInstance()->absoluteUrl(sprintf("%s/%s", $path, $safe_filename), null, URL::PATH_TO_FILE); - } - - /** - * Return the full path of the cached file - * - * @param string $subdir the subdirectory related to cache base - * @param string $filename the filename - * @param boolean $forceOriginalImage if true, the origiunal image path in the cache dir is returned. - * @return string the cache directory path relative to Web Root - */ - protected function getCacheFilePath($subdir, $filename, ImageEvent $event, $forceOriginalImage = false) - { - $path = $this->getCachePath($subdir); - - $safe_filename = preg_replace("[^:alnum:\-\._]", "-", strtolower(basename($filename))); - - // Keep original safe name if no tranformations are applied - if ($forceOriginalImage || $event->isOriginalImage()) - return sprintf("%s/%s", $path, $safe_filename); - else - return sprintf("%s/%s-%s", $path, $event->getOptionsHash(), $safe_filename); - } - - /** - * Return the cache directory path relative to Web Root - * - * @param string $subdir the subdirectory related to cache base, or null to get the cache directory only. - * @return string the cache directory path relative to Web Root - */ - protected function getCachePathFromWebRoot($subdir = null) - { - $cache_dir_from_web_root = ConfigQuery::read('image_cache_dir_from_web_root', 'cache'); - - if ($subdir != null) { - $safe_subdir = basename($subdir); - - $path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir); - } else - $path = $cache_dir_from_web_root; - - // Check if path is valid, e.g. in the cache dir - return $path; - } - - /** - * Return the absolute cache directory path - * - * @param string $subdir the subdirectory related to cache base, or null to get the cache base directory. - * @throws \RuntimeException if cache directory cannot be created - * @return string the absolute cache directory path - */ - protected function getCachePath($subdir = null, $create_if_not_exists = true) - { - $cache_base = $this->getCachePathFromWebRoot($subdir); - - $web_root = rtrim(THELIA_WEB_DIR, '/'); - - $path = sprintf("%s/%s", $web_root, $cache_base); - - // Create directory (recursively) if it does not exists. - if ($create_if_not_exists && !is_dir($path)) { - if (!@mkdir($path, 0777, true)) { - throw new ImageException(sprintf("Failed to create %s/%s image cache directory", $cache_base)); - } - } - - // Check if path is valid, e.g. in the cache dir - $cache_base = realpath(sprintf("%s/%s", $web_root, $this->getCachePathFromWebRoot())); - - if (strpos(realpath($path), $cache_base) !== 0) { - throw new \InvalidArgumentException(sprintf("Invalid cache path %s, with subdirectory %s", $path, $subdir)); - } - - return $path; - } - /** * Create a new Imagine object using current driver configuration * diff --git a/core/lib/Thelia/Action/Message.php b/core/lib/Thelia/Action/Message.php index faac35bf2..8918913fe 100644 --- a/core/lib/Thelia/Action/Message.php +++ b/core/lib/Thelia/Action/Message.php @@ -70,7 +70,7 @@ class Message extends BaseAction implements EventSubscriberInterface { $search = MessageQuery::create(); - if (null !== $message = MessageQuery::create()->findOneById($event->getMessageId())) { + if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) { $message ->setDispatcher($this->getDispatcher()) @@ -99,7 +99,7 @@ class Message extends BaseAction implements EventSubscriberInterface public function delete(MessageDeleteEvent $event) { - if (null !== ($message = MessageQuery::create()->findOneById($event->getMessageId()))) { + if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) { $message ->setDispatcher($this->getDispatcher()) diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php new file mode 100755 index 000000000..15266fac1 --- /dev/null +++ b/core/lib/Thelia/Action/Order.php @@ -0,0 +1,97 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\ProductPrice; +use Thelia\Model\ProductPriceQuery; +use Thelia\Model\CartItem; +use Thelia\Model\CartItemQuery; +use Thelia\Model\ConfigQuery; + +/** + * + * Class Order + * @package Thelia\Action + * @author Etienne Roudeix + */ +class Order extends BaseAction implements EventSubscriberInterface +{ + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setDeliveryAddress(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->chosenDeliveryAddress = $event->getDeliveryAddress(); + + $event->setOrder($order); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setDeliveryModule(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->setDeliveryModuleId($event->getDeliveryModule()); + $order->setPostage($event->getPostage()); + + $event->setOrder($order); + } + + /** + * 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::ORDER_SET_DELIVERY_ADDRESS => array("setDeliveryAddress", 128), + TheliaEvents::ORDER_SET_DELIVERY_MODULE => array("setDeliveryModule", 128), + ); + } +} diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php new file mode 100644 index 000000000..cb7bb04df --- /dev/null +++ b/core/lib/Thelia/Action/Product.php @@ -0,0 +1,206 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +use Thelia\Model\ProductQuery; +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\UpdatePositionEvent; +use Thelia\Core\Event\ProductToggleVisibilityEvent; +use Thelia\Core\Event\ProductAddContentEvent; +use Thelia\Core\Event\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; + +class Product extends BaseAction implements EventSubscriberInterface +{ + /** + * Create a new product entry + * + * @param ProductCreateEvent $event + */ + public function create(ProductCreateEvent $event) + { + $product = new ProductModel(); + + $product + ->setDispatcher($this->getDispatcher()) + + ->setRef($event->getRef()) + ->setTitle($event->getTitle()) + ->setLocale($event->getLocale()) + ->setVisible($event->getVisible()) + + // Set the default tax rule to this product + ->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true)) + + ->create($event->getDefaultCategory()) + ; + + $event->setProduct($product); + } + + /** + * Change a product + * + * @param ProductUpdateEvent $event + */ + public function update(ProductUpdateEvent $event) + { + $search = ProductQuery::create(); + + if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { + + $product + ->setDispatcher($this->getDispatcher()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->setChapo($event->getChapo()) + ->setPostscriptum($event->getPostscriptum()) + + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save(); + + $event->setProduct($product); + } + } + + /** + * Delete a product entry + * + * @param ProductDeleteEvent $event + */ + public function delete(ProductDeleteEvent $event) + { + if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { + + $product + ->setDispatcher($this->getDispatcher()) + ->delete() + ; + + $event->setProduct($product); + } + } + + /** + * Toggle product visibility. No form used here + * + * @param ActionEvent $event + */ + public function toggleVisibility(ProductToggleVisibilityEvent $event) + { + $product = $event->getProduct(); + + $product + ->setDispatcher($this->getDispatcher()) + ->setVisible($product->getVisible() ? false : true) + ->save() + ; + } + + /** + * Changes position, selecting absolute ou relative change. + * + * @param ProductChangePositionEvent $event + */ + 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(); + } + } + + public function addContent(ProductAddContentEvent $event) { + + if (ProductAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByProduct($event->getProduct())->count() <= 0) { + + $content = new ProductAssociatedContent(); + + $content + ->setProduct($event->getProduct()) + ->setContentId($event->getContentId()) + ->save() + ; + } + } + + public function removeContent(ProductDeleteContentEvent $event) { + + $content = ProductAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByProduct($event->getProduct())->findOne() + ; + + if ($content !== null) $content->delete(); + } + + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::PRODUCT_CREATE => array("create", 128), + TheliaEvents::PRODUCT_UPDATE => array("update", 128), + TheliaEvents::PRODUCT_DELETE => array("delete", 128), + TheliaEvents::PRODUCT_TOGGLE_VISIBILITY => array("toggleVisibility", 128), + + TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128), + + TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128), + TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128), + + ); + } +} diff --git a/core/lib/Thelia/Command/ReloadDatabaseCommand.php b/core/lib/Thelia/Command/ReloadDatabaseCommand.php index 70fab56d9..311b20552 100644 --- a/core/lib/Thelia/Command/ReloadDatabaseCommand.php +++ b/core/lib/Thelia/Command/ReloadDatabaseCommand.php @@ -54,6 +54,13 @@ class ReloadDatabaseCommand extends BaseModuleGenerate $connection = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); $connection = $connection->getWrappedConnection(); + $tables = $connection->query("SHOW TABLES"); + $connection->query("SET FOREIGN_KEY_CHECKS = 0"); + foreach($tables as $table) { + $connection->query(sprintf("DROP TABLE `%s`", $table[0])); + } + $connection->query("SET FOREIGN_KEY_CHECKS = 1"); + $database = new Database($connection); $output->writeln(array( '', diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index a586667d1..f7ef4806d 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -17,6 +17,11 @@ + + + + + @@ -37,6 +42,11 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 691cf2198..faf3b4241 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -24,6 +24,7 @@ + @@ -37,9 +38,12 @@ + +
+ @@ -51,13 +55,19 @@ - + + + + + + + @@ -201,6 +211,7 @@ + @@ -267,6 +278,10 @@ + + + + diff --git a/core/lib/Thelia/Config/Resources/routing.xml b/core/lib/Thelia/Config/Resources/routing.xml index a8ad18abf..efeea61e8 100755 --- a/core/lib/Thelia/Config/Resources/routing.xml +++ b/core/lib/Thelia/Config/Resources/routing.xml @@ -56,17 +56,6 @@ - - - install.xml - - %kernel.cache_dir% - %kernel.debug% - - - - - front.xml diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index dc650d8d6..af7c950af 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -85,7 +85,7 @@ - Thelia\Controller\Admin\CategoryController::toggleOnlineAction + Thelia\Controller\Admin\CategoryController::setToggleVisibilityAction @@ -95,11 +95,68 @@ Thelia\Controller\Admin\CategoryController::updatePositionAction + + + Thelia\Controller\Admin\CategoryController::addRelatedContentAction + + + + Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction + + + + Thelia\Controller\Admin\CategoryController::getAvailableRelatedContentAction + xml|json + + Thelia\Controller\Admin\CategoryController::getByParentIdAction xml|json + + + + Thelia\Controller\Admin\ProductController::defaultAction + + + + Thelia\Controller\Admin\ProductController::createAction + + + + Thelia\Controller\Admin\ProductController::updateAction + + + + Thelia\Controller\Admin\ProductController::processUpdateAction + + + + Thelia\Controller\Admin\ProductController::setToggleVisibilityAction + + + + Thelia\Controller\Admin\ProductController::deleteAction + + + + Thelia\Controller\Admin\ProductController::updatePositionAction + + + + Thelia\Controller\Admin\ProductController::addRelatedContentAction + + + + Thelia\Controller\Admin\ProductController::deleteRelatedContentAction + + + + Thelia\Controller\Admin\ProductController::getAvailableRelatedContentAction + xml|json + + diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index adbb7d529..c1e153af0 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -97,6 +97,7 @@ Thelia\Controller\Front\DefaultController::noAction cart + Thelia\Controller\Front\CartController::addItem @@ -111,6 +112,26 @@ cart + + Thelia\Controller\Front\OrderController::deliver + order_delivery + + + + Thelia\Controller\Front\DefaultController::noAction + order_delivery + + + + Thelia\Controller\Front\OrderController::pay + order_invoice + + + + Thelia\Controller\Front\DefaultController::noAction + order_invoice + + diff --git a/core/lib/Thelia/Config/Resources/routing/install.xml b/core/lib/Thelia/Config/Resources/routing/install.xml deleted file mode 100644 index 37ddde487..000000000 --- a/core/lib/Thelia/Config/Resources/routing/install.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - Thelia\Controller\Install\InstallController::index - - - - Thelia\Controller\Install\InstallController::checkPermission - - - - Thelia\Controller\Install\InstallController::databaseConnection - - - - Thelia\Controller\Install\InstallController::databaseSelection - - - - Thelia\Controller\Install\InstallController::generalInformation - - - - Thelia\Controller\Install\InstallController::thanks - - - diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index fad774023..7b9550610 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -224,7 +224,7 @@ abstract class AbstractCrudController extends BaseAdminController * @param unknown $updateEvent the update event * @return Response a response, or null to continue normal processing */ - protected function performAdditionalUpdateAction($updateeEvent) + protected function performAdditionalUpdateAction($updateEvent) { return null; } @@ -240,6 +240,17 @@ abstract class AbstractCrudController extends BaseAdminController return null; } + /** + * Put in this method post object position change processing if required. + * + * @param unknown $deleteEvent the delete event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalUpdatePositionAction($positionChangeEvent) + { + return null; + } + /** * Return the current list order identifier, updating it in the same time. */ @@ -309,14 +320,18 @@ abstract class AbstractCrudController extends BaseAdminController $this->adminLogAppend(sprintf("%s %s (ID %s) created", ucfirst($this->objectName), $this->getObjectLabel($createdObject), $this->getObjectId($createdObject))); } - $this->performAdditionalCreateAction($createEvent); + $response = $this->performAdditionalCreateAction($createEvent); - // Substitute _ID_ in the URL with the ID of the created object - $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl()); - - // Redirect to the success URL - $this->redirect($successUrl); + if ($response == null) { + // Substitute _ID_ in the URL with the ID of the created object + $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl()); + // Redirect to the success URL + $this->redirect($successUrl); + } + else { + return $response; + } } catch (FormValidationException $ex) { // Form cannot be validated @@ -396,16 +411,21 @@ abstract class AbstractCrudController extends BaseAdminController $this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject))); } - $this->performAdditionalUpdateAction($changeEvent); + $response = $this->performAdditionalUpdateAction($changeEvent); - // If we have to stay on the same page, do not redirect to the succesUrl, - // just redirect to the edit page again. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToEditionTemplate($this->getRequest()); + if ($response == null) { + // If we have to stay on the same page, do not redirect to the succesUrl, + // just redirect to the edit page again. + if ($this->getRequest()->get('save_mode') == 'stay') { + $this->redirectToEditionTemplate($this->getRequest()); + } + + // Redirect to the success URL + $this->redirect($changeForm->getSuccessUrl()); + } + else { + return $response; } - - // Redirect to the success URL - $this->redirect($changeForm->getSuccessUrl()); } catch (FormValidationException $ex) { // Form cannot be validated @@ -452,7 +472,14 @@ abstract class AbstractCrudController extends BaseAdminController return $this->errorPage($ex); } - $this->redirectToListTemplate(); + $response = $this->performAdditionalUpdatePositionAction($event); + + if ($response == null) { + $this->redirectToListTemplate(); + } + else { + return $response; + } } /** @@ -475,7 +502,7 @@ abstract class AbstractCrudController extends BaseAdminController return $this->errorPage($ex); } - $this->redirectToRoute('admin.categories.default'); + $this->redirectToListTemplate(); } /** diff --git a/core/lib/Thelia/Controller/Admin/AttributeAvController.php b/core/lib/Thelia/Controller/Admin/AttributeAvController.php index b3afa687d..1ab12a081 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeAvController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeAvController.php @@ -33,7 +33,7 @@ use Thelia\Form\AttributeAvCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages attributes-av sent by mail + * Manages attributes-av * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index 247b89632..48a65baa7 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -37,7 +37,7 @@ use Thelia\Core\Event\AttributeAvUpdateEvent; use Thelia\Core\Event\AttributeEvent; /** - * Manages attributes sent by mail + * Manages attributes * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index fba832ec8..4d0d15ef1 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -23,226 +23,178 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\Event\TheliaEvents; -use Thelia\Core\Event\CategoryCreateEvent; -use Thelia\Form\CategoryCreationForm; use Thelia\Core\Event\CategoryDeleteEvent; -use Thelia\Core\Event\CategoryUpdatePositionEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\CategoryUpdateEvent; +use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Model\CategoryQuery; use Thelia\Form\CategoryModificationForm; +use Thelia\Form\CategoryCreationForm; +use Thelia\Core\Event\UpdatePositionEvent; +use Thelia\Core\Event\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Core\Event\CategoryAddContentEvent; +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Model\FolderQuery; +use Thelia\Model\ContentQuery; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Model\CategoryAssociatedContentQuery; -class CategoryController extends BaseAdminController +/** + * Manages categories + * + * @author Franck Allimant + */ +class CategoryController extends AbstractCrudController { - /** - * Render the categories list, ensuring the sort order is set. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - protected function renderList() - { - return $this->render('categories', $this->getTemplateArgs()); + public function __construct() { + parent::__construct( + 'category', + 'manual', + 'category_order', + + 'admin.categories.default', + 'admin.categories.create', + 'admin.categories.update', + 'admin.categories.delete', + + TheliaEvents::CATEGORY_CREATE, + TheliaEvents::CATEGORY_UPDATE, + TheliaEvents::CATEGORY_DELETE, + TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, + TheliaEvents::CATEGORY_UPDATE_POSITION + ); } - protected function getTemplateArgs() - { - // Get the category ID - $category_id = $this->getRequest()->get('category_id', 0); + protected function getCreationForm() { + return new CategoryCreationForm($this->getRequest()); + } - // Find the current category order - $category_order = $this->getRequest()->get( - 'order', - $this->getSession()->get('admin.category_order', 'manual') + protected function getUpdateForm() { + return new CategoryModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) { + $createEvent = new CategoryCreateEvent(); + + $createEvent + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ->setParent($formData['parent']) + ->setVisible($formData['visible']) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) { + $changeEvent = new CategoryUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setParent($formData['parent']) + ; + + return $changeEvent; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { + + return new UpdatePositionEvent( + $this->getRequest()->get('category_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() { + return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0)); + } + + protected function eventContainsObject($event) { + return $event->hasCategory(); + } + + protected function hydrateObjectForm($object) { + + // Prepare the data that will hydrate the form + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'chapo' => $object->getChapo(), + 'description' => $object->getDescription(), + 'postscriptum' => $object->getPostscriptum(), + 'visible' => $object->getVisible(), + 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), + 'parent' => $object->getParent() ); - $args = array( - 'current_category_id' => $category_id, - 'category_order' => $category_order, + // Setup the object form + return new CategoryModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) { + return $event->hasCategory() ? $event->getCategory() : null; + } + + protected function getExistingObject() { + return CategoryQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('category_id', 0)); + } + + protected function getObjectLabel($object) { + return $object->getTitle(); + } + + protected function getObjectId($object) { + return $object->getId(); + } + + protected function getEditionArguments() + { + return array( + 'category_id' => $this->getRequest()->get('category_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') ); - - // Store the current sort order in session - $this->getSession()->set('admin.category_order', $category_order); - - return $args; } - /** - * The default action is displaying the categories list. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function defaultAction() - { - if (null !== $response = $this->checkAuth("admin.categories.view")) return $response; - return $this->renderList(); + protected function renderListTemplate($currentOrder) { + + // Get product order + $product_order = $this->getListOrderFromSession('product', 'product_order', 'manual'); + + return $this->render('categories', + array( + 'category_order' => $currentOrder, + 'product_order' => $product_order, + 'category_id' => $this->getRequest()->get('category_id', 0) + )); } - /** - * Create a new category object - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function createAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.create")) return $response; - - $error_msg = false; - - // Create the Creation Form - $creationForm = new CategoryCreationForm($this->getRequest()); - - try { - - // Validate the form, create the CategoryCreation event and dispatch it. - $form = $this->validateForm($creationForm, "POST"); - - $data = $form->getData(); - - $createEvent = new CategoryCreateEvent( - $data["title"], - $data["parent"], - $data["locale"] - ); - - $this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent); - - if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was created.")); - - $createdObject = $createEvent->getCategory(); - - // Log category creation - $this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getTitle(), $createdObject->getId())); - - // Substitute _ID_ in the URL with the ID of the created object - $successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl()); - - // Redirect to the success URL - $this->redirect($successUrl); - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any other error - $error_msg = $ex->getMessage(); - } - - $this->setupFormErrorContext("category creation", $error_msg, $creationForm, $ex); - - // At this point, the form has error, and should be redisplayed. - return $this->renderList(); + protected function redirectToListTemplate() { + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $this->getRequest()->get('category_id', 0)) + ); } - /** - * Load a category object for modification, and display the edit template. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function changeAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; + protected function renderEditionTemplate() { - // Load the category object - $category = CategoryQuery::create() - ->joinWithI18n($this->getCurrentEditionLocale()) - ->findOneById($this->getRequest()->get('category_id')); - - if ($category != null) { - - // Prepare the data that will hydrate the form - $data = array( - 'id' => $category->getId(), - 'locale' => $category->getLocale(), - 'title' => $category->getTitle(), - 'chapo' => $category->getChapo(), - 'description' => $category->getDescription(), - 'postscriptum' => $category->getPostscriptum(), - 'parent' => $category->getParent(), - 'visible' => $category->getVisible() ? true : false, - 'url' => $category->getUrl($this->getCurrentEditionLocale()) - // tbc !!! - ); - - // Setup the object form - $changeForm = new CategoryModificationForm($this->getRequest(), "form", $data); - - // Pass it to the parser - $this->getParserContext()->addForm($changeForm); - } - - // Render the edition template. - return $this->render('category-edit', $this->getTemplateArgs()); + return $this->render('category-edit', $this->getEditionArguments()); } - /** - * Save changes on a modified category object, and either go back to the category list, or stay on the edition page. - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function saveChangeAction() - { - // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - - $error_msg = false; - - // Create the form from the request - $changeForm = new CategoryModificationForm($this->getRequest()); - - // Get the category ID - $category_id = $this->getRequest()->get('category_id'); - - try { - - // Check the form against constraints violations - $form = $this->validateForm($changeForm, "POST"); - - // Get the form field values - $data = $form->getData(); - - $changeEvent = new CategoryUpdateEvent($data['id']); - - // Create and dispatch the change event - $changeEvent - ->setCategoryName($data['name']) - ->setLocale($data["locale"]) - ->setSymbol($data['symbol']) - ->setCode($data['code']) - ->setRate($data['rate']) - ; - - $this->dispatch(TheliaEvents::CATEGORY_UPDATE, $changeEvent); - - if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was updated.")); - - // Log category modification - $changedObject = $changeEvent->getCategory(); - - $this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getTitle(), $changedObject->getId())); - - // If we have to stay on the same page, do not redirect to the succesUrl, - // just redirect to the edit page again. - if ($this->getRequest()->get('save_mode') == 'stay') { - $this->redirectToRoute( - "admin.categories.update", - array('category_id' => $category_id) - ); - } - - // Redirect to the success URL - $this->redirect($changeForm->getSuccessUrl()); - } catch (FormValidationException $ex) { - // Form cannot be validated - $error_msg = $this->createStandardFormValidationErrorMessage($ex); - } catch (\Exception $ex) { - // Any other error - $error_msg = $ex->getMessage(); - } - - $this->setupFormErrorContext("category modification", $error_msg, $changeForm, $ex); - - // At this point, the form has errors, and should be redisplayed. - return $this->render('category-edit', array('category_id' => $category_id)); + protected function redirectToEditionTemplate() { + $this->redirectToRoute("admin.categories.update", $this->getEditionArguments()); } /** @@ -253,74 +205,130 @@ class CategoryController extends BaseAdminController // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - $changeEvent = new CategoryUpdateEvent($this->getRequest()->get('category_id', 0)); - - // Create and dispatch the change event - $changeEvent->setIsDefault(true); + $event = new CategoryToggleVisibilityEvent($this->getExistingObject()); try { - $this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent); + $this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event); } catch (\Exception $ex) { // Any error return $this->errorPage($ex); } - $this->redirectToRoute('admin.categories.default'); + // Ajax response -> no action + return $this->nullResponse(); } - /** - * Update categoryposition - */ - public function updatePositionAction() + protected function performAdditionalDeleteAction($deleteEvent) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $deleteEvent->getCategory()->getParent()) + ); + } + + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $updateEvent->getCategory()->getParent()) + ); + } + } + + protected function performAdditionalUpdatePositionAction($event) + { + + $category = CategoryQuery::create()->findPk($event->getObjectId()); + + if ($category != null) { + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $category->getParent()) + ); + } + + return null; + } + + public function getAvailableRelatedContentAction($categoryId, $folderId) { + + $result = array(); + + $folders = FolderQuery::create()->filterById($folderId)->find(); + + if ($folders !== null) { + + $list = ContentQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByFolder($folders, Criteria::IN) + ->filterById(CategoryAssociatedContentQuery::create()->select('content_id')->findByCategoryId($categoryId), Criteria::NOT_IN) + ->find(); + ; + + if ($list !== null) { + foreach($list as $item) { + $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); + } + } + } + + return $this->jsonResponse(json_encode($result)); + } + + public function addRelatedContentAction() { + // Check current user authorization if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - try { - $mode = $this->getRequest()->get('mode', null); + $content_id = intval($this->getRequest()->get('content_id')); - if ($mode == 'up') - $mode = CategoryUpdatePositionEvent::POSITION_UP; - else if ($mode == 'down') - $mode = CategoryUpdatePositionEvent::POSITION_DOWN; - else - $mode = CategoryUpdatePositionEvent::POSITION_ABSOLUTE; + if ($content_id > 0) { - $position = $this->getRequest()->get('position', null); - - $event = new CategoryUpdatePositionEvent( - $this->getRequest()->get('category_id', null), - $mode, - $this->getRequest()->get('position', null) + $event = new CategoryAddContentEvent( + $this->getExistingObject(), + $content_id ); - $this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event); - } catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); + try { + $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } } - $this->redirectToRoute('admin.categories.default'); + $this->redirectToEditionTemplate(); } - /** - * Delete a category object - * - * @return Symfony\Component\HttpFoundation\Response the response - */ - public function deleteAction() - { + public function deleteRelatedContentAction() { + // Check current user authorization - if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response; + if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; - // Get the category id, and dispatch the deleted request - $event = new CategoryDeleteEvent($this->getRequest()->get('category_id')); + $content_id = intval($this->getRequest()->get('content_id')); - $this->dispatch(TheliaEvents::CATEGORY_DELETE, $event); + if ($content_id > 0) { - if ($event->hasCategory()) - $this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $event->getCategory()->getTitle(), $event->getCategory()->getId())); + $event = new CategoryDeleteContentEvent( + $this->getExistingObject(), + $content_id + ); - $this->redirectToRoute('admin.categories.default'); + try { + $this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); } } diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php index ff0e4bb39..8701710b0 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigController.php @@ -33,7 +33,7 @@ use Thelia\Form\ConfigCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages variables sent by mail + * Manages variables * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/CurrencyController.php b/core/lib/Thelia/Controller/Admin/CurrencyController.php index 4f3fdaaea..f0081d698 100644 --- a/core/lib/Thelia/Controller/Admin/CurrencyController.php +++ b/core/lib/Thelia/Controller/Admin/CurrencyController.php @@ -33,7 +33,7 @@ use Thelia\Form\CurrencyCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages currencies sent by mail + * Manages currencies * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/FeatureAvController.php b/core/lib/Thelia/Controller/Admin/FeatureAvController.php index 25c7a5495..fc6571ccc 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureAvController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureAvController.php @@ -33,7 +33,7 @@ use Thelia\Form\FeatureAvCreationForm; use Thelia\Core\Event\UpdatePositionEvent; /** - * Manages features-av sent by mail + * Manages features-av * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php index 92cb89d33..f81f55919 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -37,7 +37,7 @@ use Thelia\Core\Event\FeatureAvUpdateEvent; use Thelia\Core\Event\FeatureEvent; /** - * Manages features sent by mail + * Manages features * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php new file mode 100644 index 000000000..2dc57d3cb --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -0,0 +1,356 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\ProductDeleteEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\ProductUpdateEvent; +use Thelia\Core\Event\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\Model\FolderQuery; +use Thelia\Model\ContentQuery; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Model\ProductAssociatedContentQuery; + +/** + * Manages products + * + * @author Franck Allimant + */ +class ProductController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'product', + 'manual', + 'product_order', + + 'admin.products.default', + 'admin.products.create', + 'admin.products.update', + 'admin.products.delete', + + TheliaEvents::PRODUCT_CREATE, + TheliaEvents::PRODUCT_UPDATE, + TheliaEvents::PRODUCT_DELETE, + + TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, + TheliaEvents::PRODUCT_UPDATE_POSITION + ); + } + + protected function getCreationForm() + { + return new ProductCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new ProductModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $createEvent = new ProductCreateEvent(); + + $createEvent + ->setRef($formData['ref']) + ->setTitle($formData['title']) + ->setLocale($formData['locale']) + ->setDefaultCategory($formData['default_category']) + ->setVisible($formData['visible']) + ; + + return $createEvent; + } + + protected function getUpdateEvent($formData) + { + $changeEvent = new ProductUpdateEvent($formData['id']); + + // Create and dispatch the change event + $changeEvent + ->setLocale($formData['locale']) + ->setTitle($formData['title']) + ->setChapo($formData['chapo']) + ->setDescription($formData['description']) + ->setPostscriptum($formData['postscriptum']) + ->setVisible($formData['visible']) + ->setUrl($formData['url']) + ->setParent($formData['parent']) + ; + + return $changeEvent; + } + + protected function createUpdatePositionEvent($positionChangeMode, $positionValue) + { + return new UpdatePositionEvent( + $this->getRequest()->get('product_id', null), + $positionChangeMode, + $positionValue + ); + } + + protected function getDeleteEvent() + { + return new ProductDeleteEvent($this->getRequest()->get('product_id', 0)); + } + + protected function eventContainsObject($event) + { + return $event->hasProduct(); + } + + 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()), + 'default_category' => $object->getDefaultCategoryId() + ); + + // Setup the object form + return new ProductModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasProduct() ? $event->getProduct() : null; + } + + protected function getExistingObject() + { + return ProductQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('product_id', 0)); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + 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), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') + ); + } + + protected function getCategoryId() { + // Trouver le category_id, soit depuis la reques, souit depuis le produit courant + $category_id = $this->getRequest()->get('category_id', null); + + if ($category_id == null) { + $product = $this->getExistingObject(); + + if ($product !== null) $category_id = $product->getDefaultCategoryId(); + } + + return $category_id != null ? $category_id : 0; + } + + protected function renderListTemplate($currentOrder) + { + $this->getListOrderFromSession('product', 'product_order', 'manual'); + + return $this->render('categories', + array( + 'product_order' => $currentOrder, + 'category_id' => $this->getCategoryId() + )); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute( + 'admin.products.default', + array('category_id' => $this->getCategoryId()) + ); + } + + protected function renderEditionTemplate() + { + return $this->render('product-edit', $this->getEditionArguments()); + } + + protected function redirectToEditionTemplate() + { + $this->redirectToRoute("admin.products.update", $this->getEditionArguments()); + } + + /** + * Online status toggle product + */ + public function setToggleVisibilityAction() + { + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $event = new ProductToggleVisibilityEvent($this->getExistingObject()); + + try { + $this->dispatch(TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, $event); + } catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + + // Ajax response -> no action + return $this->nullResponse(); + } + + protected function performAdditionalDeleteAction($deleteEvent) + { + // Redirect to parent product list + $this->redirectToRoute( + 'admin.products.default', + array('category_id' => $this->getCategoryId()) + ); + } + + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent product list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $this->getCategoryId()) + ); + } + } + + protected function performAdditionalUpdatePositionAction($positionEvent) + { + // Redirect to parent product list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $this->getCategoryId()) + ); + } + + public function getAvailableRelatedContentAction($productId, $folderId) + { + $result = array(); + + $folders = FolderQuery::create()->filterById($folderId)->find(); + + if ($folders !== null) { + + $list = ContentQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByFolder($folders, Criteria::IN) + ->filterById(ProductAssociatedContentQuery::create()->select('content_id')->findByProductId($productId), Criteria::NOT_IN) + ->find(); + ; + + if ($list !== null) { + foreach($list as $item) { + $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); + } + } + } + + return $this->jsonResponse(json_encode($result)); + } + + public function addRelatedContentAction() + { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new ProductAddContentEvent( + $this->getExistingObject(), + $content_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_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.products.update")) return $response; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new ProductDeleteContentEvent( + $this->getExistingObject(), + $content_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } +} diff --git a/core/lib/Thelia/Controller/Admin/TemplateController.php b/core/lib/Thelia/Controller/Admin/TemplateController.php index 3685a359a..c9e30612c 100644 --- a/core/lib/Thelia/Controller/Admin/TemplateController.php +++ b/core/lib/Thelia/Controller/Admin/TemplateController.php @@ -41,7 +41,7 @@ use Thelia\Core\Event\TemplateAddFeatureEvent; use Thelia\Core\Event\TemplateDeleteFeatureEvent; /** - * Manages templates sent by mail + * Manages product templates * * @author Franck Allimant */ diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 19e62a400..8ba0cb038 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -31,6 +31,7 @@ use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Router; use Thelia\Core\Security\SecurityContext; +use Thelia\Core\Translation\Translator; use Thelia\Tools\URL; use Thelia\Tools\Redirect; use Thelia\Core\Template\ParserContext; @@ -62,6 +63,14 @@ class BaseController extends ContainerAware return new Response(); } + /** + * Return a JSON response + */ + protected function jsonResponse($json_data) + { + return new Response($json_data, 200, array('content-type' => 'application/json')); + } + /** * Dispatch a Thelia event * @@ -89,7 +98,7 @@ class BaseController extends ContainerAware * * return the Translator * - * @return mixed \Thelia\Core\Translation\Translator + * @return Translator */ public function getTranslator() { @@ -281,4 +290,16 @@ class BaseController extends ContainerAware $this->accessDenied(); } } + + /** + * + * return an instance of \Swift_Mailer with good Transporter configured. + * + * @return \Swift_Mailer + */ + public function getMailer() + { + $mailer = $this->container->get('mailer'); + return $mailer->getSwiftMailer(); + } } diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index 1c4a13977..74e918b2d 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -57,4 +57,22 @@ class BaseFrontController extends BaseController $this->redirectToRoute("customer.login.view"); } } + + protected function checkCartNotEmpty() + { + $cart = $this->getSession()->getCart(); + if($cart===null || $cart->countCartItems() == 0) { + $this->redirectToRoute("cart.view"); + } + } + + protected function checkValidDelivery() + { + $order = $this->getSession()->getOrder(); + if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) { + $this->redirectToRoute("order.delivery"); + } + + + } } diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php new file mode 100755 index 000000000..75fa91b36 --- /dev/null +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -0,0 +1,197 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Controller\Front; + +use Propel\Runtime\Exception\PropelException; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Symfony\Component\HttpFoundation\Request; +use Thelia\Form\OrderDelivery; +use Thelia\Form\OrderPayment; +use Thelia\Log\Tlog; +use Thelia\Model\AddressQuery; +use Thelia\Model\AreaDeliveryModuleQuery; +use Thelia\Model\CountryQuery; +use Thelia\Model\ModuleQuery; +use Thelia\Model\Order; + +/** + * Class OrderController + * @package Thelia\Controller\Front + * @author Etienne Roudeix + */ +class OrderController extends BaseFrontController +{ + /** + * set delivery address + * set delivery module + */ + public function deliver() + { + $this->checkAuth(); + $this->checkCartNotEmpty(); + + $message = false; + + $orderDelivery = new OrderDelivery($this->getRequest()); + + try { + $form = $this->validateForm($orderDelivery, "post"); + + $deliveryAddressId = $form->get("delivery-address")->getData(); + $deliveryModuleId = $form->get("delivery-module")->getData(); + $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); + $deliveryModule = ModuleQuery::create()->findPk($deliveryModuleId); + + /* check that the delivery address belongs to the current customer */ + $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); + if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { + throw new \Exception("Delivery address does not belong to the current customer"); + } + + /* check that the delivery module fetches the delivery address area */ + if(AreaDeliveryModuleQuery::create() + ->filterByAreaId($deliveryAddress->getCountry()->getAreaId()) + ->filterByDeliveryModuleId($deliveryModuleId) + ->count() == 0) { + throw new \Exception("Delivery module cannot be use with selected delivery address"); + } + + /* try to 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()); + + $orderEvent = $this->getOrderEvent(); + $orderEvent->setDeliveryAddress($deliveryAddressId); + $orderEvent->setDeliveryModule($deliveryModuleId); + $orderEvent->setPostage($postage); + + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent); + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent); + + $this->redirectToRoute("order.invoice"); + + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); + } catch (PropelException $e) { + $this->getParserContext()->setGeneralError($e->getMessage()); + } catch (\Exception $e) { + $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage())); + + $orderDelivery->setErrorMessage($message); + + $this->getParserContext() + ->addForm($orderDelivery) + ->setGeneralError($message) + ; + } + + } + + /** + * set invoice address + * set payment module + */ + public function pay() + { + $this->checkAuth(); + $this->checkCartNotEmpty(); + $this->checkValidDelivery(); + + $message = false; + + $orderPayment = new OrderPayment($this->getRequest()); + + try { + $form = $this->validateForm($orderPayment, "post"); + + $deliveryAddressId = $form->get("delivery-address")->getData(); + $deliveryModuleId = $form->get("delivery-module")->getData(); + + /* check that the invoice address belongs to the current customer */ + $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); + if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { + throw new \Exception("Invoice address does not belong to the current customer"); + } + + $orderEvent = $this->getOrderEvent(); + $orderEvent->setInvoiceAddress($deliveryAddressId); + $orderEvent->setPaymentModule($deliveryModuleId); + + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent); + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent); + + $this->redirectToRoute("order.invoice"); + + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); + } catch (PropelException $e) { + $this->getParserContext()->setGeneralError($e->getMessage()); + } catch (\Exception $e) { + $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage())); + + $orderPayment->setErrorMessage($message); + + $this->getParserContext() + ->addForm($orderPayment) + ->setGeneralError($message) + ; + } + + } + + protected function getOrderEvent() + { + $order = $this->getOrder($this->getRequest()); + + return new OrderEvent($order); + } + + public function getOrder(Request $request) + { + $session = $request->getSession(); + + if (null !== $order = $session->getOrder()) { + return $order; + } + + $order = new Order(); + + $session->setOrder($order); + + return $order; + } +} diff --git a/core/lib/Thelia/Core/Event/CachedFileEvent.php b/core/lib/Thelia/Core/Event/CachedFileEvent.php new file mode 100644 index 000000000..8f3a026d9 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CachedFileEvent.php @@ -0,0 +1,94 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class CachedFileEvent extends ActionEvent +{ + /** + * @var string The complete file name (with path) of the source file + */ + protected $source_filepath = null; + /** + * @var string The target subdirectory in the cache + */ + protected $cache_subdirectory = null; + + /** + * @var string The absolute URL of the cached file (in the web space) + */ + protected $file_url = null; + + /** + * @var string The absolute path of the cached file + */ + protected $cache_filepath = null; + + public function getFileUrl() + { + return $this->file_url; + } + + public function setFileUrl($file_url) + { + $this->file_url = $file_url; + + return $this; + } + + public function getCacheFilepath() + { + return $this->cache_filepath; + } + + public function setCacheFilepath($cache_filepath) + { + $this->cache_filepath = $cache_filepath; + + return $this; + } + + public function getSourceFilepath() + { + return $this->source_filepath; + } + + public function setSourceFilepath($source_filepath) + { + $this->source_filepath = $source_filepath; + + return $this; + } + + public function getCacheSubdirectory() + { + return $this->cache_subdirectory; + } + + public function setCacheSubdirectory($cache_subdirectory) + { + $this->cache_subdirectory = $cache_subdirectory; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php b/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php new file mode 100644 index 000000000..3ca5b2ae5 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Category; + +class CategoryAddContentEvent extends CategoryEvent +{ + protected $content_id; + + public function __construct(Category $category, $content_id) + { + parent::__construct($category); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php index 5a687217c..41529019c 100644 --- a/core/lib/Thelia/Core/Event/CategoryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryCreateEvent.php @@ -28,13 +28,7 @@ class CategoryCreateEvent extends CategoryEvent protected $title; protected $parent; protected $locale; - - public function __construct($title, $parent, $locale) - { - $this->title = $title; - $this->parent = $parent; - $this->locale = $locale; - } + protected $visible; public function getTitle() { @@ -71,4 +65,16 @@ class CategoryCreateEvent extends CategoryEvent return $this; } + + public function getVisible() + { + return $this->visible; + } + + public function setVisible($visible) + { + $this->visible = $visible; + + return $this; + } } diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php b/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php new file mode 100644 index 000000000..bb28beb21 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Category; + +class CategoryDeleteContentEvent extends CategoryEvent +{ + protected $content_id; + + public function __construct(Category $category, $content_id) + { + parent::__construct($category); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php new file mode 100644 index 000000000..f90378e38 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class CategoryToggleVisibilityEvent extends CategoryEvent +{ +} diff --git a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php index 44e760549..f5f775a22 100644 --- a/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/CategoryUpdateEvent.php @@ -32,7 +32,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent protected $postscriptum; protected $url; - protected $visibility; protected $parent; public function __construct($category_id) @@ -100,18 +99,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent return $this; } - public function getVisibility() - { - return $this->visibility; - } - - public function setVisibility($visibility) - { - $this->visibility = $visibility; - - return $this; - } - public function getParent() { return $this->parent; diff --git a/core/lib/Thelia/Core/Event/DocumentEvent.php b/core/lib/Thelia/Core/Event/DocumentEvent.php new file mode 100644 index 000000000..f58d51083 --- /dev/null +++ b/core/lib/Thelia/Core/Event/DocumentEvent.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class DocumentEvent extends CachedFileEvent +{ + protected $document_path; + protected $document_url; + + /** + * @return the document file path + */ + public function getDocumentPath() + { + return $this->document_path; + } + + /** + * @param string $document_path the document file path + */ + public function setDocumentPath($document_path) + { + $this->document_path = $document_path; + + return $this; + } + + /** + * @return the document URL + */ + public function getDocumentUrl() + { + return $this->document_url; + } + + /** + * @param string $document_url the document URL + */ + public function setDocumentUrl($document_url) + { + $this->document_url = $document_url; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/ImageEvent.php b/core/lib/Thelia/Core/Event/ImageEvent.php index 5ea1581cd..462fa012d 100755 --- a/core/lib/Thelia/Core/Event/ImageEvent.php +++ b/core/lib/Thelia/Core/Event/ImageEvent.php @@ -23,22 +23,8 @@ namespace Thelia\Core\Event; -class ImageEvent extends ActionEvent +class ImageEvent extends CachedFileEvent { - /** - * @var string The complete file name (with path) of the source image - */ - protected $source_filepath = null; - /** - * @var string The target subdirectory in the image cache - */ - protected $cache_subdirectory = null; - - /** - * @var string The absolute URL of the cached image (in the web space) - */ - protected $file_url = null; - /** * @var string The absolute path of the cached image file */ @@ -121,6 +107,8 @@ class ImageEvent extends ActionEvent public function setCategory($category) { $this->category = $category; + + return $this; } public function getWidth() @@ -131,6 +119,8 @@ class ImageEvent extends ActionEvent public function setWidth($width) { $this->width = $width; + + return $this; } public function getHeight() @@ -141,6 +131,8 @@ class ImageEvent extends ActionEvent public function setHeight($height) { $this->height = $height; + + return $this; } public function getResizeMode() @@ -151,6 +143,8 @@ class ImageEvent extends ActionEvent public function setResizeMode($resize_mode) { $this->resize_mode = $resize_mode; + + return $this; } public function getBackgroundColor() @@ -161,6 +155,8 @@ class ImageEvent extends ActionEvent public function setBackgroundColor($background_color) { $this->background_color = $background_color; + + return $this; } public function getEffects() @@ -171,6 +167,8 @@ class ImageEvent extends ActionEvent public function setEffects(array $effects) { $this->effects = $effects; + + return $this; } public function getRotation() @@ -181,46 +179,8 @@ class ImageEvent extends ActionEvent public function setRotation($rotation) { $this->rotation = $rotation; - } - public function getFileUrl() - { - return $this->file_url; - } - - public function setFileUrl($file_url) - { - $this->file_url = $file_url; - } - - public function getCacheFilepath() - { - return $this->cache_filepath; - } - - public function setCacheFilepath($cache_filepath) - { - $this->cache_filepath = $cache_filepath; - } - - public function getSourceFilepath() - { - return $this->source_filepath; - } - - public function setSourceFilepath($source_filepath) - { - $this->source_filepath = $source_filepath; - } - - public function getCacheSubdirectory() - { - return $this->cache_subdirectory; - } - - public function setCacheSubdirectory($cache_subdirectory) - { - $this->cache_subdirectory = $cache_subdirectory; + return $this; } public function getQuality() @@ -231,6 +191,8 @@ class ImageEvent extends ActionEvent public function setQuality($quality) { $this->quality = $quality; + + return $this; } public function getOriginalFileUrl() @@ -241,6 +203,8 @@ class ImageEvent extends ActionEvent public function setOriginalFileUrl($original_file_url) { $this->original_file_url = $original_file_url; + + return $this; } public function getCacheOriginalFilepath() @@ -251,5 +215,7 @@ class ImageEvent extends ActionEvent public function setCacheOriginalFilepath($cache_original_filepath) { $this->cache_original_filepath = $cache_original_filepath; + + return $this; } } diff --git a/core/lib/Thelia/Controller/Install/BaseInstallController.php b/core/lib/Thelia/Core/Event/MailTransporterEvent.php similarity index 71% rename from core/lib/Thelia/Controller/Install/BaseInstallController.php rename to core/lib/Thelia/Core/Event/MailTransporterEvent.php index bac7a4f19..d47ac693f 100644 --- a/core/lib/Thelia/Controller/Install/BaseInstallController.php +++ b/core/lib/Thelia/Core/Event/MailTransporterEvent.php @@ -21,39 +21,32 @@ /* */ /*************************************************************************************/ -namespace Thelia\Controller\Install; -use Symfony\Component\HttpFoundation\Response; -use Thelia\Controller\BaseController; +namespace Thelia\Core\Event; + /** - * Class BaseInstallController - * @package Thelia\Controller\Install + * Class MailTransporterEvent + * @package Thelia\Core\Event * @author Manuel Raynaud */ -class BaseInstallController extends BaseController -{ +class MailTransporterEvent extends ActionEvent { /** - * @return a ParserInterface instance parser + * @var \Swift_Transport */ - protected function getParser() + protected $transporter; + + public function setMailerTransporter(\Swift_Transport $transporter) { - $parser = $this->container->get("thelia.parser"); - - // Define the template that shoud be used - $parser->setTemplate("install"); - - return $parser; + $this->transporter = $transporter; } - public function render($templateName, $args = array()) + public function getTransporter() { - return new Response($this->renderRaw($templateName, $args)); + return $this->transporter; } - public function renderRaw($templateName, $args = array()) + public function hasTransporter() { - $data = $this->getParser()->render($templateName, $args); - - return $data; + return null !== $this->transporter; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/OrderEvent.php new file mode 100755 index 000000000..349fd53a1 --- /dev/null +++ b/core/lib/Thelia/Core/Event/OrderEvent.php @@ -0,0 +1,140 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Order; + +class OrderEvent extends ActionEvent +{ + protected $order = null; + protected $invoiceAddress = null; + protected $deliveryAddress = null; + protected $deliveryModule = null; + protected $paymentModule = null; + protected $postage = null; + + /** + * @param Order $order + */ + public function __construct(Order $order) + { + $this->setOrder($order); + } + + /** + * @param Order $order + */ + public function setOrder(Order $order) + { + $this->order = $order; + } + + /** + * @param $address + */ + public function setInvoiceAddress($address) + { + $this->deliveryAddress = $address; + } + + /** + * @param $address + */ + public function setDeliveryAddress($address) + { + $this->deliveryAddress = $address; + } + + /** + * @param $module + */ + public function setDeliveryModule($module) + { + $this->deliveryModule = $module; + } + + /** + * @param $module + */ + public function setPaymentModule($module) + { + $this->paymentModule = $module; + } + + /** + * @param $postage + */ + public function setPostage($postage) + { + $this->postage = $postage; + } + + /** + * @return null|Order + */ + public function getOrder() + { + return $this->order; + } + + /** + * @return null|int + */ + public function getInvoiceAddress() + { + return $this->invoiceAddress; + } + + /** + * @return null|int + */ + public function getDeliveryAddress() + { + return $this->deliveryAddress; + } + + /** + * @return null|int + */ + public function getDeliveryModule() + { + return $this->deliveryModule; + } + + /** + * @return null|int + */ + public function getPaymentModule() + { + return $this->paymentModule; + } + + /** + * @return null|int + */ + public function getPostage() + { + return $this->postage; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductAddContentEvent.php b/core/lib/Thelia/Core/Event/ProductAddContentEvent.php new file mode 100644 index 000000000..8cd648753 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductAddContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; + +class ProductAddContentEvent extends ProductEvent +{ + protected $content_id; + + public function __construct(Product $product, $content_id) + { + parent::__construct($product); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductCreateEvent.php b/core/lib/Thelia/Core/Event/ProductCreateEvent.php new file mode 100644 index 000000000..d2d30a11a --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductCreateEvent.php @@ -0,0 +1,88 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductCreateEvent extends ProductEvent +{ + protected $ref; + protected $title; + protected $locale; + protected $default_category; + protected $visible; + + public function getRef() + { + return $this->ref; + } + + public function setRef($ref) + { + $this->ref = $ref; + return $this; + } + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + public function getDefaultCategory() + { + return $this->default_category; + } + + public function setDefaultCategory($default_category) + { + $this->default_category = $default_category; + return $this; + } + + public function getVisible() + { + return $this->visible; + } + + public function setVisible($visible) + { + $this->visible = $visible; + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php b/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php new file mode 100644 index 000000000..f3cdbda1f --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; + +class ProductDeleteContentEvent extends ProductEvent +{ + protected $content_id; + + public function __construct(Product $product, $content_id) + { + parent::__construct($product); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductDeleteEvent.php b/core/lib/Thelia/Core/Event/ProductDeleteEvent.php new file mode 100644 index 000000000..43273887c --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductDeleteEvent.php @@ -0,0 +1,44 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductDeleteEvent extends ProductEvent +{ + public function __construct($product_id) + { + $this->product_id = $product_id; + } + + public function getProductId() + { + return $this->product_id; + } + + public function setProductId($product_id) + { + $this->product_id = $product_id; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductEvent.php b/core/lib/Thelia/Core/Event/ProductEvent.php new file mode 100644 index 000000000..6decd8101 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductEvent.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; +use Thelia\Core\Event\ActionEvent; + +class ProductEvent extends ActionEvent +{ + public $product = null; + + public function __construct(Product $product = null) + { + $this->product = $product; + } + + public function hasProduct() + { + return ! is_null($this->product); + } + + public function getProduct() + { + return $this->product; + } + + public function setProduct(Product $product) + { + $this->product = $product; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php b/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php new file mode 100644 index 000000000..732cfac76 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php @@ -0,0 +1,28 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductToggleVisibilityEvent extends ProductEvent +{ +} diff --git a/core/lib/Thelia/Core/Event/ProductUpdateEvent.php b/core/lib/Thelia/Core/Event/ProductUpdateEvent.php new file mode 100644 index 000000000..8ade33c74 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductUpdateEvent.php @@ -0,0 +1,113 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductUpdateEvent extends ProductCreateEvent +{ + protected $product_id; + + protected $chapo; + protected $description; + protected $postscriptum; + + protected $url; + protected $parent; + + public function __construct($product_id) + { + $this->product_id = $product_id; + } + + public function getProductId() + { + return $this->product_id; + } + + public function setProductId($product_id) + { + $this->product_id = $product_id; + + return $this; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + + return $this; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + + return $this; + } + + public function getUrl() + { + return $this->url; + } + + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 2867762aa..dab2db208 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -145,52 +145,46 @@ final class TheliaEvents // -- END ADDRESS MANAGEMENT --------------------------------------------------------- - /** - * Sent once the category creation form has been successfully validated, and before category insertion in the database. - */ - const BEFORE_CREATECATEGORY = "action.before_createcategory"; + // -- Categories management ----------------------------------------------- - /** - * Create, change or delete a category - */ - const CATEGORY_CREATE = "action.createCategory"; - const CATEGORY_UPDATE = "action.updateCategory"; - const CATEGORY_DELETE = "action.deleteCategory"; - - /** - * Toggle category visibility - */ + const CATEGORY_CREATE = "action.createCategory"; + const CATEGORY_UPDATE = "action.updateCategory"; + const CATEGORY_DELETE = "action.deleteCategory"; const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; + const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition"; - /** - * Change category position - */ - const CATEGORY_CHANGE_POSITION = "action.updateCategoryPosition"; + const CATEGORY_ADD_CONTENT = "action.categoryAddContent"; + const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent"; - /** - * Sent just after a successful insert of a new category in the database. - */ + const BEFORE_CREATECATEGORY = "action.before_createcategory"; const AFTER_CREATECATEGORY = "action.after_createcategory"; - /** - * Sent befonre deleting a category - */ - const BEFORE_DELETECATEGORY = "action.before_deletecategory"; - /** - * Sent just after a successful delete of a category from the database. - */ + const BEFORE_DELETECATEGORY = "action.before_deletecategory"; const AFTER_DELETECATEGORY = "action.after_deletecategory"; - /** - * Sent just before a successful change of a category in the database. - */ const BEFORE_UPDATECATEGORY = "action.before_updateCategory"; - - /** - * Sent just after a successful change of a category in the database. - */ const AFTER_UPDATECATEGORY = "action.after_updateCategory"; + // -- Product management ----------------------------------------------- + + const PRODUCT_CREATE = "action.createProduct"; + const PRODUCT_UPDATE = "action.updateProduct"; + const PRODUCT_DELETE = "action.deleteProduct"; + 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 BEFORE_CREATEPRODUCT = "action.before_createproduct"; + const AFTER_CREATEPRODUCT = "action.after_createproduct"; + + const BEFORE_DELETEPRODUCT = "action.before_deleteproduct"; + const AFTER_DELETEPRODUCT = "action.after_deleteproduct"; + + const BEFORE_UPDATEPRODUCT = "action.before_updateProduct"; + const AFTER_UPDATEPRODUCT = "action.after_updateProduct"; + /** * sent when a new existing cat id duplicated. This append when current customer is different from current cart */ @@ -218,13 +212,25 @@ final class TheliaEvents const CART_DELETEITEM = "action.deleteArticle"; + /** + * Order linked event + */ + const ORDER_SET_BILLING_ADDRESS = "action.order.setBillingAddress"; + const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress"; + const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule"; + /** * Sent on image processing */ const IMAGE_PROCESS = "action.processImage"; /** - * Sent on cimage cache clear request + * Sent on document processing + */ + const DOCUMENT_PROCESS = "action.processDocument"; + + /** + * Sent on image cache clear request */ const IMAGE_CLEAR_CACHE = "action.clearImageCache"; @@ -430,4 +436,9 @@ final class TheliaEvents const BEFORE_DELETEFEATURE_AV = "action.before_deleteFeatureAv"; const AFTER_DELETEFEATURE_AV = "action.after_deleteFeatureAv"; + /** + * sent when system find a mailer transporter. + */ + const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config'; + } diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index c723c2112..9de281dbe 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -28,8 +28,10 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Router; use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserInterface; +use Thelia\Exception\OrderException; use Thelia\Tools\Redirect; use Thelia\Tools\URL; use Thelia\Core\Security\Exception\AuthenticationException; @@ -87,6 +89,19 @@ 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()) { + case OrderException::CART_EMPTY: + // Redirect to the cart template + Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL)); + break; + case OrderException::UNDEFINED_DELIVERY: + // Redirect to the delivery choice template + Redirect::exec($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL)); + break; + } + + throw $e; } } diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index e9e3d50bf..8a0952ff4 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -29,6 +29,7 @@ use Thelia\Exception\InvalidCartException; use Thelia\Model\CartQuery; use Thelia\Model\Cart; use Thelia\Model\Currency; +use Thelia\Model\Order; use Thelia\Tools\URL; use Thelia\Model\Lang; @@ -43,6 +44,8 @@ use Thelia\Model\Lang; class Session extends BaseSession { /** + * @param bool $forceDefault + * * @return \Thelia\Model\Lang|null */ public function getLang($forceDefault = true) @@ -205,22 +208,22 @@ class Session extends BaseSession return $this; } - /** - * assign delivery id in session - * - * @param $delivery_id - * @return $this - */ - public function setDelivery($delivery_id) + // -- Order ------------------------------------------------------------------ + + + public function setOrder(Order $order) { - $this->set("thelia.delivery_id", $delivery_id); + $this->set("thelia.order", $order); return $this; } - public function getDelivery() + /** + * @return Order + */ + public function getOrder() { - return $this->get("thelia.delivery_id"); + return $this->get("thelia.order"); } diff --git a/core/lib/Thelia/Core/Routing/RewritingRouter.php b/core/lib/Thelia/Core/Routing/RewritingRouter.php index 2b663a979..9b736a614 100644 --- a/core/lib/Thelia/Core/Routing/RewritingRouter.php +++ b/core/lib/Thelia/Core/Routing/RewritingRouter.php @@ -128,7 +128,7 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface */ public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { - // TODO: Implement generate() method. + throw new RouteNotFoundException(); } /** diff --git a/core/lib/Thelia/Core/Template/Loop/Address.php b/core/lib/Thelia/Core/Template/Loop/Address.php index 1321592f4..9ca4352e9 100755 --- a/core/lib/Thelia/Core/Template/Loop/Address.php +++ b/core/lib/Thelia/Core/Template/Loop/Address.php @@ -54,7 +54,13 @@ class Address extends BaseLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntListTypeArgument('id'), + new Argument( + 'id', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('*', 'any')) + ) + ), new Argument( 'customer', new TypeCollection( @@ -63,8 +69,14 @@ class Address extends BaseLoop ), 'current' ), - Argument::createBooleanTypeArgument('default'), - Argument::createIntListTypeArgument('exclude') + Argument::createBooleanOrBothTypeArgument('default'), + new Argument( + 'exclude', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('none')) + ) + ) ); } @@ -79,7 +91,7 @@ class Address extends BaseLoop $id = $this->getId(); - if (null !== $id) { + if (null !== $id && !in_array($id, array('*', 'any'))) { $search->filterById($id, Criteria::IN); } @@ -106,7 +118,7 @@ class Address extends BaseLoop $exclude = $this->getExclude(); - if (!is_null($exclude)) { + if (null !== $exclude && 'none' !== $exclude) { $search->filterById($exclude, Criteria::NOT_IN); } diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 253c48da7..d85f75fa6 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -53,8 +53,12 @@ class AssociatedContent extends Content { $argumentCollection = parent::getArgDefinitions(); - $argumentCollection->addArgument(Argument::createIntTypeArgument('product')) - ->addArgument(Argument::createIntTypeArgument('category')); + $argumentCollection + ->addArgument(Argument::createIntTypeArgument('product')) + ->addArgument(Argument::createIntTypeArgument('category')) + ->addArgument(Argument::createIntTypeArgument('exclude_product')) + ->addArgument(Argument::createIntTypeArgument('exclude_category')) + ; $argumentCollection->get('order')->default = "associated_content"; @@ -91,6 +95,28 @@ class AssociatedContent extends Content $search->filterByCategoryId($category, Criteria::EQUAL); } + $exclude_product = $this->getExcludeProduct(); + + // If we have to filter by template, find all attributes assigned to this template, and filter by found IDs + if (null !== $exclude_product) { + // Exclure tous les attribut qui sont attachés aux templates indiqués + $search->filterById( + ProductAssociatedContentQuery::create()->filterByProductId($exclude_product)->select('product_id')->find(), + Criteria::NOT_IN + ); + } + + $exclude_category = $this->getExcludeCategory(); + + // If we have to filter by template, find all attributes assigned to this template, and filter by found IDs + if (null !== $exclude_category) { + // Exclure tous les attribut qui sont attachés aux templates indiqués + $search->filterById( + CategoryAssociatedContentQuery::create()->filterByProductId($exclude_category)->select('category_id')->find(), + Criteria::NOT_IN + ); + } + $order = $this->getOrder(); $orderByAssociatedContent = array_search('associated_content', $order); $orderByAssociatedContentReverse = array_search('associated_content_reverse', $order); diff --git a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php index 2aaa173dc..6f5f23707 100644 --- a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php +++ b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php @@ -29,7 +29,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\ModuleQuery; /** - * Class Delivery * @package Thelia\Core\Template\Loop * @author Manuel Raynaud */ @@ -93,6 +92,8 @@ class BaseSpecificModule extends BaseI18nLoop { $search = ModuleQuery::create(); + $search->filterByActivate(1); + if (null !== $id = $this->getId()) { $search->filterById($id); } diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index f65afdf40..3c8724d68 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -13,6 +13,7 @@ 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\Model\CountryQuery; class Cart extends BaseLoop { @@ -82,7 +83,7 @@ class Cart extends BaseLoop foreach ($cartItems as $cartItem) { $product = $cartItem->getProduct(); - //$product->setLocale($this->request->getSession()->getLocale()); + $productSaleElement = $cartItem->getProductSaleElements(); $loopResultRow = new LoopResultRow($result, $cartItem, $this->versionable, $this->timestampable, $this->countable); @@ -92,6 +93,17 @@ class Cart extends BaseLoop $loopResultRow->set("QUANTITY", $cartItem->getQuantity()); $loopResultRow->set("PRICE", $cartItem->getPrice()); $loopResultRow->set("PRODUCT_ID", $product->getId()); + $loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale())) + ->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("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 2b1156b98..bd1c32de2 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -173,6 +173,22 @@ class Category extends BaseI18nLoop $loopResult = new LoopResult($categories); foreach ($categories as $category) { + + // Find previous and next category + $previous = CategoryQuery::create() + ->filterByParent($category->getParent()) + ->filterByPosition($category->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() + ; + + $next = CategoryQuery::create() + ->filterByParent($category->getParent()) + ->filterByPosition($category->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + /* * no cause pagination lost : * if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue; @@ -193,7 +209,13 @@ class Category extends BaseI18nLoop ->set("PRODUCT_COUNT", $category->countChild()) ->set("VISIBLE", $category->getVisible() ? "1" : "0") ->set("POSITION", $category->getPosition()) - ; + + ->set("HAS_PREVIOUS", $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + + ->set("PREVIOUS", $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ; $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php index afcd0410e..712767954 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, array $exclude, LoopResult &$loopResult) + protected function buildCategoryTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult) { if ($level > $max_level) return; @@ -73,7 +73,7 @@ class CategoryTree extends BaseI18nLoop if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible); - $search->filterById($exclude, Criteria::NOT_IN); + if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN); $search->orderByPosition(Criteria::ASC); diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index 2d849b218..a29cb2e60 100755 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -61,6 +61,7 @@ class Content extends BaseI18nLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntListTypeArgument('folder'), + Argument::createIntListTypeArgument('folder_default'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('current_folder'), Argument::createIntTypeArgument('depth', 1), @@ -97,9 +98,20 @@ class Content extends BaseI18nLoop } $folder = $this->getFolder(); + $folderDefault = $this->getFolderDefault(); - if (!is_null($folder)) { - $folders = FolderQuery::create()->filterById($folder, Criteria::IN)->find(); + if (!is_null($folder) || !is_null($folderDefault)) { + + $foldersIds = array(); + if (!is_array($folder)) { + $folder = array(); + } + if (!is_array($folderDefault)) { + $folderDefault = array(); + } + + $foldersIds = array_merge($foldersIds, $folder, $folderDefault); + $folders =FolderQuery::create()->filterById($foldersIds, Criteria::IN)->find(); $depth = $this->getDepth(); @@ -164,12 +176,12 @@ class Content extends BaseI18nLoop $search->addDescendingOrderByColumn('i18n_TITLE'); break; case "manual": - if(null === $folder || count($folder) != 1) + if(null === $foldersIds || count($foldersIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single folder argument'); $search->orderByPosition(Criteria::ASC); break; case "manual_reverse": - if(null === $folder || count($folder) != 1) + if(null === $foldersIds || count($foldersIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single folder argument'); $search->orderByPosition(Criteria::DESC); break; diff --git a/core/lib/Thelia/Core/Template/Loop/Country.php b/core/lib/Thelia/Core/Template/Loop/Country.php index f14b97efc..3a05b684a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Country.php +++ b/core/lib/Thelia/Core/Template/Loop/Country.php @@ -87,7 +87,7 @@ class Country extends BaseI18nLoop if (true === $withArea) { $search->filterByAreaId(null, Criteria::ISNOTNULL); - } elseif (false == $withArea) { + } elseif (false === $withArea) { $search->filterByAreaId(null, Criteria::ISNULL); } diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php index a0e9ebb7a..5d33d398d 100644 --- a/core/lib/Thelia/Core/Template/Loop/Delivery.php +++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php @@ -22,9 +22,12 @@ /*************************************************************************************/ 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\Model\CountryQuery; +use Thelia\Module\BaseModule; /** * Class Delivery @@ -50,6 +53,19 @@ class Delivery extends BaseSpecificModule $search = parent::exec($pagination); /* manage translations */ $locale = $this->configureI18nProcessing($search); + + $search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL); + + $countryId = $this->getCountry(); + if(null !== $countryId) { + $country = CountryQuery::create()->findPk($countryId); + if(null === $country) { + throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop'); + } + } else { + $country = CountryQuery::create()->findOneByByDefault(1); + } + /* perform search */ $deliveryModules = $this->search($search, $pagination); @@ -73,7 +89,7 @@ class Delivery extends BaseSpecificModule ->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO')) ->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION')) ->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set('PRICE', $moduleInstance->calculate($this->getCountry())) + ->set('POSTAGE', $moduleInstance->getPostage($country)) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Document.php b/core/lib/Thelia/Core/Template/Loop/Document.php new file mode 100644 index 000000000..0e7e979c9 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Document.php @@ -0,0 +1,277 @@ +. */ +/* */ +/*************************************************************************************/ + +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\TheliaEvents; +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Type\TypeCollection; +use Thelia\Type\EnumListType; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Template\Element\LoopResultRow; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Type\EnumType; +use Thelia\Log\Tlog; + +/** + * The document loop + * + * @author Franck Allimant + */ +class Document extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @var array Possible document sources + */ + protected $possible_sources = array('category', 'product', 'folder', 'content'); + + /** + * @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection + */ + protected function getArgDefinitions() + { + $collection = new ArgumentCollection( + + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('exclude'), + new Argument( + 'order', + new TypeCollection( + new EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual-reverse', 'random')) + ), + 'manual' + ), + Argument::createIntTypeArgument('lang'), + + Argument::createIntTypeArgument('category'), + Argument::createIntTypeArgument('product'), + Argument::createIntTypeArgument('folder'), + Argument::createIntTypeArgument('content'), + + new Argument( + 'source', + new TypeCollection( + new EnumType($this->possible_sources) + ) + ), + Argument::createIntTypeArgument('source_id') + ); + + // Add possible document sources + foreach ($this->possible_sources as $source) { + $collection->addArgument(Argument::createIntTypeArgument($source)); + } + + return $collection; + } + + /** + * Dynamically create the search query, and set the proper filter and order + * + * @param string $source a valid source identifier (@see $possible_sources) + * @param int $object_id the source object ID + * @return ModelCriteria the propel Query object + */ + protected function createSearchQuery($source, $object_id) + { + $object = ucfirst($source); + + $queryClass = sprintf("\Thelia\Model\%sDocumentQuery", $object); + $filterMethod = sprintf("filterBy%sId", $object); + + // xxxDocumentQuery::create() + $method = new \ReflectionMethod($queryClass, 'create'); + $search = $method->invoke(null); // Static ! + + // $query->filterByXXX(id) + if (! is_null($object_id)) { + $method = new \ReflectionMethod($queryClass, $filterMethod); + $method->invoke($search, $object_id); + } + + $orders = $this->getOrder(); + + // Results ordering + foreach ($orders as $order) { + switch ($order) { + case "alpha": + $search->addAscendingOrderByColumn('i18n_TITLE'); + break; + case "alpha-reverse": + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + case "manual-reverse": + $search->orderByPosition(Criteria::DESC); + break; + case "manual": + $search->orderByPosition(Criteria::ASC); + break; + case "random": + $search->clearOrderByColumns(); + $search->addAscendingOrderByColumn('RAND()'); + break(2); + break; + } + } + + return $search; + } + + /** + * Dynamically create the search query, and set the proper filter and order + * + * @param string $object_type (returned) the a valid source identifier (@see $possible_sources) + * @param string $object_id (returned) the ID of the source object + * @return ModelCriteria the propel Query object + */ + protected function getSearchQuery(&$object_type, &$object_id) + { + $search = null; + + // Check form source="product" source_id="123" style arguments + $source = $this->getSource(); + + if (! is_null($source)) { + + $source_id = $this->getSourceId(); + $id = $this->getId(); + + // echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."
"; + + if (is_null($source_id) && is_null($id)) { + throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified"); + } + + $search = $this->createSearchQuery($source, $source_id); + + $object_type = $source; + $object_id = $source_id; + } else { + // Check for product="id" folder="id", etc. style arguments + foreach ($this->possible_sources as $source) { + + $argValue = intval($this->getArgValue($source)); + + if ($argValue > 0) { + + $search = $this->createSearchQuery($source, $argValue); + + $object_type = $source; + $object_id = $argValue; + + break; + } + } + } + + if ($search == null) + throw new \InvalidArgumentException(sprintf("Unable to find document source. Valid sources are %s", implode(',', $this->possible_sources))); + + return $search; + } + + /** + * @param unknown $pagination + */ + public function exec(&$pagination) + { + // Select the proper query to use, and get the object type + $object_type = $object_id = null; + + $search = $this->getSearchQuery($object_type, $object_id); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (! is_null($id)) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + if (!is_null($exclude)) + $search->filterById($exclude, Criteria::NOT_IN); + + // Create document processing event + $event = new DocumentEvent($this->request); + + // echo "sql=".$search->toString(); + + $results = $this->search($search, $pagination); + + $loopResult = new LoopResult($results); + + foreach ($results as $result) { + + // Create document processing event + $event = new DocumentEvent($this->request); + + // Put source document file path + $source_filepath = sprintf("%s%s/%s/%s", + THELIA_ROOT, + ConfigQuery::read('documents_library_path', 'local/media/documents'), + $object_type, + $result->getFile() + ); + + $event->setSourceFilepath($source_filepath); + $event->setCacheSubdirectory($object_type); + + try { + // Dispatch document processing event + $this->dispatcher->dispatch(TheliaEvents::DOCUMENT_PROCESS, $event); + + $loopResultRow = new LoopResultRow($loopResult, $result, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("ID" , $result->getId()) + ->set("LOCALE" ,$locale) + ->set("DOCUMENT_URL" , $event->getFileUrl()) + ->set("DOCUMENT_PATH" , $event->getCacheFilepath()) + ->set("ORIGINAL_DOCUMENT_PATH", $source_filepath) + ->set("TITLE" , $result->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $result->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $result->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $result->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("POSITION" , $result->getPosition()) + ->set("OBJECT_TYPE" , $object_type) + ->set("OBJECT_ID" , $object_id) + ; + + $loopResult->addRow($loopResultRow); + } + catch (\Exception $ex) { + // Ignore the result and log an error + Tlog::getInstance()->addError("Failed to process document in document loop: ", $this->args); + } + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index c7714731b..8d0c99400 100755 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -123,8 +123,10 @@ class Image extends BaseI18nLoop $search = $method->invoke(null); // Static ! // $query->filterByXXX(id) - $method = new \ReflectionMethod($queryClass, $filterMethod); - $method->invoke($search, $object_id); + if (! is_null($object_id)) { + $method = new \ReflectionMethod($queryClass, $filterMethod); + $method->invoke($search, $object_id); + } $orders = $this->getOrder(); @@ -171,11 +173,12 @@ class Image extends BaseI18nLoop if (! is_null($source)) { $source_id = $this->getSourceId(); + $id = $this->getId(); - // echo "source = ".$this->getSource().", id=".$source_id." - ".$this->getArg('source_id')->getValue()."
"; + //echo "source = ".$this->getSourceId()."source_id=$source_id, id=$id
"; - if (is_null($source_id)) { - throw new \InvalidArgumentException("'source_id' argument cannot be null if 'source' argument is specified."); + if (is_null($source_id) && is_null($id)) { + throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified"); } $search = $this->createSearchQuery($source, $source_id); @@ -211,6 +214,7 @@ class Image extends BaseI18nLoop */ public function exec(&$pagination) { + // Select the proper query to use, and get the object type $object_type = $object_id = null; @@ -282,7 +286,7 @@ class Image extends BaseI18nLoop // Put source image file path $source_filepath = sprintf("%s%s/%s/%s", THELIA_ROOT, - ConfigQuery::read('documents_library_path', 'local/media/images'), + ConfigQuery::read('images_library_path', 'local/media/images'), $object_type, $result->getFile() ); @@ -313,7 +317,8 @@ 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/Payment.php b/core/lib/Thelia/Core/Template/Loop/Payment.php new file mode 100644 index 000000000..542ffb590 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Payment.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +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; + +/** + * Class Payment + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Payment extends BaseSpecificModule +{ + + public function getArgDefinitions() + { + $collection = parent::getArgDefinitions(); + + return $collection; + } + + public function exec(&$pagination) + { + $search = parent::exec($pagination); + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $search->filterByType(BaseModule::PAYMENT_MODULE_TYPE, Criteria::EQUAL); + + /* perform search */ + $paymentModules = $this->search($search, $pagination); + + $loopResult = new LoopResult($paymentModules); + + foreach ($paymentModules as $paymentModule) { + $loopResultRow = new LoopResultRow($loopResult, $paymentModule, $this->versionable, $this->timestampable, $this->countable); + + $moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); + if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) { + throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode())); + } + $moduleInstance = $moduleReflection->newInstance(); + + $moduleInstance->setRequest($this->request); + $moduleInstance->setDispatcher($this->dispatcher); + + $loopResultRow + ->set('ID', $paymentModule->getId()) + ->set('TITLE', $paymentModule->getVirtualColumn('i18n_TITLE')) + ->set('CHAPO', $paymentModule->getVirtualColumn('i18n_CHAPO')) + ->set('DESCRIPTION', $paymentModule->getVirtualColumn('i18n_DESCRIPTION')) + ->set('POSTSCRIPTUM', $paymentModule->getVirtualColumn('i18n_POSTSCRIPTUM')) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index f6ab423ab..7c71e542b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -73,6 +73,7 @@ class Product extends BaseI18nLoop ) ), Argument::createIntListTypeArgument('category'), + Argument::createIntListTypeArgument('category_default'), Argument::createBooleanTypeArgument('new'), Argument::createBooleanTypeArgument('promo'), Argument::createFloatTypeArgument('min_price'), @@ -88,7 +89,7 @@ class Product extends BaseI18nLoop new Argument( 'order', new TypeCollection( - new Type\EnumListType(array('alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id')) + new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id')) ), 'alpha' ), @@ -170,9 +171,20 @@ class Product extends BaseI18nLoop } $category = $this->getCategory(); + $categoryDefault = $this->getCategoryDefault(); - if (!is_null($category)) { - $categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find(); + if (!is_null($category) ||!is_null($categoryDefault)) { + + $categoryIds = array(); + if (!is_array($category)) { + $category = array(); + } + if (!is_array($categoryDefault)) { + $categoryDefault = array(); + } + + $categoryIds = array_merge($categoryIds, $category, $categoryDefault); + $categories =CategoryQuery::create()->filterById($categoryIds, Criteria::IN)->find(); $depth = $this->getDepth(); @@ -527,6 +539,12 @@ class Product 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; @@ -540,12 +558,12 @@ class Product extends BaseI18nLoop $search->addDescendingOrderByColumn('real_lowest_price'); break; case "manual": - if(null === $category || count($category) != 1) + if(null === $categoryIds || count($categoryIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); $search->orderByPosition(Criteria::ASC); break; case "manual_reverse": - if(null === $category || count($category) != 1) + if(null === $categoryIds || count($categoryIds) != 1) throw new \InvalidArgumentException('Manual order cannot be set without single category argument'); $search->orderByPosition(Criteria::DESC); break; @@ -579,32 +597,62 @@ class Product extends BaseI18nLoop $loopResult = new LoopResult($products); + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic + foreach ($products as $product) { + $loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable); $price = $product->getRealLowestPrice(); - $taxedPrice = $product->getTaxedPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic + + $taxedPrice = null === $price ? null : $product->getTaxedPrice( + $taxCountry ); + // Find previous and next product, in the default category. + $default_category_id = $product->getDefaultCategoryId(); - $loopResultRow->set("ID", $product->getId()) - ->set("REF",$product->getRef()) - ->set("IS_TRANSLATED",$product->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE",$locale) - ->set("TITLE",$product->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("URL", $product->getUrl($locale)) - ->set("BEST_PRICE", $price) - ->set("BEST_PRICE_TAX", $taxedPrice - $price) - ->set("BEST_TAXED_PRICE", $taxedPrice) - ->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo')) - ->set("IS_NEW", $product->getVirtualColumn('main_product_is_new')) - ->set("POSITION", $product->getPosition()) + $previous = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() ; + $next = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + + $loopResultRow + ->set("ID" , $product->getId()) + ->set("REF" , $product->getRef()) + ->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $locale) + ->set("TITLE" , $product->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("URL" , $product->getUrl($locale)) + ->set("BEST_PRICE" , $price) + ->set("BEST_PRICE_TAX" , $taxedPrice - $price) + ->set("BEST_TAXED_PRICE" , $taxedPrice) + ->set("IS_PROMO" , $product->getVirtualColumn('main_product_is_promo')) + ->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new')) + ->set("POSITION" , $product->getPosition()) + ->set("VISIBLE" , $product->getVisible() ? "1" : "0") + ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ->set("DEFAULT_CATEGORY" , $default_category_id) + + ; + $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index 980ade454..e27626129 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -115,7 +115,7 @@ class ProductSaleElements extends BaseLoop $currencyId = $this->getCurrency(); if (null !== $currencyId) { - $currency = CurrencyQuery::create()->findOneById($currencyId); + $currency = CurrencyQuery::create()->findPk($currencyId); if (null === $currency) { throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); } diff --git a/core/lib/Thelia/Core/Template/Loop/TaxRule.php b/core/lib/Thelia/Core/Template/Loop/TaxRule.php new file mode 100644 index 000000000..5851f631d --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/TaxRule.php @@ -0,0 +1,135 @@ +. */ +/* */ +/*************************************************************************************/ + +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\Type\TypeCollection; +use Thelia\Type; +use Thelia\Model\TaxRuleQuery; + +/** + * + * TaxRule loop + * + * + * Class TaxRule + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class TaxRule extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + Argument::createIntListTypeArgument('exclude'), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse')) + ), + 'alpha' + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = TaxRuleQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION')); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (null !== $exclude) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $orders = $this->getOrder(); + + 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; + case "alpha_reverse": + $search->addDescendingOrderByColumn('i18n_TITLE'); + break; + } + } + + /* perform search */ + $tax_rules = $this->search($search, $pagination); + + $loopResult = new LoopResult($tax_rules); + + foreach ($tax_rules as $tax_rule) { + + $loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("ID" , $tax_rule->getId()) + ->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $locale) + ->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE')) + ->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION')) + ->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0') + ; + + $loopResult->addRow($loopResultRow); + } + + 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 802dfcff2..ffad52785 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -31,6 +31,7 @@ use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Model\CategoryQuery; use Thelia\Model\ContentQuery; +use Thelia\Model\CountryQuery; use Thelia\Model\CurrencyQuery; use Thelia\Model\FolderQuery; use Thelia\Model\Product; @@ -154,25 +155,58 @@ class DataAccessFunctions extends AbstractSmartyPlugin } } + public function countryDataAccess($params, $smarty) + { + $defaultCountry = CountryQuery::create()->findOneByByDefault(1); + + switch($params["attr"]) { + case "default": + return $defaultCountry->getId(); + } + } + public function cartDataAccess($params, $smarty) { $cart = $this->getCart($this->request); $result = ""; switch($params["attr"]) { case "count_item": - $result = $cart->getCartItems()->count(); break; + case "total_price": + $result = $cart->getTotalAmount(); + break; + case "total_taxed_price": + $result = $cart->getTaxedAmount( + CountryQuery::create()->findOneById(64) // @TODO : make it magic + ); + break; } return $result; } + public function orderDataAccess($params, &$smarty) + { + $order = $this->request->getSession()->getOrder(); + $attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr')); + switch($attribute) { + case 'postage': + return $order->getPostage(); + case 'delivery_address': + return $order->chosenDeliveryAddress; + } + + throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", 'Order', $attribute)); + } + /** * Lang global data * * @param $params * @param $smarty + * + * @return string */ public function langDataAccess($params, $smarty) { @@ -271,6 +305,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin */ public function getPluginDescriptors() { + return array( new SmartyPluginDescriptor('function', 'admin', $this, 'adminDataAccess'), new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess'), @@ -279,8 +314,10 @@ class DataAccessFunctions extends AbstractSmartyPlugin new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'), new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'), new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'), + new SmartyPluginDescriptor('function', 'country', $this, 'countryDataAccess'), new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'), new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'), + new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'), ); } } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index 24d2c29ee..abe84a292 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -23,18 +23,22 @@ namespace Thelia\Core\Template\Smarty\Plugins; +use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Security\SecurityContext; use Thelia\Core\Security\Exception\AuthenticationException; +use Thelia\Exception\OrderException; class Security extends AbstractSmartyPlugin { + protected $request; private $securityContext; - public function __construct(SecurityContext $securityContext) + public function __construct(Request $request, SecurityContext $securityContext) { $this->securityContext = $securityContext; + $this->request = $request; } /** @@ -43,32 +47,53 @@ class Security extends AbstractSmartyPlugin * @param array $params * @param unknown $smarty * @return string no text is returned. + * @throws \Thelia\Core\Security\Exception\AuthenticationException */ public function checkAuthFunction($params, &$smarty) { - $roles = $this->_explode($this->getParam($params, 'roles')); - $permissions = $this->_explode($this->getParam($params, 'permissions')); + $roles = $this->_explode($this->getParam($params, 'roles')); + $permissions = $this->_explode($this->getParam($params, 'permissions')); - if (! $this->securityContext->isGranted($roles, $permissions)) { + if (! $this->securityContext->isGranted($roles, $permissions)) { - $ex = new AuthenticationException( - sprintf("User not granted for roles '%s', permissions '%s' in context '%s'.", - implode(',', $roles), implode(',', $permissions), $context - ) - ); + $ex = new AuthenticationException( + sprintf("User not granted for roles '%s', permissions '%s' in context '%s'.", + implode(',', $roles), implode(',', $permissions), $context + ) + ); - $loginTpl = $this->getParam($params, 'login_tpl'); + $loginTpl = $this->getParam($params, 'login_tpl'); - if (null != $loginTpl) { - $ex->setLoginTemplate($loginTpl); - } + if (null != $loginTpl) { + $ex->setLoginTemplate($loginTpl); + } - throw $ex; - } + throw $ex; + } - return ''; + return ''; } + public function checkCartNotEmptyFunction($params, &$smarty) + { + $cart = $this->request->getSession()->getCart(); + if($cart===null || $cart->countCartItems() == 0) { + throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY, array('empty' => 1)); + } + + return ""; + } + + public function checkValidDeliveryFunction($params, &$smarty) + { + $order = $this->request->getSession()->getOrder(); + if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) { + throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1)); + } + + return ""; + } + /** * Define the various smarty plugins handled by this class * @@ -77,7 +102,9 @@ class Security extends AbstractSmartyPlugin public function getPluginDescriptors() { return array( - new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction') + new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction'), + new SmartyPluginDescriptor('function', 'check_cart_not_empty', $this, 'checkCartNotEmptyFunction'), + new SmartyPluginDescriptor('function', 'check_valid_delivery', $this, 'checkValidDeliveryFunction'), ); } } diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index eb560a484..dbfe48e17 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -86,6 +86,8 @@ class Thelia extends Kernel $serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance()); $con->useDebug(true); } + + } /** diff --git a/core/lib/Thelia/Exception/DocumentException.php b/core/lib/Thelia/Exception/DocumentException.php new file mode 100644 index 000000000..9727a4267 --- /dev/null +++ b/core/lib/Thelia/Exception/DocumentException.php @@ -0,0 +1,36 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +use Thelia\Log\Tlog; + +class DocumentException extends \RuntimeException +{ + public function __construct($message, $code = null, $previous = null) + { + Tlog::getInstance()->addError($message); + + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Exception/OrderException.php b/core/lib/Thelia/Exception/OrderException.php new file mode 100755 index 000000000..70fd21c01 --- /dev/null +++ b/core/lib/Thelia/Exception/OrderException.php @@ -0,0 +1,52 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +class OrderException extends \RuntimeException +{ + /** + * @var string The cart template name + */ + public $cartRoute = "cart.view"; + public $orderDeliveryRoute = "order.delivery"; + + public $arguments = array(); + + const UNKNOWN_EXCEPTION = 0; + + const CART_EMPTY = 100; + + const UNDEFINED_DELIVERY = 200; + + public function __construct($message, $code = null, $arguments = array(), $previous = null) + { + if(is_array($arguments)) { + $this->arguments = $arguments; + } + if ($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index 5dce6a049..6a0172180 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -39,15 +39,22 @@ class CategoryCreationForm extends BaseForm "for" => "title" ) )) - ->add("parent", "integer", array( + ->add("parent", "text", array( + "label" => Translator::getInstance()->trans("Parent category *"), "constraints" => array( new NotBlank() - ) + ), + "label_attr" => array("for" => "parent_create") )) ->add("locale", "text", array( "constraints" => array( new NotBlank() - ) + ), + "label_attr" => array("for" => "locale_create") + )) + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This category is online."), + "label_attr" => array("for" => "visible_create") )) ; } diff --git a/core/lib/Thelia/Form/CategoryModificationForm.php b/core/lib/Thelia/Form/CategoryModificationForm.php index d9de36d16..943c0d941 100644 --- a/core/lib/Thelia/Form/CategoryModificationForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -24,6 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; class CategoryModificationForm extends CategoryCreationForm { @@ -36,12 +37,14 @@ class CategoryModificationForm extends CategoryCreationForm $this->formBuilder ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) - ->add("visible", "checkbox", array( - "label" => Translator::getInstance()->trans("This category is online on the front office.") + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url") )) ; - // Add standard description fields + // Add standard description fields, excluding title and locale, which a re defined in parent class $this->addStandardDescFields(array('title', 'locale')); } diff --git a/core/lib/Thelia/Form/InstallStep3Form.php b/core/lib/Thelia/Form/InstallStep3Form.php new file mode 100755 index 000000000..9388f14db --- /dev/null +++ b/core/lib/Thelia/Form/InstallStep3Form.php @@ -0,0 +1,111 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; + +/** + * Created by JetBrains PhpStorm. + * Date: 8/29/13 + * Time: 3:45 PM + * + * Allow to build a form Install Step 3 Database connection + * + * @package Coupon + * @author Guillaume MOREL + * + */ +class InstallStep3Form extends BaseForm +{ + /** + * Build Coupon form + * + * @return void + */ + protected function buildForm() + { + $this->formBuilder + ->add( + 'host', + 'text', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ) + ->add( + 'user', + 'text', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ) + ->add( + 'password', + 'text', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ) + ->add( + 'port', + 'text', + array( + 'constraints' => array( + new NotBlank(), + new GreaterThan( + array( + 'value' => 0 + ) + ) + ) + ) + ) + ->add( + 'locale', + 'hidden', + array( + 'constraints' => array( + new NotBlank() + ) + ) + ); + } + + /** + * Get form name + * + * @return string + */ + public function getName() + { + return 'thelia_install_step3'; + } +} diff --git a/core/lib/Thelia/Form/OrderDelivery.php b/core/lib/Thelia/Form/OrderDelivery.php new file mode 100755 index 000000000..3ef1444f6 --- /dev/null +++ b/core/lib/Thelia/Form/OrderDelivery.php @@ -0,0 +1,94 @@ +. */ +/* */ +/*************************************************************************************/ +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; + +/** + * Class OrderDelivery + * @package Thelia\Form + * @author Etienne Roudeix + */ +class OrderDelivery extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("delivery-address", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyDeliveryAddress") + ) + )) + ) + )) + ->add("delivery-module", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyDeliveryModule") + ) + )) + ) + )); + } + + public function verifyDeliveryAddress($value, ExecutionContextInterface $context) + { + $address = AddressQuery::create() + ->findPk($value); + + if(null === $address) { + $context->addViolation("Address ID not found"); + } + } + + public function verifyDeliveryModule($value, ExecutionContextInterface $context) + { + $module = ModuleQuery::create() + ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) + ->filterByActivate(1) + ->filterById($value) + ->find(); + + if(null === $module) { + $context->addViolation("Delivery module ID not found"); + } + } + + public function getName() + { + 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 new file mode 100755 index 000000000..d3ebe4daf --- /dev/null +++ b/core/lib/Thelia/Form/OrderPayment.php @@ -0,0 +1,94 @@ +. */ +/* */ +/*************************************************************************************/ +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; + +/** + * Class OrderPayment + * @package Thelia\Form + * @author Etienne Roudeix + */ +class OrderPayment extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("invoice-address", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyInvoiceAddress") + ) + )) + ) + )) + ->add("payment-module", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyPaymentModule") + ) + )) + ) + )); + } + + public function verifyInvoiceAddress($value, ExecutionContextInterface $context) + { + $address = AddressQuery::create() + ->findPk($value); + + if(null === $address) { + $context->addViolation("Address ID not found"); + } + } + + public function verifyPaymentModule($value, ExecutionContextInterface $context) + { + $module = ModuleQuery::create() + ->filterByType(BaseModule::PAYMENT_MODULE_TYPE) + ->filterByActivate(1) + ->filterById($value) + ->find(); + + if(null === $module) { + $context->addViolation("Payment module ID not found"); + } + } + + public function getName() + { + return "thelia_order_payment"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php index 396f6d0d5..a4ffdde32 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -23,16 +23,26 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Thelia\Model\ProductQuery; +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\ExecutionContextInterface; class ProductCreationForm extends BaseForm { - protected function buildForm() + protected function buildForm($change_mode = false) { + $ref_constraints = array(new NotBlank()); + + if (! $change_mode) { + $ref_constraints[] = new Callback(array( + "methods" => array(array($this, "checkDuplicateRef")) + )); + } + $this->formBuilder ->add("ref", "text", array( - "constraints" => array( - new NotBlank() - ), + "constraints" => $ref_constraints, "label" => "Product reference *", "label_attr" => array( "for" => "ref" @@ -47,7 +57,7 @@ class ProductCreationForm extends BaseForm "for" => "title" ) )) - ->add("parent", "integer", array( + ->add("default_category", "integer", array( "constraints" => array( new NotBlank() ) @@ -57,7 +67,24 @@ class ProductCreationForm extends BaseForm new NotBlank() ) )) - ; + ->add("visible", "integer", array( + "label" => Translator::getInstance()->trans("This product is online."), + "label_attr" => array("for" => "visible_create") + )) + ; + } + + public function checkDuplicateRef($value, ExecutionContextInterface $context) + { + $count = ProductQuery::create()->filterByRef($value)->count(); + + if ($count > 0) { + $context->addViolation( + Translator::getInstance()->trans( + "A product with reference %ref already exists. Please choose another reference.", + array('%ref' => $value) + )); + } } public function getName() diff --git a/core/lib/Thelia/Form/ProductModificationForm.php b/core/lib/Thelia/Form/ProductModificationForm.php new file mode 100644 index 000000000..dbda15eaa --- /dev/null +++ b/core/lib/Thelia/Form/ProductModificationForm.php @@ -0,0 +1,64 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; + +class ProductModificationForm extends ProductCreationForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + parent::buildForm(true); + + $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("template_id", "integer", array( + "label" => Translator::getInstance()->trans("Product template"), + "label_attr" => array("for" => "product_template_field") + + )) + ->add("url", "text", array( + "label" => Translator::getInstance()->trans("Rewriten URL *"), + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url_field") + )) + ; + + // 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_product_modification"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php index 9d1851252..b35aad12f 100644 --- a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php +++ b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php @@ -58,7 +58,8 @@ trait StandardDescriptionFieldsTrait "label" => Translator::getInstance()->trans("Title"), "label_attr" => array( "for" => "title" - ) + ), + "label_attr" => array("for" => "title_field") ) ); @@ -67,7 +68,7 @@ trait StandardDescriptionFieldsTrait ->add("chapo", "text", array( "label" => Translator::getInstance()->trans("Summary"), "label_attr" => array( - "for" => "summary" + "for" => "summary_field" ) )); @@ -76,7 +77,7 @@ trait StandardDescriptionFieldsTrait ->add("description", "text", array( "label" => Translator::getInstance()->trans("Detailed description"), "label_attr" => array( - "for" => "detailed_description" + "for" => "detailed_description_field" ) )); @@ -85,7 +86,7 @@ trait StandardDescriptionFieldsTrait ->add("postscriptum", "text", array( "label" => Translator::getInstance()->trans("Conclusion"), "label_attr" => array( - "for" => "conclusion" + "for" => "conclusion_field" ) )); } diff --git a/core/lib/Thelia/Install/BaseInstall.php b/core/lib/Thelia/Install/BaseInstall.php index 11b8d0999..aa41140dd 100644 --- a/core/lib/Thelia/Install/BaseInstall.php +++ b/core/lib/Thelia/Install/BaseInstall.php @@ -25,19 +25,33 @@ use Thelia\Install\Exception\AlreadyInstallException; /** * Class BaseInstall + * * @author Manuel Raynaud */ abstract class BaseInstall { + /** @var bool If Installation wizard is launched by CLI */ + protected $isConsoleMode = true; + /** - * Verify if an installation already exists + * Constructor + * + * @param bool $verifyInstall Verify if an installation already exists + * + * @throws Exception\AlreadyInstallException */ public function __construct($verifyInstall = true) { - /* TODO : activate this part + + // Check if install wizard is launched via CLI + if (php_sapi_name() == 'cli') { + $this->isConsoleMode = true; + } else { + $this->isConsoleMode = false; + } if (file_exists(THELIA_ROOT . '/local/config/database.yml') && $verifyInstall) { throw new AlreadyInstallException("Thelia is already installed"); - }*/ + } $this->exec(); diff --git a/core/lib/Thelia/Install/CheckDatabaseConnection.php b/core/lib/Thelia/Install/CheckDatabaseConnection.php new file mode 100644 index 000000000..c9c2060f5 --- /dev/null +++ b/core/lib/Thelia/Install/CheckDatabaseConnection.php @@ -0,0 +1,122 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Install; + +use PDO; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; +use Symfony\Component\Translation\TranslatorInterface; +use Thelia\Core\Translation\Translator; +use Thelia\Install\Exception\InstallException; + + +/** + * Class CheckDatabaseConnection + * + * Take care of integration tests (database connection) + * + * @package Thelia\Install + * @author Manuel Raynaud + * @author Guillaume MOREL + */ +class CheckDatabaseConnection extends BaseInstall +{ + protected $validationMessages = array(); + + /** @var bool If permissions are OK */ + protected $isValid = true; + + /** @var TranslatorInterface Translator Service */ + protected $translator = null; + + /** @var string Database host information */ + protected $host = null; + + /** @var string Database user information */ + protected $user = null; + + /** @var string Database password information */ + protected $password = null; + + /** @var int Database port information */ + protected $port = null; + + /** + * @var \PDO instance + */ + protected $connection = null; + + /** + * Constructor + * + * @param string $host Database host information + * @param string $user Database user information + * @param string $password Database password information + * @param int $port Database port information + * @param bool $verifyInstall If verify install + * @param Translator $translator Translator Service + * necessary for install wizard + */ + public function __construct($host, $user, $password, $port, $verifyInstall = true, Translator $translator = null) + { + $this->host = $host; + $this->user = $user; + $this->password = $password; + $this->port = $port; + + parent::__construct($verifyInstall); + } + + /** + * Perform database connection check + * + * @return bool + */ + public function exec() + { + + $dsn = "mysql:host=%s;port=%s"; + + try { + $this->connection = new \PDO( + sprintf($dsn, $this->host, $this->port), + $this->user, + $this->password + ); + } catch (\PDOException $e) { + + $this->validationMessages = 'Wrong connection information'; + + $this->isValid = false; + } + + return $this->isValid; + } + + public function getConnection() + { + return $this->connection; + } + +} diff --git a/core/lib/Thelia/Install/CheckPermission.php b/core/lib/Thelia/Install/CheckPermission.php index db73330cf..15317211b 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -23,56 +23,366 @@ namespace Thelia\Install; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; +use Symfony\Component\Translation\TranslatorInterface; +use Thelia\Core\Translation\Translator; + /** * Class CheckPermission + * + * Take care of integration tests (files permissions) + * * @package Thelia\Install - * @author Manuel Raynaud + * @author Manuel Raynaud + * @author Guillaume MOREL */ class CheckPermission extends BaseInstall { - const CONF = "const"; - const LOG = "log"; - const CACHE = "cache"; - private $directories = array(); - private $validation = array(); - private $valid = true; + const DIR_CONF = 'local/config'; + const DIR_LOG = 'log'; + const DIR_CACHE = 'cache'; + const DIR_WEB = 'web'; - public function __construct($verifyInstall = true) + /** @var array Directory needed to be writable */ + protected $directoriesToBeWritable = array( + self::DIR_CONF, + self::DIR_LOG, + self::DIR_CACHE, + self::DIR_WEB, + ); + + /** @var array Minimum server configuration necessary */ + protected $minServerConfigurationNecessary = array( + 'memory_limit' => 134217728, + 'post_max_size' => 20971520, + 'upload_max_filesize' => 2097152 + ); + + protected $validationMessages = array(); + + /** @var bool If permissions are OK */ + protected $isValid = true; + + /** @var TranslatorInterface Translator Service */ + protected $translator = null; + + /** + * Constructor + * + * @param bool $verifyInstall If verify install + * @param Translator $translator Translator Service + * necessary for install wizard + */ + public function __construct($verifyInstall = true, Translator $translator = null) { + $this->translator = $translator; - - $this->directories = array( - self::CONF => THELIA_ROOT . "local/config", - self::LOG => THELIA_ROOT . "log", - self::CACHE => THELIA_ROOT . "cache" + $this->validationMessages['php_version'] = array( + 'text' => $this->getI18nPhpVersionText('5.4', phpversion(), true), + 'hint' => $this->getI18nPhpVersionHint(), + 'status' => true ); - $this->validation = array( - self::CONF => array( - "text" => sprintf("config directory(%s)...", $this->directories[self::CONF]), - "status" => true - ), - self::LOG => array( - "text" => sprintf("cache directory(%s)...", $this->directories[self::LOG]), - "status" => true - ), - self::CACHE => array( - "text" => sprintf("log directory(%s)...", $this->directories[self::CACHE]), - "status" => true - ) - ); + foreach ($this->directoriesToBeWritable as $directory) { + $this->validationMessages[$directory] = array( + 'text' => '', + 'hint' => '', + 'status' => true + ); + } + foreach ($this->minServerConfigurationNecessary as $key => $value) { + $this->validationMessages[$key] = array( + 'text' => '', + 'hint' => $this->getI18nConfigHint(), + 'status' => true + ); + } + parent::__construct($verifyInstall); } + /** + * Perform file permission check + * + * @return bool + */ public function exec() { - foreach ($this->directories as $key => $directory) { - if(is_writable($directory) === false) { - $this->valid = false; - $this->validation[$key]["status"] = false; + if (version_compare(phpversion(), '5.4', '<')) { + $this->validationMessages['php_version'] = $this->getI18nPhpVersionText('5.4', phpversion(), false); + } + + foreach ($this->directoriesToBeWritable as $directory) { + $fullDirectory = THELIA_ROOT . $directory; + $this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, true); + if (is_writable($fullDirectory) === false) { + if (!$this->makeDirectoryWritable($fullDirectory)) { + $this->isValid = false; + $this->validationMessages[$directory]['status'] = false; + $this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, false); + $this->validationMessages[$directory]['hint'] = $this->getI18nDirectoryHint($fullDirectory); + } } } + + foreach ($this->minServerConfigurationNecessary as $key => $value) { + $this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), true); + if (!$this->verifyServerMemoryValues($key, $value)) { + $this->isValid = false; + $this->validationMessages[$key]['status'] = false; + $this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), false);; + } + } + + + + + return $this->isValid; } -} \ No newline at end of file + + /** + * Get validation messages + * + * @return array + */ + public function getValidationMessages() + { + return $this->validationMessages; + } + + /** + * Make a directory writable (recursively) + * + * @param string $directory path to directory + * + * @return bool + */ + protected function makeDirectoryWritable($directory) + { + chmod($directory, 0777); + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($directory) + ); + foreach ($iterator as $item) { + chmod($item, 0777); + } + + return (is_writable(THELIA_ROOT . $directory) === true); + } + + + + /** + * Get Translated text about the directory state + * + * @param string $directory Directory being checked + * @param bool $isValid If directory permission is valid + * + * @return string + */ + protected function getI18nDirectoryText($directory, $isValid) + { + if ($this->translator !== null) { + if ($isValid) { + $sentence = 'Your directory %directory% is writable'; + } else { + $sentence = 'Your directory %directory% is not writable'; + } + + $translatedText = $this->translator->trans( + $sentence, + array( + '%directory%' => $directory + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('Your directory %s needs to be writable', $directory); + } + + return $translatedText; + } + + /** + * Get Translated hint about the directory state + * + * @param string $directory Directory being checked + * + * @return string + */ + protected function getI18nDirectoryHint($directory) + { + if ($this->translator !== null) { + $sentence = 'chmod 777 %directory% on your server with admin rights could help'; + $translatedText = $this->translator->trans( + $sentence, + array( + '%directory%' => $directory + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('chmod 777 %s on your server with admin rights could help', $directory); + } + + return $translatedText; + } + + + /** + * Get Translated text about the directory state + * Not usable with CLI + * + * @param string $key .ini file key + * @param string $expectedValue Expected server value + * @param string $currentValue Actual server value + * @param bool $isValid If server configuration is valid + * + * @return string + */ + protected function getI18nConfigText($key, $expectedValue, $currentValue, $isValid) + { + if ($isValid) { + $sentence = 'Your %key% server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)'; + } else { + $sentence = 'Your %key% server configuration (currently %currentValue%) is not sufficient enough in order to run Thelia2 (%expectedValue% needed)'; + } + + $translatedText = $this->translator->trans( + $sentence, + array( + '%key%' => $key, + '%expectedValue%' => $expectedValue, + '%currentValue%' => $currentValue, + ), + 'install-wizard' + ); + + return $translatedText; + } + + /** + * Get Translated hint about the config requirement issue + * + * @return string + */ + protected function getI18nConfigHint() + { + $sentence = 'Modifying this value on your server php.ini file with admin rights could help'; + $translatedText = $this->translator->trans( + $sentence, + array(), + 'install-wizard' + ); + + return $translatedText; + } + + /** + * Get Translated hint about the PHP version requirement issue + * + * @param string $expectedValue + * @param string $currentValue + * @param bool $isValid + * + * @return string + */ + protected function getI18nPhpVersionText($expectedValue, $currentValue, $isValid) + { + if ($this->translator !== null) { + if ($isValid) { + $sentence = 'Your PHP version %currentValue% is well enough to run Thelia2 (%expectedValue% needed)'; + } else { + $sentence = 'Your PHP version %currentValue% is not sufficient enough to run Thelia2 (%expectedValue% needed)'; + } + + $translatedText = $this->translator->trans( + $sentence, + array( + '%expectedValue%' => $expectedValue, + '%currentValue%' => $currentValue, + ), + 'install-wizard' + ); + } else { + $translatedText = sprintf('Thelia needs at least PHP %s (%s currently)', $expectedValue, $currentValue); + } + + return $translatedText; + } + + /** + * Get Translated hint about the config requirement issue + * + * @return string + */ + protected function getI18nPhpVersionHint() + { + $sentence = 'Upgrading your version of PHP with admin rights could help'; + $translatedText = $this->translator->trans( + $sentence, + array(), + 'install-wizard' + ); + + return $translatedText; + } + + /** + * Check if a server memory value is met or not + * + * @param string $key .ini file key + * @param int $necessaryValueInBytes Expected value in bytes + * + * @return bool + */ + protected function verifyServerMemoryValues($key, $necessaryValueInBytes) + { + $serverValueInBytes = $this->returnBytes(ini_get($key)); + + return ($serverValueInBytes >= $necessaryValueInBytes); + } + + /** + * Return bytes from memory .ini value + * + * @param string $val .ini value + * + * @return int + */ + protected function returnBytes($val) + { + $val = trim($val); + $last = strtolower($val[strlen($val)-1]); + switch($last) { + // The 'G' modifier is available since PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return $val; + } + + /** + * Convert bytes to readable string + * + * @param int $bytes bytes + * @param int $precision conversion precision + * + * @return string + */ + protected function formatBytes($bytes, $precision = 2) + { + $base = log($bytes) / log(1024); + $suffixes = array('', 'k', 'M', 'G', 'T'); + + return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; + } +} diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 34ca97dae..648a6431a 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -93,7 +93,7 @@ class Database */ public function createDatabase($dbName) { - $this->connection->query( + $this->connection->exec( sprintf( "CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8", $dbName diff --git a/core/lib/Thelia/Controller/Install/InstallController.php b/core/lib/Thelia/Mailer/MailerFactory.php similarity index 51% rename from core/lib/Thelia/Controller/Install/InstallController.php rename to core/lib/Thelia/Mailer/MailerFactory.php index 40e6643db..a327a155f 100644 --- a/core/lib/Thelia/Controller/Install/InstallController.php +++ b/core/lib/Thelia/Mailer/MailerFactory.php @@ -21,91 +21,71 @@ /* */ /*************************************************************************************/ -namespace Thelia\Controller\Install; -use Thelia\Install\CheckPermission; +namespace Thelia\Mailer; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Thelia\Core\Event\MailTransporterEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\ConfigQuery; + /** - * Class InstallController - * @package Thelia\Controller\Install + * Class MailerFactory + * @package Thelia\Mailer * @author Manuel Raynaud */ -class InstallController extends BaseInstallController -{ - public function index() +class MailerFactory { + /** + * @var \Swift_Mailer + */ + protected $swiftMailer; + + protected $dispatcher; + + public function __construct(EventDispatcherInterface $dispatcher) { - //$this->verifyStep(1); - $this->getSession()->set("step", 1); + $this->dispatcher = $dispatcher; - return $this->render("index.html"); - } + $transporterEvent = new MailTransporterEvent(); + $this->dispatcher->dispatch(TheliaEvents::MAILTRANSPORTER_CONFIG, $transporterEvent); - public function checkPermission() - { - //$this->verifyStep(2); - - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 2); - return $this->render("step-2.html"); - } - - public function databaseConnection() - { - //$this->verifyStep(2); - - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 3); - return $this->render("step-3.html"); - } - - public function databaseSelection() - { - //$this->verifyStep(2); - - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 4); - return $this->render("step-4.html"); - } - - public function generalInformation() - { - //$this->verifyStep(2); - - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 5); - return $this->render("step-5.html"); - } - - public function thanks() - { - //$this->verifyStep(2); - - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 6); - return $this->render("thanks.html"); - } - - protected function verifyStep($step) - { - $session = $this->getSession(); - - if ($session->has("step")) { - $sessionStep = $session->get("step"); + if($transporterEvent->hasTransporter()) { + $transporter = $transporterEvent->getTransporter(); } else { - return true; + if (ConfigQuery::read("smtp.enabled")) { + $transporter = $this->configureSmtp(); + } else { + $transporter = \Swift_MailTransport::newInstance(); + } } - switch ($step) { - case "1" : - if ($sessionStep > 1) { - $this->redirect("/install/step/2"); - } - break; - } + $this->swiftMailer = new \Swift_Mailer($transporter); } -} + + private function configureSmtp() + { + $smtpTransporter = new \Swift_SmtpTransport(); + $smtpTransporter->setHost(Configquery::read('smtp.host', 'localhost')) + ->setPort(ConfigQuery::read('smtp.host')) + ->setEncryption(ConfigQuery::read('smtp.encryption')) + ->setUsername(ConfigQuery::read('smtp.username')) + ->setPassword(ConfigQuery::read('smtp.password')) + ->setAuthMode(ConfigQuery::read('smtp.authmode')) + ->setTimeout(ConfigQuery::read('smtp.timeout', 30)) + ->setSourceIp(ConfigQuery::read('smtp.sourceip')) + ; + return $smtpTransporter; + } + + public function send(\Swift_Mime_Message $message, &$failedRecipients = null) + { + $this->swiftMailer->send($message, $failedRecipients); + } + + public function getSwiftMailer() + { + return $this->swiftMailer; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index 67f6a5928..2712eb95c 100755 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -34,8 +34,6 @@ class Admin extends BaseAdmin implements UserInterface public function setPassword($password) { - \Thelia\Log\Tlog::getInstance()->debug($password); - if ($this->isNew() && ($password === null || trim($password) == "")) { throw new \InvalidArgumentException("customer password is mandatory on creation"); } diff --git a/core/lib/Thelia/Model/AreaDeliveryModule.php b/core/lib/Thelia/Model/AreaDeliveryModule.php new file mode 100644 index 000000000..206625a12 --- /dev/null +++ b/core/lib/Thelia/Model/AreaDeliveryModule.php @@ -0,0 +1,10 @@ +unit; + return $this->postage; } /** @@ -491,25 +491,25 @@ abstract class Area implements ActiveRecordInterface } // setName() /** - * Set the value of [unit] column. + * Set the value of [postage] column. * * @param double $v new value * @return \Thelia\Model\Area The current object (for fluent API support) */ - public function setUnit($v) + public function setPostage($v) { if ($v !== null) { $v = (double) $v; } - if ($this->unit !== $v) { - $this->unit = $v; - $this->modifiedColumns[] = AreaTableMap::UNIT; + if ($this->postage !== $v) { + $this->postage = $v; + $this->modifiedColumns[] = AreaTableMap::POSTAGE; } return $this; - } // setUnit() + } // setPostage() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -596,8 +596,8 @@ abstract class Area implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; $this->name = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Unit', TableMap::TYPE_PHPNAME, $indexType)]; - $this->unit = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postage = (null !== $col) ? (double) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -681,7 +681,7 @@ abstract class Area implements ActiveRecordInterface $this->collCountries = null; - $this->collDelivzones = null; + $this->collAreaDeliveryModules = null; } // if (deep) } @@ -834,18 +834,17 @@ abstract class Area implements ActiveRecordInterface } } - if ($this->delivzonesScheduledForDeletion !== null) { - if (!$this->delivzonesScheduledForDeletion->isEmpty()) { - foreach ($this->delivzonesScheduledForDeletion as $delivzone) { - // need to save related object because we set the relation to null - $delivzone->save($con); - } - $this->delivzonesScheduledForDeletion = null; + if ($this->areaDeliveryModulesScheduledForDeletion !== null) { + if (!$this->areaDeliveryModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AreaDeliveryModuleQuery::create() + ->filterByPrimaryKeys($this->areaDeliveryModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->areaDeliveryModulesScheduledForDeletion = null; } } - if ($this->collDelivzones !== null) { - foreach ($this->collDelivzones as $referrerFK) { + if ($this->collAreaDeliveryModules !== null) { + foreach ($this->collAreaDeliveryModules as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -884,8 +883,8 @@ abstract class Area implements ActiveRecordInterface if ($this->isColumnModified(AreaTableMap::NAME)) { $modifiedColumns[':p' . $index++] = 'NAME'; } - if ($this->isColumnModified(AreaTableMap::UNIT)) { - $modifiedColumns[':p' . $index++] = 'UNIT'; + if ($this->isColumnModified(AreaTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; } if ($this->isColumnModified(AreaTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -910,8 +909,8 @@ abstract class Area implements ActiveRecordInterface case 'NAME': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case 'UNIT': - $stmt->bindValue($identifier, $this->unit, PDO::PARAM_STR); + case 'POSTAGE': + $stmt->bindValue($identifier, $this->postage, 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); @@ -988,7 +987,7 @@ abstract class Area implements ActiveRecordInterface return $this->getName(); break; case 2: - return $this->getUnit(); + return $this->getPostage(); break; case 3: return $this->getCreatedAt(); @@ -1027,7 +1026,7 @@ abstract class Area implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getName(), - $keys[2] => $this->getUnit(), + $keys[2] => $this->getPostage(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -1041,8 +1040,8 @@ abstract class Area implements ActiveRecordInterface if (null !== $this->collCountries) { $result['Countries'] = $this->collCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collDelivzones) { - $result['Delivzones'] = $this->collDelivzones->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAreaDeliveryModules) { + $result['AreaDeliveryModules'] = $this->collAreaDeliveryModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1085,7 +1084,7 @@ abstract class Area implements ActiveRecordInterface $this->setName($value); break; case 2: - $this->setUnit($value); + $this->setPostage($value); break; case 3: $this->setCreatedAt($value); @@ -1119,7 +1118,7 @@ abstract class Area implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setUnit($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setPostage($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]]); } @@ -1135,7 +1134,7 @@ abstract class Area implements ActiveRecordInterface if ($this->isColumnModified(AreaTableMap::ID)) $criteria->add(AreaTableMap::ID, $this->id); if ($this->isColumnModified(AreaTableMap::NAME)) $criteria->add(AreaTableMap::NAME, $this->name); - if ($this->isColumnModified(AreaTableMap::UNIT)) $criteria->add(AreaTableMap::UNIT, $this->unit); + if ($this->isColumnModified(AreaTableMap::POSTAGE)) $criteria->add(AreaTableMap::POSTAGE, $this->postage); if ($this->isColumnModified(AreaTableMap::CREATED_AT)) $criteria->add(AreaTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AreaTableMap::UPDATED_AT)) $criteria->add(AreaTableMap::UPDATED_AT, $this->updated_at); @@ -1202,7 +1201,7 @@ abstract class Area implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setName($this->getName()); - $copyObj->setUnit($this->getUnit()); + $copyObj->setPostage($this->getPostage()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1217,9 +1216,9 @@ abstract class Area implements ActiveRecordInterface } } - foreach ($this->getDelivzones() as $relObj) { + foreach ($this->getAreaDeliveryModules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDelivzone($relObj->copy($deepCopy)); + $copyObj->addAreaDeliveryModule($relObj->copy($deepCopy)); } } @@ -1267,8 +1266,8 @@ abstract class Area implements ActiveRecordInterface if ('Country' == $relationName) { return $this->initCountries(); } - if ('Delivzone' == $relationName) { - return $this->initDelivzones(); + if ('AreaDeliveryModule' == $relationName) { + return $this->initAreaDeliveryModules(); } } @@ -1491,31 +1490,31 @@ abstract class Area implements ActiveRecordInterface } /** - * Clears out the collDelivzones collection + * Clears out the collAreaDeliveryModules 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 addDelivzones() + * @see addAreaDeliveryModules() */ - public function clearDelivzones() + public function clearAreaDeliveryModules() { - $this->collDelivzones = null; // important to set this to NULL since that means it is uninitialized + $this->collAreaDeliveryModules = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collDelivzones collection loaded partially. + * Reset is the collAreaDeliveryModules collection loaded partially. */ - public function resetPartialDelivzones($v = true) + public function resetPartialAreaDeliveryModules($v = true) { - $this->collDelivzonesPartial = $v; + $this->collAreaDeliveryModulesPartial = $v; } /** - * Initializes the collDelivzones collection. + * Initializes the collAreaDeliveryModules collection. * - * By default this just sets the collDelivzones collection to an empty array (like clearcollDelivzones()); + * By default this just sets the collAreaDeliveryModules collection to an empty array (like clearcollAreaDeliveryModules()); * 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. * @@ -1524,17 +1523,17 @@ abstract class Area implements ActiveRecordInterface * * @return void */ - public function initDelivzones($overrideExisting = true) + public function initAreaDeliveryModules($overrideExisting = true) { - if (null !== $this->collDelivzones && !$overrideExisting) { + if (null !== $this->collAreaDeliveryModules && !$overrideExisting) { return; } - $this->collDelivzones = new ObjectCollection(); - $this->collDelivzones->setModel('\Thelia\Model\Delivzone'); + $this->collAreaDeliveryModules = new ObjectCollection(); + $this->collAreaDeliveryModules->setModel('\Thelia\Model\AreaDeliveryModule'); } /** - * Gets an array of ChildDelivzone objects which contain a foreign key that references this object. + * Gets an array of ChildAreaDeliveryModule 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. @@ -1544,109 +1543,109 @@ abstract class Area implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDelivzone[] List of ChildDelivzone objects + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects * @throws PropelException */ - public function getDelivzones($criteria = null, ConnectionInterface $con = null) + public function getAreaDeliveryModules($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { // return empty collection - $this->initDelivzones(); + $this->initAreaDeliveryModules(); } else { - $collDelivzones = ChildDelivzoneQuery::create(null, $criteria) + $collAreaDeliveryModules = ChildAreaDeliveryModuleQuery::create(null, $criteria) ->filterByArea($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collDelivzonesPartial && count($collDelivzones)) { - $this->initDelivzones(false); + if (false !== $this->collAreaDeliveryModulesPartial && count($collAreaDeliveryModules)) { + $this->initAreaDeliveryModules(false); - foreach ($collDelivzones as $obj) { - if (false == $this->collDelivzones->contains($obj)) { - $this->collDelivzones->append($obj); + foreach ($collAreaDeliveryModules as $obj) { + if (false == $this->collAreaDeliveryModules->contains($obj)) { + $this->collAreaDeliveryModules->append($obj); } } - $this->collDelivzonesPartial = true; + $this->collAreaDeliveryModulesPartial = true; } - $collDelivzones->getInternalIterator()->rewind(); + $collAreaDeliveryModules->getInternalIterator()->rewind(); - return $collDelivzones; + return $collAreaDeliveryModules; } - if ($partial && $this->collDelivzones) { - foreach ($this->collDelivzones as $obj) { + if ($partial && $this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $obj) { if ($obj->isNew()) { - $collDelivzones[] = $obj; + $collAreaDeliveryModules[] = $obj; } } } - $this->collDelivzones = $collDelivzones; - $this->collDelivzonesPartial = false; + $this->collAreaDeliveryModules = $collAreaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; } } - return $this->collDelivzones; + return $this->collAreaDeliveryModules; } /** - * Sets a collection of Delivzone objects related by a one-to-many relationship + * Sets a collection of AreaDeliveryModule 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 $delivzones A Propel collection. + * @param Collection $areaDeliveryModules A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildArea The current object (for fluent API support) */ - public function setDelivzones(Collection $delivzones, ConnectionInterface $con = null) + public function setAreaDeliveryModules(Collection $areaDeliveryModules, ConnectionInterface $con = null) { - $delivzonesToDelete = $this->getDelivzones(new Criteria(), $con)->diff($delivzones); + $areaDeliveryModulesToDelete = $this->getAreaDeliveryModules(new Criteria(), $con)->diff($areaDeliveryModules); - $this->delivzonesScheduledForDeletion = $delivzonesToDelete; + $this->areaDeliveryModulesScheduledForDeletion = $areaDeliveryModulesToDelete; - foreach ($delivzonesToDelete as $delivzoneRemoved) { - $delivzoneRemoved->setArea(null); + foreach ($areaDeliveryModulesToDelete as $areaDeliveryModuleRemoved) { + $areaDeliveryModuleRemoved->setArea(null); } - $this->collDelivzones = null; - foreach ($delivzones as $delivzone) { - $this->addDelivzone($delivzone); + $this->collAreaDeliveryModules = null; + foreach ($areaDeliveryModules as $areaDeliveryModule) { + $this->addAreaDeliveryModule($areaDeliveryModule); } - $this->collDelivzones = $delivzones; - $this->collDelivzonesPartial = false; + $this->collAreaDeliveryModules = $areaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; return $this; } /** - * Returns the number of related Delivzone objects. + * Returns the number of related AreaDeliveryModule objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related Delivzone objects. + * @return int Count of related AreaDeliveryModule objects. * @throws PropelException */ - public function countDelivzones(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countAreaDeliveryModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { return 0; } if ($partial && !$criteria) { - return count($this->getDelivzones()); + return count($this->getAreaDeliveryModules()); } - $query = ChildDelivzoneQuery::create(null, $criteria); + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1656,58 +1655,83 @@ abstract class Area implements ActiveRecordInterface ->count($con); } - return count($this->collDelivzones); + return count($this->collAreaDeliveryModules); } /** - * Method called to associate a ChildDelivzone object to this object - * through the ChildDelivzone foreign key attribute. + * Method called to associate a ChildAreaDeliveryModule object to this object + * through the ChildAreaDeliveryModule foreign key attribute. * - * @param ChildDelivzone $l ChildDelivzone + * @param ChildAreaDeliveryModule $l ChildAreaDeliveryModule * @return \Thelia\Model\Area The current object (for fluent API support) */ - public function addDelivzone(ChildDelivzone $l) + public function addAreaDeliveryModule(ChildAreaDeliveryModule $l) { - if ($this->collDelivzones === null) { - $this->initDelivzones(); - $this->collDelivzonesPartial = true; + if ($this->collAreaDeliveryModules === null) { + $this->initAreaDeliveryModules(); + $this->collAreaDeliveryModulesPartial = true; } - if (!in_array($l, $this->collDelivzones->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDelivzone($l); + if (!in_array($l, $this->collAreaDeliveryModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAreaDeliveryModule($l); } return $this; } /** - * @param Delivzone $delivzone The delivzone object to add. + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to add. */ - protected function doAddDelivzone($delivzone) + protected function doAddAreaDeliveryModule($areaDeliveryModule) { - $this->collDelivzones[]= $delivzone; - $delivzone->setArea($this); + $this->collAreaDeliveryModules[]= $areaDeliveryModule; + $areaDeliveryModule->setArea($this); } /** - * @param Delivzone $delivzone The delivzone object to remove. + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to remove. * @return ChildArea The current object (for fluent API support) */ - public function removeDelivzone($delivzone) + public function removeAreaDeliveryModule($areaDeliveryModule) { - if ($this->getDelivzones()->contains($delivzone)) { - $this->collDelivzones->remove($this->collDelivzones->search($delivzone)); - if (null === $this->delivzonesScheduledForDeletion) { - $this->delivzonesScheduledForDeletion = clone $this->collDelivzones; - $this->delivzonesScheduledForDeletion->clear(); + if ($this->getAreaDeliveryModules()->contains($areaDeliveryModule)) { + $this->collAreaDeliveryModules->remove($this->collAreaDeliveryModules->search($areaDeliveryModule)); + if (null === $this->areaDeliveryModulesScheduledForDeletion) { + $this->areaDeliveryModulesScheduledForDeletion = clone $this->collAreaDeliveryModules; + $this->areaDeliveryModulesScheduledForDeletion->clear(); } - $this->delivzonesScheduledForDeletion[]= $delivzone; - $delivzone->setArea(null); + $this->areaDeliveryModulesScheduledForDeletion[]= clone $areaDeliveryModule; + $areaDeliveryModule->setArea(null); } return $this; } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Area is new, it will return + * an empty collection; or if this Area has previously + * been saved, it will retrieve related AreaDeliveryModules from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Area. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + */ + public function getAreaDeliveryModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + $query->joinWith('Module', $joinBehavior); + + return $this->getAreaDeliveryModules($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1715,7 +1739,7 @@ abstract class Area implements ActiveRecordInterface { $this->id = null; $this->name = null; - $this->unit = null; + $this->postage = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1742,8 +1766,8 @@ abstract class Area implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collDelivzones) { - foreach ($this->collDelivzones as $o) { + if ($this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $o) { $o->clearAllReferences($deep); } } @@ -1753,10 +1777,10 @@ abstract class Area implements ActiveRecordInterface $this->collCountries->clearIterator(); } $this->collCountries = null; - if ($this->collDelivzones instanceof Collection) { - $this->collDelivzones->clearIterator(); + if ($this->collAreaDeliveryModules instanceof Collection) { + $this->collAreaDeliveryModules->clearIterator(); } - $this->collDelivzones = null; + $this->collAreaDeliveryModules = null; } /** diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php similarity index 80% rename from core/lib/Thelia/Model/Base/Delivzone.php rename to core/lib/Thelia/Model/Base/AreaDeliveryModule.php index deb21997e..38a16dd5a 100644 --- a/core/lib/Thelia/Model/Base/Delivzone.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php @@ -17,17 +17,19 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Area as ChildArea; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; use Thelia\Model\AreaQuery as ChildAreaQuery; -use Thelia\Model\Delivzone as ChildDelivzone; -use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery; -use Thelia\Model\Map\DelivzoneTableMap; +use Thelia\Model\Module as ChildModule; +use Thelia\Model\ModuleQuery as ChildModuleQuery; +use Thelia\Model\Map\AreaDeliveryModuleTableMap; -abstract class Delivzone implements ActiveRecordInterface +abstract class AreaDeliveryModule implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\DelivzoneTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\AreaDeliveryModuleTableMap'; /** @@ -69,10 +71,10 @@ abstract class Delivzone implements ActiveRecordInterface protected $area_id; /** - * The value for the delivery field. - * @var string + * The value for the delivery_module_id field. + * @var int */ - protected $delivery; + protected $delivery_module_id; /** * The value for the created_at field. @@ -91,6 +93,11 @@ abstract class Delivzone implements ActiveRecordInterface */ protected $aArea; + /** + * @var Module + */ + protected $aModule; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -100,7 +107,7 @@ abstract class Delivzone implements ActiveRecordInterface protected $alreadyInSave = false; /** - * Initializes internal state of Thelia\Model\Base\Delivzone object. + * Initializes internal state of Thelia\Model\Base\AreaDeliveryModule object. */ public function __construct() { @@ -195,9 +202,9 @@ abstract class Delivzone implements ActiveRecordInterface } /** - * Compares this with another Delivzone instance. If - * obj is an instance of Delivzone, delegates to - * equals(Delivzone). Otherwise, returns false. + * Compares this with another AreaDeliveryModule instance. If + * 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. @@ -278,7 +285,7 @@ abstract class Delivzone implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return Delivzone The current object, for fluid interface + * @return AreaDeliveryModule The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -310,7 +317,7 @@ abstract class Delivzone implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return Delivzone The current object, for fluid interface + * @return AreaDeliveryModule The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -376,14 +383,14 @@ abstract class Delivzone implements ActiveRecordInterface } /** - * Get the [delivery] column value. + * Get the [delivery_module_id] column value. * - * @return string + * @return int */ - public function getDelivery() + public function getDeliveryModuleId() { - return $this->delivery; + return $this->delivery_module_id; } /** @@ -430,7 +437,7 @@ abstract class Delivzone implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setId($v) { @@ -440,7 +447,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = DelivzoneTableMap::ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::ID; } @@ -451,7 +458,7 @@ abstract class Delivzone implements ActiveRecordInterface * Set the value of [area_id] column. * * @param int $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setAreaId($v) { @@ -461,7 +468,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->area_id !== $v) { $this->area_id = $v; - $this->modifiedColumns[] = DelivzoneTableMap::AREA_ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::AREA_ID; } if ($this->aArea !== null && $this->aArea->getId() !== $v) { @@ -473,32 +480,36 @@ abstract class Delivzone implements ActiveRecordInterface } // setAreaId() /** - * Set the value of [delivery] column. + * Set the value of [delivery_module_id] column. * - * @param string $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ - public function setDelivery($v) + public function setDeliveryModuleId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->delivery !== $v) { - $this->delivery = $v; - $this->modifiedColumns[] = DelivzoneTableMap::DELIVERY; + if ($this->delivery_module_id !== $v) { + $this->delivery_module_id = $v; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID; + } + + if ($this->aModule !== null && $this->aModule->getId() !== $v) { + $this->aModule = null; } return $this; - } // setDelivery() + } // setDeliveryModuleId() /** * 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\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -506,7 +517,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = DelivzoneTableMap::CREATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::CREATED_AT; } } // if either are not null @@ -519,7 +530,7 @@ abstract class Delivzone implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -527,7 +538,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::UPDATED_AT; } } // if either are not null @@ -572,22 +583,22 @@ abstract class Delivzone implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DelivzoneTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DelivzoneTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; $this->area_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DelivzoneTableMap::translateFieldName('Delivery', TableMap::TYPE_PHPNAME, $indexType)]; - $this->delivery = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_module_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DelivzoneTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaDeliveryModuleTableMap::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 : DelivzoneTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -600,10 +611,10 @@ abstract class Delivzone implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = DelivzoneTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = AreaDeliveryModuleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Delivzone object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\AreaDeliveryModule object", 0, $e); } } @@ -625,6 +636,9 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { $this->aArea = null; } + if ($this->aModule !== null && $this->delivery_module_id !== $this->aModule->getId()) { + $this->aModule = null; + } } // ensureConsistency /** @@ -648,13 +662,13 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildDelivzoneQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildAreaDeliveryModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -665,6 +679,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aArea = null; + $this->aModule = null; } // if (deep) } @@ -674,8 +689,8 @@ abstract class Delivzone implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see Delivzone::setDeleted() - * @see Delivzone::isDeleted() + * @see AreaDeliveryModule::setDeleted() + * @see AreaDeliveryModule::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -684,12 +699,12 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildDelivzoneQuery::create() + $deleteQuery = ChildAreaDeliveryModuleQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -726,7 +741,7 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -736,16 +751,16 @@ abstract class Delivzone implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + if (!$this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -757,7 +772,7 @@ abstract class Delivzone implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - DelivzoneTableMap::addInstanceToPool($this); + AreaDeliveryModuleTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -799,6 +814,13 @@ abstract class Delivzone implements ActiveRecordInterface $this->setArea($this->aArea); } + if ($this->aModule !== null) { + if ($this->aModule->isModified() || $this->aModule->isNew()) { + $affectedRows += $this->aModule->save($con); + } + $this->setModule($this->aModule); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -830,30 +852,30 @@ abstract class Delivzone implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = DelivzoneTableMap::ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . DelivzoneTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AreaDeliveryModuleTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DelivzoneTableMap::ID)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::AREA_ID)) { $modifiedColumns[':p' . $index++] = 'AREA_ID'; } - if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) { - $modifiedColumns[':p' . $index++] = 'DELIVERY'; + if ($this->isColumnModified(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; } - if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO delivzone (%s) VALUES (%s)', + 'INSERT INTO area_delivery_module (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -868,8 +890,8 @@ abstract class Delivzone implements ActiveRecordInterface case 'AREA_ID': $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); break; - case 'DELIVERY': - $stmt->bindValue($identifier, $this->delivery, PDO::PARAM_STR); + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_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); @@ -923,7 +945,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AreaDeliveryModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -946,7 +968,7 @@ abstract class Delivzone implements ActiveRecordInterface return $this->getAreaId(); break; case 2: - return $this->getDelivery(); + return $this->getDeliveryModuleId(); break; case 3: return $this->getCreatedAt(); @@ -977,15 +999,15 @@ abstract class Delivzone implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['AreaDeliveryModule'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()] = true; - $keys = DelivzoneTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['AreaDeliveryModule'][$this->getPrimaryKey()] = true; + $keys = AreaDeliveryModuleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getAreaId(), - $keys[2] => $this->getDelivery(), + $keys[2] => $this->getDeliveryModuleId(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -999,6 +1021,9 @@ abstract class Delivzone implements ActiveRecordInterface if (null !== $this->aArea) { $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aModule) { + $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } } return $result; @@ -1017,7 +1042,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AreaDeliveryModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1040,7 +1065,7 @@ abstract class Delivzone implements ActiveRecordInterface $this->setAreaId($value); break; case 2: - $this->setDelivery($value); + $this->setDeliveryModuleId($value); break; case 3: $this->setCreatedAt($value); @@ -1070,11 +1095,11 @@ abstract class Delivzone implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = DelivzoneTableMap::getFieldNames($keyType); + $keys = AreaDeliveryModuleTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDelivery($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setDeliveryModuleId($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]]); } @@ -1086,13 +1111,13 @@ abstract class Delivzone implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); - if ($this->isColumnModified(DelivzoneTableMap::ID)) $criteria->add(DelivzoneTableMap::ID, $this->id); - if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) $criteria->add(DelivzoneTableMap::AREA_ID, $this->area_id); - if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) $criteria->add(DelivzoneTableMap::DELIVERY, $this->delivery); - if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) $criteria->add(DelivzoneTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) $criteria->add(DelivzoneTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::ID)) $criteria->add(AreaDeliveryModuleTableMap::ID, $this->id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::AREA_ID)) $criteria->add(AreaDeliveryModuleTableMap::AREA_ID, $this->area_id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID)) $criteria->add(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $this->delivery_module_id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) $criteria->add(AreaDeliveryModuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) $criteria->add(AreaDeliveryModuleTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1107,8 +1132,8 @@ abstract class Delivzone implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); - $criteria->add(DelivzoneTableMap::ID, $this->id); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); + $criteria->add(AreaDeliveryModuleTableMap::ID, $this->id); return $criteria; } @@ -1149,7 +1174,7 @@ abstract class Delivzone implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\Delivzone (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\AreaDeliveryModule (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 @@ -1157,7 +1182,7 @@ abstract class Delivzone implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setAreaId($this->getAreaId()); - $copyObj->setDelivery($this->getDelivery()); + $copyObj->setDeliveryModuleId($this->getDeliveryModuleId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1175,7 +1200,7 @@ abstract class Delivzone implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Delivzone Clone of current object. + * @return \Thelia\Model\AreaDeliveryModule Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1192,7 +1217,7 @@ abstract class Delivzone implements ActiveRecordInterface * Declares an association between this object and a ChildArea object. * * @param ChildArea $v - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) * @throws PropelException */ public function setArea(ChildArea $v = null) @@ -1208,7 +1233,7 @@ abstract class Delivzone implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildArea object, it will not be re-added. if ($v !== null) { - $v->addDelivzone($this); + $v->addAreaDeliveryModule($this); } @@ -1232,13 +1257,64 @@ abstract class Delivzone implements ActiveRecordInterface 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->aArea->addDelivzones($this); + $this->aArea->addAreaDeliveryModules($this); */ } return $this->aArea; } + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $v = null) + { + if ($v === null) { + $this->setDeliveryModuleId(NULL); + } else { + $this->setDeliveryModuleId($v->getId()); + } + + $this->aModule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addAreaDeliveryModule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->delivery_module_id !== null)) { + $this->aModule = ChildModuleQuery::create()->findPk($this->delivery_module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModule->addAreaDeliveryModules($this); + */ + } + + return $this->aModule; + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1246,7 +1322,7 @@ abstract class Delivzone implements ActiveRecordInterface { $this->id = null; $this->area_id = null; - $this->delivery = null; + $this->delivery_module_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1271,6 +1347,7 @@ abstract class Delivzone implements ActiveRecordInterface } // if ($deep) $this->aArea = null; + $this->aModule = null; } /** @@ -1280,7 +1357,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(DelivzoneTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(AreaDeliveryModuleTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1288,11 +1365,11 @@ abstract class Delivzone implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildDelivzone The current object (for fluent API support) + * @return ChildAreaDeliveryModule The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php similarity index 55% rename from core/lib/Thelia/Model/Base/FeatureCategoryQuery.php rename to core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php index b9c9a67be..394fe651e 100644 --- a/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php @@ -12,84 +12,84 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\FeatureCategory as ChildFeatureCategory; -use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery; -use Thelia\Model\Map\FeatureCategoryTableMap; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; +use Thelia\Model\Map\AreaDeliveryModuleTableMap; /** - * Base class that represents a query for the 'feature_category' table. + * Base class that represents a query for the 'area_delivery_module' table. * * * - * @method ChildFeatureCategoryQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildFeatureCategoryQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column - * @method ChildFeatureCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column - * @method ChildFeatureCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ChildFeatureCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildAreaDeliveryModuleQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildAreaDeliveryModuleQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column + * @method ChildAreaDeliveryModuleQuery orderByDeliveryModuleId($order = Criteria::ASC) Order by the delivery_module_id column + * @method ChildAreaDeliveryModuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method ChildAreaDeliveryModuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * - * @method ChildFeatureCategoryQuery groupById() Group by the id column - * @method ChildFeatureCategoryQuery groupByFeatureId() Group by the feature_id column - * @method ChildFeatureCategoryQuery groupByCategoryId() Group by the category_id column - * @method ChildFeatureCategoryQuery groupByCreatedAt() Group by the created_at column - * @method ChildFeatureCategoryQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildAreaDeliveryModuleQuery groupById() Group by the id column + * @method ChildAreaDeliveryModuleQuery groupByAreaId() Group by the area_id column + * @method ChildAreaDeliveryModuleQuery groupByDeliveryModuleId() Group by the delivery_module_id column + * @method ChildAreaDeliveryModuleQuery groupByCreatedAt() Group by the created_at column + * @method ChildAreaDeliveryModuleQuery groupByUpdatedAt() Group by the updated_at column * - * @method ChildFeatureCategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildFeatureCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildFeatureCategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildFeatureCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation - * @method ChildFeatureCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation - * @method ChildFeatureCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation + * @method ChildAreaDeliveryModuleQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation * - * @method ChildFeatureCategoryQuery leftJoinFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the Feature relation - * @method ChildFeatureCategoryQuery rightJoinFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Feature relation - * @method ChildFeatureCategoryQuery innerJoinFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the Feature relation + * @method ChildAreaDeliveryModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation + * @method ChildAreaDeliveryModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation + * @method ChildAreaDeliveryModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation * - * @method ChildFeatureCategory findOne(ConnectionInterface $con = null) Return the first ChildFeatureCategory matching the query - * @method ChildFeatureCategory findOneOrCreate(ConnectionInterface $con = null) Return the first ChildFeatureCategory matching the query, or a new ChildFeatureCategory object populated from the query conditions when no match is found + * @method ChildAreaDeliveryModule findOne(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query + * @method ChildAreaDeliveryModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query, or a new ChildAreaDeliveryModule object populated from the query conditions when no match is found * - * @method ChildFeatureCategory findOneById(int $id) Return the first ChildFeatureCategory filtered by the id column - * @method ChildFeatureCategory findOneByFeatureId(int $feature_id) Return the first ChildFeatureCategory filtered by the feature_id column - * @method ChildFeatureCategory findOneByCategoryId(int $category_id) Return the first ChildFeatureCategory filtered by the category_id column - * @method ChildFeatureCategory findOneByCreatedAt(string $created_at) Return the first ChildFeatureCategory filtered by the created_at column - * @method ChildFeatureCategory findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureCategory filtered by the updated_at column + * @method ChildAreaDeliveryModule findOneById(int $id) Return the first ChildAreaDeliveryModule filtered by the id column + * @method ChildAreaDeliveryModule findOneByAreaId(int $area_id) Return the first ChildAreaDeliveryModule filtered by the area_id column + * @method ChildAreaDeliveryModule findOneByDeliveryModuleId(int $delivery_module_id) Return the first ChildAreaDeliveryModule filtered by the delivery_module_id column + * @method ChildAreaDeliveryModule findOneByCreatedAt(string $created_at) Return the first ChildAreaDeliveryModule filtered by the created_at column + * @method ChildAreaDeliveryModule findOneByUpdatedAt(string $updated_at) Return the first ChildAreaDeliveryModule filtered by the updated_at column * - * @method array findById(int $id) Return ChildFeatureCategory objects filtered by the id column - * @method array findByFeatureId(int $feature_id) Return ChildFeatureCategory objects filtered by the feature_id column - * @method array findByCategoryId(int $category_id) Return ChildFeatureCategory objects filtered by the category_id column - * @method array findByCreatedAt(string $created_at) Return ChildFeatureCategory objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_at) Return ChildFeatureCategory objects filtered by the updated_at column + * @method array findById(int $id) Return ChildAreaDeliveryModule objects filtered by the id column + * @method array findByAreaId(int $area_id) Return ChildAreaDeliveryModule objects filtered by the area_id column + * @method array findByDeliveryModuleId(int $delivery_module_id) Return ChildAreaDeliveryModule objects filtered by the delivery_module_id column + * @method array findByCreatedAt(string $created_at) Return ChildAreaDeliveryModule objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return ChildAreaDeliveryModule objects filtered by the updated_at column * */ -abstract class FeatureCategoryQuery extends ModelCriteria +abstract class AreaDeliveryModuleQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\FeatureCategoryQuery object. + * Initializes internal state of \Thelia\Model\Base\AreaDeliveryModuleQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\FeatureCategory', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AreaDeliveryModule', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildFeatureCategoryQuery object. + * Returns a new ChildAreaDeliveryModuleQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildFeatureCategoryQuery + * @return ChildAreaDeliveryModuleQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\FeatureCategoryQuery) { + if ($criteria instanceof \Thelia\Model\AreaDeliveryModuleQuery) { return $criteria; } - $query = new \Thelia\Model\FeatureCategoryQuery(); + $query = new \Thelia\Model\AreaDeliveryModuleQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -112,19 +112,19 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter + * @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + if ((null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,11 +143,11 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildFeatureCategory A model object, or null if the key is not found + * @return ChildAreaDeliveryModule A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, FEATURE_ID, CATEGORY_ID, CREATED_AT, UPDATED_AT FROM feature_category WHERE ID = :p0'; + $sql = 'SELECT ID, AREA_ID, DELIVERY_MODULE_ID, CREATED_AT, UPDATED_AT FROM area_delivery_module WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -158,9 +158,9 @@ abstract class FeatureCategoryQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildFeatureCategory(); + $obj = new ChildAreaDeliveryModule(); $obj->hydrate($row); - FeatureCategoryTableMap::addInstanceToPool($obj, (string) $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -173,7 +173,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter + * @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -215,12 +215,12 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(FeatureCategoryTableMap::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -228,12 +228,12 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(FeatureCategoryTableMap::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $keys, Criteria::IN); } /** @@ -252,18 +252,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery 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(FeatureCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -274,39 +274,39 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::ID, $id, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id, $comparison); } /** - * Filter the query on the feature_id column + * Filter the query on the area_id column * * Example usage: * - * $query->filterByFeatureId(1234); // WHERE feature_id = 1234 - * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) - * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 + * $query->filterByAreaId(1234); // WHERE area_id = 1234 + * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) + * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 * * - * @see filterByFeature() + * @see filterByArea() * - * @param mixed $featureId The value to use as filter. + * @param mixed $areaId 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 ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function filterByFeatureId($featureId = null, $comparison = null) + public function filterByAreaId($areaId = null, $comparison = null) { - if (is_array($featureId)) { + if (is_array($areaId)) { $useMinMax = false; - if (isset($featureId['min'])) { - $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); + if (isset($areaId['min'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); + if (isset($areaId['max'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -317,39 +317,39 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId, $comparison); } /** - * Filter the query on the category_id column + * Filter the query on the delivery_module_id column * * Example usage: * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 + * $query->filterByDeliveryModuleId(1234); // WHERE delivery_module_id = 1234 + * $query->filterByDeliveryModuleId(array(12, 34)); // WHERE delivery_module_id IN (12, 34) + * $query->filterByDeliveryModuleId(array('min' => 12)); // WHERE delivery_module_id > 12 * * - * @see filterByCategory() + * @see filterByModule() * - * @param mixed $categoryId The value to use as filter. + * @param mixed $deliveryModuleId 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 ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function filterByCategoryId($categoryId = null, $comparison = null) + public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null) { - if (is_array($categoryId)) { + if (is_array($deliveryModuleId)) { $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); + if (isset($deliveryModuleId['min'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($categoryId['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + if (isset($deliveryModuleId['max'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -360,7 +360,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison); } /** @@ -381,18 +381,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery 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(FeatureCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -403,7 +403,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -424,18 +424,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery 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(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -446,46 +446,46 @@ abstract class FeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related \Thelia\Model\Category object + * Filter the query by a related \Thelia\Model\Area object * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter + * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function filterByCategory($category, $comparison = null) + public function filterByArea($area, $comparison = null) { - if ($category instanceof \Thelia\Model\Category) { + if ($area instanceof \Thelia\Model\Area) { return $this - ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { + ->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->getId(), $comparison); + } elseif ($area instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); + throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); } } /** - * Adds a JOIN clause to the query using the Category relation + * Adds a JOIN clause to the query using the Area relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); + $relationMap = $tableMap->getRelation('Area'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -500,14 +500,14 @@ abstract class FeatureCategoryQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Category'); + $this->addJoinObject($join, 'Area'); } return $this; } /** - * Use the Category relation Category object + * Use the Area relation Area object * * @see useQuery() * @@ -515,52 +515,52 @@ abstract class FeatureCategoryQuery 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\CategoryQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); + ->joinArea($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery'); } /** - * Filter the query by a related \Thelia\Model\Feature object + * Filter the query by a related \Thelia\Model\Module object * - * @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function filterByFeature($feature, $comparison = null) + public function filterByModule($module, $comparison = null) { - if ($feature instanceof \Thelia\Model\Feature) { + if ($module instanceof \Thelia\Model\Module) { return $this - ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->getId(), $comparison); - } elseif ($feature instanceof ObjectCollection) { + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); } } /** - * Adds a JOIN clause to the query using the Feature relation + * Adds a JOIN clause to the query using the Module relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Feature'); + $relationMap = $tableMap->getRelation('Module'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -575,14 +575,14 @@ abstract class FeatureCategoryQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Feature'); + $this->addJoinObject($join, 'Module'); } return $this; } /** - * Use the Feature relation Feature object + * Use the Module relation Module object * * @see useQuery() * @@ -590,33 +590,33 @@ abstract class FeatureCategoryQuery 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\FeatureQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query */ - public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); } /** * Exclude object from result * - * @param ChildFeatureCategory $featureCategory Object to remove from the list of results + * @param ChildAreaDeliveryModule $areaDeliveryModule Object to remove from the list of results * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function prune($featureCategory = null) + public function prune($areaDeliveryModule = null) { - if ($featureCategory) { - $this->addUsingAlias(FeatureCategoryTableMap::ID, $featureCategory->getId(), Criteria::NOT_EQUAL); + if ($areaDeliveryModule) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $areaDeliveryModule->getId(), Criteria::NOT_EQUAL); } return $this; } /** - * Deletes all rows from the feature_category table. + * Deletes all rows from the area_delivery_module table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -624,7 +624,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -635,8 +635,8 @@ abstract class FeatureCategoryQuery extends ModelCriteria // 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). - FeatureCategoryTableMap::clearInstancePool(); - FeatureCategoryTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -648,9 +648,9 @@ abstract class FeatureCategoryQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildFeatureCategory or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildAreaDeliveryModule or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildFeatureCategory object or primary key or array of primary keys + * @param mixed $values Criteria or ChildAreaDeliveryModule 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 @@ -661,13 +661,13 @@ abstract class FeatureCategoryQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(FeatureCategoryTableMap::DATABASE_NAME); + $criteria->setDbName(AreaDeliveryModuleTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -677,10 +677,10 @@ abstract class FeatureCategoryQuery extends ModelCriteria $con->beginTransaction(); - FeatureCategoryTableMap::removeInstanceFromPool($criteria); + AreaDeliveryModuleTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - FeatureCategoryTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -697,11 +697,11 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function recentlyUpdated($nbDays = 7) { - return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -709,51 +709,51 @@ abstract class FeatureCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function recentlyCreated($nbDays = 7) { - return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** * Order by update date desc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastUpdatedFirst() { - return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by update date asc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstUpdatedFirst() { - return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ChildFeatureCategoryQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } -} // FeatureCategoryQuery +} // AreaDeliveryModuleQuery diff --git a/core/lib/Thelia/Model/Base/AreaQuery.php b/core/lib/Thelia/Model/Base/AreaQuery.php index f583a30dd..ea4cd8b90 100644 --- a/core/lib/Thelia/Model/Base/AreaQuery.php +++ b/core/lib/Thelia/Model/Base/AreaQuery.php @@ -23,13 +23,13 @@ use Thelia\Model\Map\AreaTableMap; * * @method ChildAreaQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildAreaQuery orderByName($order = Criteria::ASC) Order by the name column - * @method ChildAreaQuery orderByUnit($order = Criteria::ASC) Order by the unit column + * @method ChildAreaQuery orderByPostage($order = Criteria::ASC) Order by the postage column * @method ChildAreaQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAreaQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildAreaQuery groupById() Group by the id column * @method ChildAreaQuery groupByName() Group by the name column - * @method ChildAreaQuery groupByUnit() Group by the unit column + * @method ChildAreaQuery groupByPostage() Group by the postage column * @method ChildAreaQuery groupByCreatedAt() Group by the created_at column * @method ChildAreaQuery groupByUpdatedAt() Group by the updated_at column * @@ -41,22 +41,22 @@ use Thelia\Model\Map\AreaTableMap; * @method ChildAreaQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation * @method ChildAreaQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation * - * @method ChildAreaQuery leftJoinDelivzone($relationAlias = null) Adds a LEFT JOIN clause to the query using the Delivzone relation - * @method ChildAreaQuery rightJoinDelivzone($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Delivzone relation - * @method ChildAreaQuery innerJoinDelivzone($relationAlias = null) Adds a INNER JOIN clause to the query using the Delivzone relation + * @method ChildAreaQuery leftJoinAreaDeliveryModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildAreaQuery rightJoinAreaDeliveryModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildAreaQuery innerJoinAreaDeliveryModule($relationAlias = null) Adds a INNER JOIN clause to the query using the AreaDeliveryModule relation * * @method ChildArea findOne(ConnectionInterface $con = null) Return the first ChildArea matching the query * @method ChildArea findOneOrCreate(ConnectionInterface $con = null) Return the first ChildArea matching the query, or a new ChildArea object populated from the query conditions when no match is found * * @method ChildArea findOneById(int $id) Return the first ChildArea filtered by the id column * @method ChildArea findOneByName(string $name) Return the first ChildArea filtered by the name column - * @method ChildArea findOneByUnit(double $unit) Return the first ChildArea filtered by the unit column + * @method ChildArea findOneByPostage(double $postage) Return the first ChildArea filtered by the postage column * @method ChildArea findOneByCreatedAt(string $created_at) Return the first ChildArea filtered by the created_at column * @method ChildArea findOneByUpdatedAt(string $updated_at) Return the first ChildArea filtered by the updated_at column * * @method array findById(int $id) Return ChildArea objects filtered by the id column * @method array findByName(string $name) Return ChildArea objects filtered by the name column - * @method array findByUnit(double $unit) Return ChildArea objects filtered by the unit column + * @method array findByPostage(double $postage) Return ChildArea objects filtered by the postage column * @method array findByCreatedAt(string $created_at) Return ChildArea objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildArea objects filtered by the updated_at column * @@ -147,7 +147,7 @@ abstract class AreaQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, NAME, UNIT, CREATED_AT, UPDATED_AT FROM area WHERE ID = :p0'; + $sql = 'SELECT ID, NAME, POSTAGE, CREATED_AT, UPDATED_AT FROM area WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -307,16 +307,16 @@ abstract class AreaQuery extends ModelCriteria } /** - * Filter the query on the unit column + * Filter the query on the postage column * * Example usage: * - * $query->filterByUnit(1234); // WHERE unit = 1234 - * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34) - * $query->filterByUnit(array('min' => 12)); // WHERE unit > 12 + * $query->filterByPostage(1234); // WHERE postage = 1234 + * $query->filterByPostage(array(12, 34)); // WHERE postage IN (12, 34) + * $query->filterByPostage(array('min' => 12)); // WHERE postage > 12 * * - * @param mixed $unit The value to use as filter. + * @param mixed $postage 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. @@ -324,16 +324,16 @@ abstract class AreaQuery extends ModelCriteria * * @return ChildAreaQuery The current query, for fluid interface */ - public function filterByUnit($unit = null, $comparison = null) + public function filterByPostage($postage = null, $comparison = null) { - if (is_array($unit)) { + if (is_array($postage)) { $useMinMax = false; - if (isset($unit['min'])) { - $this->addUsingAlias(AreaTableMap::UNIT, $unit['min'], Criteria::GREATER_EQUAL); + if (isset($postage['min'])) { + $this->addUsingAlias(AreaTableMap::POSTAGE, $postage['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($unit['max'])) { - $this->addUsingAlias(AreaTableMap::UNIT, $unit['max'], Criteria::LESS_EQUAL); + if (isset($postage['max'])) { + $this->addUsingAlias(AreaTableMap::POSTAGE, $postage['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -344,7 +344,7 @@ abstract class AreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaTableMap::UNIT, $unit, $comparison); + return $this->addUsingAlias(AreaTableMap::POSTAGE, $postage, $comparison); } /** @@ -507,40 +507,40 @@ abstract class AreaQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Delivzone object + * Filter the query by a related \Thelia\Model\AreaDeliveryModule object * - * @param \Thelia\Model\Delivzone|ObjectCollection $delivzone the related object to use as filter + * @param \Thelia\Model\AreaDeliveryModule|ObjectCollection $areaDeliveryModule the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAreaQuery The current query, for fluid interface */ - public function filterByDelivzone($delivzone, $comparison = null) + public function filterByAreaDeliveryModule($areaDeliveryModule, $comparison = null) { - if ($delivzone instanceof \Thelia\Model\Delivzone) { + if ($areaDeliveryModule instanceof \Thelia\Model\AreaDeliveryModule) { return $this - ->addUsingAlias(AreaTableMap::ID, $delivzone->getAreaId(), $comparison); - } elseif ($delivzone instanceof ObjectCollection) { + ->addUsingAlias(AreaTableMap::ID, $areaDeliveryModule->getAreaId(), $comparison); + } elseif ($areaDeliveryModule instanceof ObjectCollection) { return $this - ->useDelivzoneQuery() - ->filterByPrimaryKeys($delivzone->getPrimaryKeys()) + ->useAreaDeliveryModuleQuery() + ->filterByPrimaryKeys($areaDeliveryModule->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDelivzone() only accepts arguments of type \Thelia\Model\Delivzone or Collection'); + throw new PropelException('filterByAreaDeliveryModule() only accepts arguments of type \Thelia\Model\AreaDeliveryModule or Collection'); } } /** - * Adds a JOIN clause to the query using the Delivzone relation + * Adds a JOIN clause to the query using the AreaDeliveryModule relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildAreaQuery The current query, for fluid interface */ - public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinAreaDeliveryModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Delivzone'); + $relationMap = $tableMap->getRelation('AreaDeliveryModule'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -555,14 +555,14 @@ abstract class AreaQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Delivzone'); + $this->addJoinObject($join, 'AreaDeliveryModule'); } return $this; } /** - * Use the Delivzone relation Delivzone object + * Use the AreaDeliveryModule relation AreaDeliveryModule object * * @see useQuery() * @@ -570,13 +570,13 @@ abstract class AreaQuery 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\DelivzoneQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AreaDeliveryModuleQuery A secondary query class using the current class as primary query */ - public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useAreaDeliveryModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinDelivzone($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Delivzone', '\Thelia\Model\DelivzoneQuery'); + ->joinAreaDeliveryModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AreaDeliveryModule', '\Thelia\Model\AreaDeliveryModuleQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/AttributeCategory.php b/core/lib/Thelia/Model/Base/AttributeCategory.php deleted file mode 100644 index da702559a..000000000 --- a/core/lib/Thelia/Model/Base/AttributeCategory.php +++ /dev/null @@ -1,1495 +0,0 @@ -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 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 AttributeCategory instance. If - * obj is an instance of AttributeCategory, delegates to - * equals(AttributeCategory). Otherwise, returns false. - * - * @param obj The object to compare to. - * @return 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 - * - * @param string $name The virtual column name - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @return mixed - */ - 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 AttributeCategory 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 AttributeCategory The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - } - - /** - * 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 [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - - return $this->category_id; - } - - /** - * Get the [attribute_id] column value. - * - * @return int - */ - public function getAttributeId() - { - - return $this->attribute_id; - } - - /** - * 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 !== null ? $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 !== null ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\AttributeCategory 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[] = AttributeCategoryTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = AttributeCategoryTableMap::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [attribute_id] column. - * - * @param int $v new value - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) - */ - public function setAttributeId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->attribute_id !== $v) { - $this->attribute_id = $v; - $this->modifiedColumns[] = AttributeCategoryTableMap::ATTRIBUTE_ID; - } - - if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) { - $this->aAttribute = null; - } - - - return $this; - } // setAttributeId() - - /** - * 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\AttributeCategory 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[] = AttributeCategoryTableMap::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\AttributeCategory 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[] = AttributeCategoryTableMap::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 : AttributeCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCategoryTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCategoryTableMap::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 : AttributeCategoryTableMap::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 + 5; // 5 = AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\AttributeCategory 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->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) { - $this->aAttribute = 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(AttributeCategoryTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildAttributeCategoryQuery::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->aCategory = null; - $this->aAttribute = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see AttributeCategory::setDeleted() - * @see AttributeCategory::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(AttributeCategoryTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildAttributeCategoryQuery::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(AttributeCategoryTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AttributeCategoryTableMap::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->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aAttribute !== null) { - if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) { - $affectedRows += $this->aAttribute->save($con); - } - $this->setAttribute($this->aAttribute); - } - - 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[] = AttributeCategoryTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCategoryTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeCategoryTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; - } - if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID'; - } - if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO attribute_category (%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 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case 'ATTRIBUTE_ID': - $stmt->bindValue($identifier, $this->attribute_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); - } - - /** - * 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 = AttributeCategoryTableMap::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->getCategoryId(); - break; - case 2: - return $this->getAttributeId(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - 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['AttributeCategory'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()] = true; - $keys = AttributeCategoryTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getAttributeId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aAttribute) { - $result['Attribute'] = $this->aAttribute->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 = AttributeCategoryTableMap::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->setCategoryId($value); - break; - case 2: - $this->setAttributeId($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $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 = AttributeCategoryTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAttributeId($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]]); - } - - /** - * 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(AttributeCategoryTableMap::DATABASE_NAME); - - if ($this->isColumnModified(AttributeCategoryTableMap::ID)) $criteria->add(AttributeCategoryTableMap::ID, $this->id); - if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) $criteria->add(AttributeCategoryTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCategoryTableMap::ATTRIBUTE_ID, $this->attribute_id); - if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) $criteria->add(AttributeCategoryTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) $criteria->add(AttributeCategoryTableMap::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(AttributeCategoryTableMap::DATABASE_NAME); - $criteria->add(AttributeCategoryTableMap::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\AttributeCategory (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->setCategoryId($this->getCategoryId()); - $copyObj->setAttributeId($this->getAttributeId()); - $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\AttributeCategory 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 ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCategory($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_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->aCategory->addAttributeCategories($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a ChildAttribute object. - * - * @param ChildAttribute $v - * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setAttribute(ChildAttribute $v = null) - { - if ($v === null) { - $this->setAttributeId(NULL); - } else { - $this->setAttributeId($v->getId()); - } - - $this->aAttribute = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildAttribute object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCategory($this); - } - - - return $this; - } - - - /** - * Get the associated ChildAttribute object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildAttribute The associated ChildAttribute object. - * @throws PropelException - */ - public function getAttribute(ConnectionInterface $con = null) - { - if ($this->aAttribute === null && ($this->attribute_id !== null)) { - $this->aAttribute = ChildAttributeQuery::create()->findPk($this->attribute_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->aAttribute->addAttributeCategories($this); - */ - } - - return $this->aAttribute; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->category_id = null; - $this->attribute_id = 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->aCategory = null; - $this->aAttribute = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AttributeCategoryTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildAttributeCategory The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AttributeCategoryTableMap::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/AttributeCategoryQuery.php b/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php deleted file mode 100644 index d325d2037..000000000 --- a/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php +++ /dev/null @@ -1,759 +0,0 @@ -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 ChildAttributeCategory|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::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 ChildAttributeCategory A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, CATEGORY_ID, ATTRIBUTE_ID, CREATED_AT, UPDATED_AT FROM attribute_category 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 ChildAttributeCategory(); - $obj->hydrate($row); - AttributeCategoryTableMap::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 ChildAttributeCategory|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 ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AttributeCategoryTableMap::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 ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AttributeCategoryTableMap::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 ChildAttributeCategoryQuery 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(AttributeCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId 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 ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the attribute_id column - * - * Example usage: - * - * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234 - * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34) - * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12 - * - * - * @see filterByAttribute() - * - * @param mixed $attributeId 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 ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByAttributeId($attributeId = null, $comparison = null) - { - if (is_array($attributeId)) { - $useMinMax = false; - if (isset($attributeId['min'])) { - $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId, $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 ChildAttributeCategoryQuery 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(AttributeCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryTableMap::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 ChildAttributeCategoryQuery 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(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Category object - * - * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof \Thelia\Model\Category) { - return $this - ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // 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, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category 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\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Attribute object - * - * @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function filterByAttribute($attribute, $comparison = null) - { - if ($attribute instanceof \Thelia\Model\Attribute) { - return $this - ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Attribute relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Attribute'); - - // 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, 'Attribute'); - } - - return $this; - } - - /** - * Use the Attribute relation Attribute 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\AttributeQuery A secondary query class using the current class as primary query - */ - public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttribute($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery'); - } - - /** - * Exclude object from result - * - * @param ChildAttributeCategory $attributeCategory Object to remove from the list of results - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function prune($attributeCategory = null) - { - if ($attributeCategory) { - $this->addUsingAlias(AttributeCategoryTableMap::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the attribute_category 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(AttributeCategoryTableMap::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). - AttributeCategoryTableMap::clearInstancePool(); - AttributeCategoryTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildAttributeCategory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildAttributeCategory 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(AttributeCategoryTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryTableMap::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(); - - - AttributeCategoryTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - AttributeCategoryTableMap::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 ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildAttributeCategoryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT); - } - -} // AttributeCategoryQuery diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php index 51d72b974..809825d51 100644 --- a/core/lib/Thelia/Model/Base/ContentFolder.php +++ b/core/lib/Thelia/Model/Base/ContentFolder.php @@ -70,6 +70,12 @@ abstract class ContentFolder implements ActiveRecordInterface */ protected $folder_id; + /** + * The value for the default_folder field. + * @var boolean + */ + protected $default_folder; + /** * The value for the created_at field. * @var string @@ -376,6 +382,17 @@ abstract class ContentFolder implements ActiveRecordInterface return $this->folder_id; } + /** + * Get the [default_folder] column value. + * + * @return boolean + */ + public function getDefaultFolder() + { + + return $this->default_folder; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -466,6 +483,35 @@ abstract class ContentFolder implements ActiveRecordInterface return $this; } // setFolderId() + /** + * Sets the value of the [default_folder] 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\ContentFolder The current object (for fluent API support) + */ + public function setDefaultFolder($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->default_folder !== $v) { + $this->default_folder = $v; + $this->modifiedColumns[] = ContentFolderTableMap::DEFAULT_FOLDER; + } + + + return $this; + } // setDefaultFolder() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -551,13 +597,16 @@ abstract class ContentFolder implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentFolderTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; $this->folder_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentFolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentFolderTableMap::translateFieldName('DefaultFolder', TableMap::TYPE_PHPNAME, $indexType)]; + $this->default_folder = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentFolderTableMap::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 ? 3 + $startcol : ContentFolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentFolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -570,7 +619,7 @@ abstract class ContentFolder implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 4; // 4 = ContentFolderTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = ContentFolderTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ContentFolder object", 0, $e); @@ -819,6 +868,9 @@ abstract class ContentFolder implements ActiveRecordInterface if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) { $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; } + if ($this->isColumnModified(ContentFolderTableMap::DEFAULT_FOLDER)) { + $modifiedColumns[':p' . $index++] = 'DEFAULT_FOLDER'; + } if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -842,6 +894,9 @@ abstract class ContentFolder implements ActiveRecordInterface case 'FOLDER_ID': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; + case 'DEFAULT_FOLDER': + $stmt->bindValue($identifier, (int) $this->default_folder, 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; @@ -910,9 +965,12 @@ abstract class ContentFolder implements ActiveRecordInterface return $this->getFolderId(); break; case 2: - return $this->getCreatedAt(); + return $this->getDefaultFolder(); break; case 3: + return $this->getCreatedAt(); + break; + case 4: return $this->getUpdatedAt(); break; default: @@ -946,8 +1004,9 @@ abstract class ContentFolder implements ActiveRecordInterface $result = array( $keys[0] => $this->getContentId(), $keys[1] => $this->getFolderId(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), + $keys[2] => $this->getDefaultFolder(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1003,9 +1062,12 @@ abstract class ContentFolder implements ActiveRecordInterface $this->setFolderId($value); break; case 2: - $this->setCreatedAt($value); + $this->setDefaultFolder($value); break; case 3: + $this->setCreatedAt($value); + break; + case 4: $this->setUpdatedAt($value); break; } // switch() @@ -1034,8 +1096,9 @@ abstract class ContentFolder implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setContentId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); + if (array_key_exists($keys[2], $arr)) $this->setDefaultFolder($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]]); } /** @@ -1049,6 +1112,7 @@ abstract class ContentFolder implements ActiveRecordInterface if ($this->isColumnModified(ContentFolderTableMap::CONTENT_ID)) $criteria->add(ContentFolderTableMap::CONTENT_ID, $this->content_id); if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) $criteria->add(ContentFolderTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(ContentFolderTableMap::DEFAULT_FOLDER)) $criteria->add(ContentFolderTableMap::DEFAULT_FOLDER, $this->default_folder); if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) $criteria->add(ContentFolderTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) $criteria->add(ContentFolderTableMap::UPDATED_AT, $this->updated_at); @@ -1123,6 +1187,7 @@ abstract class ContentFolder implements ActiveRecordInterface { $copyObj->setContentId($this->getContentId()); $copyObj->setFolderId($this->getFolderId()); + $copyObj->setDefaultFolder($this->getDefaultFolder()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1261,6 +1326,7 @@ abstract class ContentFolder implements ActiveRecordInterface { $this->content_id = null; $this->folder_id = null; + $this->default_folder = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ContentFolderQuery.php b/core/lib/Thelia/Model/Base/ContentFolderQuery.php index 208ba80cf..72561ae77 100644 --- a/core/lib/Thelia/Model/Base/ContentFolderQuery.php +++ b/core/lib/Thelia/Model/Base/ContentFolderQuery.php @@ -23,11 +23,13 @@ use Thelia\Model\Map\ContentFolderTableMap; * * @method ChildContentFolderQuery orderByContentId($order = Criteria::ASC) Order by the content_id column * @method ChildContentFolderQuery orderByFolderId($order = Criteria::ASC) Order by the folder_id column + * @method ChildContentFolderQuery orderByDefaultFolder($order = Criteria::ASC) Order by the default_folder column * @method ChildContentFolderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildContentFolderQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildContentFolderQuery groupByContentId() Group by the content_id column * @method ChildContentFolderQuery groupByFolderId() Group by the folder_id column + * @method ChildContentFolderQuery groupByDefaultFolder() Group by the default_folder column * @method ChildContentFolderQuery groupByCreatedAt() Group by the created_at column * @method ChildContentFolderQuery groupByUpdatedAt() Group by the updated_at column * @@ -48,11 +50,13 @@ use Thelia\Model\Map\ContentFolderTableMap; * * @method ChildContentFolder findOneByContentId(int $content_id) Return the first ChildContentFolder filtered by the content_id column * @method ChildContentFolder findOneByFolderId(int $folder_id) Return the first ChildContentFolder filtered by the folder_id column + * @method ChildContentFolder findOneByDefaultFolder(boolean $default_folder) Return the first ChildContentFolder filtered by the default_folder column * @method ChildContentFolder findOneByCreatedAt(string $created_at) Return the first ChildContentFolder filtered by the created_at column * @method ChildContentFolder findOneByUpdatedAt(string $updated_at) Return the first ChildContentFolder filtered by the updated_at column * * @method array findByContentId(int $content_id) Return ChildContentFolder objects filtered by the content_id column * @method array findByFolderId(int $folder_id) Return ChildContentFolder objects filtered by the folder_id column + * @method array findByDefaultFolder(boolean $default_folder) Return ChildContentFolder objects filtered by the default_folder column * @method array findByCreatedAt(string $created_at) Return ChildContentFolder objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildContentFolder objects filtered by the updated_at column * @@ -143,7 +147,7 @@ abstract class ContentFolderQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT CONTENT_ID, FOLDER_ID, CREATED_AT, UPDATED_AT FROM content_folder WHERE CONTENT_ID = :p0 AND FOLDER_ID = :p1'; + $sql = 'SELECT CONTENT_ID, FOLDER_ID, DEFAULT_FOLDER, CREATED_AT, UPDATED_AT FROM content_folder WHERE CONTENT_ID = :p0 AND FOLDER_ID = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -330,6 +334,33 @@ abstract class ContentFolderQuery extends ModelCriteria return $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId, $comparison); } + /** + * Filter the query on the default_folder column + * + * Example usage: + * + * $query->filterByDefaultFolder(true); // WHERE default_folder = true + * $query->filterByDefaultFolder('yes'); // WHERE default_folder = true + * + * + * @param boolean|string $defaultFolder 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 ChildContentFolderQuery The current query, for fluid interface + */ + public function filterByDefaultFolder($defaultFolder = null, $comparison = null) + { + if (is_string($defaultFolder)) { + $default_folder = in_array(strtolower($defaultFolder), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(ContentFolderTableMap::DEFAULT_FOLDER, $defaultFolder, $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 26d6573a9..e46176739 100644 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -987,10 +987,9 @@ abstract class Currency implements ActiveRecordInterface if ($this->ordersScheduledForDeletion !== null) { if (!$this->ordersScheduledForDeletion->isEmpty()) { - foreach ($this->ordersScheduledForDeletion as $order) { - // need to save related object because we set the relation to null - $order->save($con); - } + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->ordersScheduledForDeletion = null; } } @@ -1758,7 +1757,7 @@ abstract class Currency implements ActiveRecordInterface $this->ordersScheduledForDeletion = clone $this->collOrders; $this->ordersScheduledForDeletion->clear(); } - $this->ordersScheduledForDeletion[]= $order; + $this->ordersScheduledForDeletion[]= clone $order; $order->setCurrency(null); } @@ -1807,10 +1806,10 @@ abstract class Currency implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -1832,10 +1831,10 @@ abstract class Currency implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -1865,6 +1864,81 @@ abstract class Currency implements ActiveRecordInterface return $this->getOrders($query, $con); } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Currency is new, it will return + * an empty collection; or if this Currency has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Currency. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Currency is new, it will return + * an empty collection; or if this Currency has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Currency. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Currency is new, it will return + * an empty collection; or if this Currency has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Currency. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrders($query, $con); + } + /** * Clears out the collCarts collection * diff --git a/core/lib/Thelia/Model/Base/CurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php index eb4b1b2f7..4276000a1 100644 --- a/core/lib/Thelia/Model/Base/CurrencyQuery.php +++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php @@ -596,7 +596,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return ChildCurrencyQuery The current query, for fluid interface */ - public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Order'); @@ -631,7 +631,7 @@ abstract class CurrencyQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinOrder($relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index 06553ecfe..e7bd688af 100644 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -2552,10 +2552,10 @@ abstract class Customer implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -2577,10 +2577,10 @@ abstract class Customer implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -2610,6 +2610,81 @@ abstract class Customer implements ActiveRecordInterface return $this->getOrders($query, $con); } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Customer is new, it will return + * an empty collection; or if this Customer has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Customer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Customer is new, it will return + * an empty collection; or if this Customer has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Customer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Customer is new, it will return + * an empty collection; or if this Customer has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Customer. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrders($query, $con); + } + /** * Clears out the collCarts collection * diff --git a/core/lib/Thelia/Model/Base/DelivzoneQuery.php b/core/lib/Thelia/Model/Base/DelivzoneQuery.php deleted file mode 100644 index e4b8a8ab5..000000000 --- a/core/lib/Thelia/Model/Base/DelivzoneQuery.php +++ /dev/null @@ -1,666 +0,0 @@ -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 ChildDelivzone|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = DelivzoneTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::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 ChildDelivzone A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, AREA_ID, DELIVERY, CREATED_AT, UPDATED_AT FROM delivzone 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 ChildDelivzone(); - $obj->hydrate($row); - DelivzoneTableMap::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 ChildDelivzone|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 ChildDelivzoneQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(DelivzoneTableMap::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 ChildDelivzoneQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(DelivzoneTableMap::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 ChildDelivzoneQuery 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(DelivzoneTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(DelivzoneTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzoneTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the area_id column - * - * Example usage: - * - * $query->filterByAreaId(1234); // WHERE area_id = 1234 - * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) - * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 - * - * - * @see filterByArea() - * - * @param mixed $areaId 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 ChildDelivzoneQuery The current query, for fluid interface - */ - public function filterByAreaId($areaId = null, $comparison = null) - { - if (is_array($areaId)) { - $useMinMax = false; - if (isset($areaId['min'])) { - $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($areaId['max'])) { - $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId, $comparison); - } - - /** - * Filter the query on the delivery column - * - * Example usage: - * - * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue' - * $query->filterByDelivery('%fooValue%'); // WHERE delivery LIKE '%fooValue%' - * - * - * @param string $delivery 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 ChildDelivzoneQuery The current query, for fluid interface - */ - public function filterByDelivery($delivery = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($delivery)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $delivery)) { - $delivery = str_replace('*', '%', $delivery); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DelivzoneTableMap::DELIVERY, $delivery, $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 ChildDelivzoneQuery 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(DelivzoneTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzoneTableMap::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 ChildDelivzoneQuery 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(DelivzoneTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Area object - * - * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function filterByArea($area, $comparison = null) - { - if ($area instanceof \Thelia\Model\Area) { - return $this - ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->getId(), $comparison); - } elseif ($area instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Area relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Area'); - - // 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, 'Area'); - } - - return $this; - } - - /** - * Use the Area relation Area 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\AreaQuery A secondary query class using the current class as primary query - */ - public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinArea($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery'); - } - - /** - * Exclude object from result - * - * @param ChildDelivzone $delivzone Object to remove from the list of results - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function prune($delivzone = null) - { - if ($delivzone) { - $this->addUsingAlias(DelivzoneTableMap::ID, $delivzone->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the delivzone 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(DelivzoneTableMap::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). - DelivzoneTableMap::clearInstancePool(); - DelivzoneTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildDelivzone or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildDelivzone 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(DelivzoneTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(DelivzoneTableMap::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(); - - - DelivzoneTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - DelivzoneTableMap::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 ChildDelivzoneQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildDelivzoneQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::CREATED_AT); - } - -} // DelivzoneQuery diff --git a/core/lib/Thelia/Model/Base/FeatureCategory.php b/core/lib/Thelia/Model/Base/FeatureCategory.php deleted file mode 100644 index 035e077d2..000000000 --- a/core/lib/Thelia/Model/Base/FeatureCategory.php +++ /dev/null @@ -1,1495 +0,0 @@ -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 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 FeatureCategory instance. If - * obj is an instance of FeatureCategory, delegates to - * equals(FeatureCategory). Otherwise, returns false. - * - * @param obj The object to compare to. - * @return 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 - * - * @param string $name The virtual column name - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @return mixed - */ - 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 FeatureCategory 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 FeatureCategory The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - } - - /** - * 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 [feature_id] column value. - * - * @return int - */ - public function getFeatureId() - { - - return $this->feature_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - - return $this->category_id; - } - - /** - * 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 !== null ? $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 !== null ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\FeatureCategory 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[] = FeatureCategoryTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [feature_id] column. - * - * @param int $v new value - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) - */ - public function setFeatureId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->feature_id !== $v) { - $this->feature_id = $v; - $this->modifiedColumns[] = FeatureCategoryTableMap::FEATURE_ID; - } - - if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { - $this->aFeature = null; - } - - - return $this; - } // setFeatureId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = FeatureCategoryTableMap::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * 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\FeatureCategory 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[] = FeatureCategoryTableMap::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\FeatureCategory 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[] = FeatureCategoryTableMap::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 : FeatureCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureCategoryTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->feature_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->category_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureCategoryTableMap::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 : FeatureCategoryTableMap::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 + 5; // 5 = FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\FeatureCategory 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->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) { - $this->aFeature = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = 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(FeatureCategoryTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildFeatureCategoryQuery::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->aCategory = null; - $this->aFeature = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see FeatureCategory::setDeleted() - * @see FeatureCategory::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(FeatureCategoryTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildFeatureCategoryQuery::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(FeatureCategoryTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - FeatureCategoryTableMap::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->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aFeature !== null) { - if ($this->aFeature->isModified() || $this->aFeature->isNew()) { - $affectedRows += $this->aFeature->save($con); - } - $this->setFeature($this->aFeature); - } - - 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[] = FeatureCategoryTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureCategoryTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureCategoryTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = 'FEATURE_ID'; - } - if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; - } - if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO feature_category (%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 'FEATURE_ID': - $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); - break; - case 'CATEGORY_ID': - $stmt->bindValue($identifier, $this->category_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); - } - - /** - * 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 = FeatureCategoryTableMap::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->getFeatureId(); - break; - case 2: - return $this->getCategoryId(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - 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['FeatureCategory'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()] = true; - $keys = FeatureCategoryTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getFeatureId(), - $keys[2] => $this->getCategoryId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFeature) { - $result['Feature'] = $this->aFeature->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 = FeatureCategoryTableMap::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->setFeatureId($value); - break; - case 2: - $this->setCategoryId($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $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 = FeatureCategoryTableMap::getFieldNames($keyType); - - 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->setCategoryId($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]]); - } - - /** - * 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(FeatureCategoryTableMap::DATABASE_NAME); - - if ($this->isColumnModified(FeatureCategoryTableMap::ID)) $criteria->add(FeatureCategoryTableMap::ID, $this->id); - if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) $criteria->add(FeatureCategoryTableMap::FEATURE_ID, $this->feature_id); - if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) $criteria->add(FeatureCategoryTableMap::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) $criteria->add(FeatureCategoryTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) $criteria->add(FeatureCategoryTableMap::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(FeatureCategoryTableMap::DATABASE_NAME); - $criteria->add(FeatureCategoryTableMap::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\FeatureCategory (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->setFeatureId($this->getFeatureId()); - $copyObj->setCategoryId($this->getCategoryId()); - $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\FeatureCategory 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 ChildCategory object. - * - * @param ChildCategory $v - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(ChildCategory $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildCategory object, it will not be re-added. - if ($v !== null) { - $v->addFeatureCategory($this); - } - - - return $this; - } - - - /** - * Get the associated ChildCategory object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildCategory The associated ChildCategory object. - * @throws PropelException - */ - public function getCategory(ConnectionInterface $con = null) - { - if ($this->aCategory === null && ($this->category_id !== null)) { - $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_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->aCategory->addFeatureCategories($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a ChildFeature object. - * - * @param ChildFeature $v - * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setFeature(ChildFeature $v = null) - { - if ($v === null) { - $this->setFeatureId(NULL); - } else { - $this->setFeatureId($v->getId()); - } - - $this->aFeature = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildFeature object, it will not be re-added. - if ($v !== null) { - $v->addFeatureCategory($this); - } - - - return $this; - } - - - /** - * Get the associated ChildFeature object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildFeature The associated ChildFeature object. - * @throws PropelException - */ - public function getFeature(ConnectionInterface $con = null) - { - if ($this->aFeature === null && ($this->feature_id !== null)) { - $this->aFeature = ChildFeatureQuery::create()->findPk($this->feature_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->aFeature->addFeatureCategories($this); - */ - } - - return $this->aFeature; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->feature_id = null; - $this->category_id = 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->aCategory = null; - $this->aFeature = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FeatureCategoryTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildFeatureCategory The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = FeatureCategoryTableMap::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/Lang.php b/core/lib/Thelia/Model/Base/Lang.php index 1c11103af..59836e27d 100644 --- a/core/lib/Thelia/Model/Base/Lang.php +++ b/core/lib/Thelia/Model/Base/Lang.php @@ -10,6 +10,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Exception\PropelException; @@ -18,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Lang as ChildLang; use Thelia\Model\LangQuery as ChildLangQuery; +use Thelia\Model\Order as ChildOrder; +use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\LangTableMap; abstract class Lang implements ActiveRecordInterface @@ -144,6 +147,12 @@ abstract class Lang implements ActiveRecordInterface */ protected $updated_at; + /** + * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. + */ + protected $collOrders; + protected $collOrdersPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -152,6 +161,12 @@ abstract class Lang implements ActiveRecordInterface */ protected $alreadyInSave = false; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $ordersScheduledForDeletion = null; + /** * Initializes internal state of Thelia\Model\Base\Lang object. */ @@ -1060,6 +1075,8 @@ abstract class Lang implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->collOrders = null; + } // if (deep) } @@ -1193,6 +1210,23 @@ abstract class Lang implements ActiveRecordInterface $this->resetModified(); } + if ($this->ordersScheduledForDeletion !== null) { + if (!$this->ordersScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersScheduledForDeletion = null; + } + } + + if ($this->collOrders !== null) { + foreach ($this->collOrders as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -1444,10 +1478,11 @@ abstract class Lang implements ActiveRecordInterface * 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()) + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['Lang'][$this->getPrimaryKey()])) { return '*RECURSION*'; @@ -1477,6 +1512,11 @@ abstract class Lang implements ActiveRecordInterface $result[$key] = $virtualColumn; } + if ($includeForeignObjects) { + if (null !== $this->collOrders) { + $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } return $result; } @@ -1697,6 +1737,20 @@ abstract class Lang implements ActiveRecordInterface $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getOrders() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrder($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value @@ -1725,6 +1779,415 @@ abstract class Lang implements ActiveRecordInterface return $copyObj; } + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('Order' == $relationName) { + return $this->initOrders(); + } + } + + /** + * Clears out the collOrders 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 addOrders() + */ + public function clearOrders() + { + $this->collOrders = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrders collection loaded partially. + */ + public function resetPartialOrders($v = true) + { + $this->collOrdersPartial = $v; + } + + /** + * Initializes the collOrders collection. + * + * By default this just sets the collOrders collection to an empty array (like clearcollOrders()); + * 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 initOrders($overrideExisting = true) + { + if (null !== $this->collOrders && !$overrideExisting) { + return; + } + $this->collOrders = new ObjectCollection(); + $this->collOrders->setModel('\Thelia\Model\Order'); + } + + /** + * Gets an array of ChildOrder 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 ChildLang 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|ChildOrder[] List of ChildOrder objects + * @throws PropelException + */ + public function getOrders($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrdersPartial && !$this->isNew(); + if (null === $this->collOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrders) { + // return empty collection + $this->initOrders(); + } else { + $collOrders = ChildOrderQuery::create(null, $criteria) + ->filterByLang($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrdersPartial && count($collOrders)) { + $this->initOrders(false); + + foreach ($collOrders as $obj) { + if (false == $this->collOrders->contains($obj)) { + $this->collOrders->append($obj); + } + } + + $this->collOrdersPartial = true; + } + + $collOrders->getInternalIterator()->rewind(); + + return $collOrders; + } + + if ($partial && $this->collOrders) { + foreach ($this->collOrders as $obj) { + if ($obj->isNew()) { + $collOrders[] = $obj; + } + } + } + + $this->collOrders = $collOrders; + $this->collOrdersPartial = false; + } + } + + return $this->collOrders; + } + + /** + * Sets a collection of Order 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 $orders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildLang The current object (for fluent API support) + */ + public function setOrders(Collection $orders, ConnectionInterface $con = null) + { + $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); + + + $this->ordersScheduledForDeletion = $ordersToDelete; + + foreach ($ordersToDelete as $orderRemoved) { + $orderRemoved->setLang(null); + } + + $this->collOrders = null; + foreach ($orders as $order) { + $this->addOrder($order); + } + + $this->collOrders = $orders; + $this->collOrdersPartial = false; + + return $this; + } + + /** + * Returns the number of related Order objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Order objects. + * @throws PropelException + */ + public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrdersPartial && !$this->isNew(); + if (null === $this->collOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrders) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrders()); + } + + $query = ChildOrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByLang($this) + ->count($con); + } + + return count($this->collOrders); + } + + /** + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. + * + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function addOrder(ChildOrder $l) + { + if ($this->collOrders === null) { + $this->initOrders(); + $this->collOrdersPartial = true; + } + + if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrder($l); + } + + return $this; + } + + /** + * @param Order $order The order object to add. + */ + protected function doAddOrder($order) + { + $this->collOrders[]= $order; + $order->setLang($this); + } + + /** + * @param Order $order The order object to remove. + * @return ChildLang The current object (for fluent API support) + */ + public function removeOrder($order) + { + if ($this->getOrders()->contains($order)) { + $this->collOrders->remove($this->collOrders->search($order)); + if (null === $this->ordersScheduledForDeletion) { + $this->ordersScheduledForDeletion = clone $this->collOrders; + $this->ordersScheduledForDeletion->clear(); + } + $this->ordersScheduledForDeletion[]= clone $order; + $order->setLang(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Lang is new, it will return + * an empty collection; or if this Lang has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Lang. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1764,8 +2227,17 @@ abstract class Lang implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collOrders) { + foreach ($this->collOrders as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) + if ($this->collOrders instanceof Collection) { + $this->collOrders->clearIterator(); + } + $this->collOrders = null; } /** diff --git a/core/lib/Thelia/Model/Base/LangQuery.php b/core/lib/Thelia/Model/Base/LangQuery.php index 2fabec9ee..045ee0887 100644 --- a/core/lib/Thelia/Model/Base/LangQuery.php +++ b/core/lib/Thelia/Model/Base/LangQuery.php @@ -7,6 +7,9 @@ use \PDO; use Propel\Runtime\Propel; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\ActiveQuery\ModelJoin; +use Propel\Runtime\Collection\Collection; +use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; use Thelia\Model\Lang as ChildLang; @@ -54,6 +57,10 @@ use Thelia\Model\Map\LangTableMap; * @method ChildLangQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildLangQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildLangQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation + * @method ChildLangQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation + * @method ChildLangQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation + * * @method ChildLang findOne(ConnectionInterface $con = null) Return the first ChildLang matching the query * @method ChildLang findOneOrCreate(ConnectionInterface $con = null) Return the first ChildLang matching the query, or a new ChildLang object populated from the query conditions when no match is found * @@ -764,6 +771,79 @@ abstract class LangQuery extends ModelCriteria return $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt, $comparison); } + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildLangQuery The current query, for fluid interface + */ + public function filterByOrder($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(LangTableMap::ID, $order->getLangId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + return $this + ->useOrderQuery() + ->filterByPrimaryKeys($order->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Order relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildLangQuery The current query, for fluid interface + */ + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Order'); + + // 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, 'Order'); + } + + return $this; + } + + /** + * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); + } + /** * Exclude object from result * diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index 9cc89381a..7f4df77ce 100644 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -17,12 +17,16 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; use Thelia\Model\GroupModule as ChildGroupModule; use Thelia\Model\GroupModuleQuery as ChildGroupModuleQuery; use Thelia\Model\Module as ChildModule; use Thelia\Model\ModuleI18n as ChildModuleI18n; use Thelia\Model\ModuleI18nQuery as ChildModuleI18nQuery; use Thelia\Model\ModuleQuery as ChildModuleQuery; +use Thelia\Model\Order as ChildOrder; +use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\ModuleTableMap; abstract class Module implements ActiveRecordInterface @@ -107,6 +111,24 @@ abstract class Module implements ActiveRecordInterface */ protected $updated_at; + /** + * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. + */ + protected $collOrdersRelatedByPaymentModuleId; + protected $collOrdersRelatedByPaymentModuleIdPartial; + + /** + * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. + */ + protected $collOrdersRelatedByDeliveryModuleId; + protected $collOrdersRelatedByDeliveryModuleIdPartial; + + /** + * @var ObjectCollection|ChildAreaDeliveryModule[] Collection to store aggregation of ChildAreaDeliveryModule objects. + */ + protected $collAreaDeliveryModules; + protected $collAreaDeliveryModulesPartial; + /** * @var ObjectCollection|ChildGroupModule[] Collection to store aggregation of ChildGroupModule objects. */ @@ -141,6 +163,24 @@ abstract class Module implements ActiveRecordInterface */ protected $currentTranslations; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $ordersRelatedByPaymentModuleIdScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $ordersRelatedByDeliveryModuleIdScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $areaDeliveryModulesScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -816,6 +856,12 @@ abstract class Module implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->collOrdersRelatedByPaymentModuleId = null; + + $this->collOrdersRelatedByDeliveryModuleId = null; + + $this->collAreaDeliveryModules = null; + $this->collGroupModules = null; $this->collModuleI18ns = null; @@ -953,6 +999,57 @@ abstract class Module implements ActiveRecordInterface $this->resetModified(); } + if ($this->ordersRelatedByPaymentModuleIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByPaymentModuleIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByPaymentModuleIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion = null; + } + } + + if ($this->collOrdersRelatedByPaymentModuleId !== null) { + foreach ($this->collOrdersRelatedByPaymentModuleId as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->ordersRelatedByDeliveryModuleIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByDeliveryModuleIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByDeliveryModuleIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion = null; + } + } + + if ($this->collOrdersRelatedByDeliveryModuleId !== null) { + foreach ($this->collOrdersRelatedByDeliveryModuleId as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->areaDeliveryModulesScheduledForDeletion !== null) { + if (!$this->areaDeliveryModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AreaDeliveryModuleQuery::create() + ->filterByPrimaryKeys($this->areaDeliveryModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->areaDeliveryModulesScheduledForDeletion = null; + } + } + + if ($this->collAreaDeliveryModules !== null) { + foreach ($this->collAreaDeliveryModules as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->groupModulesScheduledForDeletion !== null) { if (!$this->groupModulesScheduledForDeletion->isEmpty()) { \Thelia\Model\GroupModuleQuery::create() @@ -1203,6 +1300,15 @@ abstract class Module implements ActiveRecordInterface } if ($includeForeignObjects) { + if (null !== $this->collOrdersRelatedByPaymentModuleId) { + $result['OrdersRelatedByPaymentModuleId'] = $this->collOrdersRelatedByPaymentModuleId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collOrdersRelatedByDeliveryModuleId) { + $result['OrdersRelatedByDeliveryModuleId'] = $this->collOrdersRelatedByDeliveryModuleId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collAreaDeliveryModules) { + $result['AreaDeliveryModules'] = $this->collAreaDeliveryModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collGroupModules) { $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1394,6 +1500,24 @@ abstract class Module implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); + foreach ($this->getOrdersRelatedByPaymentModuleId() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderRelatedByPaymentModuleId($relObj->copy($deepCopy)); + } + } + + foreach ($this->getOrdersRelatedByDeliveryModuleId() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderRelatedByDeliveryModuleId($relObj->copy($deepCopy)); + } + } + + foreach ($this->getAreaDeliveryModules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAreaDeliveryModule($relObj->copy($deepCopy)); + } + } + foreach ($this->getGroupModules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addGroupModule($relObj->copy($deepCopy)); @@ -1447,6 +1571,15 @@ abstract class Module implements ActiveRecordInterface */ public function initRelation($relationName) { + if ('OrderRelatedByPaymentModuleId' == $relationName) { + return $this->initOrdersRelatedByPaymentModuleId(); + } + if ('OrderRelatedByDeliveryModuleId' == $relationName) { + return $this->initOrdersRelatedByDeliveryModuleId(); + } + if ('AreaDeliveryModule' == $relationName) { + return $this->initAreaDeliveryModules(); + } if ('GroupModule' == $relationName) { return $this->initGroupModules(); } @@ -1455,6 +1588,985 @@ abstract class Module implements ActiveRecordInterface } } + /** + * Clears out the collOrdersRelatedByPaymentModuleId 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 addOrdersRelatedByPaymentModuleId() + */ + public function clearOrdersRelatedByPaymentModuleId() + { + $this->collOrdersRelatedByPaymentModuleId = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrdersRelatedByPaymentModuleId collection loaded partially. + */ + public function resetPartialOrdersRelatedByPaymentModuleId($v = true) + { + $this->collOrdersRelatedByPaymentModuleIdPartial = $v; + } + + /** + * Initializes the collOrdersRelatedByPaymentModuleId collection. + * + * By default this just sets the collOrdersRelatedByPaymentModuleId collection to an empty array (like clearcollOrdersRelatedByPaymentModuleId()); + * 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 initOrdersRelatedByPaymentModuleId($overrideExisting = true) + { + if (null !== $this->collOrdersRelatedByPaymentModuleId && !$overrideExisting) { + return; + } + $this->collOrdersRelatedByPaymentModuleId = new ObjectCollection(); + $this->collOrdersRelatedByPaymentModuleId->setModel('\Thelia\Model\Order'); + } + + /** + * Gets an array of ChildOrder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects + * @throws PropelException + */ + public function getOrdersRelatedByPaymentModuleId($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByPaymentModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByPaymentModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByPaymentModuleId) { + // return empty collection + $this->initOrdersRelatedByPaymentModuleId(); + } else { + $collOrdersRelatedByPaymentModuleId = ChildOrderQuery::create(null, $criteria) + ->filterByModuleRelatedByPaymentModuleId($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrdersRelatedByPaymentModuleIdPartial && count($collOrdersRelatedByPaymentModuleId)) { + $this->initOrdersRelatedByPaymentModuleId(false); + + foreach ($collOrdersRelatedByPaymentModuleId as $obj) { + if (false == $this->collOrdersRelatedByPaymentModuleId->contains($obj)) { + $this->collOrdersRelatedByPaymentModuleId->append($obj); + } + } + + $this->collOrdersRelatedByPaymentModuleIdPartial = true; + } + + $collOrdersRelatedByPaymentModuleId->getInternalIterator()->rewind(); + + return $collOrdersRelatedByPaymentModuleId; + } + + if ($partial && $this->collOrdersRelatedByPaymentModuleId) { + foreach ($this->collOrdersRelatedByPaymentModuleId as $obj) { + if ($obj->isNew()) { + $collOrdersRelatedByPaymentModuleId[] = $obj; + } + } + } + + $this->collOrdersRelatedByPaymentModuleId = $collOrdersRelatedByPaymentModuleId; + $this->collOrdersRelatedByPaymentModuleIdPartial = false; + } + } + + return $this->collOrdersRelatedByPaymentModuleId; + } + + /** + * Sets a collection of OrderRelatedByPaymentModuleId 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 $ordersRelatedByPaymentModuleId A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setOrdersRelatedByPaymentModuleId(Collection $ordersRelatedByPaymentModuleId, ConnectionInterface $con = null) + { + $ordersRelatedByPaymentModuleIdToDelete = $this->getOrdersRelatedByPaymentModuleId(new Criteria(), $con)->diff($ordersRelatedByPaymentModuleId); + + + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion = $ordersRelatedByPaymentModuleIdToDelete; + + foreach ($ordersRelatedByPaymentModuleIdToDelete as $orderRelatedByPaymentModuleIdRemoved) { + $orderRelatedByPaymentModuleIdRemoved->setModuleRelatedByPaymentModuleId(null); + } + + $this->collOrdersRelatedByPaymentModuleId = null; + foreach ($ordersRelatedByPaymentModuleId as $orderRelatedByPaymentModuleId) { + $this->addOrderRelatedByPaymentModuleId($orderRelatedByPaymentModuleId); + } + + $this->collOrdersRelatedByPaymentModuleId = $ordersRelatedByPaymentModuleId; + $this->collOrdersRelatedByPaymentModuleIdPartial = false; + + return $this; + } + + /** + * Returns the number of related Order objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Order objects. + * @throws PropelException + */ + public function countOrdersRelatedByPaymentModuleId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByPaymentModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByPaymentModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByPaymentModuleId) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrdersRelatedByPaymentModuleId()); + } + + $query = ChildOrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModuleRelatedByPaymentModuleId($this) + ->count($con); + } + + return count($this->collOrdersRelatedByPaymentModuleId); + } + + /** + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. + * + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addOrderRelatedByPaymentModuleId(ChildOrder $l) + { + if ($this->collOrdersRelatedByPaymentModuleId === null) { + $this->initOrdersRelatedByPaymentModuleId(); + $this->collOrdersRelatedByPaymentModuleIdPartial = true; + } + + if (!in_array($l, $this->collOrdersRelatedByPaymentModuleId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByPaymentModuleId($l); + } + + return $this; + } + + /** + * @param OrderRelatedByPaymentModuleId $orderRelatedByPaymentModuleId The orderRelatedByPaymentModuleId object to add. + */ + protected function doAddOrderRelatedByPaymentModuleId($orderRelatedByPaymentModuleId) + { + $this->collOrdersRelatedByPaymentModuleId[]= $orderRelatedByPaymentModuleId; + $orderRelatedByPaymentModuleId->setModuleRelatedByPaymentModuleId($this); + } + + /** + * @param OrderRelatedByPaymentModuleId $orderRelatedByPaymentModuleId The orderRelatedByPaymentModuleId object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeOrderRelatedByPaymentModuleId($orderRelatedByPaymentModuleId) + { + if ($this->getOrdersRelatedByPaymentModuleId()->contains($orderRelatedByPaymentModuleId)) { + $this->collOrdersRelatedByPaymentModuleId->remove($this->collOrdersRelatedByPaymentModuleId->search($orderRelatedByPaymentModuleId)); + if (null === $this->ordersRelatedByPaymentModuleIdScheduledForDeletion) { + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion = clone $this->collOrdersRelatedByPaymentModuleId; + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion->clear(); + } + $this->ordersRelatedByPaymentModuleIdScheduledForDeletion[]= clone $orderRelatedByPaymentModuleId; + $orderRelatedByPaymentModuleId->setModuleRelatedByPaymentModuleId(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByPaymentModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByPaymentModuleIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByPaymentModuleId($query, $con); + } + + /** + * Clears out the collOrdersRelatedByDeliveryModuleId 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 addOrdersRelatedByDeliveryModuleId() + */ + public function clearOrdersRelatedByDeliveryModuleId() + { + $this->collOrdersRelatedByDeliveryModuleId = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrdersRelatedByDeliveryModuleId collection loaded partially. + */ + public function resetPartialOrdersRelatedByDeliveryModuleId($v = true) + { + $this->collOrdersRelatedByDeliveryModuleIdPartial = $v; + } + + /** + * Initializes the collOrdersRelatedByDeliveryModuleId collection. + * + * By default this just sets the collOrdersRelatedByDeliveryModuleId collection to an empty array (like clearcollOrdersRelatedByDeliveryModuleId()); + * 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 initOrdersRelatedByDeliveryModuleId($overrideExisting = true) + { + if (null !== $this->collOrdersRelatedByDeliveryModuleId && !$overrideExisting) { + return; + } + $this->collOrdersRelatedByDeliveryModuleId = new ObjectCollection(); + $this->collOrdersRelatedByDeliveryModuleId->setModel('\Thelia\Model\Order'); + } + + /** + * Gets an array of ChildOrder objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects + * @throws PropelException + */ + public function getOrdersRelatedByDeliveryModuleId($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByDeliveryModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryModuleId) { + // return empty collection + $this->initOrdersRelatedByDeliveryModuleId(); + } else { + $collOrdersRelatedByDeliveryModuleId = ChildOrderQuery::create(null, $criteria) + ->filterByModuleRelatedByDeliveryModuleId($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrdersRelatedByDeliveryModuleIdPartial && count($collOrdersRelatedByDeliveryModuleId)) { + $this->initOrdersRelatedByDeliveryModuleId(false); + + foreach ($collOrdersRelatedByDeliveryModuleId as $obj) { + if (false == $this->collOrdersRelatedByDeliveryModuleId->contains($obj)) { + $this->collOrdersRelatedByDeliveryModuleId->append($obj); + } + } + + $this->collOrdersRelatedByDeliveryModuleIdPartial = true; + } + + $collOrdersRelatedByDeliveryModuleId->getInternalIterator()->rewind(); + + return $collOrdersRelatedByDeliveryModuleId; + } + + if ($partial && $this->collOrdersRelatedByDeliveryModuleId) { + foreach ($this->collOrdersRelatedByDeliveryModuleId as $obj) { + if ($obj->isNew()) { + $collOrdersRelatedByDeliveryModuleId[] = $obj; + } + } + } + + $this->collOrdersRelatedByDeliveryModuleId = $collOrdersRelatedByDeliveryModuleId; + $this->collOrdersRelatedByDeliveryModuleIdPartial = false; + } + } + + return $this->collOrdersRelatedByDeliveryModuleId; + } + + /** + * Sets a collection of OrderRelatedByDeliveryModuleId 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 $ordersRelatedByDeliveryModuleId A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setOrdersRelatedByDeliveryModuleId(Collection $ordersRelatedByDeliveryModuleId, ConnectionInterface $con = null) + { + $ordersRelatedByDeliveryModuleIdToDelete = $this->getOrdersRelatedByDeliveryModuleId(new Criteria(), $con)->diff($ordersRelatedByDeliveryModuleId); + + + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion = $ordersRelatedByDeliveryModuleIdToDelete; + + foreach ($ordersRelatedByDeliveryModuleIdToDelete as $orderRelatedByDeliveryModuleIdRemoved) { + $orderRelatedByDeliveryModuleIdRemoved->setModuleRelatedByDeliveryModuleId(null); + } + + $this->collOrdersRelatedByDeliveryModuleId = null; + foreach ($ordersRelatedByDeliveryModuleId as $orderRelatedByDeliveryModuleId) { + $this->addOrderRelatedByDeliveryModuleId($orderRelatedByDeliveryModuleId); + } + + $this->collOrdersRelatedByDeliveryModuleId = $ordersRelatedByDeliveryModuleId; + $this->collOrdersRelatedByDeliveryModuleIdPartial = false; + + return $this; + } + + /** + * Returns the number of related Order objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Order objects. + * @throws PropelException + */ + public function countOrdersRelatedByDeliveryModuleId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrdersRelatedByDeliveryModuleIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryModuleId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryModuleId) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrdersRelatedByDeliveryModuleId()); + } + + $query = ChildOrderQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModuleRelatedByDeliveryModuleId($this) + ->count($con); + } + + return count($this->collOrdersRelatedByDeliveryModuleId); + } + + /** + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. + * + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addOrderRelatedByDeliveryModuleId(ChildOrder $l) + { + if ($this->collOrdersRelatedByDeliveryModuleId === null) { + $this->initOrdersRelatedByDeliveryModuleId(); + $this->collOrdersRelatedByDeliveryModuleIdPartial = true; + } + + if (!in_array($l, $this->collOrdersRelatedByDeliveryModuleId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByDeliveryModuleId($l); + } + + return $this; + } + + /** + * @param OrderRelatedByDeliveryModuleId $orderRelatedByDeliveryModuleId The orderRelatedByDeliveryModuleId object to add. + */ + protected function doAddOrderRelatedByDeliveryModuleId($orderRelatedByDeliveryModuleId) + { + $this->collOrdersRelatedByDeliveryModuleId[]= $orderRelatedByDeliveryModuleId; + $orderRelatedByDeliveryModuleId->setModuleRelatedByDeliveryModuleId($this); + } + + /** + * @param OrderRelatedByDeliveryModuleId $orderRelatedByDeliveryModuleId The orderRelatedByDeliveryModuleId object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeOrderRelatedByDeliveryModuleId($orderRelatedByDeliveryModuleId) + { + if ($this->getOrdersRelatedByDeliveryModuleId()->contains($orderRelatedByDeliveryModuleId)) { + $this->collOrdersRelatedByDeliveryModuleId->remove($this->collOrdersRelatedByDeliveryModuleId->search($orderRelatedByDeliveryModuleId)); + if (null === $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion) { + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion = clone $this->collOrdersRelatedByDeliveryModuleId; + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion->clear(); + } + $this->ordersRelatedByDeliveryModuleIdScheduledForDeletion[]= clone $orderRelatedByDeliveryModuleId; + $orderRelatedByDeliveryModuleId->setModuleRelatedByDeliveryModuleId(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryModuleId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryModuleIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryModuleId($query, $con); + } + + /** + * Clears out the collAreaDeliveryModules 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 addAreaDeliveryModules() + */ + public function clearAreaDeliveryModules() + { + $this->collAreaDeliveryModules = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collAreaDeliveryModules collection loaded partially. + */ + public function resetPartialAreaDeliveryModules($v = true) + { + $this->collAreaDeliveryModulesPartial = $v; + } + + /** + * Initializes the collAreaDeliveryModules collection. + * + * By default this just sets the collAreaDeliveryModules collection to an empty array (like clearcollAreaDeliveryModules()); + * 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 initAreaDeliveryModules($overrideExisting = true) + { + if (null !== $this->collAreaDeliveryModules && !$overrideExisting) { + return; + } + $this->collAreaDeliveryModules = new ObjectCollection(); + $this->collAreaDeliveryModules->setModel('\Thelia\Model\AreaDeliveryModule'); + } + + /** + * Gets an array of ChildAreaDeliveryModule objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + * @throws PropelException + */ + public function getAreaDeliveryModules($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { + // return empty collection + $this->initAreaDeliveryModules(); + } else { + $collAreaDeliveryModules = ChildAreaDeliveryModuleQuery::create(null, $criteria) + ->filterByModule($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collAreaDeliveryModulesPartial && count($collAreaDeliveryModules)) { + $this->initAreaDeliveryModules(false); + + foreach ($collAreaDeliveryModules as $obj) { + if (false == $this->collAreaDeliveryModules->contains($obj)) { + $this->collAreaDeliveryModules->append($obj); + } + } + + $this->collAreaDeliveryModulesPartial = true; + } + + $collAreaDeliveryModules->getInternalIterator()->rewind(); + + return $collAreaDeliveryModules; + } + + if ($partial && $this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $obj) { + if ($obj->isNew()) { + $collAreaDeliveryModules[] = $obj; + } + } + } + + $this->collAreaDeliveryModules = $collAreaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; + } + } + + return $this->collAreaDeliveryModules; + } + + /** + * Sets a collection of AreaDeliveryModule 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 $areaDeliveryModules A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setAreaDeliveryModules(Collection $areaDeliveryModules, ConnectionInterface $con = null) + { + $areaDeliveryModulesToDelete = $this->getAreaDeliveryModules(new Criteria(), $con)->diff($areaDeliveryModules); + + + $this->areaDeliveryModulesScheduledForDeletion = $areaDeliveryModulesToDelete; + + foreach ($areaDeliveryModulesToDelete as $areaDeliveryModuleRemoved) { + $areaDeliveryModuleRemoved->setModule(null); + } + + $this->collAreaDeliveryModules = null; + foreach ($areaDeliveryModules as $areaDeliveryModule) { + $this->addAreaDeliveryModule($areaDeliveryModule); + } + + $this->collAreaDeliveryModules = $areaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; + + return $this; + } + + /** + * Returns the number of related AreaDeliveryModule objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related AreaDeliveryModule objects. + * @throws PropelException + */ + public function countAreaDeliveryModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAreaDeliveryModules()); + } + + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModule($this) + ->count($con); + } + + return count($this->collAreaDeliveryModules); + } + + /** + * Method called to associate a ChildAreaDeliveryModule object to this object + * through the ChildAreaDeliveryModule foreign key attribute. + * + * @param ChildAreaDeliveryModule $l ChildAreaDeliveryModule + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addAreaDeliveryModule(ChildAreaDeliveryModule $l) + { + if ($this->collAreaDeliveryModules === null) { + $this->initAreaDeliveryModules(); + $this->collAreaDeliveryModulesPartial = true; + } + + if (!in_array($l, $this->collAreaDeliveryModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAreaDeliveryModule($l); + } + + return $this; + } + + /** + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to add. + */ + protected function doAddAreaDeliveryModule($areaDeliveryModule) + { + $this->collAreaDeliveryModules[]= $areaDeliveryModule; + $areaDeliveryModule->setModule($this); + } + + /** + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeAreaDeliveryModule($areaDeliveryModule) + { + if ($this->getAreaDeliveryModules()->contains($areaDeliveryModule)) { + $this->collAreaDeliveryModules->remove($this->collAreaDeliveryModules->search($areaDeliveryModule)); + if (null === $this->areaDeliveryModulesScheduledForDeletion) { + $this->areaDeliveryModulesScheduledForDeletion = clone $this->collAreaDeliveryModules; + $this->areaDeliveryModulesScheduledForDeletion->clear(); + } + $this->areaDeliveryModulesScheduledForDeletion[]= clone $areaDeliveryModule; + $areaDeliveryModule->setModule(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related AreaDeliveryModules from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + */ + public function getAreaDeliveryModulesJoinArea($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + $query->joinWith('Area', $joinBehavior); + + return $this->getAreaDeliveryModules($query, $con); + } + /** * Clears out the collGroupModules collection * @@ -1955,6 +3067,21 @@ abstract class Module implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { + if ($this->collOrdersRelatedByPaymentModuleId) { + foreach ($this->collOrdersRelatedByPaymentModuleId as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collOrdersRelatedByDeliveryModuleId) { + foreach ($this->collOrdersRelatedByDeliveryModuleId as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collGroupModules) { foreach ($this->collGroupModules as $o) { $o->clearAllReferences($deep); @@ -1971,6 +3098,18 @@ abstract class Module implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; + if ($this->collOrdersRelatedByPaymentModuleId instanceof Collection) { + $this->collOrdersRelatedByPaymentModuleId->clearIterator(); + } + $this->collOrdersRelatedByPaymentModuleId = null; + if ($this->collOrdersRelatedByDeliveryModuleId instanceof Collection) { + $this->collOrdersRelatedByDeliveryModuleId->clearIterator(); + } + $this->collOrdersRelatedByDeliveryModuleId = null; + if ($this->collAreaDeliveryModules instanceof Collection) { + $this->collAreaDeliveryModules->clearIterator(); + } + $this->collAreaDeliveryModules = null; if ($this->collGroupModules instanceof Collection) { $this->collGroupModules->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php index 6f8d4b551..0ed6c5293 100644 --- a/core/lib/Thelia/Model/Base/ModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -44,6 +44,18 @@ use Thelia\Model\Map\ModuleTableMap; * @method ChildModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildModuleQuery leftJoinOrderRelatedByPaymentModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * @method ChildModuleQuery rightJoinOrderRelatedByPaymentModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * @method ChildModuleQuery innerJoinOrderRelatedByPaymentModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * + * @method ChildModuleQuery leftJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * @method ChildModuleQuery rightJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * @method ChildModuleQuery innerJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * + * @method ChildModuleQuery leftJoinAreaDeliveryModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildModuleQuery rightJoinAreaDeliveryModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildModuleQuery innerJoinAreaDeliveryModule($relationAlias = null) Adds a INNER JOIN clause to the query using the AreaDeliveryModule relation + * * @method ChildModuleQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation * @method ChildModuleQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation * @method ChildModuleQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation @@ -557,6 +569,225 @@ abstract class ModuleQuery extends ModelCriteria return $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByOrderRelatedByPaymentModuleId($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $order->getPaymentModuleId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + return $this + ->useOrderRelatedByPaymentModuleIdQuery() + ->filterByPrimaryKeys($order->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderRelatedByPaymentModuleId() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderRelatedByPaymentModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinOrderRelatedByPaymentModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderRelatedByPaymentModuleId'); + + // 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, 'OrderRelatedByPaymentModuleId'); + } + + return $this; + } + + /** + * Use the OrderRelatedByPaymentModuleId relation Order 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\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderRelatedByPaymentModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderRelatedByPaymentModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByPaymentModuleId', '\Thelia\Model\OrderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByOrderRelatedByDeliveryModuleId($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $order->getDeliveryModuleId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + return $this + ->useOrderRelatedByDeliveryModuleIdQuery() + ->filterByPrimaryKeys($order->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderRelatedByDeliveryModuleId() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinOrderRelatedByDeliveryModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderRelatedByDeliveryModuleId'); + + // 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, 'OrderRelatedByDeliveryModuleId'); + } + + return $this; + } + + /** + * Use the OrderRelatedByDeliveryModuleId relation Order 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\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderRelatedByDeliveryModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderRelatedByDeliveryModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByDeliveryModuleId', '\Thelia\Model\OrderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\AreaDeliveryModule object + * + * @param \Thelia\Model\AreaDeliveryModule|ObjectCollection $areaDeliveryModule the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByAreaDeliveryModule($areaDeliveryModule, $comparison = null) + { + if ($areaDeliveryModule instanceof \Thelia\Model\AreaDeliveryModule) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $areaDeliveryModule->getDeliveryModuleId(), $comparison); + } elseif ($areaDeliveryModule instanceof ObjectCollection) { + return $this + ->useAreaDeliveryModuleQuery() + ->filterByPrimaryKeys($areaDeliveryModule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAreaDeliveryModule() only accepts arguments of type \Thelia\Model\AreaDeliveryModule or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the AreaDeliveryModule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinAreaDeliveryModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AreaDeliveryModule'); + + // 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, 'AreaDeliveryModule'); + } + + return $this; + } + + /** + * Use the AreaDeliveryModule relation AreaDeliveryModule 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\AreaDeliveryModuleQuery A secondary query class using the current class as primary query + */ + public function useAreaDeliveryModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAreaDeliveryModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AreaDeliveryModule', '\Thelia\Model\AreaDeliveryModuleQuery'); + } + /** * Filter the query by a related \Thelia\Model\GroupModule object * diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index 6932ec6c4..a2cd3f829 100644 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -23,6 +23,10 @@ use Thelia\Model\Currency as ChildCurrency; use Thelia\Model\CurrencyQuery as ChildCurrencyQuery; use Thelia\Model\Customer as ChildCustomer; use Thelia\Model\CustomerQuery as ChildCustomerQuery; +use Thelia\Model\Lang as ChildLang; +use Thelia\Model\LangQuery as ChildLangQuery; +use Thelia\Model\Module as ChildModule; +use Thelia\Model\ModuleQuery as ChildModuleQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderAddress as ChildOrderAddress; use Thelia\Model\OrderAddressQuery as ChildOrderAddressQuery; @@ -86,16 +90,16 @@ abstract class Order implements ActiveRecordInterface protected $customer_id; /** - * The value for the address_invoice field. + * The value for the invoice_order_address_id field. * @var int */ - protected $address_invoice; + protected $invoice_order_address_id; /** - * The value for the address_delivery field. + * The value for the delivery_order_address_id field. * @var int */ - protected $address_delivery; + protected $delivery_order_address_id; /** * The value for the invoice_date field. @@ -116,22 +120,22 @@ abstract class Order implements ActiveRecordInterface protected $currency_rate; /** - * The value for the transaction field. + * The value for the transaction_ref field. * @var string */ - protected $transaction; + protected $transaction_ref; /** - * The value for the delivery_num field. + * The value for the delivery_ref field. * @var string */ - protected $delivery_num; + protected $delivery_ref; /** - * The value for the invoice field. + * The value for the invoice_ref field. * @var string */ - protected $invoice; + protected $invoice_ref; /** * The value for the postage field. @@ -140,16 +144,16 @@ abstract class Order implements ActiveRecordInterface protected $postage; /** - * The value for the payment field. - * @var string + * The value for the payment_module_id field. + * @var int */ - protected $payment; + protected $payment_module_id; /** - * The value for the carrier field. - * @var string + * The value for the delivery_module_id field. + * @var int */ - protected $carrier; + protected $delivery_module_id; /** * The value for the status_id field. @@ -158,10 +162,10 @@ abstract class Order implements ActiveRecordInterface protected $status_id; /** - * The value for the lang field. - * @var string + * The value for the lang_id field. + * @var int */ - protected $lang; + protected $lang_id; /** * The value for the created_at field. @@ -188,18 +192,33 @@ abstract class Order implements ActiveRecordInterface /** * @var OrderAddress */ - protected $aOrderAddressRelatedByAddressInvoice; + protected $aOrderAddressRelatedByInvoiceOrderAddressId; /** * @var OrderAddress */ - protected $aOrderAddressRelatedByAddressDelivery; + protected $aOrderAddressRelatedByDeliveryOrderAddressId; /** * @var OrderStatus */ protected $aOrderStatus; + /** + * @var Module + */ + protected $aModuleRelatedByPaymentModuleId; + + /** + * @var Module + */ + protected $aModuleRelatedByDeliveryModuleId; + + /** + * @var Lang + */ + protected $aLang; + /** * @var ObjectCollection|ChildOrderProduct[] Collection to store aggregation of ChildOrderProduct objects. */ @@ -520,25 +539,25 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [address_invoice] column value. + * Get the [invoice_order_address_id] column value. * * @return int */ - public function getAddressInvoice() + public function getInvoiceOrderAddressId() { - return $this->address_invoice; + return $this->invoice_order_address_id; } /** - * Get the [address_delivery] column value. + * Get the [delivery_order_address_id] column value. * * @return int */ - public function getAddressDelivery() + public function getDeliveryOrderAddressId() { - return $this->address_delivery; + return $this->delivery_order_address_id; } /** @@ -584,36 +603,36 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [transaction] column value. - * + * Get the [transaction_ref] column value. + * transaction reference - usually use to identify a transaction with banking modules * @return string */ - public function getTransaction() + public function getTransactionRef() { - return $this->transaction; + return $this->transaction_ref; } /** - * Get the [delivery_num] column value. - * + * Get the [delivery_ref] column value. + * delivery reference - usually use to identify a delivery progress on a distant delivery tracker website * @return string */ - public function getDeliveryNum() + public function getDeliveryRef() { - return $this->delivery_num; + return $this->delivery_ref; } /** - * Get the [invoice] column value. - * + * Get the [invoice_ref] column value. + * the invoice reference * @return string */ - public function getInvoice() + public function getInvoiceRef() { - return $this->invoice; + return $this->invoice_ref; } /** @@ -628,25 +647,25 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [payment] column value. + * Get the [payment_module_id] column value. * - * @return string + * @return int */ - public function getPayment() + public function getPaymentModuleId() { - return $this->payment; + return $this->payment_module_id; } /** - * Get the [carrier] column value. + * Get the [delivery_module_id] column value. * - * @return string + * @return int */ - public function getCarrier() + public function getDeliveryModuleId() { - return $this->carrier; + return $this->delivery_module_id; } /** @@ -661,14 +680,14 @@ abstract class Order implements ActiveRecordInterface } /** - * Get the [lang] column value. + * Get the [lang_id] column value. * - * @return string + * @return int */ - public function getLang() + public function getLangId() { - return $this->lang; + return $this->lang_id; } /** @@ -779,54 +798,54 @@ abstract class Order implements ActiveRecordInterface } // setCustomerId() /** - * Set the value of [address_invoice] column. + * Set the value of [invoice_order_address_id] column. * * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setAddressInvoice($v) + public function setInvoiceOrderAddressId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->address_invoice !== $v) { - $this->address_invoice = $v; - $this->modifiedColumns[] = OrderTableMap::ADDRESS_INVOICE; + if ($this->invoice_order_address_id !== $v) { + $this->invoice_order_address_id = $v; + $this->modifiedColumns[] = OrderTableMap::INVOICE_ORDER_ADDRESS_ID; } - if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->aOrderAddressRelatedByAddressInvoice->getId() !== $v) { - $this->aOrderAddressRelatedByAddressInvoice = null; + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId !== null && $this->aOrderAddressRelatedByInvoiceOrderAddressId->getId() !== $v) { + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; } return $this; - } // setAddressInvoice() + } // setInvoiceOrderAddressId() /** - * Set the value of [address_delivery] column. + * Set the value of [delivery_order_address_id] column. * * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setAddressDelivery($v) + public function setDeliveryOrderAddressId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->address_delivery !== $v) { - $this->address_delivery = $v; - $this->modifiedColumns[] = OrderTableMap::ADDRESS_DELIVERY; + if ($this->delivery_order_address_id !== $v) { + $this->delivery_order_address_id = $v; + $this->modifiedColumns[] = OrderTableMap::DELIVERY_ORDER_ADDRESS_ID; } - if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->aOrderAddressRelatedByAddressDelivery->getId() !== $v) { - $this->aOrderAddressRelatedByAddressDelivery = null; + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId !== null && $this->aOrderAddressRelatedByDeliveryOrderAddressId->getId() !== $v) { + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; } return $this; - } // setAddressDelivery() + } // setDeliveryOrderAddressId() /** * Sets the value of [invoice_date] column to a normalized version of the date/time value specified. @@ -896,67 +915,67 @@ abstract class Order implements ActiveRecordInterface } // setCurrencyRate() /** - * Set the value of [transaction] column. - * + * Set the value of [transaction_ref] column. + * transaction reference - usually use to identify a transaction with banking modules * @param string $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setTransaction($v) + public function setTransactionRef($v) { if ($v !== null) { $v = (string) $v; } - if ($this->transaction !== $v) { - $this->transaction = $v; - $this->modifiedColumns[] = OrderTableMap::TRANSACTION; + if ($this->transaction_ref !== $v) { + $this->transaction_ref = $v; + $this->modifiedColumns[] = OrderTableMap::TRANSACTION_REF; } return $this; - } // setTransaction() + } // setTransactionRef() /** - * Set the value of [delivery_num] column. - * + * Set the value of [delivery_ref] column. + * delivery reference - usually use to identify a delivery progress on a distant delivery tracker website * @param string $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setDeliveryNum($v) + public function setDeliveryRef($v) { if ($v !== null) { $v = (string) $v; } - if ($this->delivery_num !== $v) { - $this->delivery_num = $v; - $this->modifiedColumns[] = OrderTableMap::DELIVERY_NUM; + if ($this->delivery_ref !== $v) { + $this->delivery_ref = $v; + $this->modifiedColumns[] = OrderTableMap::DELIVERY_REF; } return $this; - } // setDeliveryNum() + } // setDeliveryRef() /** - * Set the value of [invoice] column. - * + * Set the value of [invoice_ref] column. + * the invoice reference * @param string $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setInvoice($v) + public function setInvoiceRef($v) { if ($v !== null) { $v = (string) $v; } - if ($this->invoice !== $v) { - $this->invoice = $v; - $this->modifiedColumns[] = OrderTableMap::INVOICE; + if ($this->invoice_ref !== $v) { + $this->invoice_ref = $v; + $this->modifiedColumns[] = OrderTableMap::INVOICE_REF; } return $this; - } // setInvoice() + } // setInvoiceRef() /** * Set the value of [postage] column. @@ -980,46 +999,54 @@ abstract class Order implements ActiveRecordInterface } // setPostage() /** - * Set the value of [payment] column. + * Set the value of [payment_module_id] column. * - * @param string $v new value + * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setPayment($v) + public function setPaymentModuleId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->payment !== $v) { - $this->payment = $v; - $this->modifiedColumns[] = OrderTableMap::PAYMENT; + if ($this->payment_module_id !== $v) { + $this->payment_module_id = $v; + $this->modifiedColumns[] = OrderTableMap::PAYMENT_MODULE_ID; + } + + if ($this->aModuleRelatedByPaymentModuleId !== null && $this->aModuleRelatedByPaymentModuleId->getId() !== $v) { + $this->aModuleRelatedByPaymentModuleId = null; } return $this; - } // setPayment() + } // setPaymentModuleId() /** - * Set the value of [carrier] column. + * Set the value of [delivery_module_id] column. * - * @param string $v new value + * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setCarrier($v) + public function setDeliveryModuleId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->carrier !== $v) { - $this->carrier = $v; - $this->modifiedColumns[] = OrderTableMap::CARRIER; + if ($this->delivery_module_id !== $v) { + $this->delivery_module_id = $v; + $this->modifiedColumns[] = OrderTableMap::DELIVERY_MODULE_ID; + } + + if ($this->aModuleRelatedByDeliveryModuleId !== null && $this->aModuleRelatedByDeliveryModuleId->getId() !== $v) { + $this->aModuleRelatedByDeliveryModuleId = null; } return $this; - } // setCarrier() + } // setDeliveryModuleId() /** * Set the value of [status_id] column. @@ -1047,25 +1074,29 @@ abstract class Order implements ActiveRecordInterface } // setStatusId() /** - * Set the value of [lang] column. + * Set the value of [lang_id] column. * - * @param string $v new value + * @param int $v new value * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function setLang($v) + public function setLangId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->lang !== $v) { - $this->lang = $v; - $this->modifiedColumns[] = OrderTableMap::LANG; + if ($this->lang_id !== $v) { + $this->lang_id = $v; + $this->modifiedColumns[] = OrderTableMap::LANG_ID; + } + + if ($this->aLang !== null && $this->aLang->getId() !== $v) { + $this->aLang = null; } return $this; - } // setLang() + } // setLangId() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -1155,11 +1186,11 @@ abstract class Order implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)]; $this->customer_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderTableMap::translateFieldName('AddressInvoice', TableMap::TYPE_PHPNAME, $indexType)]; - $this->address_invoice = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderTableMap::translateFieldName('InvoiceOrderAddressId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->invoice_order_address_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderTableMap::translateFieldName('AddressDelivery', TableMap::TYPE_PHPNAME, $indexType)]; - $this->address_delivery = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderTableMap::translateFieldName('DeliveryOrderAddressId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_order_address_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderTableMap::translateFieldName('InvoiceDate', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00') { @@ -1173,29 +1204,29 @@ abstract class Order implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderTableMap::translateFieldName('CurrencyRate', TableMap::TYPE_PHPNAME, $indexType)]; $this->currency_rate = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderTableMap::translateFieldName('Transaction', TableMap::TYPE_PHPNAME, $indexType)]; - $this->transaction = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderTableMap::translateFieldName('TransactionRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->transaction_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderTableMap::translateFieldName('DeliveryNum', TableMap::TYPE_PHPNAME, $indexType)]; - $this->delivery_num = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderTableMap::translateFieldName('DeliveryRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderTableMap::translateFieldName('Invoice', TableMap::TYPE_PHPNAME, $indexType)]; - $this->invoice = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderTableMap::translateFieldName('InvoiceRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->invoice_ref = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; $this->postage = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('Payment', TableMap::TYPE_PHPNAME, $indexType)]; - $this->payment = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('PaymentModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->payment_module_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('Carrier', TableMap::TYPE_PHPNAME, $indexType)]; - $this->carrier = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_module_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)]; $this->status_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; - $this->lang = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('LangId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lang_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -1241,18 +1272,27 @@ abstract class Order implements ActiveRecordInterface if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) { $this->aCustomer = null; } - if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->address_invoice !== $this->aOrderAddressRelatedByAddressInvoice->getId()) { - $this->aOrderAddressRelatedByAddressInvoice = null; + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId !== null && $this->invoice_order_address_id !== $this->aOrderAddressRelatedByInvoiceOrderAddressId->getId()) { + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; } - if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->address_delivery !== $this->aOrderAddressRelatedByAddressDelivery->getId()) { - $this->aOrderAddressRelatedByAddressDelivery = null; + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId !== null && $this->delivery_order_address_id !== $this->aOrderAddressRelatedByDeliveryOrderAddressId->getId()) { + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; } if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) { $this->aCurrency = null; } + if ($this->aModuleRelatedByPaymentModuleId !== null && $this->payment_module_id !== $this->aModuleRelatedByPaymentModuleId->getId()) { + $this->aModuleRelatedByPaymentModuleId = null; + } + if ($this->aModuleRelatedByDeliveryModuleId !== null && $this->delivery_module_id !== $this->aModuleRelatedByDeliveryModuleId->getId()) { + $this->aModuleRelatedByDeliveryModuleId = null; + } if ($this->aOrderStatus !== null && $this->status_id !== $this->aOrderStatus->getId()) { $this->aOrderStatus = null; } + if ($this->aLang !== null && $this->lang_id !== $this->aLang->getId()) { + $this->aLang = null; + } } // ensureConsistency /** @@ -1294,9 +1334,12 @@ abstract class Order implements ActiveRecordInterface $this->aCurrency = null; $this->aCustomer = null; - $this->aOrderAddressRelatedByAddressInvoice = null; - $this->aOrderAddressRelatedByAddressDelivery = null; + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; $this->aOrderStatus = null; + $this->aModuleRelatedByPaymentModuleId = null; + $this->aModuleRelatedByDeliveryModuleId = null; + $this->aLang = null; $this->collOrderProducts = null; $this->collCouponOrders = null; @@ -1442,18 +1485,18 @@ abstract class Order implements ActiveRecordInterface $this->setCustomer($this->aCustomer); } - if ($this->aOrderAddressRelatedByAddressInvoice !== null) { - if ($this->aOrderAddressRelatedByAddressInvoice->isModified() || $this->aOrderAddressRelatedByAddressInvoice->isNew()) { - $affectedRows += $this->aOrderAddressRelatedByAddressInvoice->save($con); + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId !== null) { + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId->isModified() || $this->aOrderAddressRelatedByInvoiceOrderAddressId->isNew()) { + $affectedRows += $this->aOrderAddressRelatedByInvoiceOrderAddressId->save($con); } - $this->setOrderAddressRelatedByAddressInvoice($this->aOrderAddressRelatedByAddressInvoice); + $this->setOrderAddressRelatedByInvoiceOrderAddressId($this->aOrderAddressRelatedByInvoiceOrderAddressId); } - if ($this->aOrderAddressRelatedByAddressDelivery !== null) { - if ($this->aOrderAddressRelatedByAddressDelivery->isModified() || $this->aOrderAddressRelatedByAddressDelivery->isNew()) { - $affectedRows += $this->aOrderAddressRelatedByAddressDelivery->save($con); + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId !== null) { + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId->isModified() || $this->aOrderAddressRelatedByDeliveryOrderAddressId->isNew()) { + $affectedRows += $this->aOrderAddressRelatedByDeliveryOrderAddressId->save($con); } - $this->setOrderAddressRelatedByAddressDelivery($this->aOrderAddressRelatedByAddressDelivery); + $this->setOrderAddressRelatedByDeliveryOrderAddressId($this->aOrderAddressRelatedByDeliveryOrderAddressId); } if ($this->aOrderStatus !== null) { @@ -1463,6 +1506,27 @@ abstract class Order implements ActiveRecordInterface $this->setOrderStatus($this->aOrderStatus); } + if ($this->aModuleRelatedByPaymentModuleId !== null) { + if ($this->aModuleRelatedByPaymentModuleId->isModified() || $this->aModuleRelatedByPaymentModuleId->isNew()) { + $affectedRows += $this->aModuleRelatedByPaymentModuleId->save($con); + } + $this->setModuleRelatedByPaymentModuleId($this->aModuleRelatedByPaymentModuleId); + } + + if ($this->aModuleRelatedByDeliveryModuleId !== null) { + if ($this->aModuleRelatedByDeliveryModuleId->isModified() || $this->aModuleRelatedByDeliveryModuleId->isNew()) { + $affectedRows += $this->aModuleRelatedByDeliveryModuleId->save($con); + } + $this->setModuleRelatedByDeliveryModuleId($this->aModuleRelatedByDeliveryModuleId); + } + + if ($this->aLang !== null) { + if ($this->aLang->isModified() || $this->aLang->isNew()) { + $affectedRows += $this->aLang->save($con); + } + $this->setLang($this->aLang); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -1543,11 +1607,11 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) { $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; } - if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) { - $modifiedColumns[':p' . $index++] = 'ADDRESS_INVOICE'; + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID'; } - if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) { - $modifiedColumns[':p' . $index++] = 'ADDRESS_DELIVERY'; + 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'; @@ -1558,29 +1622,29 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) { $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE'; } - if ($this->isColumnModified(OrderTableMap::TRANSACTION)) { - $modifiedColumns[':p' . $index++] = 'TRANSACTION'; + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) { + $modifiedColumns[':p' . $index++] = 'TRANSACTION_REF'; } - if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) { - $modifiedColumns[':p' . $index++] = 'DELIVERY_NUM'; + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_REF'; } - if ($this->isColumnModified(OrderTableMap::INVOICE)) { - $modifiedColumns[':p' . $index++] = 'INVOICE'; + 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)) { - $modifiedColumns[':p' . $index++] = 'PAYMENT'; + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; } - if ($this->isColumnModified(OrderTableMap::CARRIER)) { - $modifiedColumns[':p' . $index++] = 'CARRIER'; + 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)) { - $modifiedColumns[':p' . $index++] = 'LANG'; + if ($this->isColumnModified(OrderTableMap::LANG_ID)) { + $modifiedColumns[':p' . $index++] = 'LANG_ID'; } if ($this->isColumnModified(OrderTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1608,11 +1672,11 @@ abstract class Order implements ActiveRecordInterface case 'CUSTOMER_ID': $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); break; - case 'ADDRESS_INVOICE': - $stmt->bindValue($identifier, $this->address_invoice, PDO::PARAM_INT); + case 'INVOICE_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT); break; - case 'ADDRESS_DELIVERY': - $stmt->bindValue($identifier, $this->address_delivery, PDO::PARAM_INT); + 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); @@ -1623,29 +1687,29 @@ abstract class Order implements ActiveRecordInterface case 'CURRENCY_RATE': $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); break; - case 'TRANSACTION': - $stmt->bindValue($identifier, $this->transaction, PDO::PARAM_STR); + case 'TRANSACTION_REF': + $stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR); break; - case 'DELIVERY_NUM': - $stmt->bindValue($identifier, $this->delivery_num, PDO::PARAM_STR); + case 'DELIVERY_REF': + $stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR); break; - case 'INVOICE': - $stmt->bindValue($identifier, $this->invoice, PDO::PARAM_STR); + 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': - $stmt->bindValue($identifier, $this->payment, PDO::PARAM_STR); + case 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); break; - case 'CARRIER': - $stmt->bindValue($identifier, $this->carrier, PDO::PARAM_STR); + 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': - $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); + 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); @@ -1725,10 +1789,10 @@ abstract class Order implements ActiveRecordInterface return $this->getCustomerId(); break; case 3: - return $this->getAddressInvoice(); + return $this->getInvoiceOrderAddressId(); break; case 4: - return $this->getAddressDelivery(); + return $this->getDeliveryOrderAddressId(); break; case 5: return $this->getInvoiceDate(); @@ -1740,28 +1804,28 @@ abstract class Order implements ActiveRecordInterface return $this->getCurrencyRate(); break; case 8: - return $this->getTransaction(); + return $this->getTransactionRef(); break; case 9: - return $this->getDeliveryNum(); + return $this->getDeliveryRef(); break; case 10: - return $this->getInvoice(); + return $this->getInvoiceRef(); break; case 11: return $this->getPostage(); break; case 12: - return $this->getPayment(); + return $this->getPaymentModuleId(); break; case 13: - return $this->getCarrier(); + return $this->getDeliveryModuleId(); break; case 14: return $this->getStatusId(); break; case 15: - return $this->getLang(); + return $this->getLangId(); break; case 16: return $this->getCreatedAt(); @@ -1801,19 +1865,19 @@ abstract class Order implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getRef(), $keys[2] => $this->getCustomerId(), - $keys[3] => $this->getAddressInvoice(), - $keys[4] => $this->getAddressDelivery(), + $keys[3] => $this->getInvoiceOrderAddressId(), + $keys[4] => $this->getDeliveryOrderAddressId(), $keys[5] => $this->getInvoiceDate(), $keys[6] => $this->getCurrencyId(), $keys[7] => $this->getCurrencyRate(), - $keys[8] => $this->getTransaction(), - $keys[9] => $this->getDeliveryNum(), - $keys[10] => $this->getInvoice(), + $keys[8] => $this->getTransactionRef(), + $keys[9] => $this->getDeliveryRef(), + $keys[10] => $this->getInvoiceRef(), $keys[11] => $this->getPostage(), - $keys[12] => $this->getPayment(), - $keys[13] => $this->getCarrier(), + $keys[12] => $this->getPaymentModuleId(), + $keys[13] => $this->getDeliveryModuleId(), $keys[14] => $this->getStatusId(), - $keys[15] => $this->getLang(), + $keys[15] => $this->getLangId(), $keys[16] => $this->getCreatedAt(), $keys[17] => $this->getUpdatedAt(), ); @@ -1830,15 +1894,24 @@ abstract class Order implements ActiveRecordInterface if (null !== $this->aCustomer) { $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aOrderAddressRelatedByAddressInvoice) { - $result['OrderAddressRelatedByAddressInvoice'] = $this->aOrderAddressRelatedByAddressInvoice->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aOrderAddressRelatedByInvoiceOrderAddressId) { + $result['OrderAddressRelatedByInvoiceOrderAddressId'] = $this->aOrderAddressRelatedByInvoiceOrderAddressId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aOrderAddressRelatedByAddressDelivery) { - $result['OrderAddressRelatedByAddressDelivery'] = $this->aOrderAddressRelatedByAddressDelivery->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aOrderAddressRelatedByDeliveryOrderAddressId) { + $result['OrderAddressRelatedByDeliveryOrderAddressId'] = $this->aOrderAddressRelatedByDeliveryOrderAddressId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aOrderStatus) { $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aModuleRelatedByPaymentModuleId) { + $result['ModuleRelatedByPaymentModuleId'] = $this->aModuleRelatedByPaymentModuleId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aModuleRelatedByDeliveryModuleId) { + $result['ModuleRelatedByDeliveryModuleId'] = $this->aModuleRelatedByDeliveryModuleId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aLang) { + $result['Lang'] = $this->aLang->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } if (null !== $this->collOrderProducts) { $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1889,10 +1962,10 @@ abstract class Order implements ActiveRecordInterface $this->setCustomerId($value); break; case 3: - $this->setAddressInvoice($value); + $this->setInvoiceOrderAddressId($value); break; case 4: - $this->setAddressDelivery($value); + $this->setDeliveryOrderAddressId($value); break; case 5: $this->setInvoiceDate($value); @@ -1904,28 +1977,28 @@ abstract class Order implements ActiveRecordInterface $this->setCurrencyRate($value); break; case 8: - $this->setTransaction($value); + $this->setTransactionRef($value); break; case 9: - $this->setDeliveryNum($value); + $this->setDeliveryRef($value); break; case 10: - $this->setInvoice($value); + $this->setInvoiceRef($value); break; case 11: $this->setPostage($value); break; case 12: - $this->setPayment($value); + $this->setPaymentModuleId($value); break; case 13: - $this->setCarrier($value); + $this->setDeliveryModuleId($value); break; case 14: $this->setStatusId($value); break; case 15: - $this->setLang($value); + $this->setLangId($value); break; case 16: $this->setCreatedAt($value); @@ -1960,19 +2033,19 @@ abstract class Order implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAddressInvoice($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setAddressDelivery($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setInvoiceOrderAddressId($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setDeliveryOrderAddressId($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setInvoiceDate($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setCurrencyId($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setCurrencyRate($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setTransaction($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDeliveryNum($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setInvoice($arr[$keys[10]]); + if (array_key_exists($keys[8], $arr)) $this->setTransactionRef($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setDeliveryRef($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setInvoiceRef($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setPostage($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setPayment($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setCarrier($arr[$keys[13]]); + if (array_key_exists($keys[12], $arr)) $this->setPaymentModuleId($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setDeliveryModuleId($arr[$keys[13]]); if (array_key_exists($keys[14], $arr)) $this->setStatusId($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setLang($arr[$keys[15]]); + if (array_key_exists($keys[15], $arr)) $this->setLangId($arr[$keys[15]]); if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); } @@ -1989,19 +2062,19 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::ID)) $criteria->add(OrderTableMap::ID, $this->id); if ($this->isColumnModified(OrderTableMap::REF)) $criteria->add(OrderTableMap::REF, $this->ref); if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) $criteria->add(OrderTableMap::CUSTOMER_ID, $this->customer_id); - if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) $criteria->add(OrderTableMap::ADDRESS_INVOICE, $this->address_invoice); - if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) $criteria->add(OrderTableMap::ADDRESS_DELIVERY, $this->address_delivery); + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) $criteria->add(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $this->invoice_order_address_id); + if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) $criteria->add(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $this->delivery_order_address_id); if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) $criteria->add(OrderTableMap::INVOICE_DATE, $this->invoice_date); if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) $criteria->add(OrderTableMap::CURRENCY_ID, $this->currency_id); if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) $criteria->add(OrderTableMap::CURRENCY_RATE, $this->currency_rate); - if ($this->isColumnModified(OrderTableMap::TRANSACTION)) $criteria->add(OrderTableMap::TRANSACTION, $this->transaction); - if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) $criteria->add(OrderTableMap::DELIVERY_NUM, $this->delivery_num); - if ($this->isColumnModified(OrderTableMap::INVOICE)) $criteria->add(OrderTableMap::INVOICE, $this->invoice); + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) $criteria->add(OrderTableMap::TRANSACTION_REF, $this->transaction_ref); + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) $criteria->add(OrderTableMap::DELIVERY_REF, $this->delivery_ref); + if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) $criteria->add(OrderTableMap::INVOICE_REF, $this->invoice_ref); if ($this->isColumnModified(OrderTableMap::POSTAGE)) $criteria->add(OrderTableMap::POSTAGE, $this->postage); - if ($this->isColumnModified(OrderTableMap::PAYMENT)) $criteria->add(OrderTableMap::PAYMENT, $this->payment); - if ($this->isColumnModified(OrderTableMap::CARRIER)) $criteria->add(OrderTableMap::CARRIER, $this->carrier); + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) $criteria->add(OrderTableMap::PAYMENT_MODULE_ID, $this->payment_module_id); + if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) $criteria->add(OrderTableMap::DELIVERY_MODULE_ID, $this->delivery_module_id); if ($this->isColumnModified(OrderTableMap::STATUS_ID)) $criteria->add(OrderTableMap::STATUS_ID, $this->status_id); - if ($this->isColumnModified(OrderTableMap::LANG)) $criteria->add(OrderTableMap::LANG, $this->lang); + if ($this->isColumnModified(OrderTableMap::LANG_ID)) $criteria->add(OrderTableMap::LANG_ID, $this->lang_id); if ($this->isColumnModified(OrderTableMap::CREATED_AT)) $criteria->add(OrderTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) $criteria->add(OrderTableMap::UPDATED_AT, $this->updated_at); @@ -2069,19 +2142,19 @@ abstract class Order implements ActiveRecordInterface { $copyObj->setRef($this->getRef()); $copyObj->setCustomerId($this->getCustomerId()); - $copyObj->setAddressInvoice($this->getAddressInvoice()); - $copyObj->setAddressDelivery($this->getAddressDelivery()); + $copyObj->setInvoiceOrderAddressId($this->getInvoiceOrderAddressId()); + $copyObj->setDeliveryOrderAddressId($this->getDeliveryOrderAddressId()); $copyObj->setInvoiceDate($this->getInvoiceDate()); $copyObj->setCurrencyId($this->getCurrencyId()); $copyObj->setCurrencyRate($this->getCurrencyRate()); - $copyObj->setTransaction($this->getTransaction()); - $copyObj->setDeliveryNum($this->getDeliveryNum()); - $copyObj->setInvoice($this->getInvoice()); + $copyObj->setTransactionRef($this->getTransactionRef()); + $copyObj->setDeliveryRef($this->getDeliveryRef()); + $copyObj->setInvoiceRef($this->getInvoiceRef()); $copyObj->setPostage($this->getPostage()); - $copyObj->setPayment($this->getPayment()); - $copyObj->setCarrier($this->getCarrier()); + $copyObj->setPaymentModuleId($this->getPaymentModuleId()); + $copyObj->setDeliveryModuleId($this->getDeliveryModuleId()); $copyObj->setStatusId($this->getStatusId()); - $copyObj->setLang($this->getLang()); + $copyObj->setLangId($this->getLangId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2241,20 +2314,20 @@ abstract class Order implements ActiveRecordInterface * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setOrderAddressRelatedByAddressInvoice(ChildOrderAddress $v = null) + public function setOrderAddressRelatedByInvoiceOrderAddressId(ChildOrderAddress $v = null) { if ($v === null) { - $this->setAddressInvoice(NULL); + $this->setInvoiceOrderAddressId(NULL); } else { - $this->setAddressInvoice($v->getId()); + $this->setInvoiceOrderAddressId($v->getId()); } - $this->aOrderAddressRelatedByAddressInvoice = $v; + $this->aOrderAddressRelatedByInvoiceOrderAddressId = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildOrderAddress object, it will not be re-added. if ($v !== null) { - $v->addOrderRelatedByAddressInvoice($this); + $v->addOrderRelatedByInvoiceOrderAddressId($this); } @@ -2269,20 +2342,20 @@ abstract class Order implements ActiveRecordInterface * @return ChildOrderAddress The associated ChildOrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressInvoice(ConnectionInterface $con = null) + public function getOrderAddressRelatedByInvoiceOrderAddressId(ConnectionInterface $con = null) { - if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null)) { - $this->aOrderAddressRelatedByAddressInvoice = ChildOrderAddressQuery::create()->findPk($this->address_invoice, $con); + if ($this->aOrderAddressRelatedByInvoiceOrderAddressId === null && ($this->invoice_order_address_id !== null)) { + $this->aOrderAddressRelatedByInvoiceOrderAddressId = ChildOrderAddressQuery::create()->findPk($this->invoice_order_address_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->aOrderAddressRelatedByAddressInvoice->addOrdersRelatedByAddressInvoice($this); + $this->aOrderAddressRelatedByInvoiceOrderAddressId->addOrdersRelatedByInvoiceOrderAddressId($this); */ } - return $this->aOrderAddressRelatedByAddressInvoice; + return $this->aOrderAddressRelatedByInvoiceOrderAddressId; } /** @@ -2292,20 +2365,20 @@ abstract class Order implements ActiveRecordInterface * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setOrderAddressRelatedByAddressDelivery(ChildOrderAddress $v = null) + public function setOrderAddressRelatedByDeliveryOrderAddressId(ChildOrderAddress $v = null) { if ($v === null) { - $this->setAddressDelivery(NULL); + $this->setDeliveryOrderAddressId(NULL); } else { - $this->setAddressDelivery($v->getId()); + $this->setDeliveryOrderAddressId($v->getId()); } - $this->aOrderAddressRelatedByAddressDelivery = $v; + $this->aOrderAddressRelatedByDeliveryOrderAddressId = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildOrderAddress object, it will not be re-added. if ($v !== null) { - $v->addOrderRelatedByAddressDelivery($this); + $v->addOrderRelatedByDeliveryOrderAddressId($this); } @@ -2320,20 +2393,20 @@ abstract class Order implements ActiveRecordInterface * @return ChildOrderAddress The associated ChildOrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressDelivery(ConnectionInterface $con = null) + public function getOrderAddressRelatedByDeliveryOrderAddressId(ConnectionInterface $con = null) { - if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null)) { - $this->aOrderAddressRelatedByAddressDelivery = ChildOrderAddressQuery::create()->findPk($this->address_delivery, $con); + if ($this->aOrderAddressRelatedByDeliveryOrderAddressId === null && ($this->delivery_order_address_id !== null)) { + $this->aOrderAddressRelatedByDeliveryOrderAddressId = ChildOrderAddressQuery::create()->findPk($this->delivery_order_address_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->aOrderAddressRelatedByAddressDelivery->addOrdersRelatedByAddressDelivery($this); + $this->aOrderAddressRelatedByDeliveryOrderAddressId->addOrdersRelatedByDeliveryOrderAddressId($this); */ } - return $this->aOrderAddressRelatedByAddressDelivery; + return $this->aOrderAddressRelatedByDeliveryOrderAddressId; } /** @@ -2387,6 +2460,159 @@ abstract class Order implements ActiveRecordInterface return $this->aOrderStatus; } + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\Order The current object (for fluent API support) + * @throws PropelException + */ + public function setModuleRelatedByPaymentModuleId(ChildModule $v = null) + { + if ($v === null) { + $this->setPaymentModuleId(NULL); + } else { + $this->setPaymentModuleId($v->getId()); + } + + $this->aModuleRelatedByPaymentModuleId = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addOrderRelatedByPaymentModuleId($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModuleRelatedByPaymentModuleId(ConnectionInterface $con = null) + { + if ($this->aModuleRelatedByPaymentModuleId === null && ($this->payment_module_id !== null)) { + $this->aModuleRelatedByPaymentModuleId = ChildModuleQuery::create()->findPk($this->payment_module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModuleRelatedByPaymentModuleId->addOrdersRelatedByPaymentModuleId($this); + */ + } + + return $this->aModuleRelatedByPaymentModuleId; + } + + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\Order The current object (for fluent API support) + * @throws PropelException + */ + public function setModuleRelatedByDeliveryModuleId(ChildModule $v = null) + { + if ($v === null) { + $this->setDeliveryModuleId(NULL); + } else { + $this->setDeliveryModuleId($v->getId()); + } + + $this->aModuleRelatedByDeliveryModuleId = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addOrderRelatedByDeliveryModuleId($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModuleRelatedByDeliveryModuleId(ConnectionInterface $con = null) + { + if ($this->aModuleRelatedByDeliveryModuleId === null && ($this->delivery_module_id !== null)) { + $this->aModuleRelatedByDeliveryModuleId = ChildModuleQuery::create()->findPk($this->delivery_module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModuleRelatedByDeliveryModuleId->addOrdersRelatedByDeliveryModuleId($this); + */ + } + + return $this->aModuleRelatedByDeliveryModuleId; + } + + /** + * Declares an association between this object and a ChildLang object. + * + * @param ChildLang $v + * @return \Thelia\Model\Order The current object (for fluent API support) + * @throws PropelException + */ + public function setLang(ChildLang $v = null) + { + if ($v === null) { + $this->setLangId(NULL); + } else { + $this->setLangId($v->getId()); + } + + $this->aLang = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildLang object, it will not be re-added. + if ($v !== null) { + $v->addOrder($this); + } + + + return $this; + } + + + /** + * Get the associated ChildLang object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildLang The associated ChildLang object. + * @throws PropelException + */ + public function getLang(ConnectionInterface $con = null) + { + if ($this->aLang === null && ($this->lang_id !== null)) { + $this->aLang = ChildLangQuery::create()->findPk($this->lang_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->aLang->addOrders($this); + */ + } + + return $this->aLang; + } + /** * Initializes a collection based on the name of a relation. @@ -2850,19 +3076,19 @@ abstract class Order implements ActiveRecordInterface $this->id = null; $this->ref = null; $this->customer_id = null; - $this->address_invoice = null; - $this->address_delivery = null; + $this->invoice_order_address_id = null; + $this->delivery_order_address_id = null; $this->invoice_date = null; $this->currency_id = null; $this->currency_rate = null; - $this->transaction = null; - $this->delivery_num = null; - $this->invoice = null; + $this->transaction_ref = null; + $this->delivery_ref = null; + $this->invoice_ref = null; $this->postage = null; - $this->payment = null; - $this->carrier = null; + $this->payment_module_id = null; + $this->delivery_module_id = null; $this->status_id = null; - $this->lang = null; + $this->lang_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -2906,9 +3132,12 @@ abstract class Order implements ActiveRecordInterface $this->collCouponOrders = null; $this->aCurrency = null; $this->aCustomer = null; - $this->aOrderAddressRelatedByAddressInvoice = null; - $this->aOrderAddressRelatedByAddressDelivery = null; + $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; + $this->aOrderAddressRelatedByDeliveryOrderAddressId = null; $this->aOrderStatus = null; + $this->aModuleRelatedByPaymentModuleId = null; + $this->aModuleRelatedByDeliveryModuleId = null; + $this->aLang = null; } /** diff --git a/core/lib/Thelia/Model/Base/OrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php index d0220d4e0..c5502321a 100644 --- a/core/lib/Thelia/Model/Base/OrderAddress.php +++ b/core/lib/Thelia/Model/Base/OrderAddress.php @@ -144,14 +144,14 @@ abstract class OrderAddress implements ActiveRecordInterface /** * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. */ - protected $collOrdersRelatedByAddressInvoice; - protected $collOrdersRelatedByAddressInvoicePartial; + protected $collOrdersRelatedByInvoiceOrderAddressId; + protected $collOrdersRelatedByInvoiceOrderAddressIdPartial; /** * @var ObjectCollection|ChildOrder[] Collection to store aggregation of ChildOrder objects. */ - protected $collOrdersRelatedByAddressDelivery; - protected $collOrdersRelatedByAddressDeliveryPartial; + protected $collOrdersRelatedByDeliveryOrderAddressId; + protected $collOrdersRelatedByDeliveryOrderAddressIdPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -165,13 +165,13 @@ abstract class OrderAddress implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $ordersRelatedByAddressInvoiceScheduledForDeletion = null; + protected $ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $ordersRelatedByAddressDeliveryScheduledForDeletion = null; + protected $ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = null; /** * Initializes internal state of Thelia\Model\Base\OrderAddress object. @@ -1046,9 +1046,9 @@ abstract class OrderAddress implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collOrdersRelatedByAddressInvoice = null; + $this->collOrdersRelatedByInvoiceOrderAddressId = null; - $this->collOrdersRelatedByAddressDelivery = null; + $this->collOrdersRelatedByDeliveryOrderAddressId = null; } // if (deep) } @@ -1183,36 +1183,34 @@ abstract class OrderAddress implements ActiveRecordInterface $this->resetModified(); } - if ($this->ordersRelatedByAddressInvoiceScheduledForDeletion !== null) { - if (!$this->ordersRelatedByAddressInvoiceScheduledForDeletion->isEmpty()) { - foreach ($this->ordersRelatedByAddressInvoiceScheduledForDeletion as $orderRelatedByAddressInvoice) { - // need to save related object because we set the relation to null - $orderRelatedByAddressInvoice->save($con); - } - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = null; + if ($this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = null; } } - if ($this->collOrdersRelatedByAddressInvoice !== null) { - foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) { + if ($this->collOrdersRelatedByInvoiceOrderAddressId !== null) { + foreach ($this->collOrdersRelatedByInvoiceOrderAddressId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } - if ($this->ordersRelatedByAddressDeliveryScheduledForDeletion !== null) { - if (!$this->ordersRelatedByAddressDeliveryScheduledForDeletion->isEmpty()) { - foreach ($this->ordersRelatedByAddressDeliveryScheduledForDeletion as $orderRelatedByAddressDelivery) { - // need to save related object because we set the relation to null - $orderRelatedByAddressDelivery->save($con); - } - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = null; + if ($this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion !== null) { + if (!$this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = null; } } - if ($this->collOrdersRelatedByAddressDelivery !== null) { - foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) { + if ($this->collOrdersRelatedByDeliveryOrderAddressId !== null) { + foreach ($this->collOrdersRelatedByDeliveryOrderAddressId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1495,11 +1493,11 @@ abstract class OrderAddress implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collOrdersRelatedByAddressInvoice) { - $result['OrdersRelatedByAddressInvoice'] = $this->collOrdersRelatedByAddressInvoice->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collOrdersRelatedByInvoiceOrderAddressId) { + $result['OrdersRelatedByInvoiceOrderAddressId'] = $this->collOrdersRelatedByInvoiceOrderAddressId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collOrdersRelatedByAddressDelivery) { - $result['OrdersRelatedByAddressDelivery'] = $this->collOrdersRelatedByAddressDelivery->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collOrdersRelatedByDeliveryOrderAddressId) { + $result['OrdersRelatedByDeliveryOrderAddressId'] = $this->collOrdersRelatedByDeliveryOrderAddressId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1722,15 +1720,15 @@ abstract class OrderAddress implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getOrdersRelatedByAddressInvoice() as $relObj) { + foreach ($this->getOrdersRelatedByInvoiceOrderAddressId() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderRelatedByAddressInvoice($relObj->copy($deepCopy)); + $copyObj->addOrderRelatedByInvoiceOrderAddressId($relObj->copy($deepCopy)); } } - foreach ($this->getOrdersRelatedByAddressDelivery() as $relObj) { + foreach ($this->getOrdersRelatedByDeliveryOrderAddressId() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderRelatedByAddressDelivery($relObj->copy($deepCopy)); + $copyObj->addOrderRelatedByDeliveryOrderAddressId($relObj->copy($deepCopy)); } } @@ -1775,40 +1773,40 @@ abstract class OrderAddress implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('OrderRelatedByAddressInvoice' == $relationName) { - return $this->initOrdersRelatedByAddressInvoice(); + if ('OrderRelatedByInvoiceOrderAddressId' == $relationName) { + return $this->initOrdersRelatedByInvoiceOrderAddressId(); } - if ('OrderRelatedByAddressDelivery' == $relationName) { - return $this->initOrdersRelatedByAddressDelivery(); + if ('OrderRelatedByDeliveryOrderAddressId' == $relationName) { + return $this->initOrdersRelatedByDeliveryOrderAddressId(); } } /** - * Clears out the collOrdersRelatedByAddressInvoice collection + * Clears out the collOrdersRelatedByInvoiceOrderAddressId 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 addOrdersRelatedByAddressInvoice() + * @see addOrdersRelatedByInvoiceOrderAddressId() */ - public function clearOrdersRelatedByAddressInvoice() + public function clearOrdersRelatedByInvoiceOrderAddressId() { - $this->collOrdersRelatedByAddressInvoice = null; // important to set this to NULL since that means it is uninitialized + $this->collOrdersRelatedByInvoiceOrderAddressId = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrdersRelatedByAddressInvoice collection loaded partially. + * Reset is the collOrdersRelatedByInvoiceOrderAddressId collection loaded partially. */ - public function resetPartialOrdersRelatedByAddressInvoice($v = true) + public function resetPartialOrdersRelatedByInvoiceOrderAddressId($v = true) { - $this->collOrdersRelatedByAddressInvoicePartial = $v; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = $v; } /** - * Initializes the collOrdersRelatedByAddressInvoice collection. + * Initializes the collOrdersRelatedByInvoiceOrderAddressId collection. * - * By default this just sets the collOrdersRelatedByAddressInvoice collection to an empty array (like clearcollOrdersRelatedByAddressInvoice()); + * By default this just sets the collOrdersRelatedByInvoiceOrderAddressId collection to an empty array (like clearcollOrdersRelatedByInvoiceOrderAddressId()); * 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. * @@ -1817,13 +1815,13 @@ abstract class OrderAddress implements ActiveRecordInterface * * @return void */ - public function initOrdersRelatedByAddressInvoice($overrideExisting = true) + public function initOrdersRelatedByInvoiceOrderAddressId($overrideExisting = true) { - if (null !== $this->collOrdersRelatedByAddressInvoice && !$overrideExisting) { + if (null !== $this->collOrdersRelatedByInvoiceOrderAddressId && !$overrideExisting) { return; } - $this->collOrdersRelatedByAddressInvoice = new ObjectCollection(); - $this->collOrdersRelatedByAddressInvoice->setModel('\Thelia\Model\Order'); + $this->collOrdersRelatedByInvoiceOrderAddressId = new ObjectCollection(); + $this->collOrdersRelatedByInvoiceOrderAddressId->setModel('\Thelia\Model\Order'); } /** @@ -1840,80 +1838,80 @@ abstract class OrderAddress implements ActiveRecordInterface * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrdersRelatedByAddressInvoice($criteria = null, ConnectionInterface $con = null) + public function getOrdersRelatedByInvoiceOrderAddressId($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) { + $partial = $this->collOrdersRelatedByInvoiceOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByInvoiceOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByInvoiceOrderAddressId) { // return empty collection - $this->initOrdersRelatedByAddressInvoice(); + $this->initOrdersRelatedByInvoiceOrderAddressId(); } else { - $collOrdersRelatedByAddressInvoice = ChildOrderQuery::create(null, $criteria) - ->filterByOrderAddressRelatedByAddressInvoice($this) + $collOrdersRelatedByInvoiceOrderAddressId = ChildOrderQuery::create(null, $criteria) + ->filterByOrderAddressRelatedByInvoiceOrderAddressId($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrdersRelatedByAddressInvoicePartial && count($collOrdersRelatedByAddressInvoice)) { - $this->initOrdersRelatedByAddressInvoice(false); + if (false !== $this->collOrdersRelatedByInvoiceOrderAddressIdPartial && count($collOrdersRelatedByInvoiceOrderAddressId)) { + $this->initOrdersRelatedByInvoiceOrderAddressId(false); - foreach ($collOrdersRelatedByAddressInvoice as $obj) { - if (false == $this->collOrdersRelatedByAddressInvoice->contains($obj)) { - $this->collOrdersRelatedByAddressInvoice->append($obj); + foreach ($collOrdersRelatedByInvoiceOrderAddressId as $obj) { + if (false == $this->collOrdersRelatedByInvoiceOrderAddressId->contains($obj)) { + $this->collOrdersRelatedByInvoiceOrderAddressId->append($obj); } } - $this->collOrdersRelatedByAddressInvoicePartial = true; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = true; } - $collOrdersRelatedByAddressInvoice->getInternalIterator()->rewind(); + $collOrdersRelatedByInvoiceOrderAddressId->getInternalIterator()->rewind(); - return $collOrdersRelatedByAddressInvoice; + return $collOrdersRelatedByInvoiceOrderAddressId; } - if ($partial && $this->collOrdersRelatedByAddressInvoice) { - foreach ($this->collOrdersRelatedByAddressInvoice as $obj) { + if ($partial && $this->collOrdersRelatedByInvoiceOrderAddressId) { + foreach ($this->collOrdersRelatedByInvoiceOrderAddressId as $obj) { if ($obj->isNew()) { - $collOrdersRelatedByAddressInvoice[] = $obj; + $collOrdersRelatedByInvoiceOrderAddressId[] = $obj; } } } - $this->collOrdersRelatedByAddressInvoice = $collOrdersRelatedByAddressInvoice; - $this->collOrdersRelatedByAddressInvoicePartial = false; + $this->collOrdersRelatedByInvoiceOrderAddressId = $collOrdersRelatedByInvoiceOrderAddressId; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = false; } } - return $this->collOrdersRelatedByAddressInvoice; + return $this->collOrdersRelatedByInvoiceOrderAddressId; } /** - * Sets a collection of OrderRelatedByAddressInvoice objects related by a one-to-many relationship + * Sets a collection of OrderRelatedByInvoiceOrderAddressId 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 $ordersRelatedByAddressInvoice A Propel collection. + * @param Collection $ordersRelatedByInvoiceOrderAddressId A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrderAddress The current object (for fluent API support) */ - public function setOrdersRelatedByAddressInvoice(Collection $ordersRelatedByAddressInvoice, ConnectionInterface $con = null) + public function setOrdersRelatedByInvoiceOrderAddressId(Collection $ordersRelatedByInvoiceOrderAddressId, ConnectionInterface $con = null) { - $ordersRelatedByAddressInvoiceToDelete = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice); + $ordersRelatedByInvoiceOrderAddressIdToDelete = $this->getOrdersRelatedByInvoiceOrderAddressId(new Criteria(), $con)->diff($ordersRelatedByInvoiceOrderAddressId); - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = $ordersRelatedByAddressInvoiceToDelete; + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = $ordersRelatedByInvoiceOrderAddressIdToDelete; - foreach ($ordersRelatedByAddressInvoiceToDelete as $orderRelatedByAddressInvoiceRemoved) { - $orderRelatedByAddressInvoiceRemoved->setOrderAddressRelatedByAddressInvoice(null); + foreach ($ordersRelatedByInvoiceOrderAddressIdToDelete as $orderRelatedByInvoiceOrderAddressIdRemoved) { + $orderRelatedByInvoiceOrderAddressIdRemoved->setOrderAddressRelatedByInvoiceOrderAddressId(null); } - $this->collOrdersRelatedByAddressInvoice = null; - foreach ($ordersRelatedByAddressInvoice as $orderRelatedByAddressInvoice) { - $this->addOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice); + $this->collOrdersRelatedByInvoiceOrderAddressId = null; + foreach ($ordersRelatedByInvoiceOrderAddressId as $orderRelatedByInvoiceOrderAddressId) { + $this->addOrderRelatedByInvoiceOrderAddressId($orderRelatedByInvoiceOrderAddressId); } - $this->collOrdersRelatedByAddressInvoice = $ordersRelatedByAddressInvoice; - $this->collOrdersRelatedByAddressInvoicePartial = false; + $this->collOrdersRelatedByInvoiceOrderAddressId = $ordersRelatedByInvoiceOrderAddressId; + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = false; return $this; } @@ -1927,16 +1925,16 @@ abstract class OrderAddress implements ActiveRecordInterface * @return int Count of related Order objects. * @throws PropelException */ - public function countOrdersRelatedByAddressInvoice(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countOrdersRelatedByInvoiceOrderAddressId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) { + $partial = $this->collOrdersRelatedByInvoiceOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByInvoiceOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByInvoiceOrderAddressId) { return 0; } if ($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressInvoice()); + return count($this->getOrdersRelatedByInvoiceOrderAddressId()); } $query = ChildOrderQuery::create(null, $criteria); @@ -1945,11 +1943,11 @@ abstract class OrderAddress implements ActiveRecordInterface } return $query - ->filterByOrderAddressRelatedByAddressInvoice($this) + ->filterByOrderAddressRelatedByInvoiceOrderAddressId($this) ->count($con); } - return count($this->collOrdersRelatedByAddressInvoice); + return count($this->collOrdersRelatedByInvoiceOrderAddressId); } /** @@ -1959,43 +1957,43 @@ abstract class OrderAddress implements ActiveRecordInterface * @param ChildOrder $l ChildOrder * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ - public function addOrderRelatedByAddressInvoice(ChildOrder $l) + public function addOrderRelatedByInvoiceOrderAddressId(ChildOrder $l) { - if ($this->collOrdersRelatedByAddressInvoice === null) { - $this->initOrdersRelatedByAddressInvoice(); - $this->collOrdersRelatedByAddressInvoicePartial = true; + if ($this->collOrdersRelatedByInvoiceOrderAddressId === null) { + $this->initOrdersRelatedByInvoiceOrderAddressId(); + $this->collOrdersRelatedByInvoiceOrderAddressIdPartial = true; } - if (!in_array($l, $this->collOrdersRelatedByAddressInvoice->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderRelatedByAddressInvoice($l); + if (!in_array($l, $this->collOrdersRelatedByInvoiceOrderAddressId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByInvoiceOrderAddressId($l); } return $this; } /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add. + * @param OrderRelatedByInvoiceOrderAddressId $orderRelatedByInvoiceOrderAddressId The orderRelatedByInvoiceOrderAddressId object to add. */ - protected function doAddOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) + protected function doAddOrderRelatedByInvoiceOrderAddressId($orderRelatedByInvoiceOrderAddressId) { - $this->collOrdersRelatedByAddressInvoice[]= $orderRelatedByAddressInvoice; - $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice($this); + $this->collOrdersRelatedByInvoiceOrderAddressId[]= $orderRelatedByInvoiceOrderAddressId; + $orderRelatedByInvoiceOrderAddressId->setOrderAddressRelatedByInvoiceOrderAddressId($this); } /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove. + * @param OrderRelatedByInvoiceOrderAddressId $orderRelatedByInvoiceOrderAddressId The orderRelatedByInvoiceOrderAddressId object to remove. * @return ChildOrderAddress The current object (for fluent API support) */ - public function removeOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) + public function removeOrderRelatedByInvoiceOrderAddressId($orderRelatedByInvoiceOrderAddressId) { - if ($this->getOrdersRelatedByAddressInvoice()->contains($orderRelatedByAddressInvoice)) { - $this->collOrdersRelatedByAddressInvoice->remove($this->collOrdersRelatedByAddressInvoice->search($orderRelatedByAddressInvoice)); - if (null === $this->ordersRelatedByAddressInvoiceScheduledForDeletion) { - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = clone $this->collOrdersRelatedByAddressInvoice; - $this->ordersRelatedByAddressInvoiceScheduledForDeletion->clear(); + if ($this->getOrdersRelatedByInvoiceOrderAddressId()->contains($orderRelatedByInvoiceOrderAddressId)) { + $this->collOrdersRelatedByInvoiceOrderAddressId->remove($this->collOrdersRelatedByInvoiceOrderAddressId->search($orderRelatedByInvoiceOrderAddressId)); + if (null === $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion) { + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion = clone $this->collOrdersRelatedByInvoiceOrderAddressId; + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion->clear(); } - $this->ordersRelatedByAddressInvoiceScheduledForDeletion[]= $orderRelatedByAddressInvoice; - $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice(null); + $this->ordersRelatedByInvoiceOrderAddressIdScheduledForDeletion[]= clone $orderRelatedByInvoiceOrderAddressId; + $orderRelatedByInvoiceOrderAddressId->setOrderAddressRelatedByInvoiceOrderAddressId(null); } return $this; @@ -2007,7 +2005,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2018,12 +2016,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByInvoiceOrderAddressIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Currency', $joinBehavior); - return $this->getOrdersRelatedByAddressInvoice($query, $con); + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); } @@ -2032,7 +2030,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2043,12 +2041,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByInvoiceOrderAddressIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Customer', $joinBehavior); - return $this->getOrdersRelatedByAddressInvoice($query, $con); + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); } @@ -2057,7 +2055,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2068,40 +2066,115 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByInvoiceOrderAddressIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('OrderStatus', $joinBehavior); - return $this->getOrdersRelatedByAddressInvoice($query, $con); + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByInvoiceOrderAddressIdJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByInvoiceOrderAddressIdJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByInvoiceOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByInvoiceOrderAddressIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByInvoiceOrderAddressId($query, $con); } /** - * Clears out the collOrdersRelatedByAddressDelivery collection + * Clears out the collOrdersRelatedByDeliveryOrderAddressId 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 addOrdersRelatedByAddressDelivery() + * @see addOrdersRelatedByDeliveryOrderAddressId() */ - public function clearOrdersRelatedByAddressDelivery() + public function clearOrdersRelatedByDeliveryOrderAddressId() { - $this->collOrdersRelatedByAddressDelivery = null; // important to set this to NULL since that means it is uninitialized + $this->collOrdersRelatedByDeliveryOrderAddressId = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrdersRelatedByAddressDelivery collection loaded partially. + * Reset is the collOrdersRelatedByDeliveryOrderAddressId collection loaded partially. */ - public function resetPartialOrdersRelatedByAddressDelivery($v = true) + public function resetPartialOrdersRelatedByDeliveryOrderAddressId($v = true) { - $this->collOrdersRelatedByAddressDeliveryPartial = $v; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = $v; } /** - * Initializes the collOrdersRelatedByAddressDelivery collection. + * Initializes the collOrdersRelatedByDeliveryOrderAddressId collection. * - * By default this just sets the collOrdersRelatedByAddressDelivery collection to an empty array (like clearcollOrdersRelatedByAddressDelivery()); + * By default this just sets the collOrdersRelatedByDeliveryOrderAddressId collection to an empty array (like clearcollOrdersRelatedByDeliveryOrderAddressId()); * 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. * @@ -2110,13 +2183,13 @@ abstract class OrderAddress implements ActiveRecordInterface * * @return void */ - public function initOrdersRelatedByAddressDelivery($overrideExisting = true) + public function initOrdersRelatedByDeliveryOrderAddressId($overrideExisting = true) { - if (null !== $this->collOrdersRelatedByAddressDelivery && !$overrideExisting) { + if (null !== $this->collOrdersRelatedByDeliveryOrderAddressId && !$overrideExisting) { return; } - $this->collOrdersRelatedByAddressDelivery = new ObjectCollection(); - $this->collOrdersRelatedByAddressDelivery->setModel('\Thelia\Model\Order'); + $this->collOrdersRelatedByDeliveryOrderAddressId = new ObjectCollection(); + $this->collOrdersRelatedByDeliveryOrderAddressId->setModel('\Thelia\Model\Order'); } /** @@ -2133,80 +2206,80 @@ abstract class OrderAddress implements ActiveRecordInterface * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrdersRelatedByAddressDelivery($criteria = null, ConnectionInterface $con = null) + public function getOrdersRelatedByDeliveryOrderAddressId($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) { + $partial = $this->collOrdersRelatedByDeliveryOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryOrderAddressId) { // return empty collection - $this->initOrdersRelatedByAddressDelivery(); + $this->initOrdersRelatedByDeliveryOrderAddressId(); } else { - $collOrdersRelatedByAddressDelivery = ChildOrderQuery::create(null, $criteria) - ->filterByOrderAddressRelatedByAddressDelivery($this) + $collOrdersRelatedByDeliveryOrderAddressId = ChildOrderQuery::create(null, $criteria) + ->filterByOrderAddressRelatedByDeliveryOrderAddressId($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrdersRelatedByAddressDeliveryPartial && count($collOrdersRelatedByAddressDelivery)) { - $this->initOrdersRelatedByAddressDelivery(false); + if (false !== $this->collOrdersRelatedByDeliveryOrderAddressIdPartial && count($collOrdersRelatedByDeliveryOrderAddressId)) { + $this->initOrdersRelatedByDeliveryOrderAddressId(false); - foreach ($collOrdersRelatedByAddressDelivery as $obj) { - if (false == $this->collOrdersRelatedByAddressDelivery->contains($obj)) { - $this->collOrdersRelatedByAddressDelivery->append($obj); + foreach ($collOrdersRelatedByDeliveryOrderAddressId as $obj) { + if (false == $this->collOrdersRelatedByDeliveryOrderAddressId->contains($obj)) { + $this->collOrdersRelatedByDeliveryOrderAddressId->append($obj); } } - $this->collOrdersRelatedByAddressDeliveryPartial = true; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = true; } - $collOrdersRelatedByAddressDelivery->getInternalIterator()->rewind(); + $collOrdersRelatedByDeliveryOrderAddressId->getInternalIterator()->rewind(); - return $collOrdersRelatedByAddressDelivery; + return $collOrdersRelatedByDeliveryOrderAddressId; } - if ($partial && $this->collOrdersRelatedByAddressDelivery) { - foreach ($this->collOrdersRelatedByAddressDelivery as $obj) { + if ($partial && $this->collOrdersRelatedByDeliveryOrderAddressId) { + foreach ($this->collOrdersRelatedByDeliveryOrderAddressId as $obj) { if ($obj->isNew()) { - $collOrdersRelatedByAddressDelivery[] = $obj; + $collOrdersRelatedByDeliveryOrderAddressId[] = $obj; } } } - $this->collOrdersRelatedByAddressDelivery = $collOrdersRelatedByAddressDelivery; - $this->collOrdersRelatedByAddressDeliveryPartial = false; + $this->collOrdersRelatedByDeliveryOrderAddressId = $collOrdersRelatedByDeliveryOrderAddressId; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = false; } } - return $this->collOrdersRelatedByAddressDelivery; + return $this->collOrdersRelatedByDeliveryOrderAddressId; } /** - * Sets a collection of OrderRelatedByAddressDelivery objects related by a one-to-many relationship + * Sets a collection of OrderRelatedByDeliveryOrderAddressId 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 $ordersRelatedByAddressDelivery A Propel collection. + * @param Collection $ordersRelatedByDeliveryOrderAddressId A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrderAddress The current object (for fluent API support) */ - public function setOrdersRelatedByAddressDelivery(Collection $ordersRelatedByAddressDelivery, ConnectionInterface $con = null) + public function setOrdersRelatedByDeliveryOrderAddressId(Collection $ordersRelatedByDeliveryOrderAddressId, ConnectionInterface $con = null) { - $ordersRelatedByAddressDeliveryToDelete = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery); + $ordersRelatedByDeliveryOrderAddressIdToDelete = $this->getOrdersRelatedByDeliveryOrderAddressId(new Criteria(), $con)->diff($ordersRelatedByDeliveryOrderAddressId); - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = $ordersRelatedByAddressDeliveryToDelete; + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = $ordersRelatedByDeliveryOrderAddressIdToDelete; - foreach ($ordersRelatedByAddressDeliveryToDelete as $orderRelatedByAddressDeliveryRemoved) { - $orderRelatedByAddressDeliveryRemoved->setOrderAddressRelatedByAddressDelivery(null); + foreach ($ordersRelatedByDeliveryOrderAddressIdToDelete as $orderRelatedByDeliveryOrderAddressIdRemoved) { + $orderRelatedByDeliveryOrderAddressIdRemoved->setOrderAddressRelatedByDeliveryOrderAddressId(null); } - $this->collOrdersRelatedByAddressDelivery = null; - foreach ($ordersRelatedByAddressDelivery as $orderRelatedByAddressDelivery) { - $this->addOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery); + $this->collOrdersRelatedByDeliveryOrderAddressId = null; + foreach ($ordersRelatedByDeliveryOrderAddressId as $orderRelatedByDeliveryOrderAddressId) { + $this->addOrderRelatedByDeliveryOrderAddressId($orderRelatedByDeliveryOrderAddressId); } - $this->collOrdersRelatedByAddressDelivery = $ordersRelatedByAddressDelivery; - $this->collOrdersRelatedByAddressDeliveryPartial = false; + $this->collOrdersRelatedByDeliveryOrderAddressId = $ordersRelatedByDeliveryOrderAddressId; + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = false; return $this; } @@ -2220,16 +2293,16 @@ abstract class OrderAddress implements ActiveRecordInterface * @return int Count of related Order objects. * @throws PropelException */ - public function countOrdersRelatedByAddressDelivery(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countOrdersRelatedByDeliveryOrderAddressId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) { + $partial = $this->collOrdersRelatedByDeliveryOrderAddressIdPartial && !$this->isNew(); + if (null === $this->collOrdersRelatedByDeliveryOrderAddressId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrdersRelatedByDeliveryOrderAddressId) { return 0; } if ($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressDelivery()); + return count($this->getOrdersRelatedByDeliveryOrderAddressId()); } $query = ChildOrderQuery::create(null, $criteria); @@ -2238,11 +2311,11 @@ abstract class OrderAddress implements ActiveRecordInterface } return $query - ->filterByOrderAddressRelatedByAddressDelivery($this) + ->filterByOrderAddressRelatedByDeliveryOrderAddressId($this) ->count($con); } - return count($this->collOrdersRelatedByAddressDelivery); + return count($this->collOrdersRelatedByDeliveryOrderAddressId); } /** @@ -2252,43 +2325,43 @@ abstract class OrderAddress implements ActiveRecordInterface * @param ChildOrder $l ChildOrder * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ - public function addOrderRelatedByAddressDelivery(ChildOrder $l) + public function addOrderRelatedByDeliveryOrderAddressId(ChildOrder $l) { - if ($this->collOrdersRelatedByAddressDelivery === null) { - $this->initOrdersRelatedByAddressDelivery(); - $this->collOrdersRelatedByAddressDeliveryPartial = true; + if ($this->collOrdersRelatedByDeliveryOrderAddressId === null) { + $this->initOrdersRelatedByDeliveryOrderAddressId(); + $this->collOrdersRelatedByDeliveryOrderAddressIdPartial = true; } - if (!in_array($l, $this->collOrdersRelatedByAddressDelivery->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderRelatedByAddressDelivery($l); + if (!in_array($l, $this->collOrdersRelatedByDeliveryOrderAddressId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderRelatedByDeliveryOrderAddressId($l); } return $this; } /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to add. + * @param OrderRelatedByDeliveryOrderAddressId $orderRelatedByDeliveryOrderAddressId The orderRelatedByDeliveryOrderAddressId object to add. */ - protected function doAddOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) + protected function doAddOrderRelatedByDeliveryOrderAddressId($orderRelatedByDeliveryOrderAddressId) { - $this->collOrdersRelatedByAddressDelivery[]= $orderRelatedByAddressDelivery; - $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery($this); + $this->collOrdersRelatedByDeliveryOrderAddressId[]= $orderRelatedByDeliveryOrderAddressId; + $orderRelatedByDeliveryOrderAddressId->setOrderAddressRelatedByDeliveryOrderAddressId($this); } /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove. + * @param OrderRelatedByDeliveryOrderAddressId $orderRelatedByDeliveryOrderAddressId The orderRelatedByDeliveryOrderAddressId object to remove. * @return ChildOrderAddress The current object (for fluent API support) */ - public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) + public function removeOrderRelatedByDeliveryOrderAddressId($orderRelatedByDeliveryOrderAddressId) { - if ($this->getOrdersRelatedByAddressDelivery()->contains($orderRelatedByAddressDelivery)) { - $this->collOrdersRelatedByAddressDelivery->remove($this->collOrdersRelatedByAddressDelivery->search($orderRelatedByAddressDelivery)); - if (null === $this->ordersRelatedByAddressDeliveryScheduledForDeletion) { - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = clone $this->collOrdersRelatedByAddressDelivery; - $this->ordersRelatedByAddressDeliveryScheduledForDeletion->clear(); + if ($this->getOrdersRelatedByDeliveryOrderAddressId()->contains($orderRelatedByDeliveryOrderAddressId)) { + $this->collOrdersRelatedByDeliveryOrderAddressId->remove($this->collOrdersRelatedByDeliveryOrderAddressId->search($orderRelatedByDeliveryOrderAddressId)); + if (null === $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion) { + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion = clone $this->collOrdersRelatedByDeliveryOrderAddressId; + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion->clear(); } - $this->ordersRelatedByAddressDeliveryScheduledForDeletion[]= $orderRelatedByAddressDelivery; - $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery(null); + $this->ordersRelatedByDeliveryOrderAddressIdScheduledForDeletion[]= clone $orderRelatedByDeliveryOrderAddressId; + $orderRelatedByDeliveryOrderAddressId->setOrderAddressRelatedByDeliveryOrderAddressId(null); } return $this; @@ -2300,7 +2373,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2311,12 +2384,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByDeliveryOrderAddressIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Currency', $joinBehavior); - return $this->getOrdersRelatedByAddressDelivery($query, $con); + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); } @@ -2325,7 +2398,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2336,12 +2409,12 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByDeliveryOrderAddressIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('Customer', $joinBehavior); - return $this->getOrdersRelatedByAddressDelivery($query, $con); + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); } @@ -2350,7 +2423,7 @@ abstract class OrderAddress implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this OrderAddress is new, it will return * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2361,12 +2434,87 @@ abstract class OrderAddress implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByDeliveryOrderAddressIdJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); $query->joinWith('OrderStatus', $joinBehavior); - return $this->getOrdersRelatedByAddressDelivery($query, $con); + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryOrderAddressIdJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryOrderAddressIdJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderAddress is new, it will return + * an empty collection; or if this OrderAddress has previously + * been saved, it will retrieve related OrdersRelatedByDeliveryOrderAddressId from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderAddress. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersRelatedByDeliveryOrderAddressIdJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); + + return $this->getOrdersRelatedByDeliveryOrderAddressId($query, $con); } /** @@ -2407,26 +2555,26 @@ abstract class OrderAddress implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collOrdersRelatedByAddressInvoice) { - foreach ($this->collOrdersRelatedByAddressInvoice as $o) { + if ($this->collOrdersRelatedByInvoiceOrderAddressId) { + foreach ($this->collOrdersRelatedByInvoiceOrderAddressId as $o) { $o->clearAllReferences($deep); } } - if ($this->collOrdersRelatedByAddressDelivery) { - foreach ($this->collOrdersRelatedByAddressDelivery as $o) { + if ($this->collOrdersRelatedByDeliveryOrderAddressId) { + foreach ($this->collOrdersRelatedByDeliveryOrderAddressId as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collOrdersRelatedByAddressInvoice instanceof Collection) { - $this->collOrdersRelatedByAddressInvoice->clearIterator(); + if ($this->collOrdersRelatedByInvoiceOrderAddressId instanceof Collection) { + $this->collOrdersRelatedByInvoiceOrderAddressId->clearIterator(); } - $this->collOrdersRelatedByAddressInvoice = null; - if ($this->collOrdersRelatedByAddressDelivery instanceof Collection) { - $this->collOrdersRelatedByAddressDelivery->clearIterator(); + $this->collOrdersRelatedByInvoiceOrderAddressId = null; + if ($this->collOrdersRelatedByDeliveryOrderAddressId instanceof Collection) { + $this->collOrdersRelatedByDeliveryOrderAddressId->clearIterator(); } - $this->collOrdersRelatedByAddressDelivery = null; + $this->collOrdersRelatedByDeliveryOrderAddressId = null; } /** diff --git a/core/lib/Thelia/Model/Base/OrderAddressQuery.php b/core/lib/Thelia/Model/Base/OrderAddressQuery.php index 0552feb85..41f417872 100644 --- a/core/lib/Thelia/Model/Base/OrderAddressQuery.php +++ b/core/lib/Thelia/Model/Base/OrderAddressQuery.php @@ -55,13 +55,13 @@ use Thelia\Model\Map\OrderAddressTableMap; * @method ChildOrderAddressQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildOrderAddressQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildOrderAddressQuery leftJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByAddressInvoice relation - * @method ChildOrderAddressQuery rightJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByAddressInvoice relation - * @method ChildOrderAddressQuery innerJoinOrderRelatedByAddressInvoice($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByAddressInvoice relation + * @method ChildOrderAddressQuery leftJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation + * @method ChildOrderAddressQuery rightJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation + * @method ChildOrderAddressQuery innerJoinOrderRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation * - * @method ChildOrderAddressQuery leftJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByAddressDelivery relation - * @method ChildOrderAddressQuery rightJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByAddressDelivery relation - * @method ChildOrderAddressQuery innerJoinOrderRelatedByAddressDelivery($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByAddressDelivery relation + * @method ChildOrderAddressQuery leftJoinOrderRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation + * @method ChildOrderAddressQuery rightJoinOrderRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation + * @method ChildOrderAddressQuery innerJoinOrderRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation * * @method ChildOrderAddress findOne(ConnectionInterface $con = null) Return the first ChildOrderAddress matching the query * @method ChildOrderAddress findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderAddress matching the query, or a new ChildOrderAddress object populated from the query conditions when no match is found @@ -750,33 +750,33 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function filterByOrderRelatedByAddressInvoice($order, $comparison = null) + public function filterByOrderRelatedByInvoiceOrderAddressId($order, $comparison = null) { if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressInvoice(), $comparison); + ->addUsingAlias(OrderAddressTableMap::ID, $order->getInvoiceOrderAddressId(), $comparison); } elseif ($order instanceof ObjectCollection) { return $this - ->useOrderRelatedByAddressInvoiceQuery() + ->useOrderRelatedByInvoiceOrderAddressIdQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\Order or Collection'); + throw new PropelException('filterByOrderRelatedByInvoiceOrderAddressId() only accepts arguments of type \Thelia\Model\Order or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderRelatedByAddressInvoice relation + * Adds a JOIN clause to the query using the OrderRelatedByInvoiceOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function joinOrderRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderRelatedByInvoiceOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderRelatedByAddressInvoice'); + $relationMap = $tableMap->getRelation('OrderRelatedByInvoiceOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -791,14 +791,14 @@ abstract class OrderAddressQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderRelatedByAddressInvoice'); + $this->addJoinObject($join, 'OrderRelatedByInvoiceOrderAddressId'); } return $this; } /** - * Use the OrderRelatedByAddressInvoice relation Order object + * Use the OrderRelatedByInvoiceOrderAddressId relation Order object * * @see useQuery() * @@ -808,11 +808,11 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderRelatedByInvoiceOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderRelatedByAddressInvoice($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressInvoice', '\Thelia\Model\OrderQuery'); + ->joinOrderRelatedByInvoiceOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByInvoiceOrderAddressId', '\Thelia\Model\OrderQuery'); } /** @@ -823,33 +823,33 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function filterByOrderRelatedByAddressDelivery($order, $comparison = null) + public function filterByOrderRelatedByDeliveryOrderAddressId($order, $comparison = null) { if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressDelivery(), $comparison); + ->addUsingAlias(OrderAddressTableMap::ID, $order->getDeliveryOrderAddressId(), $comparison); } elseif ($order instanceof ObjectCollection) { return $this - ->useOrderRelatedByAddressDeliveryQuery() + ->useOrderRelatedByDeliveryOrderAddressIdQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\Order or Collection'); + throw new PropelException('filterByOrderRelatedByDeliveryOrderAddressId() only accepts arguments of type \Thelia\Model\Order or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderRelatedByAddressDelivery relation + * Adds a JOIN clause to the query using the OrderRelatedByDeliveryOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderAddressQuery The current query, for fluid interface */ - public function joinOrderRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderRelatedByDeliveryOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderRelatedByAddressDelivery'); + $relationMap = $tableMap->getRelation('OrderRelatedByDeliveryOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -864,14 +864,14 @@ abstract class OrderAddressQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderRelatedByAddressDelivery'); + $this->addJoinObject($join, 'OrderRelatedByDeliveryOrderAddressId'); } return $this; } /** - * Use the OrderRelatedByAddressDelivery relation Order object + * Use the OrderRelatedByDeliveryOrderAddressId relation Order object * * @see useQuery() * @@ -881,11 +881,11 @@ abstract class OrderAddressQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderRelatedByDeliveryOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderRelatedByAddressDelivery($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressDelivery', '\Thelia\Model\OrderQuery'); + ->joinOrderRelatedByDeliveryOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByDeliveryOrderAddressId', '\Thelia\Model\OrderQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/OrderQuery.php b/core/lib/Thelia/Model/Base/OrderQuery.php index bdff793a8..592864f1f 100644 --- a/core/lib/Thelia/Model/Base/OrderQuery.php +++ b/core/lib/Thelia/Model/Base/OrderQuery.php @@ -24,38 +24,38 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrderQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildOrderQuery orderByRef($order = Criteria::ASC) Order by the ref column * @method ChildOrderQuery orderByCustomerId($order = Criteria::ASC) Order by the customer_id column - * @method ChildOrderQuery orderByAddressInvoice($order = Criteria::ASC) Order by the address_invoice column - * @method ChildOrderQuery orderByAddressDelivery($order = Criteria::ASC) Order by the address_delivery column + * @method ChildOrderQuery orderByInvoiceOrderAddressId($order = Criteria::ASC) Order by the invoice_order_address_id column + * @method ChildOrderQuery orderByDeliveryOrderAddressId($order = Criteria::ASC) Order by the delivery_order_address_id column * @method ChildOrderQuery orderByInvoiceDate($order = Criteria::ASC) Order by the invoice_date column * @method ChildOrderQuery orderByCurrencyId($order = Criteria::ASC) Order by the currency_id column * @method ChildOrderQuery orderByCurrencyRate($order = Criteria::ASC) Order by the currency_rate column - * @method ChildOrderQuery orderByTransaction($order = Criteria::ASC) Order by the transaction column - * @method ChildOrderQuery orderByDeliveryNum($order = Criteria::ASC) Order by the delivery_num column - * @method ChildOrderQuery orderByInvoice($order = Criteria::ASC) Order by the invoice column + * @method ChildOrderQuery orderByTransactionRef($order = Criteria::ASC) Order by the transaction_ref column + * @method ChildOrderQuery orderByDeliveryRef($order = Criteria::ASC) Order by the delivery_ref column + * @method ChildOrderQuery orderByInvoiceRef($order = Criteria::ASC) Order by the invoice_ref column * @method ChildOrderQuery orderByPostage($order = Criteria::ASC) Order by the postage column - * @method ChildOrderQuery orderByPayment($order = Criteria::ASC) Order by the payment column - * @method ChildOrderQuery orderByCarrier($order = Criteria::ASC) Order by the carrier column + * @method ChildOrderQuery orderByPaymentModuleId($order = Criteria::ASC) Order by the payment_module_id column + * @method ChildOrderQuery orderByDeliveryModuleId($order = Criteria::ASC) Order by the delivery_module_id column * @method ChildOrderQuery orderByStatusId($order = Criteria::ASC) Order by the status_id column - * @method ChildOrderQuery orderByLang($order = Criteria::ASC) Order by the lang column + * @method ChildOrderQuery orderByLangId($order = Criteria::ASC) Order by the lang_id column * @method ChildOrderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildOrderQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildOrderQuery groupById() Group by the id column * @method ChildOrderQuery groupByRef() Group by the ref column * @method ChildOrderQuery groupByCustomerId() Group by the customer_id column - * @method ChildOrderQuery groupByAddressInvoice() Group by the address_invoice column - * @method ChildOrderQuery groupByAddressDelivery() Group by the address_delivery column + * @method ChildOrderQuery groupByInvoiceOrderAddressId() Group by the invoice_order_address_id column + * @method ChildOrderQuery groupByDeliveryOrderAddressId() Group by the delivery_order_address_id column * @method ChildOrderQuery groupByInvoiceDate() Group by the invoice_date column * @method ChildOrderQuery groupByCurrencyId() Group by the currency_id column * @method ChildOrderQuery groupByCurrencyRate() Group by the currency_rate column - * @method ChildOrderQuery groupByTransaction() Group by the transaction column - * @method ChildOrderQuery groupByDeliveryNum() Group by the delivery_num column - * @method ChildOrderQuery groupByInvoice() Group by the invoice column + * @method ChildOrderQuery groupByTransactionRef() Group by the transaction_ref column + * @method ChildOrderQuery groupByDeliveryRef() Group by the delivery_ref column + * @method ChildOrderQuery groupByInvoiceRef() Group by the invoice_ref column * @method ChildOrderQuery groupByPostage() Group by the postage column - * @method ChildOrderQuery groupByPayment() Group by the payment column - * @method ChildOrderQuery groupByCarrier() Group by the carrier column + * @method ChildOrderQuery groupByPaymentModuleId() Group by the payment_module_id column + * @method ChildOrderQuery groupByDeliveryModuleId() Group by the delivery_module_id column * @method ChildOrderQuery groupByStatusId() Group by the status_id column - * @method ChildOrderQuery groupByLang() Group by the lang column + * @method ChildOrderQuery groupByLangId() Group by the lang_id column * @method ChildOrderQuery groupByCreatedAt() Group by the created_at column * @method ChildOrderQuery groupByUpdatedAt() Group by the updated_at column * @@ -71,18 +71,30 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrderQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation * @method ChildOrderQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation * - * @method ChildOrderQuery leftJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation - * @method ChildOrderQuery rightJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation - * @method ChildOrderQuery innerJoinOrderAddressRelatedByAddressInvoice($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation + * @method ChildOrderQuery leftJoinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation + * @method ChildOrderQuery rightJoinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation + * @method ChildOrderQuery innerJoinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation * - * @method ChildOrderQuery leftJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation - * @method ChildOrderQuery rightJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation - * @method ChildOrderQuery innerJoinOrderAddressRelatedByAddressDelivery($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation + * @method ChildOrderQuery leftJoinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation + * @method ChildOrderQuery rightJoinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation + * @method ChildOrderQuery innerJoinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation * * @method ChildOrderQuery leftJoinOrderStatus($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderStatus relation * @method ChildOrderQuery rightJoinOrderStatus($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderStatus relation * @method ChildOrderQuery innerJoinOrderStatus($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderStatus relation * + * @method ChildOrderQuery leftJoinModuleRelatedByPaymentModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * @method ChildOrderQuery rightJoinModuleRelatedByPaymentModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * @method ChildOrderQuery innerJoinModuleRelatedByPaymentModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * + * @method ChildOrderQuery leftJoinModuleRelatedByDeliveryModuleId($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * @method ChildOrderQuery rightJoinModuleRelatedByDeliveryModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * @method ChildOrderQuery innerJoinModuleRelatedByDeliveryModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * + * @method ChildOrderQuery leftJoinLang($relationAlias = null) Adds a LEFT JOIN clause to the query using the Lang relation + * @method ChildOrderQuery rightJoinLang($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Lang relation + * @method ChildOrderQuery innerJoinLang($relationAlias = null) Adds a INNER JOIN clause to the query using the Lang relation + * * @method ChildOrderQuery leftJoinOrderProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProduct relation * @method ChildOrderQuery rightJoinOrderProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProduct relation * @method ChildOrderQuery innerJoinOrderProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProduct relation @@ -97,38 +109,38 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrder findOneById(int $id) Return the first ChildOrder filtered by the id column * @method ChildOrder findOneByRef(string $ref) Return the first ChildOrder filtered by the ref column * @method ChildOrder findOneByCustomerId(int $customer_id) Return the first ChildOrder filtered by the customer_id column - * @method ChildOrder findOneByAddressInvoice(int $address_invoice) Return the first ChildOrder filtered by the address_invoice column - * @method ChildOrder findOneByAddressDelivery(int $address_delivery) Return the first ChildOrder filtered by the address_delivery column + * @method ChildOrder findOneByInvoiceOrderAddressId(int $invoice_order_address_id) Return the first ChildOrder filtered by the invoice_order_address_id column + * @method ChildOrder findOneByDeliveryOrderAddressId(int $delivery_order_address_id) Return the first ChildOrder filtered by the delivery_order_address_id column * @method ChildOrder findOneByInvoiceDate(string $invoice_date) Return the first ChildOrder filtered by the invoice_date column * @method ChildOrder findOneByCurrencyId(int $currency_id) Return the first ChildOrder filtered by the currency_id column * @method ChildOrder findOneByCurrencyRate(double $currency_rate) Return the first ChildOrder filtered by the currency_rate column - * @method ChildOrder findOneByTransaction(string $transaction) Return the first ChildOrder filtered by the transaction column - * @method ChildOrder findOneByDeliveryNum(string $delivery_num) Return the first ChildOrder filtered by the delivery_num column - * @method ChildOrder findOneByInvoice(string $invoice) Return the first ChildOrder filtered by the invoice column + * @method ChildOrder findOneByTransactionRef(string $transaction_ref) Return the first ChildOrder filtered by the transaction_ref column + * @method ChildOrder findOneByDeliveryRef(string $delivery_ref) Return the first ChildOrder filtered by the delivery_ref column + * @method ChildOrder findOneByInvoiceRef(string $invoice_ref) Return the first ChildOrder filtered by the invoice_ref column * @method ChildOrder findOneByPostage(double $postage) Return the first ChildOrder filtered by the postage column - * @method ChildOrder findOneByPayment(string $payment) Return the first ChildOrder filtered by the payment column - * @method ChildOrder findOneByCarrier(string $carrier) Return the first ChildOrder filtered by the carrier column + * @method ChildOrder findOneByPaymentModuleId(int $payment_module_id) Return the first ChildOrder filtered by the payment_module_id column + * @method ChildOrder findOneByDeliveryModuleId(int $delivery_module_id) Return the first ChildOrder filtered by the delivery_module_id column * @method ChildOrder findOneByStatusId(int $status_id) Return the first ChildOrder filtered by the status_id column - * @method ChildOrder findOneByLang(string $lang) Return the first ChildOrder filtered by the lang column + * @method ChildOrder findOneByLangId(int $lang_id) Return the first ChildOrder filtered by the lang_id column * @method ChildOrder findOneByCreatedAt(string $created_at) Return the first ChildOrder filtered by the created_at column * @method ChildOrder findOneByUpdatedAt(string $updated_at) Return the first ChildOrder filtered by the updated_at column * * @method array findById(int $id) Return ChildOrder objects filtered by the id column * @method array findByRef(string $ref) Return ChildOrder objects filtered by the ref column * @method array findByCustomerId(int $customer_id) Return ChildOrder objects filtered by the customer_id column - * @method array findByAddressInvoice(int $address_invoice) Return ChildOrder objects filtered by the address_invoice column - * @method array findByAddressDelivery(int $address_delivery) Return ChildOrder objects filtered by the address_delivery column + * @method array findByInvoiceOrderAddressId(int $invoice_order_address_id) Return ChildOrder objects filtered by the invoice_order_address_id column + * @method array findByDeliveryOrderAddressId(int $delivery_order_address_id) Return ChildOrder objects filtered by the delivery_order_address_id column * @method array findByInvoiceDate(string $invoice_date) Return ChildOrder objects filtered by the invoice_date column * @method array findByCurrencyId(int $currency_id) Return ChildOrder objects filtered by the currency_id column * @method array findByCurrencyRate(double $currency_rate) Return ChildOrder objects filtered by the currency_rate column - * @method array findByTransaction(string $transaction) Return ChildOrder objects filtered by the transaction column - * @method array findByDeliveryNum(string $delivery_num) Return ChildOrder objects filtered by the delivery_num column - * @method array findByInvoice(string $invoice) Return ChildOrder objects filtered by the invoice column + * @method array findByTransactionRef(string $transaction_ref) Return ChildOrder objects filtered by the transaction_ref column + * @method array findByDeliveryRef(string $delivery_ref) Return ChildOrder objects filtered by the delivery_ref column + * @method array findByInvoiceRef(string $invoice_ref) Return ChildOrder objects filtered by the invoice_ref column * @method array findByPostage(double $postage) Return ChildOrder objects filtered by the postage column - * @method array findByPayment(string $payment) Return ChildOrder objects filtered by the payment column - * @method array findByCarrier(string $carrier) Return ChildOrder objects filtered by the carrier column + * @method array findByPaymentModuleId(int $payment_module_id) Return ChildOrder objects filtered by the payment_module_id column + * @method array findByDeliveryModuleId(int $delivery_module_id) Return ChildOrder objects filtered by the delivery_module_id column * @method array findByStatusId(int $status_id) Return ChildOrder objects filtered by the status_id column - * @method array findByLang(string $lang) Return ChildOrder objects filtered by the lang column + * @method array findByLangId(int $lang_id) Return ChildOrder objects filtered by the lang_id column * @method array findByCreatedAt(string $created_at) Return ChildOrder objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildOrder objects filtered by the updated_at column * @@ -219,7 +231,7 @@ abstract class OrderQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, CUSTOMER_ID, ADDRESS_INVOICE, ADDRESS_DELIVERY, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION, DELIVERY_NUM, INVOICE, POSTAGE, PAYMENT, CARRIER, STATUS_ID, LANG, CREATED_AT, UPDATED_AT FROM order WHERE ID = :p0'; + $sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM order WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -422,18 +434,18 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the address_invoice column + * Filter the query on the invoice_order_address_id column * * Example usage: * - * $query->filterByAddressInvoice(1234); // WHERE address_invoice = 1234 - * $query->filterByAddressInvoice(array(12, 34)); // WHERE address_invoice IN (12, 34) - * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice > 12 + * $query->filterByInvoiceOrderAddressId(1234); // WHERE invoice_order_address_id = 1234 + * $query->filterByInvoiceOrderAddressId(array(12, 34)); // WHERE invoice_order_address_id IN (12, 34) + * $query->filterByInvoiceOrderAddressId(array('min' => 12)); // WHERE invoice_order_address_id > 12 * * - * @see filterByOrderAddressRelatedByAddressInvoice() + * @see filterByOrderAddressRelatedByInvoiceOrderAddressId() * - * @param mixed $addressInvoice The value to use as filter. + * @param mixed $invoiceOrderAddressId 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. @@ -441,16 +453,16 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByAddressInvoice($addressInvoice = null, $comparison = null) + public function filterByInvoiceOrderAddressId($invoiceOrderAddressId = null, $comparison = null) { - if (is_array($addressInvoice)) { + if (is_array($invoiceOrderAddressId)) { $useMinMax = false; - if (isset($addressInvoice['min'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['min'], Criteria::GREATER_EQUAL); + if (isset($invoiceOrderAddressId['min'])) { + $this->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $invoiceOrderAddressId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($addressInvoice['max'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['max'], Criteria::LESS_EQUAL); + if (isset($invoiceOrderAddressId['max'])) { + $this->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $invoiceOrderAddressId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -461,22 +473,22 @@ abstract class OrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice, $comparison); + return $this->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $invoiceOrderAddressId, $comparison); } /** - * Filter the query on the address_delivery column + * Filter the query on the delivery_order_address_id column * * Example usage: * - * $query->filterByAddressDelivery(1234); // WHERE address_delivery = 1234 - * $query->filterByAddressDelivery(array(12, 34)); // WHERE address_delivery IN (12, 34) - * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery > 12 + * $query->filterByDeliveryOrderAddressId(1234); // WHERE delivery_order_address_id = 1234 + * $query->filterByDeliveryOrderAddressId(array(12, 34)); // WHERE delivery_order_address_id IN (12, 34) + * $query->filterByDeliveryOrderAddressId(array('min' => 12)); // WHERE delivery_order_address_id > 12 * * - * @see filterByOrderAddressRelatedByAddressDelivery() + * @see filterByOrderAddressRelatedByDeliveryOrderAddressId() * - * @param mixed $addressDelivery The value to use as filter. + * @param mixed $deliveryOrderAddressId 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. @@ -484,16 +496,16 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByAddressDelivery($addressDelivery = null, $comparison = null) + public function filterByDeliveryOrderAddressId($deliveryOrderAddressId = null, $comparison = null) { - if (is_array($addressDelivery)) { + if (is_array($deliveryOrderAddressId)) { $useMinMax = false; - if (isset($addressDelivery['min'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['min'], Criteria::GREATER_EQUAL); + if (isset($deliveryOrderAddressId['min'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $deliveryOrderAddressId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($addressDelivery['max'])) { - $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['max'], Criteria::LESS_EQUAL); + if (isset($deliveryOrderAddressId['max'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $deliveryOrderAddressId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -504,7 +516,7 @@ abstract class OrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery, $comparison); + return $this->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $deliveryOrderAddressId, $comparison); } /** @@ -635,90 +647,90 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the transaction column + * Filter the query on the transaction_ref column * * Example usage: * - * $query->filterByTransaction('fooValue'); // WHERE transaction = 'fooValue' - * $query->filterByTransaction('%fooValue%'); // WHERE transaction LIKE '%fooValue%' + * $query->filterByTransactionRef('fooValue'); // WHERE transaction_ref = 'fooValue' + * $query->filterByTransactionRef('%fooValue%'); // WHERE transaction_ref LIKE '%fooValue%' * * - * @param string $transaction The value to use as filter. + * @param string $transactionRef 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 ChildOrderQuery The current query, for fluid interface */ - public function filterByTransaction($transaction = null, $comparison = null) + public function filterByTransactionRef($transactionRef = null, $comparison = null) { if (null === $comparison) { - if (is_array($transaction)) { + if (is_array($transactionRef)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $transaction)) { - $transaction = str_replace('*', '%', $transaction); + } elseif (preg_match('/[\%\*]/', $transactionRef)) { + $transactionRef = str_replace('*', '%', $transactionRef); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::TRANSACTION, $transaction, $comparison); + return $this->addUsingAlias(OrderTableMap::TRANSACTION_REF, $transactionRef, $comparison); } /** - * Filter the query on the delivery_num column + * Filter the query on the delivery_ref column * * Example usage: * - * $query->filterByDeliveryNum('fooValue'); // WHERE delivery_num = 'fooValue' - * $query->filterByDeliveryNum('%fooValue%'); // WHERE delivery_num LIKE '%fooValue%' + * $query->filterByDeliveryRef('fooValue'); // WHERE delivery_ref = 'fooValue' + * $query->filterByDeliveryRef('%fooValue%'); // WHERE delivery_ref LIKE '%fooValue%' * * - * @param string $deliveryNum The value to use as filter. + * @param string $deliveryRef 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 ChildOrderQuery The current query, for fluid interface */ - public function filterByDeliveryNum($deliveryNum = null, $comparison = null) + public function filterByDeliveryRef($deliveryRef = null, $comparison = null) { if (null === $comparison) { - if (is_array($deliveryNum)) { + if (is_array($deliveryRef)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $deliveryNum)) { - $deliveryNum = str_replace('*', '%', $deliveryNum); + } elseif (preg_match('/[\%\*]/', $deliveryRef)) { + $deliveryRef = str_replace('*', '%', $deliveryRef); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::DELIVERY_NUM, $deliveryNum, $comparison); + return $this->addUsingAlias(OrderTableMap::DELIVERY_REF, $deliveryRef, $comparison); } /** - * Filter the query on the invoice column + * Filter the query on the invoice_ref column * * Example usage: * - * $query->filterByInvoice('fooValue'); // WHERE invoice = 'fooValue' - * $query->filterByInvoice('%fooValue%'); // WHERE invoice LIKE '%fooValue%' + * $query->filterByInvoiceRef('fooValue'); // WHERE invoice_ref = 'fooValue' + * $query->filterByInvoiceRef('%fooValue%'); // WHERE invoice_ref LIKE '%fooValue%' * * - * @param string $invoice The value to use as filter. + * @param string $invoiceRef 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 ChildOrderQuery The current query, for fluid interface */ - public function filterByInvoice($invoice = null, $comparison = null) + public function filterByInvoiceRef($invoiceRef = null, $comparison = null) { if (null === $comparison) { - if (is_array($invoice)) { + if (is_array($invoiceRef)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $invoice)) { - $invoice = str_replace('*', '%', $invoice); + } elseif (preg_match('/[\%\*]/', $invoiceRef)) { + $invoiceRef = str_replace('*', '%', $invoiceRef); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::INVOICE, $invoice, $comparison); + return $this->addUsingAlias(OrderTableMap::INVOICE_REF, $invoiceRef, $comparison); } /** @@ -763,61 +775,89 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the payment column + * Filter the query on the payment_module_id column * * Example usage: * - * $query->filterByPayment('fooValue'); // WHERE payment = 'fooValue' - * $query->filterByPayment('%fooValue%'); // WHERE payment LIKE '%fooValue%' + * $query->filterByPaymentModuleId(1234); // WHERE payment_module_id = 1234 + * $query->filterByPaymentModuleId(array(12, 34)); // WHERE payment_module_id IN (12, 34) + * $query->filterByPaymentModuleId(array('min' => 12)); // WHERE payment_module_id > 12 * * - * @param string $payment The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByModuleRelatedByPaymentModuleId() + * + * @param mixed $paymentModuleId 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 ChildOrderQuery The current query, for fluid interface */ - public function filterByPayment($payment = null, $comparison = null) + public function filterByPaymentModuleId($paymentModuleId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($payment)) { + if (is_array($paymentModuleId)) { + $useMinMax = false; + if (isset($paymentModuleId['min'])) { + $this->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $paymentModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($paymentModuleId['max'])) { + $this->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $paymentModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $payment)) { - $payment = str_replace('*', '%', $payment); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::PAYMENT, $payment, $comparison); + return $this->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $paymentModuleId, $comparison); } /** - * Filter the query on the carrier column + * Filter the query on the delivery_module_id column * * Example usage: * - * $query->filterByCarrier('fooValue'); // WHERE carrier = 'fooValue' - * $query->filterByCarrier('%fooValue%'); // WHERE carrier LIKE '%fooValue%' + * $query->filterByDeliveryModuleId(1234); // WHERE delivery_module_id = 1234 + * $query->filterByDeliveryModuleId(array(12, 34)); // WHERE delivery_module_id IN (12, 34) + * $query->filterByDeliveryModuleId(array('min' => 12)); // WHERE delivery_module_id > 12 * * - * @param string $carrier The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByModuleRelatedByDeliveryModuleId() + * + * @param mixed $deliveryModuleId 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 ChildOrderQuery The current query, for fluid interface */ - public function filterByCarrier($carrier = null, $comparison = null) + public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($carrier)) { + if (is_array($deliveryModuleId)) { + $useMinMax = false; + if (isset($deliveryModuleId['min'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryModuleId['max'])) { + $this->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $carrier)) { - $carrier = str_replace('*', '%', $carrier); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::CARRIER, $carrier, $comparison); + return $this->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison); } /** @@ -864,32 +904,46 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query on the lang column + * Filter the query on the lang_id column * * Example usage: * - * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue' - * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%' + * $query->filterByLangId(1234); // WHERE lang_id = 1234 + * $query->filterByLangId(array(12, 34)); // WHERE lang_id IN (12, 34) + * $query->filterByLangId(array('min' => 12)); // WHERE lang_id > 12 * * - * @param string $lang The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByLang() + * + * @param mixed $langId 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 ChildOrderQuery The current query, for fluid interface */ - public function filterByLang($lang = null, $comparison = null) + public function filterByLangId($langId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($lang)) { + if (is_array($langId)) { + $useMinMax = false; + if (isset($langId['min'])) { + $this->addUsingAlias(OrderTableMap::LANG_ID, $langId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($langId['max'])) { + $this->addUsingAlias(OrderTableMap::LANG_ID, $langId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lang)) { - $lang = str_replace('*', '%', $lang); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderTableMap::LANG, $lang, $comparison); + return $this->addUsingAlias(OrderTableMap::LANG_ID, $langId, $comparison); } /** @@ -1011,7 +1065,7 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinCurrency($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinCurrency($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Currency'); @@ -1046,7 +1100,7 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\CurrencyQuery A secondary query class using the current class as primary query */ - public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinCurrency($relationAlias, $joinType) @@ -1136,35 +1190,35 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByOrderAddressRelatedByAddressInvoice($orderAddress, $comparison = null) + public function filterByOrderAddressRelatedByInvoiceOrderAddressId($orderAddress, $comparison = null) { if ($orderAddress instanceof \Thelia\Model\OrderAddress) { return $this - ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->getId(), $comparison); + ->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $orderAddress->getId(), $comparison); } elseif ($orderAddress instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::INVOICE_ORDER_ADDRESS_ID, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); + throw new PropelException('filterByOrderAddressRelatedByInvoiceOrderAddressId() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation + * Adds a JOIN clause to the query using the OrderAddressRelatedByInvoiceOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinOrderAddressRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressInvoice'); + $relationMap = $tableMap->getRelation('OrderAddressRelatedByInvoiceOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1179,14 +1233,14 @@ abstract class OrderQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderAddressRelatedByAddressInvoice'); + $this->addJoinObject($join, 'OrderAddressRelatedByInvoiceOrderAddressId'); } return $this; } /** - * Use the OrderAddressRelatedByAddressInvoice relation OrderAddress object + * Use the OrderAddressRelatedByInvoiceOrderAddressId relation OrderAddress object * * @see useQuery() * @@ -1196,11 +1250,11 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query */ - public function useOrderAddressRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderAddressRelatedByInvoiceOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderAddressRelatedByAddressInvoice($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressInvoice', '\Thelia\Model\OrderAddressQuery'); + ->joinOrderAddressRelatedByInvoiceOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByInvoiceOrderAddressId', '\Thelia\Model\OrderAddressQuery'); } /** @@ -1211,35 +1265,35 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByOrderAddressRelatedByAddressDelivery($orderAddress, $comparison = null) + public function filterByOrderAddressRelatedByDeliveryOrderAddressId($orderAddress, $comparison = null) { if ($orderAddress instanceof \Thelia\Model\OrderAddress) { return $this - ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->getId(), $comparison); + ->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $orderAddress->getId(), $comparison); } elseif ($orderAddress instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); + throw new PropelException('filterByOrderAddressRelatedByDeliveryOrderAddressId() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation + * Adds a JOIN clause to the query using the OrderAddressRelatedByDeliveryOrderAddressId relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinOrderAddressRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressDelivery'); + $relationMap = $tableMap->getRelation('OrderAddressRelatedByDeliveryOrderAddressId'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1254,14 +1308,14 @@ abstract class OrderQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderAddressRelatedByAddressDelivery'); + $this->addJoinObject($join, 'OrderAddressRelatedByDeliveryOrderAddressId'); } return $this; } /** - * Use the OrderAddressRelatedByAddressDelivery relation OrderAddress object + * Use the OrderAddressRelatedByDeliveryOrderAddressId relation OrderAddress object * * @see useQuery() * @@ -1271,11 +1325,11 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query */ - public function useOrderAddressRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderAddressRelatedByDeliveryOrderAddressIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderAddressRelatedByAddressDelivery($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressDelivery', '\Thelia\Model\OrderAddressQuery'); + ->joinOrderAddressRelatedByDeliveryOrderAddressId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByDeliveryOrderAddressId', '\Thelia\Model\OrderAddressQuery'); } /** @@ -1311,7 +1365,7 @@ abstract class OrderQuery extends ModelCriteria * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinOrderStatus($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrderStatus($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('OrderStatus'); @@ -1346,13 +1400,238 @@ abstract class OrderQuery extends ModelCriteria * * @return \Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query */ - public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinOrderStatus($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery'); } + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function filterByModuleRelatedByPaymentModuleId($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderTableMap::PAYMENT_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModuleRelatedByPaymentModuleId() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function joinModuleRelatedByPaymentModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleRelatedByPaymentModuleId'); + + // 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, 'ModuleRelatedByPaymentModuleId'); + } + + return $this; + } + + /** + * Use the ModuleRelatedByPaymentModuleId relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleRelatedByPaymentModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModuleRelatedByPaymentModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleRelatedByPaymentModuleId', '\Thelia\Model\ModuleQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function filterByModuleRelatedByDeliveryModuleId($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModuleRelatedByDeliveryModuleId() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function joinModuleRelatedByDeliveryModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleRelatedByDeliveryModuleId'); + + // 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, 'ModuleRelatedByDeliveryModuleId'); + } + + return $this; + } + + /** + * Use the ModuleRelatedByDeliveryModuleId relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleRelatedByDeliveryModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModuleRelatedByDeliveryModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleRelatedByDeliveryModuleId', '\Thelia\Model\ModuleQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Lang object + * + * @param \Thelia\Model\Lang|ObjectCollection $lang The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function filterByLang($lang, $comparison = null) + { + if ($lang instanceof \Thelia\Model\Lang) { + return $this + ->addUsingAlias(OrderTableMap::LANG_ID, $lang->getId(), $comparison); + } elseif ($lang instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderTableMap::LANG_ID, $lang->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByLang() only accepts arguments of type \Thelia\Model\Lang or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Lang relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function joinLang($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Lang'); + + // 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, 'Lang'); + } + + return $this; + } + + /** + * Use the Lang relation Lang 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\LangQuery A secondary query class using the current class as primary query + */ + public function useLangQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinLang($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Lang', '\Thelia\Model\LangQuery'); + } + /** * Filter the query by a related \Thelia\Model\OrderProduct object * diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php index d249b4865..5771072f2 100644 --- a/core/lib/Thelia/Model/Base/OrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -791,10 +791,9 @@ abstract class OrderStatus implements ActiveRecordInterface if ($this->ordersScheduledForDeletion !== null) { if (!$this->ordersScheduledForDeletion->isEmpty()) { - foreach ($this->ordersScheduledForDeletion as $order) { - // need to save related object because we set the relation to null - $order->save($con); - } + \Thelia\Model\OrderQuery::create() + ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->ordersScheduledForDeletion = null; } } @@ -1439,7 +1438,7 @@ abstract class OrderStatus implements ActiveRecordInterface $this->ordersScheduledForDeletion = clone $this->collOrders; $this->ordersScheduledForDeletion->clear(); } - $this->ordersScheduledForDeletion[]= $order; + $this->ordersScheduledForDeletion[]= clone $order; $order->setOrderStatus(null); } @@ -1513,10 +1512,10 @@ abstract class OrderStatus implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByInvoiceOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); + $query->joinWith('OrderAddressRelatedByInvoiceOrderAddressId', $joinBehavior); return $this->getOrders($query, $con); } @@ -1538,10 +1537,85 @@ abstract class OrderStatus implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByDeliveryOrderAddressId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildOrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); + $query->joinWith('OrderAddressRelatedByDeliveryOrderAddressId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderStatus is new, it will return + * an empty collection; or if this OrderStatus has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderStatus. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByPaymentModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByPaymentModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderStatus is new, it will return + * an empty collection; or if this OrderStatus has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderStatus. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinModuleRelatedByDeliveryModuleId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('ModuleRelatedByDeliveryModuleId', $joinBehavior); + + return $this->getOrders($query, $con); + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrderStatus is new, it will return + * an empty collection; or if this OrderStatus has previously + * been saved, it will retrieve related Orders from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrderStatus. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects + */ + public function getOrdersJoinLang($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Lang', $joinBehavior); return $this->getOrders($query, $con); } diff --git a/core/lib/Thelia/Model/Base/OrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php index 908efd6b6..7050b4a5a 100644 --- a/core/lib/Thelia/Model/Base/OrderStatusQuery.php +++ b/core/lib/Thelia/Model/Base/OrderStatusQuery.php @@ -420,7 +420,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Order'); @@ -455,7 +455,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinOrder($relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php index 62a6ea425..2c6db3184 100644 --- a/core/lib/Thelia/Model/Base/ProductCategory.php +++ b/core/lib/Thelia/Model/Base/ProductCategory.php @@ -70,6 +70,12 @@ abstract class ProductCategory implements ActiveRecordInterface */ protected $category_id; + /** + * The value for the default_category field. + * @var boolean + */ + protected $default_category; + /** * The value for the created_at field. * @var string @@ -376,6 +382,17 @@ abstract class ProductCategory implements ActiveRecordInterface return $this->category_id; } + /** + * Get the [default_category] column value. + * + * @return boolean + */ + public function getDefaultCategory() + { + + return $this->default_category; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -466,6 +483,35 @@ abstract class ProductCategory implements ActiveRecordInterface return $this; } // setCategoryId() + /** + * Sets the value of the [default_category] 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\ProductCategory The current object (for fluent API support) + */ + public function setDefaultCategory($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->default_category !== $v) { + $this->default_category = $v; + $this->modifiedColumns[] = ProductCategoryTableMap::DEFAULT_CATEGORY; + } + + + return $this; + } // setDefaultCategory() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -551,13 +597,16 @@ abstract class ProductCategory implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; $this->category_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductCategoryTableMap::translateFieldName('DefaultCategory', TableMap::TYPE_PHPNAME, $indexType)]; + $this->default_category = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductCategoryTableMap::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 ? 3 + $startcol : ProductCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -570,7 +619,7 @@ abstract class ProductCategory implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 4; // 4 = ProductCategoryTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = ProductCategoryTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductCategory object", 0, $e); @@ -819,6 +868,9 @@ abstract class ProductCategory implements ActiveRecordInterface if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) { $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; } + if ($this->isColumnModified(ProductCategoryTableMap::DEFAULT_CATEGORY)) { + $modifiedColumns[':p' . $index++] = 'DEFAULT_CATEGORY'; + } if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -842,6 +894,9 @@ abstract class ProductCategory implements ActiveRecordInterface case 'CATEGORY_ID': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; + case 'DEFAULT_CATEGORY': + $stmt->bindValue($identifier, (int) $this->default_category, 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; @@ -910,9 +965,12 @@ abstract class ProductCategory implements ActiveRecordInterface return $this->getCategoryId(); break; case 2: - return $this->getCreatedAt(); + return $this->getDefaultCategory(); break; case 3: + return $this->getCreatedAt(); + break; + case 4: return $this->getUpdatedAt(); break; default: @@ -946,8 +1004,9 @@ abstract class ProductCategory implements ActiveRecordInterface $result = array( $keys[0] => $this->getProductId(), $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), + $keys[2] => $this->getDefaultCategory(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1003,9 +1062,12 @@ abstract class ProductCategory implements ActiveRecordInterface $this->setCategoryId($value); break; case 2: - $this->setCreatedAt($value); + $this->setDefaultCategory($value); break; case 3: + $this->setCreatedAt($value); + break; + case 4: $this->setUpdatedAt($value); break; } // switch() @@ -1034,8 +1096,9 @@ abstract class ProductCategory implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setProductId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); + if (array_key_exists($keys[2], $arr)) $this->setDefaultCategory($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]]); } /** @@ -1049,6 +1112,7 @@ abstract class ProductCategory implements ActiveRecordInterface if ($this->isColumnModified(ProductCategoryTableMap::PRODUCT_ID)) $criteria->add(ProductCategoryTableMap::PRODUCT_ID, $this->product_id); if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) $criteria->add(ProductCategoryTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(ProductCategoryTableMap::DEFAULT_CATEGORY)) $criteria->add(ProductCategoryTableMap::DEFAULT_CATEGORY, $this->default_category); if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) $criteria->add(ProductCategoryTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) $criteria->add(ProductCategoryTableMap::UPDATED_AT, $this->updated_at); @@ -1123,6 +1187,7 @@ abstract class ProductCategory implements ActiveRecordInterface { $copyObj->setProductId($this->getProductId()); $copyObj->setCategoryId($this->getCategoryId()); + $copyObj->setDefaultCategory($this->getDefaultCategory()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1261,6 +1326,7 @@ abstract class ProductCategory implements ActiveRecordInterface { $this->product_id = null; $this->category_id = null; + $this->default_category = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ProductCategoryQuery.php b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php index fd40e93c7..df9fc630b 100644 --- a/core/lib/Thelia/Model/Base/ProductCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php @@ -23,11 +23,13 @@ use Thelia\Model\Map\ProductCategoryTableMap; * * @method ChildProductCategoryQuery orderByProductId($order = Criteria::ASC) Order by the product_id column * @method ChildProductCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column + * @method ChildProductCategoryQuery orderByDefaultCategory($order = Criteria::ASC) Order by the default_category column * @method ChildProductCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildProductCategoryQuery groupByProductId() Group by the product_id column * @method ChildProductCategoryQuery groupByCategoryId() Group by the category_id column + * @method ChildProductCategoryQuery groupByDefaultCategory() Group by the default_category column * @method ChildProductCategoryQuery groupByCreatedAt() Group by the created_at column * @method ChildProductCategoryQuery groupByUpdatedAt() Group by the updated_at column * @@ -48,11 +50,13 @@ use Thelia\Model\Map\ProductCategoryTableMap; * * @method ChildProductCategory findOneByProductId(int $product_id) Return the first ChildProductCategory filtered by the product_id column * @method ChildProductCategory findOneByCategoryId(int $category_id) Return the first ChildProductCategory filtered by the category_id column + * @method ChildProductCategory findOneByDefaultCategory(boolean $default_category) Return the first ChildProductCategory filtered by the default_category column * @method ChildProductCategory findOneByCreatedAt(string $created_at) Return the first ChildProductCategory filtered by the created_at column * @method ChildProductCategory findOneByUpdatedAt(string $updated_at) Return the first ChildProductCategory filtered by the updated_at column * * @method array findByProductId(int $product_id) Return ChildProductCategory objects filtered by the product_id column * @method array findByCategoryId(int $category_id) Return ChildProductCategory objects filtered by the category_id column + * @method array findByDefaultCategory(boolean $default_category) Return ChildProductCategory objects filtered by the default_category column * @method array findByCreatedAt(string $created_at) Return ChildProductCategory objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProductCategory objects filtered by the updated_at column * @@ -143,7 +147,7 @@ abstract class ProductCategoryQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT PRODUCT_ID, CATEGORY_ID, CREATED_AT, UPDATED_AT FROM product_category WHERE PRODUCT_ID = :p0 AND CATEGORY_ID = :p1'; + $sql = 'SELECT PRODUCT_ID, CATEGORY_ID, DEFAULT_CATEGORY, CREATED_AT, UPDATED_AT FROM product_category WHERE PRODUCT_ID = :p0 AND CATEGORY_ID = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -330,6 +334,33 @@ abstract class ProductCategoryQuery extends ModelCriteria return $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); } + /** + * Filter the query on the default_category column + * + * Example usage: + * + * $query->filterByDefaultCategory(true); // WHERE default_category = true + * $query->filterByDefaultCategory('yes'); // WHERE default_category = true + * + * + * @param boolean|string $defaultCategory 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 ChildProductCategoryQuery The current query, for fluid interface + */ + public function filterByDefaultCategory($defaultCategory = null, $comparison = null) + { + if (is_string($defaultCategory)) { + $default_category = in_array(strtolower($defaultCategory), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(ProductCategoryTableMap::DEFAULT_CATEGORY, $defaultCategory, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index 9b1710f03..9c3b0759c 100644 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -857,7 +857,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductQuery The current query, for fluid interface */ - public function joinTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinTemplate($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Template'); @@ -892,7 +892,7 @@ abstract class ProductQuery extends ModelCriteria * * @return \Thelia\Model\TemplateQuery A secondary query class using the current class as primary query */ - public function useTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useTemplateQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinTemplate($relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php index 9edb7b2fc..b361567d8 100644 --- a/core/lib/Thelia/Model/Base/TaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -67,6 +67,13 @@ abstract class TaxRule implements ActiveRecordInterface */ protected $id; + /** + * 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 @@ -137,11 +144,24 @@ abstract class TaxRule implements ActiveRecordInterface */ protected $taxRuleI18nsScheduledForDeletion = null; + /** + * Applies default values to this object. + * This method should be called from the object's constructor (or + * equivalent initialization method). + * @see __construct() + */ + public function applyDefaultValues() + { + $this->is_default = false; + } + /** * Initializes internal state of Thelia\Model\Base\TaxRule object. + * @see applyDefaults() */ public function __construct() { + $this->applyDefaultValues(); } /** @@ -402,6 +422,17 @@ abstract class TaxRule implements ActiveRecordInterface return $this->id; } + /** + * Get the [is_default] column value. + * + * @return boolean + */ + public function getIsDefault() + { + + return $this->is_default; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -463,6 +494,35 @@ abstract class TaxRule implements ActiveRecordInterface return $this; } // setId() + /** + * 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\TaxRule 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[] = TaxRuleTableMap::IS_DEFAULT; + } + + + return $this; + } // setIsDefault() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -515,6 +575,10 @@ abstract class TaxRule implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { + if ($this->is_default !== false) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -545,13 +609,16 @@ abstract class TaxRule implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_default = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::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 ? 2 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -564,7 +631,7 @@ abstract class TaxRule implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 3; // 3 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 4; // 4 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\TaxRule object", 0, $e); @@ -845,6 +912,9 @@ abstract class TaxRule implements ActiveRecordInterface if ($this->isColumnModified(TaxRuleTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } + if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'IS_DEFAULT'; + } if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -865,6 +935,9 @@ abstract class TaxRule implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); 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; @@ -937,9 +1010,12 @@ abstract class TaxRule implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getCreatedAt(); + return $this->getIsDefault(); break; case 2: + return $this->getCreatedAt(); + break; + case 3: return $this->getUpdatedAt(); break; default: @@ -972,8 +1048,9 @@ abstract class TaxRule implements ActiveRecordInterface $keys = TaxRuleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getCreatedAt(), - $keys[2] => $this->getUpdatedAt(), + $keys[1] => $this->getIsDefault(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1029,9 +1106,12 @@ abstract class TaxRule implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setCreatedAt($value); + $this->setIsDefault($value); break; case 2: + $this->setCreatedAt($value); + break; + case 3: $this->setUpdatedAt($value); break; } // switch() @@ -1059,8 +1139,9 @@ abstract class TaxRule implements ActiveRecordInterface $keys = TaxRuleTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCreatedAt($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setUpdatedAt($arr[$keys[2]]); + if (array_key_exists($keys[1], $arr)) $this->setIsDefault($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); } /** @@ -1073,6 +1154,7 @@ abstract class TaxRule implements ActiveRecordInterface $criteria = new Criteria(TaxRuleTableMap::DATABASE_NAME); if ($this->isColumnModified(TaxRuleTableMap::ID)) $criteria->add(TaxRuleTableMap::ID, $this->id); + if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) $criteria->add(TaxRuleTableMap::IS_DEFAULT, $this->is_default); if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) $criteria->add(TaxRuleTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) $criteria->add(TaxRuleTableMap::UPDATED_AT, $this->updated_at); @@ -1138,6 +1220,7 @@ abstract class TaxRule implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { + $copyObj->setIsDefault($this->getIsDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1961,10 +2044,12 @@ abstract class TaxRule implements ActiveRecordInterface public function clear() { $this->id = null; + $this->is_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); + $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php index 8ee264415..bc20c44b1 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php @@ -23,10 +23,12 @@ use Thelia\Model\Map\TaxRuleTableMap; * * * @method ChildTaxRuleQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildTaxRuleQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column * @method ChildTaxRuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildTaxRuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildTaxRuleQuery groupById() Group by the id column + * @method ChildTaxRuleQuery groupByIsDefault() Group by the is_default column * @method ChildTaxRuleQuery groupByCreatedAt() Group by the created_at column * @method ChildTaxRuleQuery groupByUpdatedAt() Group by the updated_at column * @@ -50,10 +52,12 @@ use Thelia\Model\Map\TaxRuleTableMap; * @method ChildTaxRule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTaxRule matching the query, or a new ChildTaxRule object populated from the query conditions when no match is found * * @method ChildTaxRule findOneById(int $id) Return the first ChildTaxRule filtered by the id column + * @method ChildTaxRule findOneByIsDefault(boolean $is_default) Return the first ChildTaxRule filtered by the is_default column * @method ChildTaxRule findOneByCreatedAt(string $created_at) Return the first ChildTaxRule filtered by the created_at column * @method ChildTaxRule findOneByUpdatedAt(string $updated_at) Return the first ChildTaxRule filtered by the updated_at column * * @method array findById(int $id) Return ChildTaxRule objects filtered by the id column + * @method array findByIsDefault(boolean $is_default) Return ChildTaxRule objects filtered by the is_default column * @method array findByCreatedAt(string $created_at) Return ChildTaxRule objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildTaxRule objects filtered by the updated_at column * @@ -144,7 +148,7 @@ abstract class TaxRuleQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0'; + $sql = 'SELECT ID, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -274,6 +278,33 @@ abstract class TaxRuleQuery extends ModelCriteria return $this->addUsingAlias(TaxRuleTableMap::ID, $id, $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 ChildTaxRuleQuery 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(TaxRuleTableMap::IS_DEFAULT, $isDefault, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Template.php b/core/lib/Thelia/Model/Base/Template.php index 77efa7ba0..08bb0f3a0 100644 --- a/core/lib/Thelia/Model/Base/Template.php +++ b/core/lib/Thelia/Model/Base/Template.php @@ -864,9 +864,10 @@ abstract class Template implements ActiveRecordInterface if ($this->productsScheduledForDeletion !== null) { if (!$this->productsScheduledForDeletion->isEmpty()) { - \Thelia\Model\ProductQuery::create() - ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); + foreach ($this->productsScheduledForDeletion as $product) { + // need to save related object because we set the relation to null + $product->save($con); + } $this->productsScheduledForDeletion = null; } } @@ -1553,7 +1554,7 @@ abstract class Template implements ActiveRecordInterface $this->productsScheduledForDeletion = clone $this->collProducts; $this->productsScheduledForDeletion->clear(); } - $this->productsScheduledForDeletion[]= clone $product; + $this->productsScheduledForDeletion[]= $product; $product->setTemplate(null); } diff --git a/core/lib/Thelia/Model/Base/TemplateQuery.php b/core/lib/Thelia/Model/Base/TemplateQuery.php index 506d7d943..98c588dd8 100644 --- a/core/lib/Thelia/Model/Base/TemplateQuery.php +++ b/core/lib/Thelia/Model/Base/TemplateQuery.php @@ -395,7 +395,7 @@ abstract class TemplateQuery extends ModelCriteria * * @return ChildTemplateQuery The current query, for fluid interface */ - public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Product'); @@ -430,7 +430,7 @@ abstract class TemplateQuery extends ModelCriteria * * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinProduct($relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 1cf55089f..89eeff249 100755 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -8,6 +8,7 @@ use Thelia\Model\Base\Cart as BaseCart; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductPriceQuery; use Thelia\Model\CartItemQuery; +use Thelia\TaxEngine\Calculator; class Cart extends BaseCart { @@ -74,9 +75,25 @@ class Cart extends BaseCart ; } - public function getTaxedAmount() + public function getTaxedAmount(Country $country) { + $taxCalculator = new Calculator(); + $total = 0; + + foreach($this->getCartItems() as $cartItem) { + $subtotal = $cartItem->getRealPrice(); + $subtotal -= $cartItem->getDiscount(); + /* we round it for the unit price, before the quantity factor */ + $subtotal = round($taxCalculator->load($cartItem->getProduct(), $country)->getTaxedPrice($subtotal), 2); + $subtotal *= $cartItem->getQuantity(); + + $total += $subtotal; + } + + $total -= $this->getDiscount(); + + return $total; } public function getTotalAmount() @@ -84,7 +101,11 @@ class Cart extends BaseCart $total = 0; foreach($this->getCartItems() as $cartItem) { - $total += $cartItem->getPrice()-$cartItem->getDiscount(); + $subtotal = $cartItem->getRealPrice(); + $subtotal -= $cartItem->getDiscount(); + $subtotal *= $cartItem->getQuantity(); + + $total += $subtotal; } $total -= $this->getDiscount(); diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index 5ef6048a5..a1fb3601a 100755 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -8,6 +8,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; use Thelia\Model\ConfigQuery; use Thelia\Core\Event\CartEvent; +use Thelia\TaxEngine\Calculator; class CartItem extends BaseCartItem { @@ -64,4 +65,20 @@ class CartItem extends BaseCartItem return $this; } + public function getRealPrice() + { + return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice(); + } + + public function getTaxedPrice(Country $country) + { + $taxCalculator = new Calculator(); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2); + } + + public function getTaxedPromoPrice(Country $country) + { + $taxCalculator = new Calculator(); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2); + } } diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index ced10c94b..347a0f7f7 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -15,6 +15,8 @@ class Category extends BaseCategory use \Thelia\Model\Tools\PositionManagementTrait; + use \Thelia\Model\Tools\UrlRewritingTrait; + /** * @return int number of child for the current category */ @@ -23,30 +25,12 @@ class Category extends BaseCategory return CategoryQuery::countChild($this->getId()); } - public function getUrl($locale) - { - return URL::getInstance()->retrieve('category', $this->getId(), $locale)->toString(); - } - /** - * Create a new category. - * - * @param string $title the category title - * @param int $parent the ID of the parent category - * @param string $locale the locale of the title + * {@inheritDoc} */ - public function create($title, $parent, $locale) - { - $this - ->setLocale($locale) - ->setTitle($title) - ->setParent($parent) - ->setVisible(1) - ->setPosition($this->getNextPosition($parent)) - ; - - $this->save(); - } + protected function getRewrittenUrlViewName() { + return 'category'; + } /** * @@ -71,18 +55,36 @@ class Category extends BaseCategory return $countProduct; } + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByParent($this->getParent()); + } + + /** + * {@inheritDoc} + */ public function preInsert(ConnectionInterface $con = null) { + $this->setPosition($this->getNextPosition()); + $this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY, new CategoryEvent($this)); return true; } + /** + * {@inheritDoc} + */ public function postInsert(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::AFTER_CREATECATEGORY, new CategoryEvent($this)); } + /** + * {@inheritDoc} + */ public function preUpdate(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_UPDATECATEGORY, new CategoryEvent($this)); @@ -90,16 +92,27 @@ class Category extends BaseCategory return true; } + /** + * {@inheritDoc} + */ public function postUpdate(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::AFTER_UPDATECATEGORY, new CategoryEvent($this)); } + /** + * {@inheritDoc} + */ public function preDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY, new CategoryEvent($this)); + + return true; } + /** + * {@inheritDoc} + */ public function postDelete(ConnectionInterface $con = null) { $this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this)); diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php index bd86f1d1e..5724e2df1 100755 --- a/core/lib/Thelia/Model/CategoryDocument.php +++ b/core/lib/Thelia/Model/CategoryDocument.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\CategoryDocument as BaseCategoryDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class CategoryDocument extends BaseCategoryDocument +class CategoryDocument extends BaseCategoryDocument { + use \Thelia\Model\Tools\PositionManagementTrait; -} + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByCategory($this->getCategory()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/CategoryI18n.php b/core/lib/Thelia/Model/CategoryI18n.php index bb4e7b3f3..de3e38663 100755 --- a/core/lib/Thelia/Model/CategoryI18n.php +++ b/core/lib/Thelia/Model/CategoryI18n.php @@ -2,8 +2,13 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\CategoryI18n as BaseCategoryI18n; class CategoryI18n extends BaseCategoryI18n { - + public function postInsert(ConnectionInterface $con = null) + { + $category = $this->getCategory(); + $category->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php index ef555f83e..5bf964e10 100755 --- a/core/lib/Thelia/Model/CategoryImage.php +++ b/core/lib/Thelia/Model/CategoryImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\CategoryImage as BaseCategoryImage; +use Propel\Runtime\Connection\ConnectionInterface; - class CategoryImage extends BaseCategoryImage +class CategoryImage extends BaseCategoryImage { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByCategory($this->getCategory()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php index 5bc0ba6b2..10ed2afe3 100755 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -4,11 +4,39 @@ namespace Thelia\Model; use Thelia\Model\Base\Content as BaseContent; use Thelia\Tools\URL; +use Propel\Runtime\Connection\ConnectionInterface; class Content extends BaseContent { - public function getUrl($locale) + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + use \Thelia\Model\Tools\PositionManagementTrait; + + use \Thelia\Model\Tools\UrlRewritingTrait; + + /** + * {@inheritDoc} + */ + protected function getRewrittenUrlViewName() { + return 'content'; + } + + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + + // TODO: Find the default folder for this content, + // and generate the position relative to this folder + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) { - return URL::getInstance()->retrieve('content', $this->getId(), $locale)->toString(); + $this->setPosition($this->getNextPosition()); + + return true; } } diff --git a/core/lib/Thelia/Model/ContentDocument.php b/core/lib/Thelia/Model/ContentDocument.php index 933a089cb..8ecf3a3a9 100755 --- a/core/lib/Thelia/Model/ContentDocument.php +++ b/core/lib/Thelia/Model/ContentDocument.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\ContentDocument as BaseContentDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class ContentDocument extends BaseContentDocument +class ContentDocument extends BaseContentDocument { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByContent($this->getContent()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/ContentI18n.php b/core/lib/Thelia/Model/ContentI18n.php index 5b29d894f..11713d57b 100755 --- a/core/lib/Thelia/Model/ContentI18n.php +++ b/core/lib/Thelia/Model/ContentI18n.php @@ -2,8 +2,13 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\ContentI18n as BaseContentI18n; class ContentI18n extends BaseContentI18n { - + public function postInsert(ConnectionInterface $con = null) + { + $content = $this->getContent(); + $content->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/ContentImage.php b/core/lib/Thelia/Model/ContentImage.php index 3020e48f3..ac1dcf755 100755 --- a/core/lib/Thelia/Model/ContentImage.php +++ b/core/lib/Thelia/Model/ContentImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\ContentImage as BaseContentImage; +use Propel\Runtime\Connection\ConnectionInterface; - class ContentImage extends BaseContentImage +class ContentImage extends BaseContentImage { + use \Thelia\Model\Tools\PositionManagementTrait; -} + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByContent($this->getContent()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/CouponRule.php b/core/lib/Thelia/Model/CouponRule.php deleted file mode 100755 index 14c84deb2..000000000 --- a/core/lib/Thelia/Model/CouponRule.php +++ /dev/null @@ -1,9 +0,0 @@ -getId()); } - public function getUrl($locale) - { - return URL::getInstance()->retrieve('folder', $this->getId(), $locale)->toString(); - } - /** * * count all products for current category and sub categories @@ -43,4 +52,21 @@ class Folder extends BaseFolder return $contentsCount; } + + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByParent($this->getParent()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/FolderDocument.php b/core/lib/Thelia/Model/FolderDocument.php index c9644835e..0a86995d2 100755 --- a/core/lib/Thelia/Model/FolderDocument.php +++ b/core/lib/Thelia/Model/FolderDocument.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\FolderDocument as BaseFolderDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class FolderDocument extends BaseFolderDocument +class FolderDocument extends BaseFolderDocument { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByFolder($this->getFolder()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/FolderI18n.php b/core/lib/Thelia/Model/FolderI18n.php index d1044452b..7ede39502 100755 --- a/core/lib/Thelia/Model/FolderI18n.php +++ b/core/lib/Thelia/Model/FolderI18n.php @@ -2,8 +2,14 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\FolderI18n as BaseFolderI18n; class FolderI18n extends BaseFolderI18n { + public function postInsert(ConnectionInterface $con = null) + { + $folder = $this->getFolder(); + $folder->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/FolderImage.php b/core/lib/Thelia/Model/FolderImage.php index 4e6d285f8..58d8f928e 100755 --- a/core/lib/Thelia/Model/FolderImage.php +++ b/core/lib/Thelia/Model/FolderImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\FolderImage as BaseFolderImage; +use Propel\Runtime\Connection\ConnectionInterface; - class FolderImage extends BaseFolderImage +class FolderImage extends BaseFolderImage { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByFolder($this->getFolder()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/Map/DelivzoneTableMap.php b/core/lib/Thelia/Model/Map/AreaDeliveryModuleTableMap.php similarity index 70% rename from core/lib/Thelia/Model/Map/DelivzoneTableMap.php rename to core/lib/Thelia/Model/Map/AreaDeliveryModuleTableMap.php index ca7c5fa4d..66052e604 100644 --- a/core/lib/Thelia/Model/Map/DelivzoneTableMap.php +++ b/core/lib/Thelia/Model/Map/AreaDeliveryModuleTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\Delivzone; -use Thelia\Model\DelivzoneQuery; +use Thelia\Model\AreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery; /** - * This class defines the structure of the 'delivzone' table. + * This class defines the structure of the 'area_delivery_module' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\DelivzoneQuery; * (i.e. if it's a text column type). * */ -class DelivzoneTableMap extends TableMap +class AreaDeliveryModuleTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.DelivzoneTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.AreaDeliveryModuleTableMap'; /** * The default database name for this class @@ -42,17 +42,17 @@ class DelivzoneTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'delivzone'; + const TABLE_NAME = 'area_delivery_module'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\Delivzone'; + const OM_CLASS = '\\Thelia\\Model\\AreaDeliveryModule'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.Delivzone'; + const CLASS_DEFAULT = 'Thelia.Model.AreaDeliveryModule'; /** * The total number of columns @@ -72,27 +72,27 @@ class DelivzoneTableMap extends TableMap /** * the column name for the ID field */ - const ID = 'delivzone.ID'; + const ID = 'area_delivery_module.ID'; /** * the column name for the AREA_ID field */ - const AREA_ID = 'delivzone.AREA_ID'; + const AREA_ID = 'area_delivery_module.AREA_ID'; /** - * the column name for the DELIVERY field + * the column name for the DELIVERY_MODULE_ID field */ - const DELIVERY = 'delivzone.DELIVERY'; + const DELIVERY_MODULE_ID = 'area_delivery_module.DELIVERY_MODULE_ID'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'delivzone.CREATED_AT'; + const CREATED_AT = 'area_delivery_module.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'delivzone.UPDATED_AT'; + const UPDATED_AT = 'area_delivery_module.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -106,11 +106,11 @@ class DelivzoneTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'AreaId', 'Delivery', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'delivery', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(DelivzoneTableMap::ID, DelivzoneTableMap::AREA_ID, DelivzoneTableMap::DELIVERY, DelivzoneTableMap::CREATED_AT, DelivzoneTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'AreaId', 'DeliveryModuleId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'deliveryModuleId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AreaDeliveryModuleTableMap::ID, AreaDeliveryModuleTableMap::AREA_ID, AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, AreaDeliveryModuleTableMap::CREATED_AT, AreaDeliveryModuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY_MODULE_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery_module_id', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class DelivzoneTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Delivery' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'delivery' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(DelivzoneTableMap::ID => 0, DelivzoneTableMap::AREA_ID => 1, DelivzoneTableMap::DELIVERY => 2, DelivzoneTableMap::CREATED_AT => 3, DelivzoneTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'DeliveryModuleId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'deliveryModuleId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AreaDeliveryModuleTableMap::ID => 0, AreaDeliveryModuleTableMap::AREA_ID => 1, AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID => 2, AreaDeliveryModuleTableMap::CREATED_AT => 3, AreaDeliveryModuleTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY_MODULE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery_module_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -139,15 +139,15 @@ class DelivzoneTableMap extends TableMap public function initialize() { // attributes - $this->setName('delivzone'); - $this->setPhpName('Delivzone'); - $this->setClassName('\\Thelia\\Model\\Delivzone'); + $this->setName('area_delivery_module'); + $this->setPhpName('AreaDeliveryModule'); + $this->setClassName('\\Thelia\\Model\\AreaDeliveryModule'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null); - $this->addColumn('DELIVERY', 'Delivery', 'VARCHAR', true, 45, null); + $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', 'module', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -157,7 +157,8 @@ class DelivzoneTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('delivery_module_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() /** @@ -229,7 +230,7 @@ class DelivzoneTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? DelivzoneTableMap::CLASS_DEFAULT : DelivzoneTableMap::OM_CLASS; + return $withPrefix ? AreaDeliveryModuleTableMap::CLASS_DEFAULT : AreaDeliveryModuleTableMap::OM_CLASS; } /** @@ -243,21 +244,21 @@ class DelivzoneTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (Delivzone object, last column rank) + * @return array (AreaDeliveryModule object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) { + $key = AreaDeliveryModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AreaDeliveryModuleTableMap::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 + DelivzoneTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + AreaDeliveryModuleTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = DelivzoneTableMap::OM_CLASS; + $cls = AreaDeliveryModuleTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - DelivzoneTableMap::addInstanceToPool($obj, $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -280,8 +281,8 @@ class DelivzoneTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) { + $key = AreaDeliveryModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AreaDeliveryModuleTableMap::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 @@ -290,7 +291,7 @@ class DelivzoneTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - DelivzoneTableMap::addInstanceToPool($obj, $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -311,15 +312,15 @@ class DelivzoneTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(DelivzoneTableMap::ID); - $criteria->addSelectColumn(DelivzoneTableMap::AREA_ID); - $criteria->addSelectColumn(DelivzoneTableMap::DELIVERY); - $criteria->addSelectColumn(DelivzoneTableMap::CREATED_AT); - $criteria->addSelectColumn(DelivzoneTableMap::UPDATED_AT); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::AREA_ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::CREATED_AT); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.AREA_ID'); - $criteria->addSelectColumn($alias . '.DELIVERY'); + $criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -334,7 +335,7 @@ class DelivzoneTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME)->getTable(DelivzoneTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(AreaDeliveryModuleTableMap::DATABASE_NAME)->getTable(AreaDeliveryModuleTableMap::TABLE_NAME); } /** @@ -342,16 +343,16 @@ class DelivzoneTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(DelivzoneTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new DelivzoneTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AreaDeliveryModuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AreaDeliveryModuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AreaDeliveryModuleTableMap()); } } /** - * Performs a DELETE on the database, given a Delivzone or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a AreaDeliveryModule or Criteria object OR a primary key value. * - * @param mixed $values Criteria or Delivzone object or primary key or array of primary keys + * @param mixed $values Criteria or AreaDeliveryModule 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 @@ -362,25 +363,25 @@ class DelivzoneTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Delivzone) { // it's a model object + } elseif ($values instanceof \Thelia\Model\AreaDeliveryModule) { // 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(DelivzoneTableMap::DATABASE_NAME); - $criteria->add(DelivzoneTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); + $criteria->add(AreaDeliveryModuleTableMap::ID, (array) $values, Criteria::IN); } - $query = DelivzoneQuery::create()->mergeWith($criteria); + $query = AreaDeliveryModuleQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { DelivzoneTableMap::clearInstancePool(); + if ($values instanceof Criteria) { AreaDeliveryModuleTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { DelivzoneTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { AreaDeliveryModuleTableMap::removeInstanceFromPool($singleval); } } @@ -388,20 +389,20 @@ class DelivzoneTableMap extends TableMap } /** - * Deletes all rows from the delivzone table. + * Deletes all rows from the area_delivery_module table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return DelivzoneQuery::create()->doDeleteAll($con); + return AreaDeliveryModuleQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a Delivzone or Criteria object. + * Performs an INSERT on the database, given a AreaDeliveryModule or Criteria object. * - * @param mixed $criteria Criteria or Delivzone object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or AreaDeliveryModule 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 @@ -410,22 +411,22 @@ class DelivzoneTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Delivzone object + $criteria = $criteria->buildCriteria(); // build Criteria from AreaDeliveryModule object } - if ($criteria->containsKey(DelivzoneTableMap::ID) && $criteria->keyContainsValue(DelivzoneTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.DelivzoneTableMap::ID.')'); + if ($criteria->containsKey(AreaDeliveryModuleTableMap::ID) && $criteria->keyContainsValue(AreaDeliveryModuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AreaDeliveryModuleTableMap::ID.')'); } // Set the correct dbName - $query = DelivzoneQuery::create()->mergeWith($criteria); + $query = AreaDeliveryModuleQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -441,7 +442,7 @@ class DelivzoneTableMap extends TableMap return $pk; } -} // DelivzoneTableMap +} // AreaDeliveryModuleTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -DelivzoneTableMap::buildTableMap(); +AreaDeliveryModuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AreaTableMap.php b/core/lib/Thelia/Model/Map/AreaTableMap.php index 9dc308de5..3c1bc5ee4 100644 --- a/core/lib/Thelia/Model/Map/AreaTableMap.php +++ b/core/lib/Thelia/Model/Map/AreaTableMap.php @@ -80,9 +80,9 @@ class AreaTableMap extends TableMap const NAME = 'area.NAME'; /** - * the column name for the UNIT field + * the column name for the POSTAGE field */ - const UNIT = 'area.UNIT'; + const POSTAGE = 'area.POSTAGE'; /** * the column name for the CREATED_AT field @@ -106,11 +106,11 @@ class AreaTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Name', 'Unit', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'name', 'unit', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::UNIT, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'UNIT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'name', 'unit', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'Name', 'Postage', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'name', 'postage', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::POSTAGE, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'POSTAGE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'name', 'postage', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class AreaTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Unit' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::UNIT => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'UNIT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Postage' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'postage' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::POSTAGE => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'POSTAGE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'postage' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -147,7 +147,7 @@ class AreaTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('NAME', 'Name', 'VARCHAR', true, 100, null); - $this->addColumn('UNIT', 'Unit', 'FLOAT', false, null, null); + $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -158,7 +158,7 @@ class AreaTableMap extends TableMap public function buildRelations() { $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Countries'); - $this->addRelation('Delivzone', '\\Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Delivzones'); + $this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules'); } // buildRelations() /** @@ -181,7 +181,7 @@ class AreaTableMap 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. CountryTableMap::clearInstancePool(); - DelivzoneTableMap::clearInstancePool(); + AreaDeliveryModuleTableMap::clearInstancePool(); } /** @@ -324,13 +324,13 @@ class AreaTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(AreaTableMap::ID); $criteria->addSelectColumn(AreaTableMap::NAME); - $criteria->addSelectColumn(AreaTableMap::UNIT); + $criteria->addSelectColumn(AreaTableMap::POSTAGE); $criteria->addSelectColumn(AreaTableMap::CREATED_AT); $criteria->addSelectColumn(AreaTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.UNIT'); + $criteria->addSelectColumn($alias . '.POSTAGE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php deleted file mode 100644 index b2525e8c3..000000000 --- a/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php +++ /dev/null @@ -1,449 +0,0 @@ - array('Id', 'CategoryId', 'AttributeId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'attributeId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID, AttributeCategoryTableMap::CATEGORY_ID, AttributeCategoryTableMap::ATTRIBUTE_ID, AttributeCategoryTableMap::CREATED_AT, AttributeCategoryTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'ATTRIBUTE_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'category_id', 'attribute_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) - ); - - /** - * 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, 'CategoryId' => 1, 'AttributeId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'attributeId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID => 0, AttributeCategoryTableMap::CATEGORY_ID => 1, AttributeCategoryTableMap::ATTRIBUTE_ID => 2, AttributeCategoryTableMap::CREATED_AT => 3, AttributeCategoryTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'ATTRIBUTE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'attribute_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) - ); - - /** - * 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('attribute_category'); - $this->setPhpName('AttributeCategory'); - $this->setClassName('\\Thelia\\Model\\AttributeCategory'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null); - $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, 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('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_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 ? AttributeCategoryTableMap::CLASS_DEFAULT : AttributeCategoryTableMap::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 (AttributeCategory object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = AttributeCategoryTableMap::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 + AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = AttributeCategoryTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - AttributeCategoryTableMap::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 = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = AttributeCategoryTableMap::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; - AttributeCategoryTableMap::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(AttributeCategoryTableMap::ID); - $criteria->addSelectColumn(AttributeCategoryTableMap::CATEGORY_ID); - $criteria->addSelectColumn(AttributeCategoryTableMap::ATTRIBUTE_ID); - $criteria->addSelectColumn(AttributeCategoryTableMap::CREATED_AT); - $criteria->addSelectColumn(AttributeCategoryTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); - $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(AttributeCategoryTableMap::DATABASE_NAME)->getTable(AttributeCategoryTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeCategoryTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(AttributeCategoryTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeCategoryTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a AttributeCategory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AttributeCategory 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(AttributeCategoryTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\AttributeCategory) { // 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(AttributeCategoryTableMap::DATABASE_NAME); - $criteria->add(AttributeCategoryTableMap::ID, (array) $values, Criteria::IN); - } - - $query = AttributeCategoryQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { AttributeCategoryTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { AttributeCategoryTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the attribute_category 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 AttributeCategoryQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a AttributeCategory or Criteria object. - * - * @param mixed $criteria Criteria or AttributeCategory 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(AttributeCategoryTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from AttributeCategory object - } - - if ($criteria->containsKey(AttributeCategoryTableMap::ID) && $criteria->keyContainsValue(AttributeCategoryTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCategoryTableMap::ID.')'); - } - - - // Set the correct dbName - $query = AttributeCategoryQuery::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; - } - -} // AttributeCategoryTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -AttributeCategoryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php index a4b3520e7..c13b85bbf 100644 --- a/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php @@ -159,7 +159,7 @@ class AttributeCombinationTableMap extends TableMap { $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); $this->addRelation('AttributeAv', '\\Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), null, null); + $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() /** diff --git a/core/lib/Thelia/Model/Map/ContentFolderTableMap.php b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php index 4fedae441..9808399ff 100644 --- a/core/lib/Thelia/Model/Map/ContentFolderTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php @@ -57,7 +57,7 @@ class ContentFolderTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 5; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ContentFolderTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 4; + const NUM_HYDRATE_COLUMNS = 5; /** * the column name for the CONTENT_ID field @@ -79,6 +79,11 @@ class ContentFolderTableMap extends TableMap */ const FOLDER_ID = 'content_folder.FOLDER_ID'; + /** + * the column name for the DEFAULT_FOLDER field + */ + const DEFAULT_FOLDER = 'content_folder.DEFAULT_FOLDER'; + /** * the column name for the CREATED_AT field */ @@ -101,12 +106,12 @@ class ContentFolderTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('ContentId', 'FolderId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('contentId', 'folderId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID, ContentFolderTableMap::FOLDER_ID, ContentFolderTableMap::CREATED_AT, ContentFolderTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('CONTENT_ID', 'FOLDER_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('content_id', 'folder_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ContentId', 'FolderId', 'DefaultFolder', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('contentId', 'folderId', 'defaultFolder', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID, ContentFolderTableMap::FOLDER_ID, ContentFolderTableMap::DEFAULT_FOLDER, ContentFolderTableMap::CREATED_AT, ContentFolderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('CONTENT_ID', 'FOLDER_ID', 'DEFAULT_FOLDER', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('content_id', 'folder_id', 'default_folder', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -116,12 +121,12 @@ class ContentFolderTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('ContentId' => 0, 'FolderId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - self::TYPE_STUDLYPHPNAME => array('contentId' => 0, 'folderId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID => 0, ContentFolderTableMap::FOLDER_ID => 1, ContentFolderTableMap::CREATED_AT => 2, ContentFolderTableMap::UPDATED_AT => 3, ), - self::TYPE_RAW_COLNAME => array('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - self::TYPE_FIELDNAME => array('content_id' => 0, 'folder_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ContentId' => 0, 'FolderId' => 1, 'DefaultFolder' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('contentId' => 0, 'folderId' => 1, 'defaultFolder' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID => 0, ContentFolderTableMap::FOLDER_ID => 1, ContentFolderTableMap::DEFAULT_FOLDER => 2, ContentFolderTableMap::CREATED_AT => 3, ContentFolderTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'DEFAULT_FOLDER' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('content_id' => 0, 'folder_id' => 1, 'default_folder' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -143,6 +148,7 @@ class ContentFolderTableMap extends TableMap // columns $this->addForeignPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER' , 'content', 'ID', true, null, null); $this->addForeignPrimaryKey('FOLDER_ID', 'FolderId', 'INTEGER' , 'folder', 'ID', true, null, null); + $this->addColumn('DEFAULT_FOLDER', 'DefaultFolder', 'BOOLEAN', false, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -358,11 +364,13 @@ class ContentFolderTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(ContentFolderTableMap::CONTENT_ID); $criteria->addSelectColumn(ContentFolderTableMap::FOLDER_ID); + $criteria->addSelectColumn(ContentFolderTableMap::DEFAULT_FOLDER); $criteria->addSelectColumn(ContentFolderTableMap::CREATED_AT); $criteria->addSelectColumn(ContentFolderTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.CONTENT_ID'); $criteria->addSelectColumn($alias . '.FOLDER_ID'); + $criteria->addSelectColumn($alias . '.DEFAULT_FOLDER'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php index b37a6b30a..9c0e65296 100644 --- a/core/lib/Thelia/Model/Map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -184,7 +184,7 @@ class CurrencyTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders'); + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), null, null, 'Carts'); $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'CASCADE', null, 'ProductPrices'); $this->addRelation('CurrencyI18n', '\\Thelia\\Model\\CurrencyI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CurrencyI18ns'); @@ -210,7 +210,6 @@ class CurrencyTableMap 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. - OrderTableMap::clearInstancePool(); ProductPriceTableMap::clearInstancePool(); CurrencyI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php index 32ccf07ee..4dd1c3e7d 100644 --- a/core/lib/Thelia/Model/Map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -225,7 +225,7 @@ class CustomerTableMap extends TableMap { $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('title_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresses'); - $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders'); + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), null, null, 'Carts'); } // buildRelations() @@ -249,7 +249,6 @@ class CustomerTableMap 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. AddressTableMap::clearInstancePool(); - OrderTableMap::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php deleted file mode 100644 index 3e20805b6..000000000 --- a/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php +++ /dev/null @@ -1,449 +0,0 @@ - array('Id', 'FeatureId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'categoryId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID, FeatureCategoryTableMap::FEATURE_ID, FeatureCategoryTableMap::CATEGORY_ID, FeatureCategoryTableMap::CREATED_AT, FeatureCategoryTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'feature_id', 'category_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) - ); - - /** - * 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, 'FeatureId' => 1, 'CategoryId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'categoryId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID => 0, FeatureCategoryTableMap::FEATURE_ID => 1, FeatureCategoryTableMap::CATEGORY_ID => 2, FeatureCategoryTableMap::CREATED_AT => 3, FeatureCategoryTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'CATEGORY_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'category_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) - ); - - /** - * 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('feature_category'); - $this->setPhpName('FeatureCategory'); - $this->setClassName('\\Thelia\\Model\\FeatureCategory'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); - $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, 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('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_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 ? FeatureCategoryTableMap::CLASS_DEFAULT : FeatureCategoryTableMap::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 (FeatureCategory object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = FeatureCategoryTableMap::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 + FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = FeatureCategoryTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - FeatureCategoryTableMap::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 = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = FeatureCategoryTableMap::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; - FeatureCategoryTableMap::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(FeatureCategoryTableMap::ID); - $criteria->addSelectColumn(FeatureCategoryTableMap::FEATURE_ID); - $criteria->addSelectColumn(FeatureCategoryTableMap::CATEGORY_ID); - $criteria->addSelectColumn(FeatureCategoryTableMap::CREATED_AT); - $criteria->addSelectColumn(FeatureCategoryTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.FEATURE_ID'); - $criteria->addSelectColumn($alias . '.CATEGORY_ID'); - $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(FeatureCategoryTableMap::DATABASE_NAME)->getTable(FeatureCategoryTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureCategoryTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(FeatureCategoryTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureCategoryTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a FeatureCategory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or FeatureCategory 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(FeatureCategoryTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\FeatureCategory) { // 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(FeatureCategoryTableMap::DATABASE_NAME); - $criteria->add(FeatureCategoryTableMap::ID, (array) $values, Criteria::IN); - } - - $query = FeatureCategoryQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { FeatureCategoryTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { FeatureCategoryTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the feature_category 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 FeatureCategoryQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a FeatureCategory or Criteria object. - * - * @param mixed $criteria Criteria or FeatureCategory 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(FeatureCategoryTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from FeatureCategory object - } - - if ($criteria->containsKey(FeatureCategoryTableMap::ID) && $criteria->keyContainsValue(FeatureCategoryTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureCategoryTableMap::ID.')'); - } - - - // Set the correct dbName - $query = FeatureCategoryQuery::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; - } - -} // FeatureCategoryTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -FeatureCategoryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/LangTableMap.php b/core/lib/Thelia/Model/Map/LangTableMap.php index 6d153b869..2e1f23204 100644 --- a/core/lib/Thelia/Model/Map/LangTableMap.php +++ b/core/lib/Thelia/Model/Map/LangTableMap.php @@ -217,6 +217,7 @@ class LangTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'lang_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); } // buildRelations() /** diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index dae9fda4a..1a2f63692 100644 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -184,6 +184,9 @@ class ModuleTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('OrderRelatedByPaymentModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'payment_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByPaymentModuleId'); + $this->addRelation('OrderRelatedByDeliveryModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByDeliveryModuleId'); + $this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules'); $this->addRelation('GroupModule', '\\Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'GroupModules'); $this->addRelation('ModuleI18n', '\\Thelia\\Model\\ModuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleI18ns'); } // buildRelations() @@ -208,6 +211,7 @@ class ModuleTableMap 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. + AreaDeliveryModuleTableMap::clearInstancePool(); GroupModuleTableMap::clearInstancePool(); ModuleI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/OrderAddressTableMap.php b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php index 18753e7f0..73b8f798d 100644 --- a/core/lib/Thelia/Model/Map/OrderAddressTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php @@ -211,8 +211,8 @@ class OrderAddressTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('OrderRelatedByAddressInvoice', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressInvoice'); - $this->addRelation('OrderRelatedByAddressDelivery', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressDelivery'); + $this->addRelation('OrderRelatedByInvoiceOrderAddressId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'invoice_order_address_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByInvoiceOrderAddressId'); + $this->addRelation('OrderRelatedByDeliveryOrderAddressId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'delivery_order_address_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByDeliveryOrderAddressId'); } // buildRelations() /** @@ -227,15 +227,6 @@ class OrderAddressTableMap extends TableMap 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), ); } // getBehaviors() - /** - * Method to invalidate the instance pool of all tables related to order_address * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderTableMap::clearInstancePool(); - } /** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php index 18406d9aa..bc283a3e8 100644 --- a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php @@ -160,7 +160,7 @@ class OrderStatusTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'SET NULL', 'RESTRICT', 'Orders'); + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'RESTRICT', 'RESTRICT', 'Orders'); $this->addRelation('OrderStatusI18n', '\\Thelia\\Model\\OrderStatusI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'OrderStatusI18ns'); } // buildRelations() @@ -184,7 +184,6 @@ class OrderStatusTableMap 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. - OrderTableMap::clearInstancePool(); OrderStatusI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/OrderTableMap.php b/core/lib/Thelia/Model/Map/OrderTableMap.php index 91d9b29de..ae43bd768 100644 --- a/core/lib/Thelia/Model/Map/OrderTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderTableMap.php @@ -85,14 +85,14 @@ class OrderTableMap extends TableMap const CUSTOMER_ID = 'order.CUSTOMER_ID'; /** - * the column name for the ADDRESS_INVOICE field + * the column name for the INVOICE_ORDER_ADDRESS_ID field */ - const ADDRESS_INVOICE = 'order.ADDRESS_INVOICE'; + const INVOICE_ORDER_ADDRESS_ID = 'order.INVOICE_ORDER_ADDRESS_ID'; /** - * the column name for the ADDRESS_DELIVERY field + * the column name for the DELIVERY_ORDER_ADDRESS_ID field */ - const ADDRESS_DELIVERY = 'order.ADDRESS_DELIVERY'; + const DELIVERY_ORDER_ADDRESS_ID = 'order.DELIVERY_ORDER_ADDRESS_ID'; /** * the column name for the INVOICE_DATE field @@ -110,19 +110,19 @@ class OrderTableMap extends TableMap const CURRENCY_RATE = 'order.CURRENCY_RATE'; /** - * the column name for the TRANSACTION field + * the column name for the TRANSACTION_REF field */ - const TRANSACTION = 'order.TRANSACTION'; + const TRANSACTION_REF = 'order.TRANSACTION_REF'; /** - * the column name for the DELIVERY_NUM field + * the column name for the DELIVERY_REF field */ - const DELIVERY_NUM = 'order.DELIVERY_NUM'; + const DELIVERY_REF = 'order.DELIVERY_REF'; /** - * the column name for the INVOICE field + * the column name for the INVOICE_REF field */ - const INVOICE = 'order.INVOICE'; + const INVOICE_REF = 'order.INVOICE_REF'; /** * the column name for the POSTAGE field @@ -130,14 +130,14 @@ class OrderTableMap extends TableMap const POSTAGE = 'order.POSTAGE'; /** - * the column name for the PAYMENT field + * the column name for the PAYMENT_MODULE_ID field */ - const PAYMENT = 'order.PAYMENT'; + const PAYMENT_MODULE_ID = 'order.PAYMENT_MODULE_ID'; /** - * the column name for the CARRIER field + * the column name for the DELIVERY_MODULE_ID field */ - const CARRIER = 'order.CARRIER'; + const DELIVERY_MODULE_ID = 'order.DELIVERY_MODULE_ID'; /** * the column name for the STATUS_ID field @@ -145,9 +145,9 @@ class OrderTableMap extends TableMap const STATUS_ID = 'order.STATUS_ID'; /** - * the column name for the LANG field + * the column name for the LANG_ID field */ - const LANG = 'order.LANG'; + const LANG_ID = 'order.LANG_ID'; /** * the column name for the CREATED_AT field @@ -171,11 +171,11 @@ class OrderTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'AddressInvoice', 'AddressDelivery', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'Transaction', 'DeliveryNum', 'Invoice', 'Postage', 'Payment', 'Carrier', 'StatusId', 'Lang', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'addressInvoice', 'addressDelivery', 'invoiceDate', 'currencyId', 'currencyRate', 'transaction', 'deliveryNum', 'invoice', 'postage', 'payment', 'carrier', 'statusId', 'lang', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::ADDRESS_INVOICE, OrderTableMap::ADDRESS_DELIVERY, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION, OrderTableMap::DELIVERY_NUM, OrderTableMap::INVOICE, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT, OrderTableMap::CARRIER, OrderTableMap::STATUS_ID, OrderTableMap::LANG, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'ADDRESS_INVOICE', 'ADDRESS_DELIVERY', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION', 'DELIVERY_NUM', 'INVOICE', 'POSTAGE', 'PAYMENT', 'CARRIER', 'STATUS_ID', 'LANG', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'address_invoice', 'address_delivery', 'invoice_date', 'currency_id', 'currency_rate', 'transaction', 'delivery_num', 'invoice', 'postage', 'payment', 'carrier', 'status_id', 'lang', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'InvoiceOrderAddressId', 'DeliveryOrderAddressId', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'TransactionRef', 'DeliveryRef', 'InvoiceRef', 'Postage', 'PaymentModuleId', 'DeliveryModuleId', 'StatusId', 'LangId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'invoiceOrderAddressId', 'deliveryOrderAddressId', 'invoiceDate', 'currencyId', 'currencyRate', 'transactionRef', 'deliveryRef', 'invoiceRef', 'postage', 'paymentModuleId', 'deliveryModuleId', 'statusId', 'langId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::INVOICE_ORDER_ADDRESS_ID, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION_REF, OrderTableMap::DELIVERY_REF, OrderTableMap::INVOICE_REF, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT_MODULE_ID, OrderTableMap::DELIVERY_MODULE_ID, OrderTableMap::STATUS_ID, OrderTableMap::LANG_ID, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'INVOICE_ORDER_ADDRESS_ID', 'DELIVERY_ORDER_ADDRESS_ID', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION_REF', 'DELIVERY_REF', 'INVOICE_REF', 'POSTAGE', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'STATUS_ID', 'LANG_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'invoice_order_address_id', 'delivery_order_address_id', 'invoice_date', 'currency_id', 'currency_rate', 'transaction_ref', 'delivery_ref', 'invoice_ref', 'postage', 'payment_module_id', 'delivery_module_id', 'status_id', 'lang_id', '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, ) ); @@ -186,11 +186,11 @@ class OrderTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'AddressInvoice' => 3, 'AddressDelivery' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'Transaction' => 8, 'DeliveryNum' => 9, 'Invoice' => 10, 'Postage' => 11, 'Payment' => 12, 'Carrier' => 13, 'StatusId' => 14, 'Lang' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'addressInvoice' => 3, 'addressDelivery' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transaction' => 8, 'deliveryNum' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'statusId' => 14, 'lang' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), - self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::ADDRESS_INVOICE => 3, OrderTableMap::ADDRESS_DELIVERY => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION => 8, OrderTableMap::DELIVERY_NUM => 9, OrderTableMap::INVOICE => 10, OrderTableMap::POSTAGE => 11, OrderTableMap::PAYMENT => 12, OrderTableMap::CARRIER => 13, OrderTableMap::STATUS_ID => 14, OrderTableMap::LANG => 15, OrderTableMap::CREATED_AT => 16, OrderTableMap::UPDATED_AT => 17, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_INVOICE' => 3, 'ADDRESS_DELIVERY' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION' => 8, 'DELIVERY_NUM' => 9, 'INVOICE' => 10, 'POSTAGE' => 11, 'PAYMENT' => 12, 'CARRIER' => 13, 'STATUS_ID' => 14, 'LANG' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'address_invoice' => 3, 'address_delivery' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction' => 8, 'delivery_num' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'status_id' => 14, 'lang' => 15, 'created_at' => 16, 'updated_at' => 17, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'InvoiceOrderAddressId' => 3, 'DeliveryOrderAddressId' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'TransactionRef' => 8, 'DeliveryRef' => 9, 'InvoiceRef' => 10, 'Postage' => 11, 'PaymentModuleId' => 12, 'DeliveryModuleId' => 13, 'StatusId' => 14, 'LangId' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'invoiceOrderAddressId' => 3, 'deliveryOrderAddressId' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transactionRef' => 8, 'deliveryRef' => 9, 'invoiceRef' => 10, 'postage' => 11, 'paymentModuleId' => 12, 'deliveryModuleId' => 13, 'statusId' => 14, 'langId' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), + self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::INVOICE_ORDER_ADDRESS_ID => 3, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION_REF => 8, OrderTableMap::DELIVERY_REF => 9, OrderTableMap::INVOICE_REF => 10, OrderTableMap::POSTAGE => 11, OrderTableMap::PAYMENT_MODULE_ID => 12, OrderTableMap::DELIVERY_MODULE_ID => 13, OrderTableMap::STATUS_ID => 14, OrderTableMap::LANG_ID => 15, OrderTableMap::CREATED_AT => 16, OrderTableMap::UPDATED_AT => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'INVOICE_ORDER_ADDRESS_ID' => 3, 'DELIVERY_ORDER_ADDRESS_ID' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION_REF' => 8, 'DELIVERY_REF' => 9, 'INVOICE_REF' => 10, 'POSTAGE' => 11, 'PAYMENT_MODULE_ID' => 12, 'DELIVERY_MODULE_ID' => 13, 'STATUS_ID' => 14, 'LANG_ID' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'invoice_order_address_id' => 3, 'delivery_order_address_id' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction_ref' => 8, 'delivery_ref' => 9, 'invoice_ref' => 10, 'postage' => 11, 'payment_module_id' => 12, 'delivery_module_id' => 13, 'status_id' => 14, 'lang_id' => 15, 'created_at' => 16, 'updated_at' => 17, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); @@ -211,21 +211,21 @@ class OrderTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null); + $this->addColumn('REF', 'Ref', 'VARCHAR', true, 45, null); $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null); - $this->addForeignKey('ADDRESS_INVOICE', 'AddressInvoice', 'INTEGER', 'order_address', 'ID', false, null, null); - $this->addForeignKey('ADDRESS_DELIVERY', 'AddressDelivery', 'INTEGER', 'order_address', 'ID', false, null, null); - $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null); - $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', false, null, null); + $this->addForeignKey('INVOICE_ORDER_ADDRESS_ID', 'InvoiceOrderAddressId', 'INTEGER', 'order_address', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_ORDER_ADDRESS_ID', 'DeliveryOrderAddressId', 'INTEGER', 'order_address', 'ID', true, null, null); + $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', true, null, null); + $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null); $this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null); - $this->addColumn('TRANSACTION', 'Transaction', 'VARCHAR', false, 100, null); - $this->addColumn('DELIVERY_NUM', 'DeliveryNum', 'VARCHAR', false, 100, null); - $this->addColumn('INVOICE', 'Invoice', 'VARCHAR', false, 100, null); - $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null); - $this->addColumn('PAYMENT', 'Payment', 'VARCHAR', true, 45, null); - $this->addColumn('CARRIER', 'Carrier', 'VARCHAR', true, 45, null); - $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', false, null, null); - $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null); + $this->addColumn('TRANSACTION_REF', 'TransactionRef', 'VARCHAR', false, 100, null); + $this->addColumn('DELIVERY_REF', 'DeliveryRef', 'VARCHAR', false, 100, null); + $this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 100, null); + $this->addColumn('POSTAGE', 'Postage', 'FLOAT', true, null, null); + $this->addForeignKey('PAYMENT_MODULE_ID', 'PaymentModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', true, null, null); + $this->addForeignKey('LANG_ID', 'LangId', 'INTEGER', 'lang', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -235,11 +235,14 @@ class OrderTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderAddressRelatedByAddressInvoice', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('OrderAddressRelatedByAddressDelivery', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('OrderStatus', '\\Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('OrderAddressRelatedByInvoiceOrderAddressId', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('invoice_order_address_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('OrderAddressRelatedByDeliveryOrderAddressId', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('delivery_order_address_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('OrderStatus', '\\Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('ModuleRelatedByPaymentModuleId', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('payment_module_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('ModuleRelatedByDeliveryModuleId', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('delivery_module_id' => 'id', ), 'RESTRICT', 'RESTRICT'); + $this->addRelation('Lang', '\\Thelia\\Model\\Lang', RelationMap::MANY_TO_ONE, array('lang_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderProducts'); $this->addRelation('CouponOrder', '\\Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'CouponOrders'); } // buildRelations() @@ -408,38 +411,38 @@ class OrderTableMap extends TableMap $criteria->addSelectColumn(OrderTableMap::ID); $criteria->addSelectColumn(OrderTableMap::REF); $criteria->addSelectColumn(OrderTableMap::CUSTOMER_ID); - $criteria->addSelectColumn(OrderTableMap::ADDRESS_INVOICE); - $criteria->addSelectColumn(OrderTableMap::ADDRESS_DELIVERY); + $criteria->addSelectColumn(OrderTableMap::INVOICE_ORDER_ADDRESS_ID); + $criteria->addSelectColumn(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID); $criteria->addSelectColumn(OrderTableMap::INVOICE_DATE); $criteria->addSelectColumn(OrderTableMap::CURRENCY_ID); $criteria->addSelectColumn(OrderTableMap::CURRENCY_RATE); - $criteria->addSelectColumn(OrderTableMap::TRANSACTION); - $criteria->addSelectColumn(OrderTableMap::DELIVERY_NUM); - $criteria->addSelectColumn(OrderTableMap::INVOICE); + $criteria->addSelectColumn(OrderTableMap::TRANSACTION_REF); + $criteria->addSelectColumn(OrderTableMap::DELIVERY_REF); + $criteria->addSelectColumn(OrderTableMap::INVOICE_REF); $criteria->addSelectColumn(OrderTableMap::POSTAGE); - $criteria->addSelectColumn(OrderTableMap::PAYMENT); - $criteria->addSelectColumn(OrderTableMap::CARRIER); + $criteria->addSelectColumn(OrderTableMap::PAYMENT_MODULE_ID); + $criteria->addSelectColumn(OrderTableMap::DELIVERY_MODULE_ID); $criteria->addSelectColumn(OrderTableMap::STATUS_ID); - $criteria->addSelectColumn(OrderTableMap::LANG); + $criteria->addSelectColumn(OrderTableMap::LANG_ID); $criteria->addSelectColumn(OrderTableMap::CREATED_AT); $criteria->addSelectColumn(OrderTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.REF'); $criteria->addSelectColumn($alias . '.CUSTOMER_ID'); - $criteria->addSelectColumn($alias . '.ADDRESS_INVOICE'); - $criteria->addSelectColumn($alias . '.ADDRESS_DELIVERY'); + $criteria->addSelectColumn($alias . '.INVOICE_ORDER_ADDRESS_ID'); + $criteria->addSelectColumn($alias . '.DELIVERY_ORDER_ADDRESS_ID'); $criteria->addSelectColumn($alias . '.INVOICE_DATE'); $criteria->addSelectColumn($alias . '.CURRENCY_ID'); $criteria->addSelectColumn($alias . '.CURRENCY_RATE'); - $criteria->addSelectColumn($alias . '.TRANSACTION'); - $criteria->addSelectColumn($alias . '.DELIVERY_NUM'); - $criteria->addSelectColumn($alias . '.INVOICE'); + $criteria->addSelectColumn($alias . '.TRANSACTION_REF'); + $criteria->addSelectColumn($alias . '.DELIVERY_REF'); + $criteria->addSelectColumn($alias . '.INVOICE_REF'); $criteria->addSelectColumn($alias . '.POSTAGE'); - $criteria->addSelectColumn($alias . '.PAYMENT'); - $criteria->addSelectColumn($alias . '.CARRIER'); + $criteria->addSelectColumn($alias . '.PAYMENT_MODULE_ID'); + $criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID'); $criteria->addSelectColumn($alias . '.STATUS_ID'); - $criteria->addSelectColumn($alias . '.LANG'); + $criteria->addSelectColumn($alias . '.LANG_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php index 6a8361f27..73c87ce9f 100644 --- a/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php @@ -57,7 +57,7 @@ class ProductCategoryTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 5; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductCategoryTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 4; + const NUM_HYDRATE_COLUMNS = 5; /** * the column name for the PRODUCT_ID field @@ -79,6 +79,11 @@ class ProductCategoryTableMap extends TableMap */ const CATEGORY_ID = 'product_category.CATEGORY_ID'; + /** + * the column name for the DEFAULT_CATEGORY field + */ + const DEFAULT_CATEGORY = 'product_category.DEFAULT_CATEGORY'; + /** * the column name for the CREATED_AT field */ @@ -101,12 +106,12 @@ class ProductCategoryTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('ProductId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('productId', 'categoryId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID, ProductCategoryTableMap::CATEGORY_ID, ProductCategoryTableMap::CREATED_AT, ProductCategoryTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('PRODUCT_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('product_id', 'category_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ProductId', 'CategoryId', 'DefaultCategory', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('productId', 'categoryId', 'defaultCategory', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID, ProductCategoryTableMap::CATEGORY_ID, ProductCategoryTableMap::DEFAULT_CATEGORY, ProductCategoryTableMap::CREATED_AT, ProductCategoryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_ID', 'CATEGORY_ID', 'DEFAULT_CATEGORY', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('product_id', 'category_id', 'default_category', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -116,12 +121,12 @@ class ProductCategoryTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('ProductId' => 0, 'CategoryId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - self::TYPE_STUDLYPHPNAME => array('productId' => 0, 'categoryId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID => 0, ProductCategoryTableMap::CATEGORY_ID => 1, ProductCategoryTableMap::CREATED_AT => 2, ProductCategoryTableMap::UPDATED_AT => 3, ), - self::TYPE_RAW_COLNAME => array('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - self::TYPE_FIELDNAME => array('product_id' => 0, 'category_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('ProductId' => 0, 'CategoryId' => 1, 'DefaultCategory' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('productId' => 0, 'categoryId' => 1, 'defaultCategory' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID => 0, ProductCategoryTableMap::CATEGORY_ID => 1, ProductCategoryTableMap::DEFAULT_CATEGORY => 2, ProductCategoryTableMap::CREATED_AT => 3, ProductCategoryTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'DEFAULT_CATEGORY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('product_id' => 0, 'category_id' => 1, 'default_category' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -143,6 +148,7 @@ class ProductCategoryTableMap extends TableMap // columns $this->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER' , 'product', 'ID', true, null, null); $this->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'INTEGER' , 'category', 'ID', true, null, null); + $this->addColumn('DEFAULT_CATEGORY', 'DefaultCategory', 'BOOLEAN', false, 1, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -358,11 +364,13 @@ class ProductCategoryTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(ProductCategoryTableMap::PRODUCT_ID); $criteria->addSelectColumn(ProductCategoryTableMap::CATEGORY_ID); + $criteria->addSelectColumn(ProductCategoryTableMap::DEFAULT_CATEGORY); $criteria->addSelectColumn(ProductCategoryTableMap::CREATED_AT); $criteria->addSelectColumn(ProductCategoryTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.PRODUCT_ID'); $criteria->addSelectColumn($alias . '.CATEGORY_ID'); + $criteria->addSelectColumn($alias . '.DEFAULT_CATEGORY'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php index 9025784bc..fc23ae569 100644 --- a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php @@ -182,7 +182,7 @@ class ProductSaleElementsTableMap extends TableMap public function buildRelations() { $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'AttributeCombinations'); + $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'CartItems'); $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), 'CASCADE', null, 'ProductPrices'); } // buildRelations() @@ -206,6 +206,7 @@ class ProductSaleElementsTableMap 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. + AttributeCombinationTableMap::clearInstancePool(); ProductPriceTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index 17c4585f0..59ac236ac 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -189,7 +189,7 @@ class ProductTableMap extends TableMap $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null); + $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', false, 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); diff --git a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php index 4e84b4db8..14d38a764 100644 --- a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php @@ -180,7 +180,7 @@ class ProductVersionTableMap extends TableMap $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); - $this->addColumn('TEMPLATE_ID', 'TemplateId', 'INTEGER', true, null, null); + $this->addColumn('TEMPLATE_ID', 'TemplateId', 'INTEGER', false, 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); diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php index 391e23b6d..ccc41e013 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php @@ -57,7 +57,7 @@ class TaxRuleTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 3; + const NUM_COLUMNS = 4; /** * The number of lazy-loaded columns @@ -67,13 +67,18 @@ class TaxRuleTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 3; + const NUM_HYDRATE_COLUMNS = 4; /** * the column name for the ID field */ const ID = 'tax_rule.ID'; + /** + * the column name for the IS_DEFAULT field + */ + const IS_DEFAULT = 'tax_rule.IS_DEFAULT'; + /** * the column name for the CREATED_AT field */ @@ -105,12 +110,12 @@ class TaxRuleTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, ) + self::TYPE_PHPNAME => array('Id', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'isDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::IS_DEFAULT, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'is_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, ) ); /** @@ -120,12 +125,12 @@ class TaxRuleTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'CreatedAt' => 1, 'UpdatedAt' => 2, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'createdAt' => 1, 'updatedAt' => 2, ), - self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CREATED_AT => 1, TaxRuleTableMap::UPDATED_AT => 2, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREATED_AT' => 1, 'UPDATED_AT' => 2, ), - self::TYPE_FIELDNAME => array('id' => 0, 'created_at' => 1, 'updated_at' => 2, ), - self::TYPE_NUM => array(0, 1, 2, ) + self::TYPE_PHPNAME => array('Id' => 0, 'IsDefault' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'isDefault' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::IS_DEFAULT => 1, TaxRuleTableMap::CREATED_AT => 2, TaxRuleTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'IS_DEFAULT' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'is_default' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) ); /** @@ -145,6 +150,7 @@ class TaxRuleTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', true, 1, false); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -323,10 +329,12 @@ class TaxRuleTableMap extends TableMap { if (null === $alias) { $criteria->addSelectColumn(TaxRuleTableMap::ID); + $criteria->addSelectColumn(TaxRuleTableMap::IS_DEFAULT); $criteria->addSelectColumn(TaxRuleTableMap::CREATED_AT); $criteria->addSelectColumn(TaxRuleTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.IS_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index f8e6db193..e2eb43971 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -4,7 +4,10 @@ namespace Thelia\Model; use Thelia\Model\Base\Order as BaseOrder; -class Order extends BaseOrder { +class Order extends BaseOrder +{ + public $chosenDeliveryAddress = null; + public $chosenInvoiceAddress = null; /** * calculate the total amount diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 06c4640d0..825668cd0 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -6,19 +6,34 @@ use Propel\Runtime\Exception\PropelException; use Thelia\Model\Base\Product as BaseProduct; use Thelia\Tools\URL; use Thelia\TaxEngine\Calculator; +use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Event\ProductEvent; +use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Propel; +use Thelia\Model\Map\ProductTableMap; class Product extends BaseProduct { - public function getUrl($locale) - { - return URL::getInstance()->retrieve('product', $this->getId(), $locale)->toString(); + use \Thelia\Model\Tools\ModelEventDispatcherTrait; + + use \Thelia\Model\Tools\PositionManagementTrait; + + use \Thelia\Model\Tools\UrlRewritingTrait; + + /** + * {@inheritDoc} + */ + protected function getRewrittenUrlViewName() { + return 'product'; } public function getRealLowestPrice($virtualColumnName = 'real_lowest_price') { try { $amount = $this->getVirtualColumn($virtualColumnName); - } catch(PropelException $e) { + } + catch(PropelException $e) { throw new PropelException("Virtual column `$virtualColumnName` does not exist in Product::getRealLowestPrice"); } @@ -28,6 +43,163 @@ class Product extends BaseProduct public function getTaxedPrice(Country $country) { $taxCalculator = new Calculator(); + return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()); } + + /** + * @return the current default category ID for this product + */ + public function getDefaultCategoryId() + { + // Find default category + $default_category = ProductCategoryQuery::create() + ->filterByProductId($this->getId()) + ->filterByDefaultCategory(true) + ->findOne(); + + return $default_category == null ? 0 : $default_category->getCategoryId(); + } + + /** + * Set default category for this product + * + * @param integer $categoryId the new default category id + */ + public function setDefaultCategory($categoryId) + { + // Unset previous category + ProductCategoryQuery::create() + ->filterByProductId($this->getId()) + ->filterByDefaultCategory(true) + ->find() + ->setByDefault(false) + ->save(); + + // Set new default category + ProductCategoryQuery::create() + ->filterByProductId($this->getId()) + ->filterByCategoryId($categoryId) + ->find() + ->setByDefault(true) + ->save(); + + return $this; + } + + /** + * Create a new product, along with the default category ID + * + * @param int $defaultCategoryId the default category ID of this product + */ + public function create($defaultCategoryId) { + + $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME); + + $con->beginTransaction(); + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this)); + + try { + // Create the product + $this->save($con); + + // Add the default category + $pc = new ProductCategory(); + + $pc + ->setProduct($this) + ->setCategoryId($defaultCategoryId) + ->setDefaultCategory(true) + ->save($con) + ; + + // Set the position + $this->setPosition($this->getNextPosition())->save($con); + + // Create an empty product sale element + $sale_elements = new ProductSaleElements(); + + $sale_elements + ->setProduct($this) + ->setRef($this->getRef()) + ->setPromo(0) + ->setNewness(0) + ->setWeight(0) + ->save($con) + ; + + // Create an empty product price in the default currency + $product_price = new ProductPrice(); + + $product_price + ->setProductSaleElements($sale_elements) + ->setPromoPrice(0) + ->setPrice(0) + ->setCurrency(CurrencyQuery::create()->findOneByByDefault(true)) + ->save($con) + ; + + // Store all the stuff ! + $con->commit(); + + $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this)); + } + catch(\Exception $ex) { + + $con->rollback(); + + throw $ex; + } + } + + /** + * Calculate next position relative to our default category + */ + protected function addCriteriaToPositionQuery($query) + { + // Find products in the same category + $produits = ProductCategoryQuery::create() + ->filterByCategoryId($this->getDefaultCategoryId()) + ->filterByDefaultCategory(true) + ->select('product_id') + ->find(); + + // Filtrer la requete sur ces produits + if ($produits != null) $query->filterById($produits, Criteria::IN); + } + + + public function preUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEPRODUCT, new ProductEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postUpdate(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_UPDATEPRODUCT, new ProductEvent($this)); + } + + /** + * {@inheritDoc} + */ + public function preDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::BEFORE_DELETEPRODUCT, new ProductEvent($this)); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postDelete(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this)); + } } diff --git a/core/lib/Thelia/Model/ProductDocument.php b/core/lib/Thelia/Model/ProductDocument.php index a49c4f11e..53515ff3c 100755 --- a/core/lib/Thelia/Model/ProductDocument.php +++ b/core/lib/Thelia/Model/ProductDocument.php @@ -3,8 +3,27 @@ namespace Thelia\Model; use Thelia\Model\Base\ProductDocument as BaseProductDocument; +use Propel\Runtime\Connection\ConnectionInterface; - class ProductDocument extends BaseProductDocument +class ProductDocument extends BaseProductDocument { + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByProduct($this->getProduct()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/ProductI18n.php b/core/lib/Thelia/Model/ProductI18n.php index 7507bceb1..6ec3ac4a3 100755 --- a/core/lib/Thelia/Model/ProductI18n.php +++ b/core/lib/Thelia/Model/ProductI18n.php @@ -2,8 +2,14 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\ProductI18n as BaseProductI18n; class ProductI18n extends BaseProductI18n { + public function postInsert(ConnectionInterface $con = null) + { + $product = $this->getProduct(); + $product->generateRewrittenUrl($this->getLocale()); + } } diff --git a/core/lib/Thelia/Model/ProductImage.php b/core/lib/Thelia/Model/ProductImage.php index 9fe5b78e0..4bf0c40a6 100755 --- a/core/lib/Thelia/Model/ProductImage.php +++ b/core/lib/Thelia/Model/ProductImage.php @@ -3,8 +3,26 @@ namespace Thelia\Model; use Thelia\Model\Base\ProductImage as BaseProductImage; +use Propel\Runtime\Connection\ConnectionInterface; - class ProductImage extends BaseProductImage +class ProductImage extends BaseProductImage { + use \Thelia\Model\Tools\PositionManagementTrait; + /** + * Calculate next position relative to our parent + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByProduct($this->getProduct()); + } + + /** + * {@inheritDoc} + */ + public function preInsert(ConnectionInterface $con = null) + { + $this->setPosition($this->getNextPosition()); + + return true; + } } diff --git a/core/lib/Thelia/Model/ProductSaleElements.php b/core/lib/Thelia/Model/ProductSaleElements.php index 184e37d0a..6a95c37f3 100755 --- a/core/lib/Thelia/Model/ProductSaleElements.php +++ b/core/lib/Thelia/Model/ProductSaleElements.php @@ -32,12 +32,12 @@ class ProductSaleElements extends BaseProductSaleElements public function getTaxedPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2); } public function getTaxedPromoPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2); } } diff --git a/core/lib/Thelia/Model/Rewriting.php b/core/lib/Thelia/Model/Rewriting.php deleted file mode 100644 index 8d6f75fab..000000000 --- a/core/lib/Thelia/Model/Rewriting.php +++ /dev/null @@ -1,9 +0,0 @@ -getRedirected()) { + //check if rewriting url alredy exists and put redirect to the new one + RewritingUrlQuery::create() + ->filterByView($this->getView()) + ->filterByViewId($this->getViewId()) + ->filterByViewLocale($this->getViewLocale()) + ->filterByRedirected($this->getId(), Criteria::NOT_IN) + ->update(array( + "Redirected" => $this->getId() + )); + } + } } diff --git a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php new file mode 100644 index 000000000..182dbcaf3 --- /dev/null +++ b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php @@ -0,0 +1,133 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Model\Tools; + +use Thelia\Exception\UrlRewritingException; +use Thelia\Model\RewritingUrlQuery; +use Thelia\Model\RewritingUrl; +use Thelia\Tools\URL; +/** + * A trait for managing Rewriten URLs from model classes + */ +trait UrlRewritingTrait { + + /** + * @returns string the view name of the rewriten object (e.g., 'category', 'product') + */ + protected abstract function getRewrittenUrlViewName(); + + /** + * Get the object URL for the given locale, rewriten if rewriting is enabled. + * + * @param string $locale a valid locale (e.g. en_US) + */ + public function getUrl($locale) + { + return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString(); + } + + /** + * Generate a rewriten URL from the object title, and store it in the rewriting table + * + * @param string $locale a valid locale (e.g. en_US) + */ + public function generateRewrittenUrl($locale) + { + if ($this->isNew()) { + throw new \RuntimeException(sprintf('Object %s must be saved before generating url', $this->getRewrittenUrlViewName())); + } + // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe + + $this->setLocale($locale); + + $title = $this->getTitle() ?: $this->getRef(); + // Replace all weird characters with dashes + $string = preg_replace('/[^\w\-~_\.]+/u', '-', $title); + + // Only allow one dash separator at a time (and make string lowercase) + $cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8'); + + $urlFilePart = rtrim($cleanString, '.-~_') . ".html"; + + // TODO : + // check if URL url already exists, and add a numeric suffix, or the like + try{ + $i=0; + while(URL::getInstance()->resolve($urlFilePart)) { + $i++; + $urlFilePart = sprintf("%s-%d.html",$cleanString, $i); + } + } catch (UrlRewritingException $e) { + $rewritingUrl = new RewritingUrl(); + $rewritingUrl->setUrl($urlFilePart) + ->setView($this->getRewrittenUrlViewName()) + ->setViewId($this->getId()) + ->setViewLocale($locale) + ->save() + ; + } + + return $urlFilePart; + + } + + /** + * return the rewriten URL for the given locale + * + * @param string $locale a valid locale (e.g. en_US) + * @return null + */ + public function getRewrittenUrl($locale) + { + $rewritingUrl = RewritingUrlQuery::create() + ->filterByViewLocale($locale) + ->filterByView($this->getRewrittenUrlViewName()) + ->filterByViewId($this->getId()) + ->filterByRedirected(0) + ->findOne() + ; + + if($rewritingUrl) { + $url = $rewritingUrl->getUrl(); + } else { + $url = null; + } + + return $url; + } + + /** + * Set the rewriten URL for the given locale + * + * @param string $locale a valid locale (e.g. en_US) + * @param $url the wanted url + * @return $this + */ + public function setRewrittenUrl($locale, $url) + { + // TODO - code me ! + + return $this; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 9d76e08f3..a13403482 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -28,6 +28,9 @@ use Symfony\Component\DependencyInjection\ContainerAware; abstract class BaseModule extends ContainerAware { + const CLASSIC_MODULE_TYPE = 1; + const DELIVERY_MODULE_TYPE = 2; + const PAYMENT_MODULE_TYPE = 3; public function __construct() { diff --git a/core/lib/Thelia/Module/DeliveryModuleInterface.php b/core/lib/Thelia/Module/DeliveryModuleInterface.php index ba218ac4d..17b000d4f 100644 --- a/core/lib/Thelia/Module/DeliveryModuleInterface.php +++ b/core/lib/Thelia/Module/DeliveryModuleInterface.php @@ -23,13 +23,16 @@ namespace Thelia\Module; +use Thelia\Model\Country; + interface DeliveryModuleInterface extends BaseModuleInterface { /** - * * calculate and return delivery price * + * @param Country $country + * * @return mixed */ - public function calculate($country = null); + public function getPostage(Country $country); } diff --git a/core/lib/Thelia/Tests/Action/DocumentTest.php b/core/lib/Thelia/Tests/Action/DocumentTest.php new file mode 100644 index 000000000..39aece1f4 --- /dev/null +++ b/core/lib/Thelia/Tests/Action/DocumentTest.php @@ -0,0 +1,248 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action\DocumentTest; + +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\Model\ConfigQuery; + +/** + * Class DocumentTest + * + * @package Thelia\Tests\Action\DocumentTest + */ +class DocumentTest extends \Thelia\Tests\TestCaseWithURLToolSetup +{ + protected $request; + + protected $session; + + public function getContainer() + { + $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); + + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + + $container->set("event_dispatcher", $dispatcher); + + $request = new Request(); + $request->setSession($this->session); + + $container->set("request", $request); + + return $container; + } + + public function setUp() + { + $this->session = new Session(new MockArraySessionStorage()); + $this->request = new Request(); + + $this->request->setSession($this->session); + + // mock cache configuration. + $config = ConfigQuery::create()->filterByName('document_cache_dir_from_web_root')->findOne(); + + if ($config != null) { + $this->cache_dir_from_web_root = $config->getValue(); + + $config->setValue(__DIR__."/assets/documents/cache"); + + $config->setValue($this->cache_dir_from_web_root)->save(); + } + } + + public static function setUpBeforeClass() + { + $dir = THELIA_WEB_DIR."/cache/tests"; + if ($dh = @opendir($dir)) { + while ($file = readdir($dh)) { + if ($file == '.' || $file == '..') continue; + + unlink(sprintf("%s/%s", $dir, $file)); + } + + closedir($dh); + } + } + + public function tearDown() + { + // restore cache configuration. + $config = ConfigQuery::create()->filterByName('document_cache_dir_from_web_root')->findOne(); + + if ($config != null) { + $config->setValue($this->cache_dir_from_web_root)->save(); + } + } + + /** + * + * Documentevent is empty, mandatory parameters not specified. + * + * @expectedException \InvalidArgumentException + */ + public function testProcessEmptyDocumentEvent() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $document->processDocument($event); + } + + /** + * + * Try to process a non-existent file + * + * @expectedException \InvalidArgumentException + */ + public function testProcessNonExistentDocument() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $event->setCacheFilepath("blablabla.txt"); + $event->setCacheSubdirectory("tests"); + + $document->processDocument($event); + } + + /** + * + * Try to process a file outside of the cache + * + * @expectedException \InvalidArgumentException + */ + public function testProcessDocumentOutsideValidPath() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $event->setCacheFilepath("blablabla.pdf"); + $event->setCacheSubdirectory("../../../"); + + $document->processDocument($event); + } + + /** + * No operation done on source file -> copie ! + */ + public function testProcessDocumentCopy() + { + $event = new DocumentEvent($this->request); + + $event->setSourceFilepath(__DIR__."/assets/documents/sources/test-document-1.txt"); + $event->setCacheSubdirectory("tests"); + + $document = new Document($this->getContainer()); + + // mock cache configuration. + $config = ConfigQuery::create()->filterByName('original_document_delivery_mode')->findOne(); + + if ($config != null) { + $oldval = $config->getValue(); + $config->setValue('copy')->save(); + } + + $document->processDocument($event); + + if ($config != null) $config->setValue($oldval)->save(); + + $imgdir = ConfigQuery::read('document_cache_dir_from_web_root'); + + $this->assertFileExists(THELIA_WEB_DIR."/$imgdir/tests/test-document-1.txt"); + } + + /** + * No operation done on source file -> link ! + */ + public function testProcessDocumentSymlink() + { + $event = new DocumentEvent($this->request); + + $event->setSourceFilepath(__DIR__."/assets/documents/sources/test-document-2.txt"); + $event->setCacheSubdirectory("tests"); + + $document = new Document($this->getContainer()); + + // mock cache configuration. + $config = ConfigQuery::create()->filterByName('original_document_delivery_mode')->findOne(); + + if ($config != null) { + $oldval = $config->getValue(); + $config->setValue('symlink')->save(); + } + + $document->processDocument($event); + + if ($config != null) $config->setValue($oldval)->save(); + + $imgdir = ConfigQuery::read('document_cache_dir_from_web_root'); + + $this->assertFileExists(THELIA_WEB_DIR."/$imgdir/tests/test-document-2.txt"); + } + + public function testClearTestsCache() + { + $event = new DocumentEvent($this->request); + + $event->setCacheSubdirectory('tests'); + + $document = new Document($this->getContainer()); + + $document->clearCache($event); + } + + public function testClearWholeCache() + { + $event = new DocumentEvent($this->request); + + $document = new Document($this->getContainer()); + + $document->clearCache($event); + } + + /** + * Try to clear directory ouside of the cache + * + * @expectedException \InvalidArgumentException + */ + public function testClearUnallowedPathCache() + { + $event = new DocumentEvent($this->request); + + $event->setCacheSubdirectory('../../../..'); + + $document = new Document($this->getContainer()); + + $document->clearCache($event); + } +} diff --git a/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-1.txt b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-1.txt new file mode 100644 index 000000000..82537f32d --- /dev/null +++ b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-1.txt @@ -0,0 +1 @@ +This is a text document. \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-2.txt b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-2.txt new file mode 100644 index 000000000..82537f32d --- /dev/null +++ b/core/lib/Thelia/Tests/Action/assets/documents/sources/test-document-2.txt @@ -0,0 +1 @@ +This is a text document. \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php index 2b31d265a..eb271d4c1 100755 --- a/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php +++ b/core/lib/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php @@ -132,7 +132,7 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('\Thelia\Core\Template\Element\LoopResult', $methodReturn); } - public function baseTestSearchById($id) + public function baseTestSearchById($id, $other_args = array()) { $this->instance->initializeArgs(array_merge( $this->getMandatoryArguments(), @@ -140,7 +140,8 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase "type" => "foo", "name" => "foo", "id" => $id, - ) + ), + $other_args )); $dummy = null; diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php new file mode 100644 index 000000000..2b7019879 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Model\DocumentQuery; +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\Document; +use Thelia\Model\ProductDocumentQuery; +use Thelia\Model\CategoryDocumentQuery; +use Thelia\Model\ContentDocumentQuery; +use Thelia\Model\FolderDocumentQuery; + +/** + * + * @author Etienne Roudeix + * + */ +class DocumentTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\Document'; + } + + public function getTestedInstance() + { + return new Document($this->container); + } + + public function getMandatoryArguments() + { + return array('source' => 'product', 'id' => 1); + } + + public function testSearchByProductId() + { + $document = ProductDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'product')); + } + + public function testSearchByFolderId() + { + $document = FolderDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'folder')); + } + + public function testSearchByContentId() + { + $document = ContentDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'content')); + } + + public function testSearchByCategoryId() + { + $document = CategoryDocumentQuery::create()->findOne(); + + $this->baseTestSearchById($document->getId(), array('source' => 'category')); + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php new file mode 100644 index 000000000..ba4bfadc5 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Model\ImageQuery; +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\Image; +use Thelia\Model\ProductImageQuery; +use Thelia\Model\CategoryImageQuery; +use Thelia\Model\ContentImageQuery; +use Thelia\Model\FolderImageQuery; + +/** + * + * @author Etienne Roudeix + * + */ +class ImageTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\Image'; + } + + public function getTestedInstance() + { + return new Image($this->container); + } + + public function getMandatoryArguments() + { + return array('source' => 'product', 'id' => 1); + } + + public function testSearchByProductId() + { + $image = ProductImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'product')); + } + + public function testSearchByFolderId() + { + $image = FolderImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'folder')); + } + + public function testSearchByContentId() + { + $image = ContentImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'content')); + } + + public function testSearchByCategoryId() + { + $image = CategoryImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId(), array('source' => 'category')); + } +} diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php index 1b307c5b5..07e179cbd 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php @@ -27,6 +27,7 @@ use Thelia\Model\ProductQuery; use Thelia\Tests\Core\Template\Element\BaseLoopTestor; use Thelia\Core\Template\Loop\Product; +use Propel\Runtime\ActiveQuery\Criteria; /** * @@ -52,7 +53,7 @@ class ProductTest extends BaseLoopTestor public function testSearchById() { - $product = ProductQuery::create()->findOne(); + $product = ProductQuery::create()->orderById(Criteria::ASC)->findOne(); $this->baseTestSearchById($product->getId()); } diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php new file mode 100644 index 000000000..fa24d72ee --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php @@ -0,0 +1,60 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop; + +use Thelia\Tests\Core\Template\Element\BaseLoopTestor; + +use Thelia\Core\Template\Loop\TaxRule; +use Thelia\Model\TaxRuleQuery; + +/** + * + * @author Etienne Roudeix + * + */ +class TaxRuleTest extends BaseLoopTestor +{ + public function getTestedClassName() + { + return 'Thelia\Core\Template\Loop\TaxRule'; + } + + public function getTestedInstance() + { + return new TaxRule($this->container); + } + + public function getMandatoryArguments() + { + return array(); + } + + public function testSearchById() + { + $tr = TaxRuleQuery::create()->findOne(); + + $this->baseTestSearchById($tr->getId(), array('force_return' => true)); + } + +} diff --git a/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php new file mode 100644 index 000000000..b6601289d --- /dev/null +++ b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php @@ -0,0 +1,89 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Rewriting; +use Thelia\Model\Product; +use Thelia\Model\ProductQuery; + + +/** + * Class ProductRewriteTest + * @package Thelia\Tests\Rewriting + * @author Manuel Raynaud + */ +class ProductRewriteTest extends \PHPUnit_Framework_TestCase +{ + protected static $productId; + + public static function setUpBeforeClass() + { + $product = new Product(); + $product->setRef(sprintf("TestRewrittenProduct%s",uniqid())) + ->setPosition(1) + ->setVisible(1) + ->setLocale('en_US') + ->setTitle('My english super Title') + ->setLocale('fr_FR') + ->setTitle('Mon super titre en français') + ->save(); + + self::$productId = $product->getId(); + } + + /** + * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl + */ + public function testFrenchRewrittenUrl() + { + $product = ProductQuery::create()->findPk(self::$productId); + + $rewrittenUrl = $product->generateRewrittenUrl('fr_FR'); + $this->assertNotNull($rewrittenUrl, "rewritten url can not be null"); + $this->assertRegExp('/^mon-super-titre-en-français(-[0-9]+)?\.html$/', $rewrittenUrl); + //mon-super-titre-en-français-2.html + } + + /** + * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl + */ + public function testEnglishRewrittenUrl() + { + $product = ProductQuery::create()->findPk(self::$productId); + + $rewrittenUrl = $product->generateRewrittenUrl('en_US'); + $this->assertNotNull($rewrittenUrl, "rewritten url can not be null"); + $this->assertRegExp('/^my-english-super-title(-[0-9]+)?\.html$/', $rewrittenUrl); + } + + /** + * @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl + * @expectedException \RuntimeException + * @expectedExceptionMessage Object product must be saved before generating url + */ + public function testOnNotSavedProduct() + { + $product = new Product(); + + $product->generateRewrittenUrl('fr_FR'); + } +} \ 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 e0443c5ba..502b14c7e 100755 --- a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php +++ b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php @@ -78,7 +78,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase public function testLoad() { - $productQuery = ProductQuery::create()->findOneById(1); + $productQuery = ProductQuery::create()->findOne(); $countryQuery = CountryQuery::create()->findOneById(64); $calculator = new Calculator(); diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 32c1aadb5..363860064 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -43,14 +43,15 @@ class URL protected static $instance = null; - public function __construct(ContainerInterface $container) + public function __construct(ContainerInterface $container = null) { // Allow singleton style calls once intanciated. // For this to work, the URL service has to be instanciated very early. This is done manually // in TheliaHttpKernel, by calling $this->container->get('thelia.url.manager'); self::$instance = $this; - $this->requestContext = $container->get('router.admin')->getContext(); + if ($container !== null) + $this->requestContext = $container->get('router.admin')->getContext(); $this->retriever = new RewritingRetriever(); $this->resolver = new RewritingResolver(); @@ -183,6 +184,7 @@ class URL return $this->absoluteUrl($path, $parameters); } + /** * Retrieve a rewritten URL from a view, a view id and a locale * @@ -261,4 +263,50 @@ class URL return $this->resolver; } + + protected function sanitize($string, $force_lowercase = true, $alphabetic_only = false) + { + static $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", + "}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—", + "—", "–", ",", "<", ".", ">", "/", "?"); + + $clean = trim(str_replace($strip, "", strip_tags($string))); + + $clean = preg_replace('/\s+/', "-", $clean); + + $clean = ($alphabetic_only) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ; + + return ($force_lowercase) ? + (function_exists('mb_strtolower')) ? + mb_strtolower($clean, 'UTF-8') : + strtolower($clean) : + $clean; + } + + /** + * Genenerate the file part of a rewriten URL from a given baseString, using a view, a view id and a locale + * + * @param $view + * @param $viewId + * @param $viewLocale + * @param $baseString the string to be converted in a valid URL + * + * @return A valid file part URL. + */ + public function generateRewritenUrl($view, $viewId, $viewLocale, $baseString) + { + // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe + + // Replace all weird characters with dashes + $string = preg_replace('/[^\w\-~_\.]+/u', '-', $baseString); + + // Only allow one dash separator at a time (and make string lowercase) + $cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8'); + + $urlFilePart = $cleanString . ".html"; + + // TODO : + // check if URL url already exists, and add a numeric suffix, or the like + // insert the URL in the rewriting table + } } diff --git a/install/faker.php b/install/faker.php index 66303f05a..eed6db11a 100755 --- a/install/faker.php +++ b/install/faker.php @@ -4,12 +4,7 @@ use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\AvailableForXArticlesManager; use Thelia\Constraint\Rule\Operators; use Thelia\Coupon\CouponRuleCollection; -use Thelia\Model\ProductImage; -use Thelia\Model\CategoryImage; -use Thelia\Model\FolderImage; -use Thelia\Model\ContentImage; -use Imagine\Image\Color; -use Imagine\Image\Point; + require __DIR__ . '/../core/bootstrap.php'; @@ -23,12 +18,17 @@ $con = \Propel\Runtime\Propel::getConnection( ); $con->beginTransaction(); +// Intialize URL management +$url = new Thelia\Tools\URL(); + $currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne(); try { $stmt = $con->prepare("SET foreign_key_checks = 0"); $stmt->execute(); + echo "Clearing tables\n"; + $productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create() ->find(); $productAssociatedContent->delete(); @@ -125,9 +125,24 @@ try { ->find(); $productPrice->delete(); + \Thelia\Model\ProductImageQuery::create()->find()->delete(); + \Thelia\Model\CategoryImageQuery::create()->find()->delete(); + \Thelia\Model\FolderImageQuery::create()->find()->delete(); + \Thelia\Model\ContentImageQuery::create()->find()->delete(); + + \Thelia\Model\ProductDocumentQuery::create()->find()->delete(); + \Thelia\Model\CategoryDocumentQuery::create()->find()->delete(); + \Thelia\Model\FolderDocumentQuery::create()->find()->delete(); + \Thelia\Model\ContentDocumentQuery::create()->find()->delete(); + + \Thelia\Model\CouponQuery::create()->find()->delete(); + $stmt = $con->prepare("SET foreign_key_checks = 1"); + $stmt->execute(); + echo "Creating customer\n"; + //customer $customer = new Thelia\Model\Customer(); $customer->createOrUpdate( @@ -185,11 +200,13 @@ try { } } + echo "Creating features\n"; + //features and features_av $featureList = array(); for($i=0; $i<4; $i++) { $feature = new Thelia\Model\Feature(); - $feature->setVisible(rand(1, 10)>7 ? 0 : 1); + $feature->setVisible(1); $feature->setPosition($i); setI18n($faker, $feature); @@ -208,6 +225,8 @@ try { } } + echo "Creating attributes\n"; + //attributes and attributes_av $attributeList = array(); for($i=0; $i<4; $i++) { @@ -230,6 +249,8 @@ try { } } + echo "Creating templates\n"; + $template = new Thelia\Model\Template(); setI18n($faker, $template, array("Name" => 20)); $template->save(); @@ -252,52 +273,75 @@ try { ->save(); } + echo "Creating folders and content\n"; + //folders and contents $contentIdList = array(); for($i=0; $i<4; $i++) { $folder = new Thelia\Model\Folder(); $folder->setParent(0); - $folder->setVisible(rand(1, 10)>7 ? 0 : 1); - $folder->setPosition($i); + $folder->setVisible(1); + $folder->setPosition($i+1); setI18n($faker, $folder); $folder->save(); - $image = new FolderImage(); + $image = new \Thelia\Model\FolderImage(); $image->setFolderId($folder->getId()); generate_image($image, 1, 'folder', $folder->getId()); - for($j=1; $jsetFolderId($folder->getId()); + generate_document($document, 1, 'folder', $folder->getId()); + + for($j=0; $j<3; $j++) { $subfolder = new Thelia\Model\Folder(); $subfolder->setParent($folder->getId()); - $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); - $subfolder->setPosition($j); + $subfolder->setVisible(1); + $subfolder->setPosition($j+1); setI18n($faker, $subfolder); $subfolder->save(); - $image = new FolderImage(); + $image = new \Thelia\Model\FolderImage(); $image->setFolderId($subfolder->getId()); generate_image($image, 1, 'folder', $subfolder->getId()); - for($k=0; $ksetFolderId($folder->getId()); + generate_document($document, 1, 'folder', $subfolder->getId()); + + for($k=0; $k<4; $k++) { $content = new Thelia\Model\Content(); $content->addFolder($subfolder); - $content->setVisible(rand(1, 10)>7 ? 0 : 1); - $content->setPosition($k); + + $contentFolders = $content->getContentFolders(); + $collection = new \Propel\Runtime\Collection\Collection(); + $collection->prepend($contentFolders[0]->setDefaultFolder(1)); + $content->setContentFolders($collection); + + $content->setVisible(1); + $content->setPosition($k+1); setI18n($faker, $content); $content->save(); $contentId = $content->getId(); $contentIdList[] = $contentId; - $image = new ContentImage(); - $image->setContentId($content->getId()); + $image = new \Thelia\Model\ContentImage(); + $image->setContentId($contentId); generate_image($image, 1, 'content', $contentId); + + $document = new \Thelia\Model\ContentDocument(); + $document->setContentId($contentId); + generate_document($document, 1, 'content', $contentId); + } } } + echo "Creating categories and products\n"; + //categories and products $productIdList = array(); $categoryIdList = array(); @@ -405,20 +449,30 @@ try { } } + echo "Generating coupons fixtures\n"; + generateCouponFixtures($thelia); $con->commit(); + + echo "Successfully terminated.\n"; + } catch (Exception $e) { echo "error : ".$e->getMessage()."\n"; $con->rollBack(); } -function createProduct($faker, $category, $position, $template, &$productIdList) +function createProduct($faker, Thelia\Model\Category $category, $position, $template, &$productIdList) { $product = new Thelia\Model\Product(); $product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8)); $product->addCategory($category); - $product->setVisible(rand(1, 10)>7 ? 0 : 1); + $product->setVisible(1); + $productCategories = $product->getProductCategories(); + $collection = new \Propel\Runtime\Collection\Collection(); + $collection->prepend($productCategories[0]->setDefaultCategory(1)); + $product->setProductCategories($collection); + $product->setVisible(1); $product->setPosition($position); $product->setTaxRuleId(1); $product->setTemplate($template); @@ -429,10 +483,14 @@ function createProduct($faker, $category, $position, $template, &$productIdList) $productId = $product->getId(); $productIdList[] = $productId; - $image = new ProductImage(); + $image = new \Thelia\Model\ProductImage(); $image->setProductId($productId); generate_image($image, 1, 'product', $productId); + $document = new \Thelia\Model\ProductDocument(); + $document->setProductId($productId); + generate_document($document, 1, 'product', $productId); + return $product; } @@ -440,7 +498,7 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId { $category = new Thelia\Model\Category(); $category->setParent($parent); - $category->setVisible(rand(1, 10)>7 ? 0 : 1); + $category->setVisible(1); $category->setPosition($position); setI18n($faker, $category); @@ -464,10 +522,14 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId ->save(); } - $image = new CategoryImage(); + $image = new \Thelia\Model\CategoryImage(); $image->setCategoryId($categoryId); generate_image($image, 1, 'category', $categoryId); + $document = new \Thelia\Model\CategoryDocument(); + $document->setCategoryId($categoryId); + generate_document($document, 1, 'category', $categoryId); + return $category; } @@ -480,37 +542,36 @@ function generate_image($image, $position, $typeobj, $id) { ->setDescription($faker->text(250)) ->setChapo($faker->text(40)) ->setPostscriptum($faker->text(40)) - ->setPosition($position) ->setFile(sprintf("sample-image-%s.png", $id)) ->save() ; // Generate images $imagine = new Imagine\Gd\Imagine(); - $image = $imagine->create(new Imagine\Image\Box(320,240), new Color('#E9730F')); + $image = $imagine->create(new Imagine\Image\Box(320,240), new Imagine\Image\Color('#E9730F')); - $white = new Color('#FFF'); + $white = new Imagine\Image\Color('#FFF'); $font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 14, $white); $tbox = $font->box("THELIA"); - $image->draw()->text("THELIA", $font, new Point((320 - $tbox->getWidth()) / 2, 30)); + $image->draw()->text("THELIA", $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 30)); $str = sprintf("%s sample image", ucfirst($typeobj)); $tbox = $font->box($str); - $image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 80)); + $image->draw()->text($str, $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 80)); $font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 18, $white); $str = sprintf("%s ID %d", strtoupper($typeobj), $id); $tbox = $font->box($str); - $image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 180)); + $image->draw()->text($str, $font, new Imagine\Image\Point((320 - $tbox->getWidth()) / 2, 180)); $image->draw() - ->line(new Point(0, 0), new Point(319, 0), $white) - ->line(new Point(319, 0), new Point(319, 239), $white) - ->line(new Point(319, 239), new Point(0,239), $white) - ->line(new Point(0, 239), new Point(0, 0), $white) + ->line(new Imagine\Image\Point(0, 0), new Imagine\Image\Point(319, 0), $white) + ->line(new Imagine\Image\Point(319, 0), new Imagine\Image\Point(319, 239), $white) + ->line(new Imagine\Image\Point(319, 239), new Imagine\Image\Point(0,239), $white) + ->line(new Imagine\Image\Point(0, 239), new Imagine\Image\Point(0, 0), $white) ; $image_file = sprintf("%s/../local/media/images/%s/sample-image-%s.png", __DIR__, $typeobj, $id); @@ -520,6 +581,26 @@ function generate_image($image, $position, $typeobj, $id) { $image->save($image_file); } +function generate_document($document, $position, $typeobj, $id) { + + global $faker; + + $document + ->setTitle($faker->text(20)) + ->setDescription($faker->text(250)) + ->setChapo($faker->text(40)) + ->setPostscriptum($faker->text(40)) + ->setFile(sprintf("sample-document-%s.txt", $id)) + ->save() + ; + + $document_file = sprintf("%s/../local/media/documents/%s/sample-document-%s.txt", __DIR__, $typeobj, $id); + + if (! is_dir(dirname($document_file))) mkdir(dirname($document_file), 0777, true); + + file_put_contents($document_file, $faker->text(256)); +} + function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description' => 50) ) { $localeList = $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT'); diff --git a/install/insert.sql b/install/insert.sql index 1b8327a10..79bef3731 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -13,8 +13,11 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat ('imagine_graphic_driver', 'gd', 0, 0, NOW(), NOW()), ('default_images_quality_percent', '75', 0, 0, NOW(), NOW()), ('original_image_delivery_mode', 'symlink', 0, 0, NOW(), NOW()), +('original_document_delivery_mode', 'symlink', 0, 0, NOW(), NOW()), ('images_library_path', 'local/media/images', 0, 0, NOW(), NOW()), +('documents_library_path', 'local/media/documents', 0, 0, NOW(), NOW()), ('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()), +('document_cache_dir_from_web_root', 'cache/documents', 0, 0, NOW(), NOW()), ('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()), ('page_not_found_view', '404.html', 0, 0, NOW(), NOW()), ('use_tax_free_amounts', 0, 0, 0, NOW(), NOW()), @@ -28,7 +31,13 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES -(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW()); +(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW()), +(2, 'Colissimo', 2, 1, 1, 'Colissimo\\Colissimo', NOW(), NOW()); + +INSERT INTO `module_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES +('2', 'en_US', '72h delivery', NULL, NULL, NULL), +('2', 'fr_FR', 'Livraison par colissimo en 72h', NULL, NULL, NULL); + INSERT INTO `customer_title`(`id`, `by_default`, `position`, `created_at`, `updated_at`) VALUES (1, 1, 1, NOW(), NOW()), @@ -43,13 +52,13 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES (3, 'fr_FR', 'Mlle', 'Madamemoiselle'), (3, 'en_US', 'Miss', 'Miss'); -INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate`, `position` ,`by_default` ,`created_at` ,`updated_at`) +INSERT INTO `currency` (`id`, `code`, `symbol`, `rate`, `position`, `by_default`, `created_at`, `updated_at`) VALUES -(1, 'EUR', '€', '1', 1, '1', NOW() , NOW()), +(1, 'EUR', '€', '1', 1, '1', NOW(), NOW()), (2, 'USD', '$', '1.26', 2, '0', NOW(), NOW()), (3, 'GBP', '£', '0.89', 3, '0', NOW(), NOW()); -INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`) +INSERT INTO `currency_i18n` (`id`, `locale`, `name`) VALUES (1, 'fr_FR', 'Euro'), (1, 'en_US', 'Euro'), @@ -1128,9 +1137,9 @@ INSERT INTO `tax_i18n` (`id`, `locale`, `title`) (1, 'fr_FR', 'TVA française à 19.6%'), (1, 'en_UK', 'french 19.6% tax'); -INSERT INTO `tax_rule` (`id`, `created_at`, `updated_at`) +INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) VALUES - (1, NOW(), NOW()); + (1, 1, NOW(), NOW()); INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`) VALUES diff --git a/install/thelia.sql b/install/thelia.sql index f178467a1..7ea2f7659 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -36,7 +36,7 @@ CREATE TABLE `product` `ref` VARCHAR(255) NOT NULL, `visible` TINYINT DEFAULT 0 NOT NULL, `position` INTEGER NOT NULL, - `template_id` INTEGER NOT NULL, + `template_id` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0, @@ -66,11 +66,13 @@ CREATE TABLE `product_category` ( `product_id` INTEGER NOT NULL, `category_id` INTEGER NOT NULL, + `default_category` TINYINT(1), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`product_id`,`category_id`), INDEX `idx_product_has_category_category1` (`category_id`), INDEX `idx_product_has_category_product1` (`product_id`), + INDEX `idx_product_has_category_default` (`default_category`), CONSTRAINT `fk_product_has_category_product1` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) @@ -133,6 +135,7 @@ DROP TABLE IF EXISTS `tax_rule`; CREATE TABLE `tax_rule` ( `id` INTEGER NOT NULL AUTO_INCREMENT, + `is_default` TINYINT(1) DEFAULT 0 NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) @@ -341,6 +344,8 @@ CREATE TABLE `attribute_combination` CONSTRAINT `fk_attribute_combination_product_sale_elements_id` FOREIGN KEY (`product_sale_elements_id`) REFERENCES `product_sale_elements` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -632,54 +637,73 @@ DROP TABLE IF EXISTS `order`; CREATE TABLE `order` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `ref` VARCHAR(45), + `ref` VARCHAR(45) NOT NULL, `customer_id` INTEGER NOT NULL, - `address_invoice` INTEGER, - `address_delivery` INTEGER, - `invoice_date` DATE, - `currency_id` INTEGER, + `invoice_order_address_id` INTEGER NOT NULL, + `delivery_order_address_id` INTEGER NOT NULL, + `invoice_date` DATE NOT NULL, + `currency_id` INTEGER NOT NULL, `currency_rate` FLOAT NOT NULL, - `transaction` VARCHAR(100), - `delivery_num` VARCHAR(100), - `invoice` VARCHAR(100), - `postage` FLOAT, - `payment` VARCHAR(45) NOT NULL, - `carrier` VARCHAR(45) NOT NULL, - `status_id` INTEGER, - `lang` VARCHAR(10) NOT NULL, + `transaction_ref` VARCHAR(100) COMMENT 'transaction reference - usually use to identify a transaction with banking modules', + `delivery_ref` VARCHAR(100) COMMENT 'delivery reference - usually use to identify a delivery progress on a distant delivery tracker website', + `invoice_ref` VARCHAR(100) COMMENT 'the invoice reference', + `postage` FLOAT NOT NULL, + `payment_module_id` INTEGER NOT NULL, + `delivery_module_id` INTEGER NOT NULL, + `status_id` INTEGER NOT NULL, + `lang_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), + UNIQUE INDEX `ref_UNIQUE` (`ref`), INDEX `idx_order_currency_id` (`currency_id`), INDEX `idx_order_customer_id` (`customer_id`), - INDEX `idx_order_address_invoice` (`address_invoice`), - INDEX `idx_order_address_delivery` (`address_delivery`), + INDEX `idx_order_invoice_order_address_id` (`invoice_order_address_id`), + INDEX `idx_order_delivery_order_address_id` (`delivery_order_address_id`), INDEX `idx_order_status_id` (`status_id`), + INDEX `fk_order_payment_module_id_idx` (`payment_module_id`), + INDEX `fk_order_delivery_module_id_idx` (`delivery_module_id`), + INDEX `fk_order_lang_id_idx` (`lang_id`), CONSTRAINT `fk_order_currency_id` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL, + ON DELETE RESTRICT, CONSTRAINT `fk_order_customer_id` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON UPDATE RESTRICT - ON DELETE CASCADE, - CONSTRAINT `fk_order_address_invoice` - FOREIGN KEY (`address_invoice`) + ON DELETE RESTRICT, + CONSTRAINT `fk_order_invoice_order_address_id` + FOREIGN KEY (`invoice_order_address_id`) REFERENCES `order_address` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL, - CONSTRAINT `fk_order_address_delivery` - FOREIGN KEY (`address_delivery`) + ON DELETE RESTRICT, + CONSTRAINT `fk_order_delivery_order_address_id` + FOREIGN KEY (`delivery_order_address_id`) REFERENCES `order_address` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL, + ON DELETE RESTRICT, CONSTRAINT `fk_order_status_id` FOREIGN KEY (`status_id`) REFERENCES `order_status` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL + ON DELETE RESTRICT, + CONSTRAINT `fk_order_payment_module_id` + FOREIGN KEY (`payment_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE RESTRICT, + CONSTRAINT `fk_order_delivery_module_id` + FOREIGN KEY (`delivery_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE RESTRICT, + CONSTRAINT `fk_order_lang_id` + FOREIGN KEY (`lang_id`) + REFERENCES `lang` (`id`) + ON UPDATE RESTRICT + ON DELETE RESTRICT ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -852,32 +876,38 @@ CREATE TABLE `area` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, - `unit` FLOAT, + `postage` FLOAT, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- delivzone +-- area_delivery_module -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `delivzone`; +DROP TABLE IF EXISTS `area_delivery_module`; -CREATE TABLE `delivzone` +CREATE TABLE `area_delivery_module` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `area_id` INTEGER, - `delivery` VARCHAR(45) NOT NULL, + `area_id` INTEGER NOT NULL, + `delivery_module_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_delivzone_area_id` (`area_id`), - CONSTRAINT `fk_delivzone_area_id` + INDEX `idx_area_delivery_module_area_id` (`area_id`), + INDEX `idx_area_delivery_module_delivery_module_id_idx` (`delivery_module_id`), + CONSTRAINT `fk_area_delivery_module_area_id` FOREIGN KEY (`area_id`) REFERENCES `area` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL + ON DELETE CASCADE, + CONSTRAINT `idx_area_delivery_module_delivery_module_id` + FOREIGN KEY (`delivery_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -1128,11 +1158,13 @@ CREATE TABLE `content_folder` ( `content_id` INTEGER NOT NULL, `folder_id` INTEGER NOT NULL, + `default_folder` TINYINT(1), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`content_id`,`folder_id`), INDEX `idx_content_folder_content_id` (`content_id`), INDEX `idx_content_folder_folder_id` (`folder_id`), + INDEX `idx_content_folder_default` (`default_folder`), CONSTRAINT `fk_content_folder_content_id` FOREIGN KEY (`content_id`) REFERENCES `content` (`id`) @@ -2136,7 +2168,7 @@ CREATE TABLE `product_version` `ref` VARCHAR(255) NOT NULL, `visible` TINYINT DEFAULT 0 NOT NULL, `position` INTEGER NOT NULL, - `template_id` INTEGER NOT NULL, + `template_id` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, `version` INTEGER DEFAULT 0 NOT NULL, diff --git a/local/config/schema.xml b/local/config/schema.xml index 186bdbfd6..beab829af 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,1164 +1,1200 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - -
-
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+
diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php old mode 100644 new mode 100755 index 4d24cc059..14ad36b0d --- a/local/modules/Colissimo/Colissimo.php +++ b/local/modules/Colissimo/Colissimo.php @@ -25,6 +25,7 @@ namespace Colissimo; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; +use Thelia\Model\Country; use Thelia\Module\BaseModule; use Thelia\Module\DeliveryModuleInterface; @@ -57,10 +58,10 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface * * calculate and return delivery price * - * @param null $country + * @param Country $country * @return mixed */ - public function calculate($country = null) + public function getPostage(Country $country) { // TODO: Implement calculate() method. return 2; diff --git a/local/modules/Colissimo/Config/config.xml b/local/modules/Colissimo/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/plugin.xml b/local/modules/Colissimo/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/schema.xml b/local/modules/Colissimo/Config/schema.xml deleted file mode 100644 index a4e2315b0..000000000 --- a/local/modules/Colissimo/Config/schema.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/local/modules/DebugBar/Config/config.xml b/local/modules/DebugBar/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/plugin.xml b/local/modules/DebugBar/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/schema.xml b/local/modules/DebugBar/Config/schema.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DataCollector/PropelCollector.php b/local/modules/DebugBar/DataCollector/PropelCollector.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DebugBar.php b/local/modules/DebugBar/DebugBar.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Listeners/DebugBarListeners.php b/local/modules/DebugBar/Listeners/DebugBarListeners.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php old mode 100644 new mode 100755 index 0cd1abee9..9f3cc8386 --- a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php +++ b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php @@ -71,7 +71,11 @@ class DebugBar extends AbstractSmartyPlugin } } - file_put_contents($cssFile, $assetCss->dump()); + if(!file_exists(THELIA_WEB_DIR . "/cache")) { + @mkdir(THELIA_WEB_DIR . "/cache"); + } + + @file_put_contents($cssFile, $assetCss->dump()); } $render = sprintf('', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE)); } @@ -96,7 +100,11 @@ class DebugBar extends AbstractSmartyPlugin } } - file_put_contents($cacheFile, $assetJs->dump()); + if(!file_exists(THELIA_WEB_DIR . "/cache")) { + @mkdir(THELIA_WEB_DIR . "/cache"); + } + + @file_put_contents($cacheFile, $assetJs->dump()); } $render = sprintf('', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE)); diff --git a/reset_install.sh b/reset_install.sh index 399156b67..348927a54 100755 --- a/reset_install.sh +++ b/reset_install.sh @@ -8,7 +8,7 @@ echo -e "\n\e[01;34m[INFO] Clearing caches\e[00m\n" php Thelia cache:clear echo -e "\n\e[01;34m[INFO] Downloading vendors\e[00m\n" -composer install --prefer-dist +composer install --prefer-dist --optimize-autoloader cd local/config/ @@ -18,7 +18,7 @@ echo -e "\n\e[01;34m[INFO] Building Models file\e[00m\n" echo -e "\n\e[01;34m[INFO] Building SQL CREATE file\e[00m\n" ../../bin/propel sql:build -v --output-dir=../../install/ -echo -e "\n\e[01;34m[INFO] Reloaded Thelia2 database\e[00m\n" +echo -e "\n\e[01;34m[INFO] Reloading Thelia2 database\e[00m\n" cd ../.. rm install/sqldb.map php Thelia thelia:dev:reloadDB diff --git a/templates/admin/default/assets/less/thelia/thelia.less b/templates/admin/default/assets/less/thelia/thelia.less index b2a8545b0..ba1654c7c 100644 --- a/templates/admin/default/assets/less/thelia/thelia.less +++ b/templates/admin/default/assets/less/thelia/thelia.less @@ -35,7 +35,7 @@ .topbar { - background: url("@{imgDir}/top.jpg") repeat-x; + background: url("@{imgDir}/top.jpg") repeat-x; font-weight: bold; .version-info { @@ -203,7 +203,7 @@ border-bottom: 2px solid #A5CED8; margin-bottom: 0.5em; } - + // The action bar on the right .actions { text-align: right; @@ -218,6 +218,10 @@ text-transform: none; } } + + .inner-actions { + margin-top: 0.5em; + } } // The overall form container diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html index 6fe06f8bc..3c2e6f00a 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -1,517 +1,651 @@ {extends file="admin-layout.tpl"} -{block name="page-title"}{intl l='Catalog'}{/block} +{block name="page-title"}{intl l='Categories'}{/block} -{block name="check-permissions"}admin.catalog.view{/block} +{block name="check-permissions"}admin.categories.view{/block} {block name="main-content"} -
-
+
- {include file="includes/catalog-breadcrumb.html"} +
- {module_include location='catalog_top'} + {include file="includes/catalog-breadcrumb.html"} -
-
-
- - +
- {* display parent category name, and get current cat ID *} - {loop name="category_title" type="category" visible="*" id=$current_category_id} - {intl l="Categories in %cat" cat=$TITLE} - {$cat_id = $ID} - {/loop} - {elseloop rel="category_title"} - {intl l="Top level categories"} - {/elseloop} + {module_include location='categories_top'} - {module_include location='category_list_caption'} +
+
+
- {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} - - - - {/loop} -
+ - - + {module_include location='category_list_caption'} - + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} + + + + {/loop} + - - - {module_include location='category_list_header'} - - - - - - - - - - - {loop name="category_list" type="category" visible="*" parent=$current_category_id order=$category_order backend_context="1" lang=$lang_id} - - - - - - - - {module_include location='category_list_row'} - - - - + + - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} - - {/loop} + - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"} - - {/loop} - - - - {/loop} - - {/ifloop} + {module_include location='category_list_header'} - {elseloop rel="category_list"} - - - - {elseloop rel="can_create"} - {intl l="This category has no sub-categories."} - {/elseloop} - - - - - {/elseloop} -
+ {* display parent category name, and get current cat ID *} + {loop name="category_title" type="category" visible="*" id=$category_id} + {intl l="Categories in %cat" cat=$TITLE} + {$cat_id = $ID} + {/loop} + {elseloop rel="category_title"} + {intl l="Top level categories"} + {/elseloop} - {ifloop rel="category_list"} -
- {admin_sortable_header - current_order=$category_order - order='id' - reverse_order='id_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='ID'}" - } -   - {admin_sortable_header - current_order=$category_order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Category title'}" - } - - {admin_sortable_header - current_order=$category_order - order='visible' - reverse_order='visible_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Online'}" - } - - {admin_sortable_header - current_order=$category_order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/catalog' id_category=$current_category_id} - label="{intl l='Position'}" - } - {intl l='Actions'}
{$ID} - {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} - {$TITLE} - {/loop} - - - {$TITLE} - - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} -
- -
- {/loop} - - {elseloop rel="can_change"} -
- -
- {/elseloop} -
- {admin_position_block - permission="admin.categories.edit" - path={url path='admin/category/update-position' category_id=$ID} - url_parameter="category_id" - in_place_edit_class="categoryPositionChange" - position=$POSITION - id=$ID + {ifloop rel="category_list"} +
+ {admin_sortable_header + current_order=$category_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='ID'}" } - + -
- +
  + {admin_sortable_header + current_order=$category_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Category title'}" + } +
-
- {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} - {intl l="This category has no sub-categories. To create a new one, click the + button above."} - {/loop} +
+ {admin_sortable_header + current_order=$category_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Online'}" + } +
-
-
-
+ + {admin_sortable_header + current_order=$category_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Position'}" + } + -
-
-
- - + + - {elseloop rel="category_title"} - {intl l="Top level Products"} - {/elseloop} + + {loop name="category_list" type="category" visible="*" parent=$category_id order=$category_order backend_context="1" lang=$lang_id} + + - {module_include location='product_list_caption'} + - - - - - - {ifloop rel="product_list"} - - - - - - - - - - - - - - - - {loop name="product_list" type="product" category=$current_category_id order="manual"} - - - - - + {module_include location='category_list_row'} - + - + + + + {/loop} + + {/ifloop} + + {elseloop rel="category_list"} + + + + + + {/elseloop} +
- {* display parent category name *} - {loop name="category_title" type="category" visible="*" id=$current_category_id} - {intl l="Products in %cat" cat=$TITLE} - {/loop} +
{intl l='Actions'}
{$ID} + {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + {$TITLE} + {/loop} +
- {admin_sortable_header - current_order=$product_order - order='id' - reverse_order='id_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='ID'}" - } - -   - {admin_sortable_header - current_order=$product_order - order='ref' - reverse_order='ref_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Reference'}" - } - - {admin_sortable_header - current_order=$product_order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Product title'}" - } - - {module_include location='product_list_header'} - - - {admin_sortable_header - current_order=$product_order - order='visible' - reverse_order='visible_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Online'}" - } - - {admin_sortable_header - current_order=$product_order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/product' category_id=$current_category_id} - label="{intl l='Position'}" - } -  
{$ID} - {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} - - {$TITLE} + + + {$TITLE} - {/loop} + {$REF}{$TITLE} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} +
+ +
+ {/loop} - {module_include location='product_list_row'} + {elseloop rel="can_change"} +
+ +
+ {/elseloop} +
+ + {admin_position_block + permission="admin.categories.edit" + path={url path='admin/categories/update-position' category_id=$ID} + url_parameter="category_id" + in_place_edit_class="categoryPositionChange" + position=$POSITION + id=$ID + } + +
+ + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"} + + {/loop} +
+
+
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.categories.create"} + {intl l="This category has no sub-categories. To create a new one, click the + button above."} + {/loop} + + {elseloop rel="can_create"} + {intl l="This category has no sub-categories."} + {/elseloop} +
+
+
+
+
+ +{* -- PRODUCT MANAGEMENT ---------------------------------------------------- *} + +
+
+
+ + + + + {ifloop rel="product_list"} + + + + + + + + + + + + + + + + {loop name="product_list" type="product" visible="*" category_default=$category_id order=$product_order} + + + + + + + + {module_include location='product_list_row'} + + + - + - - - {/loop} - - {/ifloop} + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.delete"} + + {/loop} + + + + {/loop} + + {/ifloop} - {elseloop rel="product_list"} - - - - - - {/elseloop} -
+ {* display parent category name *} + {loop name="category_title" type="category" visible="*" id=$category_id} + {intl l="Products in %cat" cat=$TITLE} + {/loop} + + {elseloop rel="category_title"} + {intl l="Top level Products"} + {/elseloop} + + {module_include location='product_list_caption'} + + + + +
+ {admin_sortable_header + current_order=$product_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='ID'}" + } + +   + {admin_sortable_header + current_order=$product_order + order='ref' + reverse_order='ref_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Reference'}" + } + + {admin_sortable_header + current_order=$product_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Product title'}" + } + + {module_include location='product_list_header'} + + + {admin_sortable_header + current_order=$product_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Online'}" + } + + {admin_sortable_header + current_order=$product_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/categories' id_category=$category_id target='products'} + label="{intl l='Position'}" + } +  
{$ID} + {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"} + + {$TITLE} + + {/loop} + + {$REF}{$TITLE} {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"} -
- +
+
{/loop} {elseloop rel="can_change"} -
- -
+
+ +
{/elseloop} -
- {admin_position_block - permission="admin.product.edit" - path={url path='admin/product' category_id=$ID} - url_parameter="product_id" - in_place_edit_class="productPositionChange" - position=$POSITION - id=$ID - } - + {admin_position_block + permission="admin.product.edit" + path={url path='/admin/products/update-position' product_id=$ID} + url_parameter="product_id" + in_place_edit_class="productPositionChange" + position=$POSITION + id=$ID + } + -
- {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"} - - {/loop} +
+
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"} + + {/loop} - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.delete"} - - {/loop} -
-
{intl l="This category doesn't have any products. To add a new product, click the + button above."}
-
-
-
+ {elseloop rel="product_list"} + + +
{intl l="This category doesn't contains any products. To add a new product, click the + button above."}
+ + + {/elseloop} + - {module_include location='catalog_bottom'} -
+ +
+
+
+ + {module_include location='categories_bottom'} + + + + {module_include location='catalog_bottom'} - {* Adding a new Category *} - {form name="thelia.admin.category.creation"} +{* -- Adding a new category ------------------------------------------------- *} - {* Capture the dialog body, to pass it to the generic dialog *} - {capture "category_creation_dialog"} +{form name="thelia.admin.category.creation"} - {form_hidden_fields form=$form} + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "category_creation_dialog"} - {form_field form=$form field='success_url'} - {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} - - {/form_field} + {form_hidden_fields form=$form} - {form_field form=$form field='parent'} - - {/form_field} + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} - {form_field form=$form field='title'} -
- + {form_field form=$form field='parent'} + + {/form_field} - {loop type="lang" name="default-lang" default_only="1"} + {form_field form=$form field='title'} +
+ + {loop type="lang" name="default-lang" default_only="1"} +
+ + $TITLE +
-
- - $TITLE -
+
{intl l='Enter here the category name in the default language (%title)' title="$TITLE"}
-
{intl l='Enter here the category name in the default language (%title)' title="$TITLE"}
+ {* Switch edition to the current locale *} + - {* Switch edition to the current locale *} - + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
+ {/form_field} - {form_field form=$form field='locale'} - - {/form_field} - {/loop} -
- {/form_field} + {form_field form=$form field='visible'} +
+
+ +
+
+ {/form_field} - {module_include location='category_create_form'} - - {/capture} - - {include - file = "includes/generic-create-dialog.html" - - dialog_id = "add_category_dialog" - dialog_title = {intl l="Create a new category"} - dialog_body = {$smarty.capture.category_creation_dialog nofilter} - - dialog_ok_label = {intl l="Create this category"} - dialog_cancel_label = {intl l="Cancel"} - - form_action = {url path='/admin/categories/create'} - form_enctype = {form_enctype form=$form} - form_error_message = $form_error_message - } - {/form} - - {* Delete category confirmation dialog *} - - {capture "category_delete_dialog"} - - - - {module_include location='category_delete_form'} + {module_include location='category_create_form'} {/capture} {include - file = "includes/generic-confirm-dialog.html" + file = "includes/generic-create-dialog.html" - dialog_id = "delete_category_dialog" - dialog_title = {intl l="Delete a category"} - dialog_message = {intl l="Do you really want to delete this category, and all its contents ?"} + dialog_id = "category_creation_dialog" + dialog_title = {intl l="Create a new category"} + dialog_body = {$smarty.capture.category_creation_dialog nofilter} - form_action = {url path='/admin/categories/delete'} - form_content = {$smarty.capture.category_delete_dialog nofilter} + dialog_ok_label = {intl l="Create this category"} + + form_action = {url path='/admin/categories/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message } +{/form} + +{* -- Adding a new product -------------------------------------------------- *} + +{form name="thelia.admin.product.creation"} + + {* Capture the dialog body, to pass it to the generic dialog *} + {capture "product_creation_dialog"} + + {form_hidden_fields form=$form} + + {* Be sure to get the category_id, even if the form could not be validated *} + + + {form_field form=$form field='success_url'} + {* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *} + + {/form_field} + + {form_field form=$form field='default_category'} + + {/form_field} + + {form_field form=$form field='ref'} +
+ + +
+ +
+ +
{intl l='Enter here the product reference'}
+
+ {/form_field} + + {form_field form=$form field='title'} +
+ + {loop type="lang" name="default-lang" default_only="1"} +
+ + $TITLE +
+ +
{intl l='Enter here the product name in the default language (%title)' title="$TITLE"}
+ + {* Switch edition to the current locale *} + + + {form_field form=$form field='locale'} + + {/form_field} + {/loop} +
+ {/form_field} + + {form_field form=$form field='visible'} +
+
+ +
+
+ {/form_field} + + {module_include location='product_create_form'} + + {/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "product_creation_dialog" + dialog_title = {intl l="Create a new product"} + dialog_body = {$smarty.capture.product_creation_dialog nofilter} + + dialog_ok_label = {intl l="Create this product"} + + form_action = {url path='/admin/products/create'} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } +{/form} + +{* -- Delete category confirmation dialog ----------------------------------- *} + +{capture "category_delete_dialog"} + + + {module_include location='category_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "category_delete_dialog" + dialog_title = {intl l="Delete category"} + dialog_message = {intl l="Do you really want to delete this category and all its content ?"} + + form_action = {url path='/admin/categories/delete'} + form_content = {$smarty.capture.category_delete_dialog nofilter} +} + +{* -- Delete product confirmation dialog ------------------------------------ *} + +{capture "product_delete_dialog"} + + + + {module_include location='product_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "product_delete_dialog" + dialog_title = {intl l="Delete product"} + dialog_message = {intl l="Do you really want to delete this product ?"} + + form_action = {url path='/admin/products/delete'} + form_content = {$smarty.capture.product_delete_dialog nofilter} +} {/block} {block name="javascript-initialization"} - {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} - - {/javascripts} + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} - {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} - - {/javascripts} + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} - + {/block} \ No newline at end of file diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index e01849475..723cf8242 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -8,226 +8,337 @@
- {include file="includes/catalog-breadcrumb.html"} + {include file="includes/catalog-breadcrumb.html" editing_category="true"}
- {loop name="category_edit" type="category" visible="*" id="{$current_category_id}" backend_context="1" lang="$edit_language_id"} + {loop name="category_edit" type="category" visible="*" id="{$category_id}" backend_context="1" lang="$edit_language_id"}
- {intl l='Edit category'} + {intl l='Edit category %title' title=$TITLE}
- - - + + {if $HAS_PREVIOUS != 0} + + {else} + + {/if} + + + + {if $HAS_NEXT != 0} + + {else} + + {/if}
- +
+
-
- -
+
-
-
-
+
- {include file="includes/inner-form-toolbar.html" close_url="{url path='admin/catalog/category/edit' category_id=$current_category_id}"} +
-
-
-
- + {form name="thelia.admin.category.modification"} + -
- -
-
+ {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/categories' category_id=$category_id}"} -
- + {* Be sure to get the category ID, even if the form could not be validated *} + -
- -
-
+ -
- + {form_hidden_fields form=$form} -
- + {form_field form=$form field='success_url'} + + {/form_field} -
-
+ {form_field form=$form field='locale'} + + {/form_field} -
- + {if $form_error}
{$form_error_message}
{/if} -
- -
-
+ {include file="includes/standard-description-form-fields.html"} -
- + {form_field form=$form field='url'} +
+ -
- -
{intl l="The rewritten URL to the category page. Click \"Use Default\" button to use the default URL. Use only digits, letters, - and _ characters."}
-
-
+ +
+ {/form_field} -
-
+
+
+ {form_field form=$form field='parent'} +
-
-
-
-   -
-

{intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}

-
-
-
-
+ -
-
-
+ +
+ {/form_field} +
+ +
+ {form_field form=$form field='visible'} +
+ +
+ +
+
+ {/form_field} +
+
-
-
- - -
- -
-
-
- -
-
- - -
- -
-
-
-
- -
- - -
- +   +
+

{intl l='Category created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}

-
+
- -
-
+ + {/form} +
+
-
-

Images

-
+
+
+
+
-
- - {/loop} + {ifloop rel="folders"} +
+ +
+
+ +
+ {intl l='Select a folder to get its content'} +
+ +
+
+
+ + + + +
+ + {intl l='Select a content and click (+) to add it to this category'} +
+
+ +
+ {/ifloop} + + {elseloop rel="folders"} +
{intl l="No folders found"}
+ {/elseloop} + + +
+ + + + + + + + + {module_include location='category_contents_table_header'} + + + + + + + {loop name="assigned_contents" type="associated_content" category="$category_id" backend_context="1" lang="$edit_language_id"} + + + + + + {module_include location='category_contents_table_row'} + + + + {/loop} + + {elseloop rel="assigned_contents"} + + + + {/elseloop} + +
{intl l='ID'}{intl l='Attribute title'}{intl l="Actions"}
{$ID} + {$TITLE} + +
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.category.content.delete"} + + + + {/loop} +
+
+
+ {intl l="This category contains no contents"} +
+
+
+
+ +
+
+ +
+
+ +
+
+ + + + {/loop} + + +{* 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 ?"} + + form_action = {url path='/admin/categories/related-content/delete'} + form_content = {$smarty.capture.delete_content_dialog nofilter} +} {/block} {block name="javascript-initialization"} {/block} \ No newline at end of file diff --git a/templates/admin/default/currency-edit.html b/templates/admin/default/currency-edit.html index cc7ac16ac..57b511903 100644 --- a/templates/admin/default/currency-edit.html +++ b/templates/admin/default/currency-edit.html @@ -54,7 +54,7 @@ {form_field form=$form field='name'}
- +  
{/form_field} @@ -64,7 +64,7 @@ - + List of ISO 4217 code @@ -80,7 +80,7 @@ - + {intl l='The symbol, such as $, £, €...'} {/form_field} @@ -90,7 +90,7 @@ - + The rate from Euro: Price in Euro x rate = Price in this currency {/form_field} diff --git a/templates/admin/default/includes/catalog-breadcrumb.html b/templates/admin/default/includes/catalog-breadcrumb.html index b9312f0dd..8bbe69088 100644 --- a/templates/admin/default/includes/catalog-breadcrumb.html +++ b/templates/admin/default/includes/catalog-breadcrumb.html @@ -5,17 +5,17 @@
  • Catalog {ifloop rel="category_path"}
  • - {loop name="category_path" type="category-path" visible="*" category=$current_category_id} - {if $ID == $current_category_id} + {loop name="category_path" type="category-path" visible="*" category=$category_id} + {if $ID == $category_id}
  • - {if $action == 'edit'} - {intl l='Editing %cat' cat="{$TITLE}"} + {if $editing_category == true} + {intl l='Editing %cat' cat="{$TITLE}"} {else} - {$TITLE} {intl l="(edit)"} + {$TITLE} {intl l="(edit)"} {/if}
  • {else} -
  • {$TITLE}
  • +
  • {$TITLE}
  • {/if} {/loop} {/ifloop} diff --git a/templates/admin/default/includes/inner-form-toolbar.html b/templates/admin/default/includes/inner-form-toolbar.html index c142cbdd7..39da9fce7 100755 --- a/templates/admin/default/includes/inner-form-toolbar.html +++ b/templates/admin/default/includes/inner-form-toolbar.html @@ -21,8 +21,10 @@
    + {if $hide_submit_buttons != true} + {/if} {if ! empty($close_url)} {intl l='Close'} {/if} diff --git a/templates/admin/default/message-edit.html b/templates/admin/default/message-edit.html index db6118c05..51e97d61d 100644 --- a/templates/admin/default/message-edit.html +++ b/templates/admin/default/message-edit.html @@ -43,7 +43,7 @@ {/form_field} {form_field form=$form field='id'} - + {/form_field} {form_field form=$form field='locale'} @@ -55,7 +55,7 @@ {form_field form=$form field='name'}
    - +
    {/form_field} @@ -71,14 +71,14 @@ {form_field form=$form field='title'}
    - +
    {/form_field} {form_field form=$form field='subject'}
    - +
    {/form_field} @@ -88,7 +88,7 @@ {intl l="{$label}"} : {intl l="The mailing template in HTML format."} - +
    {/form_field} @@ -98,7 +98,7 @@ {intl l="{$label}"} : {intl l="The mailing template in text-only format."} - + {/form_field} diff --git a/templates/admin/default/orders.html b/templates/admin/default/orders.html index 4f9c6ecf8..dcf9ef7e3 100644 --- a/templates/admin/default/orders.html +++ b/templates/admin/default/orders.html @@ -59,7 +59,7 @@
    {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - + {/loop} {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} @@ -83,7 +83,7 @@
    {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - + {/loop} {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} @@ -107,7 +107,7 @@
    {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - + {/loop} {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} diff --git a/templates/admin/default/variable-edit.html b/templates/admin/default/variable-edit.html index 7e634b92a..30d9ea7c5 100644 --- a/templates/admin/default/variable-edit.html +++ b/templates/admin/default/variable-edit.html @@ -45,7 +45,7 @@ {* We do not allow creation of hidden variables *} {form_field form=$form field='id'} - + {/form_field} {form_field form=$form field='hidden'} @@ -61,14 +61,14 @@ {form_field form=$form field='name'}
    - +
    {/form_field} {form_field form=$form field='value'}
    - +
    {/form_field} diff --git a/templates/admin/default/variables.html b/templates/admin/default/variables.html index 3f1e90a09..6100466bd 100644 --- a/templates/admin/default/variables.html +++ b/templates/admin/default/variables.html @@ -95,7 +95,7 @@ {if $SECURED} {$VALUE} {else} - + {/if} diff --git a/templates/default/account.html b/templates/default/account.html index 94bd58501..cffd5d754 100644 --- a/templates/default/account.html +++ b/templates/default/account.html @@ -1,6 +1,9 @@ -{check_auth context="front" roles="CUSTOMER" login_tpl="login"} {extends file="layout.tpl"} +{block name="no-return-functions"} + {check_auth context="front" roles="CUSTOMER" login_tpl="login"} +{/block} + {block name="breadcrumb"}
    diff --git a/templates/install/index.html b/templates/install/index.html deleted file mode 100644 index dd1d5f62b..000000000 --- a/templates/install/index.html +++ /dev/null @@ -1,46 +0,0 @@ -{extends file="layout.tpl"} - -{block name="page-title"}{intl l='Installation'}{/block} - -{block name="main-content"} -
    -
    - -
    -
    -
    - -

    {intl l="Thelia installation wizard"}

    - -
    -
      -
    • 1{intl l="Welcome"}
    • -
    • 2{intl l="Checking permissions"}
    • -
    • 3{intl l="Database connection"}
    • -
    • 4{intl l="Database selection"}
    • -
    • 5{intl l="General information"}
    • -
    • 6{intl l="Thanks"}
    • -
    -
    - -
    -

    - {intl l="Welcome in the Thelia installation wizard."} -

    -

    - {intl l="We will guide you throughout this process to install any application on your system."} -

    - -
    - - - -
    -
    -
    - -
    -
    -{/block} \ No newline at end of file diff --git a/templates/install/layout.tpl b/templates/install/layout.tpl deleted file mode 100644 index 4539ce32f..000000000 --- a/templates/install/layout.tpl +++ /dev/null @@ -1,62 +0,0 @@ - - - - {block name="page-title"}Thelia Install{/block} - - {images file='../admin/default/assets/img/favicon.ico'}{/images} - - - - {stylesheets file='../admin/default/assets/less/*' filters='less,cssembed'} - - {/stylesheets} - - - -
    -
    - -
    -
    -
    {intl l='Version %ver' ver="{$THELIA_VERSION}"}
    -
    -
    - -
    -
    - - {* -- Main page content section ----------------------------------------- *} - - {block name="main-content"}Put here the content of the template{/block} - - {* -- Footer section ---------------------------------------------------- *} - -
    - - - {* -- Javascript section ------------------------------------------------ *} - - - - {block name="after-javascript-include"}{/block} - - {javascripts file='../admin/default/assets/js/bootstrap/bootstrap.js'} - - {/javascripts} - - {block name="javascript-initialization"}{/block} - - - \ No newline at end of file diff --git a/templates/install/step-2.html b/templates/install/step-2.html deleted file mode 100644 index fc24d25cb..000000000 --- a/templates/install/step-2.html +++ /dev/null @@ -1,51 +0,0 @@ -{extends file="layout.tpl"} - -{block name="page-title"}{intl l='Installation step 2'}{/block} - -{block name="main-content"} -
    -
    - -
    -
    -
    - -

    {intl l="Thelia installation wizard"}

    - -
    -
      -
    • 1{intl l="Welcome"}
    • -
    • 2{intl l="Checking permissions"}
    • -
    • 3{intl l="Database connection"}
    • -
    • 4{intl l="Database selection"}
    • -
    • 5{intl l="General information"}
    • -
    • 6{intl l="Thanks"}
    • -
    -
    - -
    -

    We will check some rights to files and directories...

    -
      -
    • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
    • -
    • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
    • -
    • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
    • -
    • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
    • -
    • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
    • -
    • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
    • -
    • Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
    • -
    - -
    - - - -
    -
    -
    - -
    -
    -{/block} \ No newline at end of file diff --git a/templates/install/step-3.html b/templates/install/step-3.html deleted file mode 100644 index cb4157dd7..000000000 --- a/templates/install/step-3.html +++ /dev/null @@ -1,56 +0,0 @@ -{extends file="layout.tpl"} - -{block name="page-title"}{intl l='Installation step 3'}{/block} - -{block name="main-content"} -
    -
    - -
    -
    -
    - -

    {intl l="Thelia installation wizard"}

    - -
    - -
    - -
    - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - -
    - - - -
    -
    -
    - -
    -
    -{/block} \ No newline at end of file diff --git a/templates/install/step-4.html b/templates/install/step-4.html deleted file mode 100644 index 981be34bb..000000000 --- a/templates/install/step-4.html +++ /dev/null @@ -1,77 +0,0 @@ -{extends file="layout.tpl"} - -{block name="page-title"}{intl l='Installation step 4'}{/block} - -{block name="main-content"} -
    -
    - -
    -
    -
    - -

    {intl l="Thelia installation wizard"}

    - -
    - -
    - -
    -
    -
    - {intl l="Choose your database"} -

    - The SQL server contains multiple databases.
    - Select below the one you want to use. -

    - -
    - -
    -
    - -
    - -

    - {intl l="or"} -

    - -
    - -
    - -
    - -
    -
    -
    -
    - - - -
    -
    -
    - -
    -
    -{/block} \ No newline at end of file diff --git a/templates/install/step-5.html b/templates/install/step-5.html deleted file mode 100644 index 611a86a20..000000000 --- a/templates/install/step-5.html +++ /dev/null @@ -1,72 +0,0 @@ -{extends file="layout.tpl"} - -{block name="page-title"}{intl l='Installation step 4'}{/block} - -{block name="main-content"} -
    -
    - -
    -
    -
    - -

    {intl l="Thelia installation wizard"}

    - - - -
    -
    - -

    - The system will now you create a custom site access. -

    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    -
    - - - -
    -
    -
    - -
    -
    -{/block} \ No newline at end of file diff --git a/templates/install/thanks.html b/templates/install/thanks.html deleted file mode 100644 index b6ed27065..000000000 --- a/templates/install/thanks.html +++ /dev/null @@ -1,42 +0,0 @@ -{extends file="layout.tpl"} - -{block name="page-title"}{intl l='Thanks'}{/block} - -{block name="main-content"} -
    -
    - -
    -
    -
    - -

    {intl l="Thelia installation wizard"}

    - - - -
    -

    - {intl l="Thank you have installed Thelia"}. -

    -

    - {intl l="You will be redirected to your personal space in order to manage your store now."} -

    - -
    - -
    -
    -
    - -
    -
    -{/block} \ No newline at end of file diff --git a/web/.htaccess b/web/.htaccess new file mode 100755 index 000000000..3840d727a --- /dev/null +++ b/web/.htaccess @@ -0,0 +1,12 @@ +Options +FollowSymlinks -Indexes + +AddDefaultCharset UTF-8 + + + RewriteEngine On + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + + RewriteRule ^(.*)$ index.php [QSA,L] + \ No newline at end of file diff --git a/web/index_dev.php b/web/index_dev.php index bb90e6ab0..16c7d5f71 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -51,5 +51,7 @@ $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); -echo "\n"; -echo "\n"; +if (strstr($response->headers->get('content-type'), 'text/html') !== false) { + echo "\n"; + echo "\n"; +} diff --git a/web/install/bdd.php b/web/install/bdd.php new file mode 100755 index 000000000..05fcfe762 --- /dev/null +++ b/web/install/bdd.php @@ -0,0 +1,119 @@ +. */ +/* */ +/*************************************************************************************/ + +$step=4; +include("header.php"); + +if (isset($_POST['host']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['port'])){ + + $_SESSION['install']['host'] = $_POST['host']; + $_SESSION['install']['username'] = $_POST['username']; + $_SESSION['install']['password'] = $_POST['password']; + $_SESSION['install']['port'] = $_POST['port']; + + $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_POST['host'], $_POST['username'], $_POST['password'], $_POST['port']); + if(! $checkConnection->exec() || $checkConnection->getConnection()->query('show databases') === false){ + header('location: connection.php?err=1'); + exit; + } +} +elseif($_SESSION['install']['step'] >=3) { + + $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_SESSION['install']['host'], $_SESSION['install']['username'], $_SESSION['install']['password'], $_SESSION['install']['port']); +} +else { + header('location: connection.php?err=1'); + exit; +} +$_SESSION['install']['step'] = 4; +$connection = $checkConnection->getConnection(); + +$databases = $connection->query('show databases'); +?> +
    +
    +
    + Choose your database +

    + The SQL server contains multiple databases.
    + Select below the one you want to use. +

    + + + exec(sprintf('use %s', $database['Database'])); + + $tables = $connection->query('SHOW TABLES'); + + $found = false; + foreach($tables as $table) { + if($table[0] == 'cart_item') { + $found = true; + break; + } + } + + ?> +
    + +
    + + exec('use information_schema'); + + $permissions = $connection->query("SELECT COUNT( * ) FROM `USER_PRIVILEGES` + WHERE PRIVILEGE_TYPE = 'CREATE' + AND GRANTEE LIKE '%".$_SESSION['install']['username']."%' + AND IS_GRANTABLE = 'YES';"); + + $writePermission = false; + if($permissions->fetchColumn(0) > 0) { + ?> +

    + or +

    + +
    + +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + + \ No newline at end of file diff --git a/web/install/bootstrap.php b/web/install/bootstrap.php new file mode 100755 index 000000000..522f6483b --- /dev/null +++ b/web/install/bootstrap.php @@ -0,0 +1,27 @@ +. */ +/* */ +/*************************************************************************************/ + +include __DIR__ . "/../../core/bootstrap.php"; + +$thelia = new \Thelia\Core\Thelia("install", false); +$thelia->boot(); \ No newline at end of file diff --git a/web/install/config.php b/web/install/config.php new file mode 100755 index 000000000..9ba221cdd --- /dev/null +++ b/web/install/config.php @@ -0,0 +1,110 @@ +. */ +/* */ +/*************************************************************************************/ + +$step = 5; +include("header.php"); +global $thelia; +$err = isset($_GET['err']) && $_GET['err']; + +if (!$err && $_SESSION['install']['step'] != $step) { + $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_SESSION['install']['host'], $_SESSION['install']['username'], $_SESSION['install']['password'], $_SESSION['install']['port']); + $connection = $checkConnection->getConnection(); + $connection->exec("SET NAMES UTF8"); + $database = new \Thelia\Install\Database($connection); + + if (isset($_POST['database'])) { + $_SESSION['install']['database'] = $_POST['database']; + } + + if (isset($_POST['database_create']) && $_POST['database_create'] != "") { + $_SESSION['install']['database'] = $_POST['database_create']; + $database->createDatabase($_SESSION['install']['database']); + } + + $database->insertSql($_SESSION['install']['database']); + + if(!file_exists(THELIA_ROOT . "/local/config/database.yml")) { + $fs = new \Symfony\Component\Filesystem\Filesystem(); + + $sampleConfigFile = THELIA_ROOT . "/local/config/database.yml.sample"; + $configFile = THELIA_ROOT . "/local/config/database.yml"; + + $fs->copy($sampleConfigFile, $configFile, true); + + $configContent = file_get_contents($configFile); + + $configContent = str_replace("%DRIVER%", "mysql", $configContent); + $configContent = str_replace("%USERNAME%", $_SESSION['install']['username'], $configContent); + $configContent = str_replace("%PASSWORD%", $_SESSION['install']['password'], $configContent); + $configContent = str_replace( + "%DSN%", + sprintf("mysql:host=%s;dbname=%s;port=%s", $_SESSION['install']['host'], $_SESSION['install']['database'], $_SESSION['install']['port']), + $configContent + ); + + file_put_contents($configFile, $configContent); + + // FA - no, as no further install will be possible + // $fs->remove($sampleConfigFile); + + $fs->remove($thelia->getContainer()->getParameter("kernel.cache_dir")); + } +} + +$_SESSION['install']['step'] = $step; + +?> +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    + +
    + +
    +
    + +
    + + + diff --git a/web/install/connection.php b/web/install/connection.php new file mode 100755 index 000000000..fdbddfafd --- /dev/null +++ b/web/install/connection.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ + +$step = 3; +include("header.php"); +if(!$_SESSION['install']['continue'] && $_SESSION['install']['step'] == 2) { + header(sprintf('location: %s', $_SESSION['install']['return_step'])); +} + +$_SESSION['install']['step'] = 3; +?> + +
    + +
    Wrong connection information
    + +
    +
    + + +
    + +
    + + +
    + +
    + + +
    +
    + + +
    + +
    + +
    +
    + +
    + +
    +
    + + \ No newline at end of file diff --git a/web/install/end.php b/web/install/end.php new file mode 100755 index 000000000..a86c2d903 --- /dev/null +++ b/web/install/end.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ +$step=6; +include "header.php"; + +if($_SESSION['install']['step'] != $step && (empty($_POST['admin_login']) || empty($_POST['admin_password']) || ($_POST['admin_password'] != $_POST['admin_password_verif']))) { + header('location: config.php?err=1'); +} + +if($_SESSION['install']['step'] == 5) { + $admin = new \Thelia\Model\Admin(); + $admin->setLogin($_POST['admin_login']) + ->setPassword($_POST['admin_password']) + ->setFirstname('admin') + ->setLastname('admin') + ->save(); + + $config = new \Thelia\Model\Config(); + $config->setName('contact_email') + ->setValue($_POST['email_contact']) + ->save(); + ; +} + +$_SESSION['install']['step'] = $step; +?> + +
    +

    + Thank you have installed Thelia +

    +

    + Don't forget to delete the web/install directory. +

    + +
    + \ No newline at end of file diff --git a/web/install/fd33fd0-6fda040.ico b/web/install/fd33fd0-6fda040.ico new file mode 100755 index 000000000..24c27fefd Binary files /dev/null and b/web/install/fd33fd0-6fda040.ico differ diff --git a/web/install/footer.php b/web/install/footer.php new file mode 100755 index 000000000..29e87f2c2 --- /dev/null +++ b/web/install/footer.php @@ -0,0 +1,41 @@ +. */ +/* */ +/*************************************************************************************/ +?> +
    + + + + +
    + + + + \ No newline at end of file diff --git a/web/install/header.php b/web/install/header.php new file mode 100755 index 000000000..983fa51ce --- /dev/null +++ b/web/install/header.php @@ -0,0 +1,59 @@ +. */ +/* */ +/*************************************************************************************/ +session_start(); +include 'bootstrap.php'; +?> + + + + Installation + + + + + +
    +
    +
    +
    +
    Version undefined
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Thelia installation wizard

    +
    +
      +
    • 1Welcome
    • +
    • 2Checking permissions
    • +
    • 3Database connection
    • +
    • 4Database selection
    • +
    • 5General information
    • +
    • 6Thanks
    • +
    +
    \ No newline at end of file diff --git a/web/install/index.php b/web/install/index.php new file mode 100755 index 000000000..884ca11b7 --- /dev/null +++ b/web/install/index.php @@ -0,0 +1,39 @@ +. */ +/* */ +/*************************************************************************************/ +?> + +
    +

    +Welcome in the Thelia installation wizard. +

    +

    +We will guide you throughout this process to install any application on your system. +

    +
    + + \ No newline at end of file diff --git a/web/install/permission.php b/web/install/permission.php new file mode 100755 index 000000000..fca995457 --- /dev/null +++ b/web/install/permission.php @@ -0,0 +1,56 @@ +. */ +/* */ +/*************************************************************************************/ +?> +getContainer()->get('thelia.translator')); +$isValid = $checkPermission->exec(); +$validationMessage = $checkPermission->getValidationMessages(); +$_SESSION['install']['return_step'] = 'permission.php'; +$_SESSION['install']['continue'] = $isValid; +$_SESSION['install']['current_step'] = 'permission.php'; +$_SESSION['install']['step'] = 2; +?> +
    +

    Checking permissions

    +
      + $data): ?> +
    • + + +
    • + +
    + +
    +
    + + Continue + + refresh + +
    + \ No newline at end of file diff --git a/web/install/script.js b/web/install/script.js new file mode 100755 index 000000000..b26e7612e --- /dev/null +++ b/web/install/script.js @@ -0,0 +1,1999 @@ +/** + * bootstrap.js v3.0.0 by @fat and @mdo + * Copyright 2013 Twitter Inc. + * http://www.apache.org/licenses/LICENSE-2.0 + */ +if (!jQuery) { throw new Error("Bootstrap requires jQuery") } + +/* ======================================================================== + * Bootstrap: transition.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#transitions + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) + // ============================================================ + + function transitionEnd() { + var el = document.createElement('bootstrap') + + var transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + } + + for (var name in transEndEventNames) { + if (el.style[name] !== undefined) { + return { end: transEndEventNames[name] } + } + } + } + + // http://blog.alexmaccaw.com/css-transitions + $.fn.emulateTransitionEnd = function (duration) { + var called = false, $el = this + $(this).one($.support.transition.end, function () { called = true }) + var callback = function () { if (!called) $($el).trigger($.support.transition.end) } + setTimeout(callback, duration) + return this + } + + $(function () { + $.support.transition = transitionEnd() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: alert.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#alerts + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // ALERT CLASS DEFINITION + // ====================== + + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } + + var $parent = $(selector) + + if (e) e.preventDefault() + + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } + + $parent.trigger(e = $.Event('close.bs.alert')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent.trigger('closed.bs.alert').remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : + removeElement() + } + + + // ALERT PLUGIN DEFINITION + // ======================= + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') + + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + // ALERT NO CONFLICT + // ================= + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + // ALERT DATA-API + // ============== + + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: button.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#buttons + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // BUTTON PUBLIC CLASS DEFINITION + // ============================== + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() + + state = state + 'Text' + + if (!data.resetText) $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d); + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + .prop('checked', !this.$element.hasClass('active')) + .trigger('change') + if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + } + + this.$element.toggleClass('active') + } + + + // BUTTON PLUGIN DEFINITION + // ======================== + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.Constructor = Button + + + // BUTTON NO CONFLICT + // ================== + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + // BUTTON DATA-API + // =============== + + $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + e.preventDefault() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: carousel.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#carousel + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.DEFAULTS = { + interval: 5000 + , pause: 'hover' + , wrap: true + } + + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) + + this.interval && clearInterval(this.interval) + + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + + return this + } + + Carousel.prototype.getActiveIndex = function () { + this.$active = this.$element.find('.item.active') + this.$items = this.$active.parent().children() + + return this.$items.index(this.$active) + } + + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getActiveIndex() + + if (pos > (this.$items.length - 1) || pos < 0) return + + if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } + + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle(true) + } + + this.interval = clearInterval(this.interval) + + return this + } + + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } + + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } + + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this + + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() + } + + this.sliding = true + + isCycling && this.pause() + + var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + + if ($next.hasClass('active')) return + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + this.$element.one('slid', function () { + var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) + $nextIndicator && $nextIndicator.addClass('active') + }) + } + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + .emulateTransitionEnd(600) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') + } + + isCycling && this.cycle() + + return this + } + + + // CAROUSEL PLUGIN DEFINITION + // ========================== + + var old = $.fn.carousel + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } + + $.fn.carousel.Constructor = Carousel + + + // CAROUSEL NO CONFLICT + // ==================== + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + + + // CAROUSEL DATA-API + // ================= + + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var $this = $(this), href + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false + + $target.carousel(options) + + if (slideIndex = $this.attr('data-slide-to')) { + $target.data('bs.carousel').to(slideIndex) + } + + e.preventDefault() + }) + + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + $carousel.carousel($carousel.data()) + }) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: collapse.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#collapse + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // COLLAPSE PUBLIC CLASS DEFINITION + // ================================ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Collapse.DEFAULTS, options) + this.transitioning = null + + if (this.options.parent) this.$parent = $(this.options.parent) + if (this.options.toggle) this.toggle() + } + + Collapse.DEFAULTS = { + toggle: true + } + + Collapse.prototype.dimension = function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + Collapse.prototype.show = function () { + if (this.transitioning || this.$element.hasClass('in')) return + + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var actives = this.$parent && this.$parent.find('> .panel > .in') + + if (actives && actives.length) { + var hasData = actives.data('bs.collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('bs.collapse', null) + } + + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + .addClass('collapsing') + [dimension](0) + + this.transitioning = 1 + + var complete = function () { + this.$element + .removeClass('collapsing') + .addClass('in') + [dimension]('auto') + this.transitioning = 0 + this.$element.trigger('shown.bs.collapse') + } + + if (!$.support.transition) return complete.call(this) + + var scrollSize = $.camelCase(['scroll', dimension].join('-')) + + this.$element + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + [dimension](this.$element[0][scrollSize]) + } + + Collapse.prototype.hide = function () { + if (this.transitioning || !this.$element.hasClass('in')) return + + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var dimension = this.dimension() + + this.$element + [dimension](this.$element[dimension]()) + [0].offsetHeight + + this.$element + .addClass('collapsing') + .removeClass('collapse') + .removeClass('in') + + this.transitioning = 1 + + var complete = function () { + this.transitioning = 0 + this.$element + .trigger('hidden.bs.collapse') + .removeClass('collapsing') + .addClass('collapse') + } + + if (!$.support.transition) return complete.call(this) + + this.$element + [dimension](0) + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + } + + Collapse.prototype.toggle = function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + + // COLLAPSE PLUGIN DEFINITION + // ========================== + + var old = $.fn.collapse + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.collapse') + var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.Constructor = Collapse + + + // COLLAPSE NO CONFLICT + // ==================== + + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + // COLLAPSE DATA-API + // ================= + + $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + var target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + var $target = $(target) + var data = $target.data('bs.collapse') + var option = data ? 'toggle' : $this.data() + var parent = $this.attr('data-parent') + var $parent = parent && $(parent) + + if (!data || !data.transitioning) { + if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') + $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + } + + $target.collapse(option) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: dropdown.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + var $el = $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we we use a backdrop because click events don't delegate + $('