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/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 a34f4a85e..64254d734 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -36,6 +36,10 @@ use Thelia\Core\Event\CategoryDeleteEvent; use Thelia\Model\ConfigQuery; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\CategoryAddContentEvent; +use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery; class Category extends BaseAction implements EventSubscriberInterface { @@ -147,6 +151,33 @@ class Category extends BaseAction implements EventSubscriberInterface } } + 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() + ; + } + } + + public function removeContent(CategoryDeleteContentEvent $event) { + + $content = CategoryAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByCategory($event->getCategory())->findOne() + ; + + if ($content !== null) $content->delete(); + } + + /** * {@inheritDoc} */ @@ -157,7 +188,12 @@ class Category extends BaseAction implements EventSubscriberInterface TheliaEvents::CATEGORY_UPDATE => array("update", 128), TheliaEvents::CATEGORY_DELETE => array("delete", 128), TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128), - TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 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/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/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..d2deb7688 --- /dev/null +++ b/core/lib/Thelia/Action/Product.php @@ -0,0 +1,199 @@ +. */ +/* */ +/*************************************************************************************/ + +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; + +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()) + + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setParent($event->getParent()) + ->setVisible($event->getVisible()) + + ->save() + ; + + $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/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 2a344bad9..c0199652d 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -24,6 +24,7 @@ + @@ -40,6 +41,8 @@ +
+ @@ -53,11 +56,17 @@ + + + + + + @@ -201,6 +210,7 @@ + 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 53c137988..af7c950af 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -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 5b7f8b60a..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; } diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 83d90c86e..4d0d15ef1 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -32,6 +32,13 @@ 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; /** * Manages categories @@ -126,7 +133,7 @@ class CategoryController extends AbstractCrudController 'description' => $object->getDescription(), 'postscriptum' => $object->getPostscriptum(), 'visible' => $object->getVisible(), - 'url' => $object->getRewritenUrl($this->getCurrentEditionLocale()), + 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), 'parent' => $object->getParent() ); @@ -152,31 +159,42 @@ class CategoryController extends AbstractCrudController 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') + ); + } + 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) - ) - ); - } - - protected function renderEditionTemplate() { - return $this->render('category-edit', array('category_id' => $this->getRequest()->get('category_id', 0))); - } - - protected function redirectToEditionTemplate() { - $this->redirectToRoute( - "admin.categories.update", - array('category_id' => $this->getRequest()->get('category_id', 0)) - ); + )); } protected function redirectToListTemplate() { $this->redirectToRoute( 'admin.categories.default', array('category_id' => $this->getRequest()->get('category_id', 0)) - ); + ); + } + + protected function renderEditionTemplate() { + + return $this->render('category-edit', $this->getEditionArguments()); + } + + protected function redirectToEditionTemplate() { + $this->redirectToRoute("admin.categories.update", $this->getEditionArguments()); } /** @@ -209,6 +227,18 @@ class CategoryController extends AbstractCrudController ); } + 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) { @@ -224,4 +254,81 @@ class CategoryController extends AbstractCrudController 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; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new CategoryAddContentEvent( + $this->getExistingObject(), + $content_id + ); + + try { + $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteRelatedContentAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new CategoryDeleteContentEvent( + $this->getExistingObject(), + $content_id + ); + + 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/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php new file mode 100644 index 000000000..b167922e0 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -0,0 +1,350 @@ +. */ +/* */ +/*************************************************************************************/ + +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 + ->setTitle($formData['title']) + ->setLocale($formData["locale"]) + ->setParent($formData['parent']) + ->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()), + 'parent' => $object->getParent() + ); + + // 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( + '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 renderListTemplate($currentOrder) + { + $this->getListOrderFromSession('product', 'product_order', 'manual'); + + return $this->render('categories', + array( + 'product_order' => $currentOrder, + 'product_id' => $this->getRequest()->get('product_id', 0) + )); + } + + protected function redirectToListTemplate() + { + // Redirect to the product default category list + $product = $this->getExistingObject(); + + $this->redirectToRoute( + 'admin.products.default', + array('category_id' => $product != null ? $product->getDefaultCategory() : 0) + ); + } + + 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' => $deleteEvent->getProduct()->getDefaultCategory()) + ); + } + + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent product list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $product->getDefaultCategory()) + ); + } + } + + protected function performAdditionalUpdatePositionAction($event) + { + $product = ProductQuery::create()->findPk($event->getObjectId()); + + if ($product != null) { + // Redirect to parent product list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $product->getDefaultCategory()) + ); + } + + return null; + } + + 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/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 3c4c0a5bc..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() { 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/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/Controller/Install/BaseInstallController.php b/core/lib/Thelia/Core/Event/DocumentEvent.php similarity index 69% rename from core/lib/Thelia/Controller/Install/BaseInstallController.php rename to core/lib/Thelia/Core/Event/DocumentEvent.php index bac7a4f19..f58d51083 100644 --- a/core/lib/Thelia/Controller/Install/BaseInstallController.php +++ b/core/lib/Thelia/Core/Event/DocumentEvent.php @@ -21,39 +21,47 @@ /* */ /*************************************************************************************/ -namespace Thelia\Controller\Install; -use Symfony\Component\HttpFoundation\Response; -use Thelia\Controller\BaseController; +namespace Thelia\Core\Event; -/** - * Class BaseInstallController - * @package Thelia\Controller\Install - * @author Manuel Raynaud - */ -class BaseInstallController extends BaseController +class DocumentEvent extends CachedFileEvent { + protected $document_path; + protected $document_url; + /** - * @return a ParserInterface instance parser + * @return the document file path */ - protected function getParser() + public function getDocumentPath() { - $parser = $this->container->get("thelia.parser"); - - // Define the template that shoud be used - $parser->setTemplate("install"); - - return $parser; + return $this->document_path; } - public function render($templateName, $args = array()) + /** + * @param string $document_path the document file path + */ + public function setDocumentPath($document_path) { - return new Response($this->renderRaw($templateName, $args)); + $this->document_path = $document_path; + + return $this; } - public function renderRaw($templateName, $args = array()) + /** + * @return the document URL + */ + public function getDocumentUrl() { - $data = $this->getParser()->render($templateName, $args); - - return $data; + 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/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..51be86e25 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductCreateEvent.php @@ -0,0 +1,80 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +class ProductCreateEvent extends ProductEvent +{ + protected $title; + protected $parent; + protected $locale; + protected $visible; + + public function getTitle() + { + return $this->title; + } + + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent($parent) + { + $this->parent = $parent; + + return $this; + } + + public function getLocale() + { + return $this->locale; + } + + public function setLocale($locale) + { + $this->locale = $locale; + + 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 ffa87f11c..dab2db208 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -153,6 +153,9 @@ final class TheliaEvents const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition"; + const CATEGORY_ADD_CONTENT = "action.categoryAddContent"; + const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent"; + const BEFORE_CREATECATEGORY = "action.before_createcategory"; const AFTER_CREATECATEGORY = "action.after_createcategory"; @@ -162,6 +165,26 @@ final class TheliaEvents const BEFORE_UPDATECATEGORY = "action.before_updateCategory"; 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 */ @@ -189,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"; 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/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..c85d41fc7 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->getSource()."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); @@ -259,14 +262,13 @@ class Image extends BaseI18nLoop } - // echo "sql=".$search->toString(); + //echo "sql=".$search->toString(); $results = $this->search($search, $pagination); $loopResult = new LoopResult($results); foreach ($results as $result) { - // Create image processing event $event = new ImageEvent($this->request); @@ -282,7 +284,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() ); 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..59f83f8fc 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; 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/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 172b09ee6..6a0172180 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -43,15 +43,18 @@ class CategoryCreationForm extends BaseForm "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 on the front office.") + "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 42b5893c1..943c0d941 100644 --- a/core/lib/Thelia/Form/CategoryModificationForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -39,7 +39,8 @@ class CategoryModificationForm extends CategoryCreationForm ->add("url", "text", array( "label" => Translator::getInstance()->trans("Rewriten URL *"), - "constraints" => array(new NotBlank()) + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url") )) ; 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..49ab76fb7 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -47,7 +47,7 @@ class ProductCreationForm extends BaseForm "for" => "title" ) )) - ->add("parent", "integer", array( + ->add("default_category", "integer", array( "constraints" => array( new NotBlank() ) @@ -57,7 +57,11 @@ 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 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..d07b8ed83 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -23,56 +23,364 @@ 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'; - public function __construct($verifyInstall = true) + /** @var array Directory needed to be writable */ + protected $directoriesToBeWritable = array( + self::DIR_CONF, + self::DIR_LOG, + self::DIR_CACHE, + ); + + /** @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/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/DelivzoneQuery.php b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php similarity index 53% rename from core/lib/Thelia/Model/Base/DelivzoneQuery.php rename to core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php index e4b8a8ab5..394fe651e 100644 --- a/core/lib/Thelia/Model/Base/DelivzoneQuery.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php @@ -12,80 +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\Delivzone as ChildDelivzone; -use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery; -use Thelia\Model\Map\DelivzoneTableMap; +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 'delivzone' table. + * Base class that represents a query for the 'area_delivery_module' table. * * * - * @method ChildDelivzoneQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildDelivzoneQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column - * @method ChildDelivzoneQuery orderByDelivery($order = Criteria::ASC) Order by the delivery column - * @method ChildDelivzoneQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ChildDelivzoneQuery 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 ChildDelivzoneQuery groupById() Group by the id column - * @method ChildDelivzoneQuery groupByAreaId() Group by the area_id column - * @method ChildDelivzoneQuery groupByDelivery() Group by the delivery column - * @method ChildDelivzoneQuery groupByCreatedAt() Group by the created_at column - * @method ChildDelivzoneQuery 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 ChildDelivzoneQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildDelivzoneQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildDelivzoneQuery 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 ChildDelivzoneQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation - * @method ChildDelivzoneQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation - * @method ChildDelivzoneQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area 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 ChildDelivzone findOne(ConnectionInterface $con = null) Return the first ChildDelivzone matching the query - * @method ChildDelivzone findOneOrCreate(ConnectionInterface $con = null) Return the first ChildDelivzone matching the query, or a new ChildDelivzone object populated from the query conditions when no match is found + * @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 ChildDelivzone findOneById(int $id) Return the first ChildDelivzone filtered by the id column - * @method ChildDelivzone findOneByAreaId(int $area_id) Return the first ChildDelivzone filtered by the area_id column - * @method ChildDelivzone findOneByDelivery(string $delivery) Return the first ChildDelivzone filtered by the delivery column - * @method ChildDelivzone findOneByCreatedAt(string $created_at) Return the first ChildDelivzone filtered by the created_at column - * @method ChildDelivzone findOneByUpdatedAt(string $updated_at) Return the first ChildDelivzone filtered by the updated_at column + * @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 array findById(int $id) Return ChildDelivzone objects filtered by the id column - * @method array findByAreaId(int $area_id) Return ChildDelivzone objects filtered by the area_id column - * @method array findByDelivery(string $delivery) Return ChildDelivzone objects filtered by the delivery column - * @method array findByCreatedAt(string $created_at) Return ChildDelivzone objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_at) Return ChildDelivzone objects 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 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 DelivzoneQuery extends ModelCriteria +abstract class AreaDeliveryModuleQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\DelivzoneQuery 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\\Delivzone', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AreaDeliveryModule', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildDelivzoneQuery 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 ChildDelivzoneQuery + * @return ChildAreaDeliveryModuleQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\DelivzoneQuery) { + if ($criteria instanceof \Thelia\Model\AreaDeliveryModuleQuery) { return $criteria; } - $query = new \Thelia\Model\DelivzoneQuery(); + $query = new \Thelia\Model\AreaDeliveryModuleQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -108,19 +112,19 @@ abstract class DelivzoneQuery extends ModelCriteria * @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 + * @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 = DelivzoneTableMap::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(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -139,11 +143,11 @@ abstract class DelivzoneQuery extends ModelCriteria * @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 + * @return ChildAreaDeliveryModule 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'; + $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); @@ -154,9 +158,9 @@ abstract class DelivzoneQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildDelivzone(); + $obj = new ChildAreaDeliveryModule(); $obj->hydrate($row); - DelivzoneTableMap::addInstanceToPool($obj, (string) $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -169,7 +173,7 @@ abstract class DelivzoneQuery extends ModelCriteria * @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 + * @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -211,12 +215,12 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(DelivzoneTableMap::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -224,12 +228,12 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(DelivzoneTableMap::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $keys, Criteria::IN); } /** @@ -248,18 +252,18 @@ abstract class DelivzoneQuery 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 ChildDelivzoneQuery 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(DelivzoneTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(DelivzoneTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -270,7 +274,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::ID, $id, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id, $comparison); } /** @@ -291,18 +295,18 @@ abstract class DelivzoneQuery 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 ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery 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); + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($areaId['max'])) { - $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -313,36 +317,50 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId, $comparison); } /** - * Filter the query on the delivery column + * Filter the query on the delivery_module_id column * * Example usage: * - * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue' - * $query->filterByDelivery('%fooValue%'); // WHERE delivery 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 $delivery The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByModule() + * + * @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 ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function filterByDelivery($delivery = null, $comparison = null) + public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($delivery)) { + if (is_array($deliveryModuleId)) { + $useMinMax = false; + if (isset($deliveryModuleId['min'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryModuleId['max'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $delivery)) { - $delivery = str_replace('*', '%', $delivery); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(DelivzoneTableMap::DELIVERY, $delivery, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison); } /** @@ -363,18 +381,18 @@ abstract class DelivzoneQuery 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 ChildDelivzoneQuery 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(DelivzoneTableMap::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(DelivzoneTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -385,7 +403,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -406,18 +424,18 @@ abstract class DelivzoneQuery 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 ChildDelivzoneQuery 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(DelivzoneTableMap::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(DelivzoneTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -428,7 +446,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -437,20 +455,20 @@ abstract class DelivzoneQuery extends ModelCriteria * @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 + * @return ChildAreaDeliveryModuleQuery 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); + ->addUsingAlias(AreaDeliveryModuleTableMap::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); + ->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); } @@ -462,9 +480,9 @@ abstract class DelivzoneQuery extends ModelCriteria * @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 + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Area'); @@ -499,7 +517,7 @@ abstract class DelivzoneQuery extends ModelCriteria * * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query */ - public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinArea($relationAlias, $joinType) @@ -507,23 +525,98 @@ abstract class DelivzoneQuery extends ModelCriteria } /** - * Exclude object from result + * Filter the query by a related \Thelia\Model\Module object * - * @param ChildDelivzone $delivzone Object to remove from the list of results + * @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 ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function prune($delivzone = null) + public function filterByModule($module, $comparison = null) { - if ($delivzone) { - $this->addUsingAlias(DelivzoneTableMap::ID, $delivzone->getId(), Criteria::NOT_EQUAL); + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Module relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface + */ + public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Module'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Module'); } return $this; } /** - * Deletes all rows from the delivzone table. + * Use the Module relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); + } + + /** + * Exclude object from result + * + * @param ChildAreaDeliveryModule $areaDeliveryModule Object to remove from the list of results + * + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface + */ + public function prune($areaDeliveryModule = null) + { + if ($areaDeliveryModule) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $areaDeliveryModule->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * 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). @@ -531,7 +624,7 @@ abstract class DelivzoneQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -542,8 +635,8 @@ abstract class DelivzoneQuery 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). - DelivzoneTableMap::clearInstancePool(); - DelivzoneTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -555,9 +648,9 @@ abstract class DelivzoneQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildDelivzone 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 ChildDelivzone 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 @@ -568,13 +661,13 @@ abstract class DelivzoneQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(DelivzoneTableMap::DATABASE_NAME); + $criteria->setDbName(AreaDeliveryModuleTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -584,10 +677,10 @@ abstract class DelivzoneQuery extends ModelCriteria $con->beginTransaction(); - DelivzoneTableMap::removeInstanceFromPool($criteria); + AreaDeliveryModuleTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - DelivzoneTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -604,11 +697,11 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery 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); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -616,51 +709,51 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery 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); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** * Order by update date desc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastUpdatedFirst() { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by update date asc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstUpdatedFirst() { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::CREATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::CREATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } -} // DelivzoneQuery +} // 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/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/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/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 042864de0..347a0f7f7 100755 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -28,7 +28,7 @@ class Category extends BaseCategory /** * {@inheritDoc} */ - protected function getRewritenUrlViewName() { + protected function getRewrittenUrlViewName() { return 'category'; } @@ -69,8 +69,6 @@ class Category extends BaseCategory { $this->setPosition($this->getNextPosition()); - $this->generateRewritenUrl($this->getLocale()); - $this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY, new CategoryEvent($this)); return true; 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/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 79660f93a..10ed2afe3 100755 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -17,7 +17,7 @@ class Content extends BaseContent /** * {@inheritDoc} */ - protected function getRewritenUrlViewName() { + protected function getRewrittenUrlViewName() { return 'content'; } @@ -37,8 +37,6 @@ class Content extends BaseContent { $this->setPosition($this->getNextPosition()); - $this->generateRewritenUrl($this->getLocale()); - 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/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/Delivzone.php b/core/lib/Thelia/Model/Delivzone.php deleted file mode 100755 index 58d4f0f7b..000000000 --- a/core/lib/Thelia/Model/Delivzone.php +++ /dev/null @@ -1,9 +0,0 @@ -setPosition($this->getNextPosition()); - $this->generateRewritenUrl($this->getLocale()); 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/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/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/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 cc082e691..fbac7c71a 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -7,6 +7,9 @@ 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; class Product extends BaseProduct { @@ -19,7 +22,7 @@ class Product extends BaseProduct /** * {@inheritDoc} */ - protected function getRewritenUrlViewName() { + protected function getRewrittenUrlViewName() { return 'product'; } @@ -38,17 +41,63 @@ class Product extends BaseProduct public function getTaxedPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()); + return round($taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()), 2); + } + + /** + * @return the current default category 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; } /** * Calculate next position relative to our default category */ - protected function addCriteriaToPositionQuery($query) { - - // TODO: Find the default category for this product, - // and generate the position relative to this category + 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); } /** @@ -58,8 +107,55 @@ class Product extends BaseProduct { $this->setPosition($this->getNextPosition()); - $this->generateRewritenUrl($this->getLocale()); + + + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this)); return true; } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this)); + } + + /** + * {@inheritDoc} + */ + 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 index 6ab24fbc4..1b9087626 100644 --- a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php +++ b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php @@ -23,6 +23,9 @@ 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 @@ -32,7 +35,7 @@ trait UrlRewritingTrait { /** * @returns string the view name of the rewriten object (e.g., 'category', 'product') */ - protected abstract function getRewritenUrlViewName(); + protected abstract function getRewrittenUrlViewName(); /** * Get the object URL for the given locale, rewriten if rewriting is enabled. @@ -41,7 +44,7 @@ trait UrlRewritingTrait { */ public function getUrl($locale) { - return URL::getInstance()->retrieve($this->getRewritenUrlViewName(), $this->getId(), $locale)->toString(); + return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString(); } /** @@ -49,27 +52,79 @@ trait UrlRewritingTrait { * * @param string $locale a valid locale (e.g. en_US) */ - public function generateRewritenUrl($locale) + public function generateRewrittenUrl($locale) { - URL::getInstance()->generateRewritenUrl($this->getRewritenUrlViewName(), $this->getId(), $locale, $this->getTitle()); + 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 = $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 getRewritenUrl($locale) + public function getRewrittenUrl($locale) { - return "fake url - TODO"; + $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 setRewritenUrl($locale, $url) + public function setRewrittenUrl($locale, $url) { // TODO - code me ! 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/Controller/Install/InstallController.php b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php similarity index 51% rename from core/lib/Thelia/Controller/Install/InstallController.php rename to core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php index 40e6643db..04e41b6f8 100644 --- a/core/lib/Thelia/Controller/Install/InstallController.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/DocumentTest.php @@ -21,91 +21,69 @@ /* */ /*************************************************************************************/ -namespace Thelia\Controller\Install; -use Thelia\Install\CheckPermission; +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; /** - * Class InstallController - * @package Thelia\Controller\Install - * @author Manuel Raynaud + * + * @author Etienne Roudeix + * */ -class InstallController extends BaseInstallController +class DocumentTest extends BaseLoopTestor { - public function index() + public function getTestedClassName() { - //$this->verifyStep(1); - - $this->getSession()->set("step", 1); - - return $this->render("index.html"); + return 'Thelia\Core\Template\Loop\Document'; } - public function checkPermission() + public function getTestedInstance() { - //$this->verifyStep(2); - - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 2); - return $this->render("step-2.html"); + return new Document($this->container); } - public function databaseConnection() + public function getMandatoryArguments() { - //$this->verifyStep(2); - - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 3); - return $this->render("step-3.html"); + return array('source' => 'product', 'id' => 1); } - public function databaseSelection() + public function testSearchByProductId() { - //$this->verifyStep(2); + $document = ProductDocumentQuery::create()->findOne(); - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 4); - return $this->render("step-4.html"); + $this->baseTestSearchById($document->getId()); } - public function generalInformation() + public function testSearchByFolderId() { - //$this->verifyStep(2); + $document = FolderDocumentQuery::create()->findOne(); - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 5); - return $this->render("step-5.html"); + $this->baseTestSearchById($document->getId()); } - public function thanks() + public function testSearchByContentId() { - //$this->verifyStep(2); + $document = ContentDocumentQuery::create()->findOne(); - //$permission = new CheckPermission(); - - $this->getSession()->set("step", 6); - return $this->render("thanks.html"); + $this->baseTestSearchById($document->getId()); } - protected function verifyStep($step) + public function testSearchByCategoryId() { - $session = $this->getSession(); + $document = CategoryDocumentQuery::create()->findOne(); - if ($session->has("step")) { - $sessionStep = $session->get("step"); - } else { - return true; - } + $this->baseTestSearchById($document->getId()); + } - switch ($step) { - case "1" : - if ($sessionStep > 1) { - $this->redirect("/install/step/2"); - } - break; - } + public function testSearchLimit() + { + $this->baseTestSearchWithLimit(1); } } 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..3d2517c0a --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ImageTest.php @@ -0,0 +1,89 @@ +. */ +/* */ +/*************************************************************************************/ + +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()); + } + + public function testSearchByFolderId() + { + $image = FolderImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId()); + } + + public function testSearchByContentId() + { + $image = ContentImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId()); + } + + public function testSearchByCategoryId() + { + $image = CategoryImageQuery::create()->findOne(); + + $this->baseTestSearchById($image->getId()); + } + + public function testSearchLimit() + { + $this->baseTestSearchWithLimit(1); + } +} 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/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 495250f99..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(); diff --git a/install/faker.php b/install/faker.php index 25112d904..94c507d02 100755 --- a/install/faker.php +++ b/install/faker.php @@ -5,12 +5,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'; @@ -24,12 +19,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(); @@ -126,9 +126,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( @@ -186,11 +201,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); @@ -209,6 +226,8 @@ try { } } + echo "Creating attributes\n"; + //attributes and attributes_av $attributeList = array(); for($i=0; $i<4; $i++) { @@ -231,6 +250,8 @@ try { } } + echo "Creating templates\n"; + $template = new Thelia\Model\Template(); setI18n($faker, $template, array("Name" => 20)); $template->save(); @@ -253,52 +274,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(); @@ -406,20 +450,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); @@ -430,10 +484,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; } @@ -441,7 +499,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); @@ -465,10 +523,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; } @@ -481,37 +543,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); @@ -521,6 +582,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..c7287089f 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'), diff --git a/install/thelia.sql b/install/thelia.sql index f178467a1..b49840d9b 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`) @@ -341,6 +343,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 +636,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 +875,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 +1157,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 +2167,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..86e313cdf 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -28,7 +28,7 @@ - + @@ -56,6 +56,7 @@ + @@ -68,6 +69,9 @@ + + +
@@ -255,7 +259,7 @@ - + @@ -491,51 +495,72 @@
- + - - - - + + + + - - - - - - - - - + + + + + + + + + - + - - + + - - + + - + + + + + + + + + + - - + + - - + + + + + + + + + + + + + +
@@ -651,19 +676,25 @@
- +
- +
- - - + + + - + + + + + + +
@@ -861,6 +892,7 @@
+ @@ -873,6 +905,9 @@ + + +
diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php index 4d24cc059..14ad36b0d 100755 --- 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/reset_install.sh b/reset_install.sh index 380a80a5f..348927a54 100755 --- a/reset_install.sh +++ b/reset_install.sh @@ -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/categories.html b/templates/admin/default/categories.html index 32b9e6cba..b2ca8440e 100755 --- a/templates/admin/default/categories.html +++ b/templates/admin/default/categories.html @@ -16,6 +16,7 @@
+
{* display parent category name, and get current cat ID *} @@ -171,6 +172,162 @@ {/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} + + {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_delete"} +
+ +
+ {/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 + } + +
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.product.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.delete"} + + {/loop} +
+
{intl l="This category doesn't contains any products. To add a new product, click the + button above."}
+ +
@@ -178,6 +335,10 @@ {module_include location='categories_bottom'} + + {module_include location='catalog_bottom'} + + @@ -251,7 +412,7 @@ {/form} - {* Delete confirmation dialog *} + {* Delete category confirmation dialog *} {capture "category_delete_dialog"} @@ -270,6 +431,26 @@ 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"} @@ -290,6 +471,11 @@ $('#category_delete_id').val($(this).data('id')); }); + // Set proper product ID in delete from + $('a.product-delete').click(function(ev) { + $('#product_delete_id').val($(this).data('id')); + }); + // JS stuff for creation form {include file = "includes/generic-js-dialog.html" diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index 626114d2a..723cf8242 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -39,8 +39,8 @@
-
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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 100644 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 + $('