Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -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
|
||||
phpmyadmin
|
||||
|
||||
23
Readme.md
23
Readme.md
@@ -12,14 +12,33 @@ Here is the most recent developed code for the next major version (v2). You can
|
||||
|
||||
Most part of the code can possibly change, a large part will be refactor soon, graphical setup does not exist yet.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* php 5.4
|
||||
* apache 2
|
||||
* mysql 5
|
||||
|
||||
If you use Mac OSX, it still doesn't use php 5.4 as default php version... There are many solutions for you :
|
||||
|
||||
* use linux (the best one)
|
||||
* use last MAMP version and put the php bin directory in your path :
|
||||
|
||||
```bash
|
||||
export PATH=/Applications/MAMP/bin/php/php5.4.x/bin/:$PATH
|
||||
```
|
||||
|
||||
* configure a complete development environment : http://php-osx.liip.ch/
|
||||
* use a virtual machine with vagrant and puppet : https://puphpet.com/
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
``` bash
|
||||
$ git clone --recursive https://github.com/thelia/thelia.git
|
||||
$ cd thelia
|
||||
$ wget http://getcomposer.org/composer.phar
|
||||
$ php composer.phar install
|
||||
$ curl -sS https://getcomposer.org/installer | php
|
||||
$ php composer.phar install --optimize-autoloader
|
||||
```
|
||||
|
||||
Finish the installation using cli tools :
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
"simplepie/simplepie": "dev-master",
|
||||
|
||||
"imagine/imagine": "dev-master",
|
||||
"symfony/icu": "1.0"
|
||||
"symfony/icu": "1.0",
|
||||
"swiftmailer/swiftmailer": "5.0.*"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
@@ -53,9 +54,5 @@
|
||||
"": "local/modules/",
|
||||
"Thelia" : "core/lib/"
|
||||
}
|
||||
},
|
||||
"scripts" : {
|
||||
"post-update-cmd": "composer dump-autoload -o",
|
||||
"post-install-cmd": "composer dump-autoload -o"
|
||||
}
|
||||
}
|
||||
|
||||
51
composer.lock
generated
51
composer.lock
generated
@@ -3,7 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "28dfdc7a840f9e70df422581f82a871f",
|
||||
"hash": "a40be01c82e68ba0c446dc204d2667da",
|
||||
"packages": [
|
||||
{
|
||||
"name": "imagine/imagine",
|
||||
@@ -445,6 +445,55 @@
|
||||
],
|
||||
"time": "2013-07-02 16:38:47"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v5.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||
"reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/f3917ecef35a4e4d98b303eb9fee463bc983f379",
|
||||
"reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/swift_required.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Chris Corbyn"
|
||||
}
|
||||
],
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"homepage": "http://swiftmailer.org",
|
||||
"keywords": [
|
||||
"mail",
|
||||
"mailer"
|
||||
],
|
||||
"time": "2013-08-30 12:35:21"
|
||||
},
|
||||
{
|
||||
"name": "symfony-cmf/routing",
|
||||
"version": "1.0.0",
|
||||
|
||||
178
core/lib/Thelia/Action/BaseCachedFile.php
Normal file
178
core/lib/Thelia/Action/BaseCachedFile.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\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/<dirname>),
|
||||
* and cached in the web space (by default in web/local/<dirname>).
|
||||
*
|
||||
* 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 <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -24,52 +24,92 @@
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Category as CategoryModel;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\Category as CategoryModel;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Map\CategoryTableMap;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\CategoryUpdateEvent;
|
||||
use Thelia\Core\Event\CategoryCreateEvent;
|
||||
use Thelia\Core\Event\CategoryDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\CategoryChangePositionEvent;
|
||||
use Thelia\Core\Event\CategoryAddContentEvent;
|
||||
use Thelia\Core\Event\CategoryDeleteContentEvent;
|
||||
use Thelia\Model\CategoryAssociatedContent;
|
||||
use Thelia\Model\CategoryAssociatedContentQuery;
|
||||
|
||||
class Category extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new category entry
|
||||
*
|
||||
* @param CategoryCreateEvent $event
|
||||
*/
|
||||
public function create(CategoryCreateEvent $event)
|
||||
{
|
||||
$category = new CategoryModel();
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->create(
|
||||
$event->getTitle(),
|
||||
$event->getParent(),
|
||||
$event->getLocale()
|
||||
);
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setCategory($category);
|
||||
}
|
||||
|
||||
public function update(CategoryChangeEvent $event)
|
||||
/**
|
||||
* Change a category
|
||||
*
|
||||
* @param CategoryUpdateEvent $event
|
||||
*/
|
||||
public function update(CategoryUpdateEvent $event)
|
||||
{
|
||||
$search = CategoryQuery::create();
|
||||
|
||||
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setCategory($category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a category
|
||||
* Delete a category entry
|
||||
*
|
||||
* @param ActionEvent $event
|
||||
* @param CategoryDeleteEvent $event
|
||||
*/
|
||||
public function delete(CategoryDeleteEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) {
|
||||
|
||||
if ($category !== null) {
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$category->setDispatcher($this->getDispatcher())->delete();
|
||||
$event->setCategory($category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,178 +120,80 @@ class Category extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function toggleVisibility(CategoryToggleVisibilityEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
$category = $event->getCategory();
|
||||
|
||||
if ($category !== null) {
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible($category->getVisible() ? false : true)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible($category->getVisible() ? false : true)
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $category = CategoryQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$category->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $category->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $category->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $category->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
public function addContent(CategoryAddContentEvent $event) {
|
||||
|
||||
if (CategoryAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByCategory($event->getCategory())->count() <= 0) {
|
||||
|
||||
$content = new CategoryAssociatedContent();
|
||||
|
||||
$content
|
||||
->setCategory($event->getCategory())
|
||||
->setContentId($event->getContentId())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes category position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function changePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
if ($event->getMode() == CategoryChangePositionEvent::POSITION_ABSOLUTE)
|
||||
return $this->changeAbsolutePosition($event);
|
||||
else
|
||||
return $this->exchangePosition($event);
|
||||
public function removeContent(CategoryDeleteContentEvent $event) {
|
||||
|
||||
$content = CategoryAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByCategory($event->getCategory())->findOne()
|
||||
;
|
||||
|
||||
if ($content !== null) $content->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move up or down a category
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
protected function exchangePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
|
||||
if ($category !== null) {
|
||||
|
||||
// The current position of the category
|
||||
$my_position = $category->getPosition();
|
||||
|
||||
// Find category to exchange position with
|
||||
$search = CategoryQuery::create()
|
||||
->filterByParent($category->getParent());
|
||||
|
||||
// Up or down ?
|
||||
if ($event->getMode() == CategoryChangePositionEvent::POSITION_UP) {
|
||||
// Find the category immediately before me
|
||||
$search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC);
|
||||
} elseif ($event->getMode() == CategoryChangePositionEvent::POSITION_DOWN) {
|
||||
// Find the category immediately after me
|
||||
$search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC);
|
||||
} else
|
||||
|
||||
return;
|
||||
|
||||
$result = $search->findOne();
|
||||
|
||||
// If we found the proper category, exchange their positions
|
||||
if ($result) {
|
||||
|
||||
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
try {
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setPosition($result->getPosition())
|
||||
->save()
|
||||
;
|
||||
|
||||
$result->setPosition($my_position)->save();
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes category position
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
protected function changeAbsolutePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
|
||||
if ($category !== null) {
|
||||
|
||||
// The required position
|
||||
$new_position = $event->getPosition();
|
||||
|
||||
// The current position
|
||||
$current_position = $category->getPosition();
|
||||
|
||||
if ($new_position != null && $new_position > 0 && $new_position != $current_position) {
|
||||
|
||||
// Find categories to offset
|
||||
$search = CategoryQuery::create()->filterByParent($category->getParent());
|
||||
|
||||
if ($new_position > $current_position) {
|
||||
// The new position is after the current position -> we will offset + 1 all categories located between us and the new position
|
||||
$search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position));
|
||||
|
||||
$delta = -1;
|
||||
} else {
|
||||
// The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position
|
||||
$search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1));
|
||||
|
||||
$delta = 1;
|
||||
}
|
||||
|
||||
$results = $search->find();
|
||||
|
||||
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
try {
|
||||
foreach ($results as $result) {
|
||||
$result->setPosition($result->getPosition() + $delta)->save($cnx);
|
||||
}
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setPosition($new_position)
|
||||
->save($cnx)
|
||||
;
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber listens to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CATEGORY_CREATE => array("create", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
|
||||
TheliaEvents::CATEGORY_CREATE => array("create", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
TheliaEvents::CATEGORY_CHANGE_POSITION => array("changePosition", 128),
|
||||
|
||||
"action.updateCategoryPositionU" => array("changePositionUp", 128),
|
||||
"action.updateCategoryPositionDown" => array("changePositionDown", 128),
|
||||
"action.updateCategoryPosition" => array("changePosition", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::CATEGORY_ADD_CONTENT => array("addContent", 128),
|
||||
TheliaEvents::CATEGORY_REMOVE_CONTENT => array("removeContent", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\ConfigQuery;
|
||||
@@ -45,18 +44,9 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setName($event->getEventName())
|
||||
->setValue($event->getValue())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setHidden($event->getHidden())
|
||||
->setSecured($event->getSecured())
|
||||
|
||||
->save()
|
||||
;
|
||||
$config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue())
|
||||
->setLocale($event->getLocale())->setTitle($event->getTitle())->setHidden($event->getHidden())
|
||||
->setSecured($event->getSecured())->save();
|
||||
|
||||
$event->setConfig($config);
|
||||
}
|
||||
@@ -70,18 +60,13 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = ConfigQuery::create();
|
||||
|
||||
if (null !== $config = $search->findOneById($event->getConfigId())) {
|
||||
if (null !== $config = $search->findPk($event->getConfigId())) {
|
||||
|
||||
if ($event->getValue() !== $config->getValue()) {
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
$config->setDispatcher($this->getDispatcher())->setValue($event->getValue())->save();
|
||||
|
||||
->setValue($event->getValue())
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setConfig($config);
|
||||
$event->setConfig($config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,23 +80,12 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = ConfigQuery::create();
|
||||
|
||||
if (null !== $config = ConfigQuery::create()->findOneById($event->getConfigId())) {
|
||||
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setName($event->getEventName())
|
||||
->setValue($event->getValue())
|
||||
->setHidden($event->getHidden())
|
||||
->setSecured($event->getSecured())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
$config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue())
|
||||
->setHidden($event->getHidden())->setSecured($event->getSecured())->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())->save();
|
||||
|
||||
$event->setConfig($config);
|
||||
}
|
||||
@@ -125,14 +99,11 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
public function delete(ConfigDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($config = ConfigQuery::create()->findOneById($event->getConfigId()))) {
|
||||
if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
|
||||
|
||||
if (! $config->getSecured()) {
|
||||
if (!$config->getSecured()) {
|
||||
|
||||
$config
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
$config->setDispatcher($this->getDispatcher())->delete();
|
||||
|
||||
$event->setConfig($config);
|
||||
}
|
||||
@@ -145,10 +116,15 @@ class Config extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CONFIG_CREATE => array("create", 128),
|
||||
TheliaEvents::CONFIG_SETVALUE => array("setValue", 128),
|
||||
TheliaEvents::CONFIG_UPDATE => array("modify", 128),
|
||||
TheliaEvents::CONFIG_DELETE => array("delete", 128),
|
||||
TheliaEvents::CONFIG_CREATE => array(
|
||||
"create", 128
|
||||
), TheliaEvents::CONFIG_SETVALUE => array(
|
||||
"setValue", 128
|
||||
), TheliaEvents::CONFIG_UPDATE => array(
|
||||
"modify", 128
|
||||
), TheliaEvents::CONFIG_DELETE => array(
|
||||
"delete", 128
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) {
|
||||
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
|
||||
|
||||
$currency
|
||||
->setDispatcher($this->getDispatcher())
|
||||
@@ -97,7 +97,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
if (null !== $currency = CurrencyQuery::create()->findOneById($event->getCurrencyId())) {
|
||||
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
|
||||
|
||||
if ($currency->getByDefault() != $event->getIsDefault()) {
|
||||
|
||||
@@ -123,7 +123,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
public function delete(CurrencyDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($currency = CurrencyQuery::create()->findOneById($event->getCurrencyId()))) {
|
||||
if (null !== ($currency = CurrencyQuery::create()->findPk($event->getCurrencyId()))) {
|
||||
|
||||
$currency
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
139
core/lib/Thelia/Action/Document.php
Normal file
139
core/lib/Thelia/Action/Document.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\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 <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*
|
||||
*/
|
||||
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
|
||||
*
|
||||
|
||||
@@ -70,7 +70,7 @@ class Message extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$search = MessageQuery::create();
|
||||
|
||||
if (null !== $message = MessageQuery::create()->findOneById($event->getMessageId())) {
|
||||
if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) {
|
||||
|
||||
$message
|
||||
->setDispatcher($this->getDispatcher())
|
||||
@@ -99,7 +99,7 @@ class Message extends BaseAction implements EventSubscriberInterface
|
||||
public function delete(MessageDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($message = MessageQuery::create()->findOneById($event->getMessageId()))) {
|
||||
if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) {
|
||||
|
||||
$message
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
97
core/lib/Thelia/Action/Order.php
Executable file
97
core/lib/Thelia/Action/Order.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\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 <eroudeix@openstudio.fr>
|
||||
*/
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
206
core/lib/Thelia/Action/Product.php
Normal file
206
core/lib/Thelia/Action/Product.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Model\Product as ProductModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\ProductUpdateEvent;
|
||||
use Thelia\Core\Event\ProductCreateEvent;
|
||||
use Thelia\Core\Event\ProductDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\ProductToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\ProductAddContentEvent;
|
||||
use Thelia\Core\Event\ProductDeleteContentEvent;
|
||||
use Thelia\Model\ProductAssociatedContent;
|
||||
use Thelia\Model\ProductAssociatedContentQuery;
|
||||
use Thelia\Model\ProductCategory;
|
||||
use Thelia\Model\TaxRule;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
use Thelia\Model\TaxQuery;
|
||||
|
||||
class Product extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new product entry
|
||||
*
|
||||
* @param ProductCreateEvent $event
|
||||
*/
|
||||
public function create(ProductCreateEvent $event)
|
||||
{
|
||||
$product = new ProductModel();
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setRef($event->getRef())
|
||||
->setTitle($event->getTitle())
|
||||
->setLocale($event->getLocale())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
// Set the default tax rule to this product
|
||||
->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true))
|
||||
|
||||
->create($event->getDefaultCategory())
|
||||
;
|
||||
|
||||
$event->setProduct($product);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product
|
||||
*
|
||||
* @param ProductUpdateEvent $event
|
||||
*/
|
||||
public function update(ProductUpdateEvent $event)
|
||||
{
|
||||
$search = ProductQuery::create();
|
||||
|
||||
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setProduct($product);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product entry
|
||||
*
|
||||
* @param ProductDeleteEvent $event
|
||||
*/
|
||||
public function delete(ProductDeleteEvent $event)
|
||||
{
|
||||
if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setProduct($product);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle product visibility. No form used here
|
||||
*
|
||||
* @param ActionEvent $event
|
||||
*/
|
||||
public function toggleVisibility(ProductToggleVisibilityEvent $event)
|
||||
{
|
||||
$product = $event->getProduct();
|
||||
|
||||
$product
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible($product->getVisible() ? false : true)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param ProductChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $product = ProductQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$product->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $product->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $product->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $product->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
public function addContent(ProductAddContentEvent $event) {
|
||||
|
||||
if (ProductAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByProduct($event->getProduct())->count() <= 0) {
|
||||
|
||||
$content = new ProductAssociatedContent();
|
||||
|
||||
$content
|
||||
->setProduct($event->getProduct())
|
||||
->setContentId($event->getContentId())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeContent(ProductDeleteContentEvent $event) {
|
||||
|
||||
$content = ProductAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByProduct($event->getProduct())->findOne()
|
||||
;
|
||||
|
||||
if ($content !== null) $content->delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::PRODUCT_CREATE => array("create", 128),
|
||||
TheliaEvents::PRODUCT_UPDATE => array("update", 128),
|
||||
TheliaEvents::PRODUCT_DELETE => array("delete", 128),
|
||||
TheliaEvents::PRODUCT_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,13 @@ class ReloadDatabaseCommand extends BaseModuleGenerate
|
||||
$connection = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||
$connection = $connection->getWrappedConnection();
|
||||
|
||||
$tables = $connection->query("SHOW TABLES");
|
||||
$connection->query("SET FOREIGN_KEY_CHECKS = 0");
|
||||
foreach($tables as $table) {
|
||||
$connection->query(sprintf("DROP TABLE `%s`", $table[0]));
|
||||
}
|
||||
$connection->query("SET FOREIGN_KEY_CHECKS = 1");
|
||||
|
||||
$database = new Database($connection);
|
||||
$output->writeln(array(
|
||||
'',
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.order" class="Thelia\Action\Order">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.customer" class="Thelia\Action\Customer">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
@@ -37,6 +42,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.product" class="Thelia\Action\Product">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.config" class="Thelia\Action\Config">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<loop class="Thelia\Core\Template\Loop\Order" name="order"/>
|
||||
<loop class="Thelia\Core\Template\Loop\OrderStatus" name="order-status"/>
|
||||
<loop class="Thelia\Core\Template\Loop\CategoryPath" name="category-path"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Payment" name="payment"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
|
||||
<loop class="Thelia\Core\Template\Loop\ProductSaleElements" name="product_sale_elements"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
|
||||
@@ -37,9 +38,12 @@
|
||||
<loop class="Thelia\Core\Template\Loop\Message" name="message"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Delivery" name="delivery"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Template" name="template"/> <!-- This is product templates ;-) -->
|
||||
<loop class="Thelia\Core\Template\Loop\TaxRule" name="tax-rule"/>
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<form name="thelia.install.step3" class="Thelia\Form\InstallStep3Form"/>
|
||||
|
||||
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
|
||||
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
|
||||
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
|
||||
@@ -51,13 +55,19 @@
|
||||
<form name="thelia.address.update" class="Thelia\Form\AddressUpdateForm" />
|
||||
|
||||
<form name="thelia.admin.category.creation" class="Thelia\Form\CategoryCreationForm"/>
|
||||
<form name="thelia.admin.category.deletion" class="Thelia\Form\CategoryModificationForm"/>
|
||||
<form name="thelia.admin.category.modification" class="Thelia\Form\CategoryModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.modification" class="Thelia\Form\ProductModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.product.creation" class="Thelia\Form\ProductCreationForm"/>
|
||||
<form name="thelia.admin.product.deletion" class="Thelia\Form\ProductModificationForm"/>
|
||||
|
||||
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
|
||||
|
||||
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>
|
||||
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
|
||||
|
||||
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
|
||||
<form name="thelia.admin.config.modification" class="Thelia\Form\ConfigModificationForm"/>
|
||||
|
||||
@@ -201,6 +211,7 @@
|
||||
|
||||
<service id="smarty.plugin.security" class="Thelia\Core\Template\Smarty\Plugins\Security" scope="request">
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
<argument type="service" id="request" />
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
</service>
|
||||
|
||||
@@ -267,6 +278,10 @@
|
||||
<tag name="thelia.coupon.addCoupon"/>
|
||||
</service>
|
||||
|
||||
<service id="mailer" class="Thelia\Mailer\MailerFactory">
|
||||
<argument type="service" id="event_dispatcher"/>
|
||||
</service>
|
||||
|
||||
|
||||
</services>
|
||||
|
||||
|
||||
@@ -56,17 +56,6 @@
|
||||
<tag name="router.register" priority="0"/>
|
||||
</service>
|
||||
|
||||
<service id="router.install" class="%router.class%">
|
||||
<argument type="service" id="router.xmlLoader"/>
|
||||
<argument>install.xml</argument>
|
||||
<argument type="collection">
|
||||
<argument key="cache_dir">%kernel.cache_dir%</argument>
|
||||
<argument key="debug">%kernel.debug%</argument>
|
||||
</argument>
|
||||
<argument type="service" id="request.context"/>
|
||||
<tag name="router.register" priority="-1"/>
|
||||
</service>
|
||||
|
||||
<service id="router.front" class="%router.class%">
|
||||
<argument type="service" id="router.xmlLoader"/>
|
||||
<argument>front.xml</argument>
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.set-default" path="/admin/categories/toggle-online">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::toggleOnlineAction</default>
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::setToggleVisibilityAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.delete" path="/admin/categories/delete">
|
||||
@@ -95,11 +95,68 @@
|
||||
<route id="admin.categories.update-position" path="/admin/categories/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.related-content.add" path="/admin/categories/related-content/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::addRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.categories.related-content.delete" path="/admin/categories/related-content/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.category.available-related-content" path="/admin/category/{categoryId}/available-related-content/{folderId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::getAvailableRelatedContentAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.category.ajax" path="/admin/catalog/category/parent/{parentId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::getByParentIdAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
<!-- Product Management -->
|
||||
|
||||
<route id="admin.products.default" path="/admin/products">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.create" path="/admin/products/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.update" path="/admin/products/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.save" path="/admin/products/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.set-default" path="/admin/products/toggle-online">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::setToggleVisibilityAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.delete" path="/admin/products/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.update-position" path="/admin/products/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.related-content.add" path="/admin/products/related-content/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::addRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.related-content.delete" path="/admin/products/related-content/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteRelatedContentAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.available-related-content" path="/admin/product/{productId}/available-related-content/{folderId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::getAvailableRelatedContentAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- Route to the Coupon controller (process Coupon browsing) -->
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.add.process" path="/cart/add">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::addItem</default>
|
||||
</route>
|
||||
@@ -111,6 +112,26 @@
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="order.delivery.process" path="/order/delivery" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::deliver</default>
|
||||
<default key="_view">order_delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="order.delivery" path="/order/delivery">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">order_delivery</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice.process" path="/order/invoice" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
<default key="_view">order_invoice</default>
|
||||
</route>
|
||||
|
||||
<route id="order.invoice" path="/order/invoice">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">order_invoice</default>
|
||||
</route>
|
||||
|
||||
<!-- end cart routes -->
|
||||
|
||||
<!-- order management process -->
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="install.step1" path="/install" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::index</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step2" path="/install/step/2" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::checkPermission</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step3" path="/install/step/3" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::databaseConnection</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step4" path="/install/step/4" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::databaseSelection</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step5" path="/install/step/5" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::generalInformation</default>
|
||||
</route>
|
||||
|
||||
<route id="install.step6" path="/install/thanks" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::thanks</default>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
@@ -224,7 +224,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
* @param unknown $updateEvent the update event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateeEvent)
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -240,6 +240,17 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in this method post object position change processing if required.
|
||||
*
|
||||
* @param unknown $deleteEvent the delete event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalUpdatePositionAction($positionChangeEvent)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current list order identifier, updating it in the same time.
|
||||
*/
|
||||
@@ -309,14 +320,18 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) created", ucfirst($this->objectName), $this->getObjectLabel($createdObject), $this->getObjectId($createdObject)));
|
||||
}
|
||||
|
||||
$this->performAdditionalCreateAction($createEvent);
|
||||
$response = $this->performAdditionalCreateAction($createEvent);
|
||||
|
||||
// Substitute _ID_ in the URL with the ID of the created object
|
||||
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($successUrl);
|
||||
if ($response == null) {
|
||||
// Substitute _ID_ in the URL with the ID of the created object
|
||||
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($successUrl);
|
||||
}
|
||||
else {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
@@ -396,16 +411,21 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject)));
|
||||
}
|
||||
|
||||
$this->performAdditionalUpdateAction($changeEvent);
|
||||
$response = $this->performAdditionalUpdateAction($changeEvent);
|
||||
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirectToEditionTemplate($this->getRequest());
|
||||
if ($response == null) {
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirectToEditionTemplate($this->getRequest());
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($changeForm->getSuccessUrl());
|
||||
}
|
||||
else {
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($changeForm->getSuccessUrl());
|
||||
}
|
||||
catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
@@ -452,7 +472,14 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
$response = $this->performAdditionalUpdatePositionAction($event);
|
||||
|
||||
if ($response == null) {
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
else {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,7 +502,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\AttributeAvCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages attributes-av sent by mail
|
||||
* Manages attributes-av
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ use Thelia\Core\Event\AttributeAvUpdateEvent;
|
||||
use Thelia\Core\Event\AttributeEvent;
|
||||
|
||||
/**
|
||||
* Manages attributes sent by mail
|
||||
* Manages attributes
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -23,226 +23,178 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\CategoryCreateEvent;
|
||||
use Thelia\Form\CategoryCreationForm;
|
||||
use Thelia\Core\Event\CategoryDeleteEvent;
|
||||
use Thelia\Core\Event\CategoryUpdatePositionEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\CategoryUpdateEvent;
|
||||
use Thelia\Core\Event\CategoryCreateEvent;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Form\CategoryModificationForm;
|
||||
use Thelia\Form\CategoryCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\CategoryDeleteContentEvent;
|
||||
use Thelia\Core\Event\CategoryAddContentEvent;
|
||||
use Thelia\Model\CategoryAssociatedContent;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\CategoryAssociatedContentQuery;
|
||||
|
||||
class CategoryController extends BaseAdminController
|
||||
/**
|
||||
* Manages categories
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class CategoryController extends AbstractCrudController
|
||||
{
|
||||
/**
|
||||
* Render the categories list, ensuring the sort order is set.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
protected function renderList()
|
||||
{
|
||||
return $this->render('categories', $this->getTemplateArgs());
|
||||
public function __construct() {
|
||||
parent::__construct(
|
||||
'category',
|
||||
'manual',
|
||||
'category_order',
|
||||
|
||||
'admin.categories.default',
|
||||
'admin.categories.create',
|
||||
'admin.categories.update',
|
||||
'admin.categories.delete',
|
||||
|
||||
TheliaEvents::CATEGORY_CREATE,
|
||||
TheliaEvents::CATEGORY_UPDATE,
|
||||
TheliaEvents::CATEGORY_DELETE,
|
||||
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::CATEGORY_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getTemplateArgs()
|
||||
{
|
||||
// Get the category ID
|
||||
$category_id = $this->getRequest()->get('category_id', 0);
|
||||
protected function getCreationForm() {
|
||||
return new CategoryCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
// Find the current category order
|
||||
$category_order = $this->getRequest()->get(
|
||||
'order',
|
||||
$this->getSession()->get('admin.category_order', 'manual')
|
||||
protected function getUpdateForm() {
|
||||
return new CategoryModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData) {
|
||||
$createEvent = new CategoryCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
->setParent($formData['parent'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData) {
|
||||
$changeEvent = new CategoryUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setParent($formData['parent'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
|
||||
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('category_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent() {
|
||||
return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event) {
|
||||
return $event->hasCategory();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object) {
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'parent' => $object->getParent()
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'current_category_id' => $category_id,
|
||||
'category_order' => $category_order,
|
||||
// Setup the object form
|
||||
return new CategoryModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event) {
|
||||
return $event->hasCategory() ? $event->getCategory() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject() {
|
||||
return CategoryQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('category_id', 0));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object) {
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object) {
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'category_id' => $this->getRequest()->get('category_id', 0),
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
|
||||
// Store the current sort order in session
|
||||
$this->getSession()->set('admin.category_order', $category_order);
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default action is displaying the categories list.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.categories.view")) return $response;
|
||||
return $this->renderList();
|
||||
protected function renderListTemplate($currentOrder) {
|
||||
|
||||
// Get product order
|
||||
$product_order = $this->getListOrderFromSession('product', 'product_order', 'manual');
|
||||
|
||||
return $this->render('categories',
|
||||
array(
|
||||
'category_order' => $currentOrder,
|
||||
'product_order' => $product_order,
|
||||
'category_id' => $this->getRequest()->get('category_id', 0)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new category object
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.create")) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the Creation Form
|
||||
$creationForm = new CategoryCreationForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
// Validate the form, create the CategoryCreation event and dispatch it.
|
||||
$form = $this->validateForm($creationForm, "POST");
|
||||
|
||||
$data = $form->getData();
|
||||
|
||||
$createEvent = new CategoryCreateEvent(
|
||||
$data["title"],
|
||||
$data["parent"],
|
||||
$data["locale"]
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_CREATE, $createEvent);
|
||||
|
||||
if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was created."));
|
||||
|
||||
$createdObject = $createEvent->getCategory();
|
||||
|
||||
// Log category creation
|
||||
$this->adminLogAppend(sprintf("Category %s (ID %s) created", $createdObject->getTitle(), $createdObject->getId()));
|
||||
|
||||
// Substitute _ID_ in the URL with the ID of the created object
|
||||
$successUrl = str_replace('_ID_', $createdObject->getId(), $creationForm->getSuccessUrl());
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($successUrl);
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext("category creation", $error_msg, $creationForm, $ex);
|
||||
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->renderList();
|
||||
protected function redirectToListTemplate() {
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $this->getRequest()->get('category_id', 0))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a category object for modification, and display the edit template.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function changeAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
protected function renderEditionTemplate() {
|
||||
|
||||
// Load the category object
|
||||
$category = CategoryQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('category_id'));
|
||||
|
||||
if ($category != null) {
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $category->getId(),
|
||||
'locale' => $category->getLocale(),
|
||||
'title' => $category->getTitle(),
|
||||
'chapo' => $category->getChapo(),
|
||||
'description' => $category->getDescription(),
|
||||
'postscriptum' => $category->getPostscriptum(),
|
||||
'parent' => $category->getParent(),
|
||||
'visible' => $category->getVisible() ? true : false,
|
||||
'url' => $category->getUrl($this->getCurrentEditionLocale())
|
||||
// tbc !!!
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
$changeForm = new CategoryModificationForm($this->getRequest(), "form", $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($changeForm);
|
||||
}
|
||||
|
||||
// Render the edition template.
|
||||
return $this->render('category-edit', $this->getTemplateArgs());
|
||||
return $this->render('category-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Save changes on a modified category object, and either go back to the category list, or stay on the edition page.
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function saveChangeAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new CategoryModificationForm($this->getRequest());
|
||||
|
||||
// Get the category ID
|
||||
$category_id = $this->getRequest()->get('category_id');
|
||||
|
||||
try {
|
||||
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($changeForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$changeEvent = new CategoryUpdateEvent($data['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setCategoryName($data['name'])
|
||||
->setLocale($data["locale"])
|
||||
->setSymbol($data['symbol'])
|
||||
->setCode($data['code'])
|
||||
->setRate($data['rate'])
|
||||
;
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_UPDATE, $changeEvent);
|
||||
|
||||
if (! $createEvent->hasCategory()) throw new \LogicException($this->getTranslator()->trans("No category was updated."));
|
||||
|
||||
// Log category modification
|
||||
$changedObject = $changeEvent->getCategory();
|
||||
|
||||
$this->adminLogAppend(sprintf("Category %s (ID %s) modified", $changedObject->getTitle(), $changedObject->getId()));
|
||||
|
||||
// If we have to stay on the same page, do not redirect to the succesUrl,
|
||||
// just redirect to the edit page again.
|
||||
if ($this->getRequest()->get('save_mode') == 'stay') {
|
||||
$this->redirectToRoute(
|
||||
"admin.categories.update",
|
||||
array('category_id' => $category_id)
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($changeForm->getSuccessUrl());
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext("category modification", $error_msg, $changeForm, $ex);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->render('category-edit', array('category_id' => $category_id));
|
||||
protected function redirectToEditionTemplate() {
|
||||
$this->redirectToRoute("admin.categories.update", $this->getEditionArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,74 +205,130 @@ class CategoryController extends BaseAdminController
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
$changeEvent = new CategoryUpdateEvent($this->getRequest()->get('category_id', 0));
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent->setIsDefault(true);
|
||||
$event = new CategoryToggleVisibilityEvent($this->getExistingObject());
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent);
|
||||
$this->dispatch(TheliaEvents::CATEGORY_TOGGLE_VISIBILITY, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
// Ajax response -> no action
|
||||
return $this->nullResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update categoryposition
|
||||
*/
|
||||
public function updatePositionAction()
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $deleteEvent->getCategory()->getParent())
|
||||
);
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $updateEvent->getCategory()->getParent())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdatePositionAction($event)
|
||||
{
|
||||
|
||||
$category = CategoryQuery::create()->findPk($event->getObjectId());
|
||||
|
||||
if ($category != null) {
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $category->getParent())
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAvailableRelatedContentAction($categoryId, $folderId) {
|
||||
|
||||
$result = array();
|
||||
|
||||
$folders = FolderQuery::create()->filterById($folderId)->find();
|
||||
|
||||
if ($folders !== null) {
|
||||
|
||||
$list = ContentQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByFolder($folders, Criteria::IN)
|
||||
->filterById(CategoryAssociatedContentQuery::create()->select('content_id')->findByCategoryId($categoryId), Criteria::NOT_IN)
|
||||
->find();
|
||||
;
|
||||
|
||||
if ($list !== null) {
|
||||
foreach($list as $item) {
|
||||
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->jsonResponse(json_encode($result));
|
||||
}
|
||||
|
||||
public function addRelatedContentAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
try {
|
||||
$mode = $this->getRequest()->get('mode', null);
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
if ($mode == 'up')
|
||||
$mode = CategoryUpdatePositionEvent::POSITION_UP;
|
||||
else if ($mode == 'down')
|
||||
$mode = CategoryUpdatePositionEvent::POSITION_DOWN;
|
||||
else
|
||||
$mode = CategoryUpdatePositionEvent::POSITION_ABSOLUTE;
|
||||
if ($content_id > 0) {
|
||||
|
||||
$position = $this->getRequest()->get('position', null);
|
||||
|
||||
$event = new CategoryUpdatePositionEvent(
|
||||
$this->getRequest()->get('category_id', null),
|
||||
$mode,
|
||||
$this->getRequest()->get('position', null)
|
||||
$event = new CategoryAddContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a category object
|
||||
*
|
||||
* @return Symfony\Component\HttpFoundation\Response the response
|
||||
*/
|
||||
public function deleteAction()
|
||||
{
|
||||
public function deleteRelatedContentAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response;
|
||||
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
|
||||
|
||||
// Get the category id, and dispatch the deleted request
|
||||
$event = new CategoryDeleteEvent($this->getRequest()->get('category_id'));
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
$this->dispatch(TheliaEvents::CATEGORY_DELETE, $event);
|
||||
if ($content_id > 0) {
|
||||
|
||||
if ($event->hasCategory())
|
||||
$this->adminLogAppend(sprintf("Category %s (ID %s) deleted", $event->getCategory()->getTitle(), $event->getCategory()->getId()));
|
||||
$event = new CategoryDeleteContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\ConfigCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages variables sent by mail
|
||||
* Manages variables
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\CurrencyCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages currencies sent by mail
|
||||
* Manages currencies
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\FeatureAvCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages features-av sent by mail
|
||||
* Manages features-av
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages features sent by mail
|
||||
* Manages features
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
356
core/lib/Thelia/Controller/Admin/ProductController.php
Normal file
356
core/lib/Thelia/Controller/Admin/ProductController.php
Normal file
@@ -0,0 +1,356 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\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 <franck@cqfdev.fr>
|
||||
*/
|
||||
class ProductController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'product',
|
||||
'manual',
|
||||
'product_order',
|
||||
|
||||
'admin.products.default',
|
||||
'admin.products.create',
|
||||
'admin.products.update',
|
||||
'admin.products.delete',
|
||||
|
||||
TheliaEvents::PRODUCT_CREATE,
|
||||
TheliaEvents::PRODUCT_UPDATE,
|
||||
TheliaEvents::PRODUCT_DELETE,
|
||||
|
||||
TheliaEvents::PRODUCT_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::PRODUCT_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new ProductCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new ProductModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new ProductCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setRef($formData['ref'])
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData['locale'])
|
||||
->setDefaultCategory($formData['default_category'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new ProductUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setParent($formData['parent'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('product_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new ProductDeleteEvent($this->getRequest()->get('product_id', 0));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasProduct();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'default_category' => $object->getDefaultCategoryId()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ProductModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasProduct() ? $event->getProduct() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return ProductQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('product_id', 0));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'category_id' => $this->getCategoryId(),
|
||||
'product_id' => $this->getRequest()->get('product_id', 0),
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCategoryId() {
|
||||
// Trouver le category_id, soit depuis la reques, souit depuis le produit courant
|
||||
$category_id = $this->getRequest()->get('category_id', null);
|
||||
|
||||
if ($category_id == null) {
|
||||
$product = $this->getExistingObject();
|
||||
|
||||
if ($product !== null) $category_id = $product->getDefaultCategoryId();
|
||||
}
|
||||
|
||||
return $category_id != null ? $category_id : 0;
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
$this->getListOrderFromSession('product', 'product_order', 'manual');
|
||||
|
||||
return $this->render('categories',
|
||||
array(
|
||||
'product_order' => $currentOrder,
|
||||
'category_id' => $this->getCategoryId()
|
||||
));
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
'admin.products.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render('product-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute("admin.products.update", $this->getEditionArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Online status toggle product
|
||||
*/
|
||||
public function setToggleVisibilityAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$event = new ProductToggleVisibilityEvent($this->getExistingObject());
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_TOGGLE_VISIBILITY, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
// Ajax response -> no action
|
||||
return $this->nullResponse();
|
||||
}
|
||||
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.products.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function performAdditionalUpdatePositionAction($positionEvent)
|
||||
{
|
||||
// Redirect to parent product list
|
||||
$this->redirectToRoute(
|
||||
'admin.categories.default',
|
||||
array('category_id' => $this->getCategoryId())
|
||||
);
|
||||
}
|
||||
|
||||
public function getAvailableRelatedContentAction($productId, $folderId)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
$folders = FolderQuery::create()->filterById($folderId)->find();
|
||||
|
||||
if ($folders !== null) {
|
||||
|
||||
$list = ContentQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByFolder($folders, Criteria::IN)
|
||||
->filterById(ProductAssociatedContentQuery::create()->select('content_id')->findByProductId($productId), Criteria::NOT_IN)
|
||||
->find();
|
||||
;
|
||||
|
||||
if ($list !== null) {
|
||||
foreach($list as $item) {
|
||||
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->jsonResponse(json_encode($result));
|
||||
}
|
||||
|
||||
public function addRelatedContentAction()
|
||||
{
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
if ($content_id > 0) {
|
||||
|
||||
$event = new ProductAddContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteRelatedContentAction()
|
||||
{
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$content_id = intval($this->getRequest()->get('content_id'));
|
||||
|
||||
if ($content_id > 0) {
|
||||
|
||||
$event = new ProductDeleteContentEvent(
|
||||
$this->getExistingObject(),
|
||||
$content_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages templates sent by mail
|
||||
* Manages product templates
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,7 @@ use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
@@ -62,6 +63,14 @@ class BaseController extends ContainerAware
|
||||
return new Response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a JSON response
|
||||
*/
|
||||
protected function jsonResponse($json_data)
|
||||
{
|
||||
return new Response($json_data, 200, array('content-type' => 'application/json'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a Thelia event
|
||||
*
|
||||
@@ -89,7 +98,7 @@ class BaseController extends ContainerAware
|
||||
*
|
||||
* return the Translator
|
||||
*
|
||||
* @return mixed \Thelia\Core\Translation\Translator
|
||||
* @return Translator
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
@@ -281,4 +290,16 @@ class BaseController extends ContainerAware
|
||||
$this->accessDenied();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* return an instance of \Swift_Mailer with good Transporter configured.
|
||||
*
|
||||
* @return \Swift_Mailer
|
||||
*/
|
||||
public function getMailer()
|
||||
{
|
||||
$mailer = $this->container->get('mailer');
|
||||
return $mailer->getSwiftMailer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
197
core/lib/Thelia/Controller/Front/OrderController.php
Executable file
197
core/lib/Thelia/Controller/Front/OrderController.php
Executable file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Controller\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 <eroudeix@openstudio.fr>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
94
core/lib/Thelia/Core/Event/CachedFileEvent.php
Normal file
94
core/lib/Thelia/Core/Event/CachedFileEvent.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class 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;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/CategoryAddContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/CategoryAddContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\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;
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,7 @@ class CategoryCreateEvent extends CategoryEvent
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
|
||||
public function __construct($title, $parent, $locale)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->parent = $parent;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
protected $visible;
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
@@ -71,4 +65,16 @@ class CategoryCreateEvent extends CategoryEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
48
core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\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;
|
||||
}
|
||||
}
|
||||
28
core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php
Normal file
28
core/lib/Thelia/Core/Event/CategoryToggleVisibilityEvent.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class CategoryToggleVisibilityEvent extends CategoryEvent
|
||||
{
|
||||
}
|
||||
@@ -32,7 +32,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
protected $visibility;
|
||||
protected $parent;
|
||||
|
||||
public function __construct($category_id)
|
||||
@@ -100,18 +99,6 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisibility()
|
||||
{
|
||||
return $this->visibility;
|
||||
}
|
||||
|
||||
public function setVisibility($visibility)
|
||||
{
|
||||
$this->visibility = $visibility;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
|
||||
67
core/lib/Thelia/Core/Event/DocumentEvent.php
Normal file
67
core/lib/Thelia/Core/Event/DocumentEvent.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class DocumentEvent extends CachedFileEvent
|
||||
{
|
||||
protected $document_path;
|
||||
protected $document_url;
|
||||
|
||||
/**
|
||||
* @return the document file path
|
||||
*/
|
||||
public function getDocumentPath()
|
||||
{
|
||||
return $this->document_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $document_path the document file path
|
||||
*/
|
||||
public function setDocumentPath($document_path)
|
||||
{
|
||||
$this->document_path = $document_path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the document URL
|
||||
*/
|
||||
public function getDocumentUrl()
|
||||
{
|
||||
return $this->document_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $document_url the document URL
|
||||
*/
|
||||
public function setDocumentUrl($document_url)
|
||||
{
|
||||
$this->document_url = $document_url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,39 +21,32 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Install;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Controller\BaseController;
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class BaseInstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* Class MailTransporterEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class BaseInstallController extends BaseController
|
||||
{
|
||||
class MailTransporterEvent extends ActionEvent {
|
||||
/**
|
||||
* @return a ParserInterface instance parser
|
||||
* @var \Swift_Transport
|
||||
*/
|
||||
protected function getParser()
|
||||
protected $transporter;
|
||||
|
||||
public function setMailerTransporter(\Swift_Transport $transporter)
|
||||
{
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template that shoud be used
|
||||
$parser->setTemplate("install");
|
||||
|
||||
return $parser;
|
||||
$this->transporter = $transporter;
|
||||
}
|
||||
|
||||
public function render($templateName, $args = array())
|
||||
public function getTransporter()
|
||||
{
|
||||
return new Response($this->renderRaw($templateName, $args));
|
||||
return $this->transporter;
|
||||
}
|
||||
|
||||
public function renderRaw($templateName, $args = array())
|
||||
public function hasTransporter()
|
||||
{
|
||||
$data = $this->getParser()->render($templateName, $args);
|
||||
|
||||
return $data;
|
||||
return null !== $this->transporter;
|
||||
}
|
||||
}
|
||||
}
|
||||
140
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
140
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\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;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/ProductAddContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductAddContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\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;
|
||||
}
|
||||
}
|
||||
88
core/lib/Thelia/Core/Event/ProductCreateEvent.php
Normal file
88
core/lib/Thelia/Core/Event/ProductCreateEvent.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class ProductCreateEvent extends ProductEvent
|
||||
{
|
||||
protected $ref;
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $default_category;
|
||||
protected $visible;
|
||||
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDefaultCategory()
|
||||
{
|
||||
return $this->default_category;
|
||||
}
|
||||
|
||||
public function setDefaultCategory($default_category)
|
||||
{
|
||||
$this->default_category = $default_category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductDeleteContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\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;
|
||||
}
|
||||
}
|
||||
44
core/lib/Thelia/Core/Event/ProductDeleteEvent.php
Normal file
44
core/lib/Thelia/Core/Event/ProductDeleteEvent.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class 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;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/ProductEvent.php
Normal file
54
core/lib/Thelia/Core/Event/ProductEvent.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\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;
|
||||
}
|
||||
}
|
||||
28
core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php
Normal file
28
core/lib/Thelia/Core/Event/ProductToggleVisibilityEvent.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class ProductToggleVisibilityEvent extends ProductEvent
|
||||
{
|
||||
}
|
||||
113
core/lib/Thelia/Core/Event/ProductUpdateEvent.php
Normal file
113
core/lib/Thelia/Core/Event/ProductUpdateEvent.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class 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;
|
||||
}
|
||||
}
|
||||
@@ -145,52 +145,46 @@ final class TheliaEvents
|
||||
|
||||
// -- END ADDRESS MANAGEMENT ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sent once the category creation form has been successfully validated, and before category insertion in the database.
|
||||
*/
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
// -- Categories management -----------------------------------------------
|
||||
|
||||
/**
|
||||
* Create, change or delete a category
|
||||
*/
|
||||
const CATEGORY_CREATE = "action.createCategory";
|
||||
const CATEGORY_UPDATE = "action.updateCategory";
|
||||
const CATEGORY_DELETE = "action.deleteCategory";
|
||||
|
||||
/**
|
||||
* Toggle category visibility
|
||||
*/
|
||||
const CATEGORY_CREATE = "action.createCategory";
|
||||
const CATEGORY_UPDATE = "action.updateCategory";
|
||||
const CATEGORY_DELETE = "action.deleteCategory";
|
||||
const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility";
|
||||
const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition";
|
||||
|
||||
/**
|
||||
* Change category position
|
||||
*/
|
||||
const CATEGORY_CHANGE_POSITION = "action.updateCategoryPosition";
|
||||
const CATEGORY_ADD_CONTENT = "action.categoryAddContent";
|
||||
const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent";
|
||||
|
||||
/**
|
||||
* Sent just after a successful insert of a new category in the database.
|
||||
*/
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
const AFTER_CREATECATEGORY = "action.after_createcategory";
|
||||
/**
|
||||
* Sent befonre deleting a category
|
||||
*/
|
||||
const BEFORE_DELETECATEGORY = "action.before_deletecategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful delete of a category from the database.
|
||||
*/
|
||||
const BEFORE_DELETECATEGORY = "action.before_deletecategory";
|
||||
const AFTER_DELETECATEGORY = "action.after_deletecategory";
|
||||
|
||||
/**
|
||||
* Sent just before a successful change of a category in the database.
|
||||
*/
|
||||
const BEFORE_UPDATECATEGORY = "action.before_updateCategory";
|
||||
|
||||
/**
|
||||
* Sent just after a successful change of a category in the database.
|
||||
*/
|
||||
const AFTER_UPDATECATEGORY = "action.after_updateCategory";
|
||||
|
||||
// -- Product management -----------------------------------------------
|
||||
|
||||
const PRODUCT_CREATE = "action.createProduct";
|
||||
const PRODUCT_UPDATE = "action.updateProduct";
|
||||
const PRODUCT_DELETE = "action.deleteProduct";
|
||||
const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility";
|
||||
const PRODUCT_UPDATE_POSITION = "action.updateProductPosition";
|
||||
|
||||
const PRODUCT_ADD_CONTENT = "action.productAddContent";
|
||||
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
|
||||
|
||||
const BEFORE_CREATEPRODUCT = "action.before_createproduct";
|
||||
const AFTER_CREATEPRODUCT = "action.after_createproduct";
|
||||
|
||||
const BEFORE_DELETEPRODUCT = "action.before_deleteproduct";
|
||||
const AFTER_DELETEPRODUCT = "action.after_deleteproduct";
|
||||
|
||||
const BEFORE_UPDATEPRODUCT = "action.before_updateProduct";
|
||||
const AFTER_UPDATEPRODUCT = "action.after_updateProduct";
|
||||
|
||||
/**
|
||||
* sent when a new existing cat id duplicated. This append when current customer is different from current cart
|
||||
*/
|
||||
@@ -218,13 +212,25 @@ final class TheliaEvents
|
||||
|
||||
const CART_DELETEITEM = "action.deleteArticle";
|
||||
|
||||
/**
|
||||
* Order linked event
|
||||
*/
|
||||
const ORDER_SET_BILLING_ADDRESS = "action.order.setBillingAddress";
|
||||
const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress";
|
||||
const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule";
|
||||
|
||||
/**
|
||||
* Sent on image processing
|
||||
*/
|
||||
const IMAGE_PROCESS = "action.processImage";
|
||||
|
||||
/**
|
||||
* Sent on cimage cache clear request
|
||||
* Sent on document processing
|
||||
*/
|
||||
const DOCUMENT_PROCESS = "action.processDocument";
|
||||
|
||||
/**
|
||||
* Sent on image cache clear request
|
||||
*/
|
||||
const IMAGE_CLEAR_CACHE = "action.clearImageCache";
|
||||
|
||||
@@ -430,4 +436,9 @@ final class TheliaEvents
|
||||
const BEFORE_DELETEFEATURE_AV = "action.before_deleteFeatureAv";
|
||||
const AFTER_DELETEFEATURE_AV = "action.after_deleteFeatureAv";
|
||||
|
||||
/**
|
||||
* sent when system find a mailer transporter.
|
||||
*/
|
||||
const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config';
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <mraynaud@openstudio.fr>
|
||||
*/
|
||||
@@ -93,6 +92,8 @@ class BaseSpecificModule extends BaseI18nLoop
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
$search->filterByActivate(1);
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$search->filterById($id);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,6 +173,22 @@ class Category extends BaseI18nLoop
|
||||
$loopResult = new LoopResult($categories);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
// Find previous and next category
|
||||
$previous = CategoryQuery::create()
|
||||
->filterByParent($category->getParent())
|
||||
->filterByPosition($category->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = CategoryQuery::create()
|
||||
->filterByParent($category->getParent())
|
||||
->filterByPosition($category->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
/*
|
||||
* no cause pagination lost :
|
||||
* if ($this->getNotEmpty() && $category->countAllProducts() == 0) continue;
|
||||
@@ -193,7 +209,13 @@ class Category extends BaseI18nLoop
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
;
|
||||
|
||||
->set("HAS_PREVIOUS", $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
|
||||
->set("PREVIOUS", $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildCategoryTree($parent, $visible, $level, $max_level, array $exclude, LoopResult &$loopResult)
|
||||
protected function buildCategoryTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
@@ -73,7 +73,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN);
|
||||
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
277
core/lib/Thelia/Core/Template/Loop/Document.php
Normal file
277
core/lib/Thelia/Core/Template/Loop/Document.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\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 <franck@cqfdev.fr>
|
||||
*/
|
||||
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()."<br />";
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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()."<br />";
|
||||
//echo "source = ".$this->getSourceId()."source_id=$source_id, id=$id<br />";
|
||||
|
||||
if (is_null($source_id)) {
|
||||
throw new \InvalidArgumentException("'source_id' argument cannot be null if 'source' argument is specified.");
|
||||
if (is_null($source_id) && is_null($id)) {
|
||||
throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified");
|
||||
}
|
||||
|
||||
$search = $this->createSearchQuery($source, $source_id);
|
||||
@@ -211,6 +214,7 @@ class Image extends BaseI18nLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
|
||||
// Select the proper query to use, and get the object type
|
||||
$object_type = $object_id = null;
|
||||
|
||||
@@ -282,7 +286,7 @@ class Image extends BaseI18nLoop
|
||||
// Put source image file path
|
||||
$source_filepath = sprintf("%s%s/%s/%s",
|
||||
THELIA_ROOT,
|
||||
ConfigQuery::read('documents_library_path', 'local/media/images'),
|
||||
ConfigQuery::read('images_library_path', 'local/media/images'),
|
||||
$object_type,
|
||||
$result->getFile()
|
||||
);
|
||||
@@ -313,7 +317,8 @@ class Image extends BaseI18nLoop
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
} catch (\Exception $ex) {
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Ignore the result and log an error
|
||||
Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args);
|
||||
}
|
||||
|
||||
84
core/lib/Thelia/Core/Template/Loop/Payment.php
Normal file
84
core/lib/Thelia/Core/Template/Loop/Payment.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\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 <eroudeix@gmail.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ class Product extends BaseI18nLoop
|
||||
)
|
||||
),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
Argument::createIntListTypeArgument('category_default'),
|
||||
Argument::createBooleanTypeArgument('new'),
|
||||
Argument::createBooleanTypeArgument('promo'),
|
||||
Argument::createFloatTypeArgument('min_price'),
|
||||
@@ -88,7 +89,7 @@ class Product extends BaseI18nLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id'))
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new', 'random', 'given_id'))
|
||||
),
|
||||
'alpha'
|
||||
),
|
||||
@@ -170,9 +171,20 @@ class Product extends BaseI18nLoop
|
||||
}
|
||||
|
||||
$category = $this->getCategory();
|
||||
$categoryDefault = $this->getCategoryDefault();
|
||||
|
||||
if (!is_null($category)) {
|
||||
$categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find();
|
||||
if (!is_null($category) ||!is_null($categoryDefault)) {
|
||||
|
||||
$categoryIds = array();
|
||||
if (!is_array($category)) {
|
||||
$category = array();
|
||||
}
|
||||
if (!is_array($categoryDefault)) {
|
||||
$categoryDefault = array();
|
||||
}
|
||||
|
||||
$categoryIds = array_merge($categoryIds, $category, $categoryDefault);
|
||||
$categories =CategoryQuery::create()->filterById($categoryIds, Criteria::IN)->find();
|
||||
|
||||
$depth = $this->getDepth();
|
||||
|
||||
@@ -527,6 +539,12 @@ class Product extends BaseI18nLoop
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case "id_reverse":
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
@@ -540,12 +558,12 @@ class Product extends BaseI18nLoop
|
||||
$search->addDescendingOrderByColumn('real_lowest_price');
|
||||
break;
|
||||
case "manual":
|
||||
if(null === $category || count($category) != 1)
|
||||
if(null === $categoryIds || count($categoryIds) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
break;
|
||||
case "manual_reverse":
|
||||
if(null === $category || count($category) != 1)
|
||||
if(null === $categoryIds || count($categoryIds) != 1)
|
||||
throw new \InvalidArgumentException('Manual order cannot be set without single category argument');
|
||||
$search->orderByPosition(Criteria::DESC);
|
||||
break;
|
||||
@@ -579,32 +597,62 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$loopResult = new LoopResult($products);
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($products as $product) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
|
||||
$taxedPrice = null === $price ? null : $product->getTaxedPrice(
|
||||
$taxCountry
|
||||
);
|
||||
|
||||
// Find previous and next product, in the default category.
|
||||
$default_category_id = $product->getDefaultCategoryId();
|
||||
|
||||
$loopResultRow->set("ID", $product->getId())
|
||||
->set("REF",$product->getRef())
|
||||
->set("IS_TRANSLATED",$product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE",$product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL", $product->getUrl($locale))
|
||||
->set("BEST_PRICE", $price)
|
||||
->set("BEST_PRICE_TAX", $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE", $taxedPrice)
|
||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION", $product->getPosition())
|
||||
$previous = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $product->getId())
|
||||
->set("REF" , $product->getRef())
|
||||
->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL" , $product->getUrl($locale))
|
||||
->set("BEST_PRICE" , $price)
|
||||
->set("BEST_PRICE_TAX" , $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE" , $taxedPrice)
|
||||
->set("IS_PROMO" , $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION" , $product->getPosition())
|
||||
->set("VISIBLE" , $product->getVisible() ? "1" : "0")
|
||||
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
->set("DEFAULT_CATEGORY" , $default_category_id)
|
||||
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* TaxRule loop
|
||||
*
|
||||
*
|
||||
* Class TaxRule
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TaxRule extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse'))
|
||||
),
|
||||
'alpha'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = TaxRuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case "id_reverse":
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$tax_rules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($tax_rules);
|
||||
|
||||
foreach ($tax_rules as $tax_rule) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $tax_rule->getId())
|
||||
->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0')
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ class Thelia extends Kernel
|
||||
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
|
||||
$con->useDebug(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
36
core/lib/Thelia/Exception/DocumentException.php
Normal file
36
core/lib/Thelia/Exception/DocumentException.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\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);
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Exception/OrderException.php
Executable file
52
core/lib/Thelia/Exception/OrderException.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\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);
|
||||
}
|
||||
}
|
||||
@@ -39,15 +39,22 @@ class CategoryCreationForm extends BaseForm
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("parent", "integer", array(
|
||||
->add("parent", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Parent category *"),
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
),
|
||||
"label_attr" => array("for" => "parent_create")
|
||||
))
|
||||
->add("locale", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
),
|
||||
"label_attr" => array("for" => "locale_create")
|
||||
))
|
||||
->add("visible", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("This category is online."),
|
||||
"label_attr" => array("for" => "visible_create")
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class CategoryModificationForm extends CategoryCreationForm
|
||||
{
|
||||
@@ -36,12 +37,14 @@ class CategoryModificationForm extends CategoryCreationForm
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
|
||||
->add("visible", "checkbox", array(
|
||||
"label" => Translator::getInstance()->trans("This category is online on the front office.")
|
||||
->add("url", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Rewriten URL *"),
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label_attr" => array("for" => "rewriten_url")
|
||||
))
|
||||
;
|
||||
|
||||
// Add standard description fields
|
||||
// Add standard description fields, excluding title and locale, which a re defined in parent class
|
||||
$this->addStandardDescFields(array('title', 'locale'));
|
||||
}
|
||||
|
||||
|
||||
111
core/lib/Thelia/Form/InstallStep3Form.php
Executable file
111
core/lib/Thelia/Form/InstallStep3Form.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
/**
|
||||
* 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 <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
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';
|
||||
}
|
||||
}
|
||||
94
core/lib/Thelia/Form/OrderDelivery.php
Executable file
94
core/lib/Thelia/Form/OrderDelivery.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use 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 <eroudeix@openstudio.fr>
|
||||
*/
|
||||
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";
|
||||
}
|
||||
}
|
||||
94
core/lib/Thelia/Form/OrderPayment.php
Executable file
94
core/lib/Thelia/Form/OrderPayment.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use 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 <eroudeix@openstudio.fr>
|
||||
*/
|
||||
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";
|
||||
}
|
||||
}
|
||||
@@ -23,16 +23,26 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
|
||||
class ProductCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$ref_constraints = array(new NotBlank());
|
||||
|
||||
if (! $change_mode) {
|
||||
$ref_constraints[] = new Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateRef"))
|
||||
));
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("ref", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"constraints" => $ref_constraints,
|
||||
"label" => "Product reference *",
|
||||
"label_attr" => array(
|
||||
"for" => "ref"
|
||||
@@ -47,7 +57,7 @@ class ProductCreationForm extends BaseForm
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("parent", "integer", array(
|
||||
->add("default_category", "integer", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
@@ -57,7 +67,24 @@ class ProductCreationForm extends BaseForm
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
;
|
||||
->add("visible", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("This product is online."),
|
||||
"label_attr" => array("for" => "visible_create")
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function checkDuplicateRef($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$count = ProductQuery::create()->filterByRef($value)->count();
|
||||
|
||||
if ($count > 0) {
|
||||
$context->addViolation(
|
||||
Translator::getInstance()->trans(
|
||||
"A product with reference %ref already exists. Please choose another reference.",
|
||||
array('%ref' => $value)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
64
core/lib/Thelia/Form/ProductModificationForm.php
Normal file
64
core/lib/Thelia/Form/ProductModificationForm.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use 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";
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -25,19 +25,33 @@ use Thelia\Install\Exception\AlreadyInstallException;
|
||||
|
||||
/**
|
||||
* Class BaseInstall
|
||||
*
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
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();
|
||||
|
||||
122
core/lib/Thelia/Install/CheckDatabaseConnection.php
Normal file
122
core/lib/Thelia/Install/CheckDatabaseConnection.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\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 <mraynaud@openstudio.fr>
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,56 +23,366 @@
|
||||
|
||||
namespace Thelia\Install;
|
||||
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
|
||||
/**
|
||||
* Class CheckPermission
|
||||
*
|
||||
* Take care of integration tests (files permissions)
|
||||
*
|
||||
* @package Thelia\Install
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*/
|
||||
class CheckPermission extends BaseInstall
|
||||
{
|
||||
const CONF = "const";
|
||||
const LOG = "log";
|
||||
const CACHE = "cache";
|
||||
|
||||
private $directories = array();
|
||||
private $validation = array();
|
||||
private $valid = true;
|
||||
const DIR_CONF = 'local/config';
|
||||
const DIR_LOG = 'log';
|
||||
const DIR_CACHE = 'cache';
|
||||
const DIR_WEB = 'web';
|
||||
|
||||
public function __construct($verifyInstall = true)
|
||||
/** @var array Directory needed to be writable */
|
||||
protected $directoriesToBeWritable = array(
|
||||
self::DIR_CONF,
|
||||
self::DIR_LOG,
|
||||
self::DIR_CACHE,
|
||||
self::DIR_WEB,
|
||||
);
|
||||
|
||||
/** @var array Minimum server configuration necessary */
|
||||
protected $minServerConfigurationNecessary = array(
|
||||
'memory_limit' => 134217728,
|
||||
'post_max_size' => 20971520,
|
||||
'upload_max_filesize' => 2097152
|
||||
);
|
||||
|
||||
protected $validationMessages = array();
|
||||
|
||||
/** @var bool If permissions are OK */
|
||||
protected $isValid = true;
|
||||
|
||||
/** @var TranslatorInterface Translator Service */
|
||||
protected $translator = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param bool $verifyInstall If verify install
|
||||
* @param Translator $translator Translator Service
|
||||
* necessary for install wizard
|
||||
*/
|
||||
public function __construct($verifyInstall = true, Translator $translator = null)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
|
||||
|
||||
$this->directories = array(
|
||||
self::CONF => THELIA_ROOT . "local/config",
|
||||
self::LOG => THELIA_ROOT . "log",
|
||||
self::CACHE => THELIA_ROOT . "cache"
|
||||
$this->validationMessages['php_version'] = array(
|
||||
'text' => $this->getI18nPhpVersionText('5.4', phpversion(), true),
|
||||
'hint' => $this->getI18nPhpVersionHint(),
|
||||
'status' => true
|
||||
);
|
||||
|
||||
$this->validation = array(
|
||||
self::CONF => array(
|
||||
"text" => sprintf("config directory(%s)...", $this->directories[self::CONF]),
|
||||
"status" => true
|
||||
),
|
||||
self::LOG => array(
|
||||
"text" => sprintf("cache directory(%s)...", $this->directories[self::LOG]),
|
||||
"status" => true
|
||||
),
|
||||
self::CACHE => array(
|
||||
"text" => sprintf("log directory(%s)...", $this->directories[self::CACHE]),
|
||||
"status" => true
|
||||
)
|
||||
);
|
||||
foreach ($this->directoriesToBeWritable as $directory) {
|
||||
$this->validationMessages[$directory] = array(
|
||||
'text' => '',
|
||||
'hint' => '',
|
||||
'status' => true
|
||||
);
|
||||
}
|
||||
foreach ($this->minServerConfigurationNecessary as $key => $value) {
|
||||
$this->validationMessages[$key] = array(
|
||||
'text' => '',
|
||||
'hint' => $this->getI18nConfigHint(),
|
||||
'status' => true
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($verifyInstall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform file permission check
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exec()
|
||||
{
|
||||
foreach ($this->directories as $key => $directory) {
|
||||
if(is_writable($directory) === false) {
|
||||
$this->valid = false;
|
||||
$this->validation[$key]["status"] = false;
|
||||
if (version_compare(phpversion(), '5.4', '<')) {
|
||||
$this->validationMessages['php_version'] = $this->getI18nPhpVersionText('5.4', phpversion(), false);
|
||||
}
|
||||
|
||||
foreach ($this->directoriesToBeWritable as $directory) {
|
||||
$fullDirectory = THELIA_ROOT . $directory;
|
||||
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, true);
|
||||
if (is_writable($fullDirectory) === false) {
|
||||
if (!$this->makeDirectoryWritable($fullDirectory)) {
|
||||
$this->isValid = false;
|
||||
$this->validationMessages[$directory]['status'] = false;
|
||||
$this->validationMessages[$directory]['text'] = $this->getI18nDirectoryText($fullDirectory, false);
|
||||
$this->validationMessages[$directory]['hint'] = $this->getI18nDirectoryHint($fullDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->minServerConfigurationNecessary as $key => $value) {
|
||||
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), true);
|
||||
if (!$this->verifyServerMemoryValues($key, $value)) {
|
||||
$this->isValid = false;
|
||||
$this->validationMessages[$key]['status'] = false;
|
||||
$this->validationMessages[$key]['text'] = $this->getI18nConfigText($key, $this->formatBytes($value), ini_get($key), false);;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->isValid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 <strong>%directory%</strong> is writable';
|
||||
} else {
|
||||
$sentence = 'Your directory <strong>%directory%</strong> 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 = '<span class="label label-primary">chmod 777 %directory%</span> 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 <span class="label label-primary">%key%</span> server configuration (currently %currentValue%) is well enough to run Thelia2 (%expectedValue% needed)';
|
||||
} else {
|
||||
$sentence = 'Your <span class="label label-primary">%key%</span> 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 <span class="label label-primary">php.ini</span> 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 <span class="label label-primary">%currentValue%</span> is well enough to run Thelia2 (%expectedValue% needed)';
|
||||
} else {
|
||||
$sentence = 'Your PHP version <span class="label label-primary">%currentValue%</span> 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)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,91 +21,71 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Install;
|
||||
use Thelia\Install\CheckPermission;
|
||||
namespace Thelia\Mailer;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Event\MailTransporterEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class InstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* Class MailerFactory
|
||||
* @package Thelia\Mailer
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class InstallController extends BaseInstallController
|
||||
{
|
||||
public function index()
|
||||
class MailerFactory {
|
||||
/**
|
||||
* @var \Swift_Mailer
|
||||
*/
|
||||
protected $swiftMailer;
|
||||
|
||||
protected $dispatcher;
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
//$this->verifyStep(1);
|
||||
|
||||
$this->getSession()->set("step", 1);
|
||||
$this->dispatcher = $dispatcher;
|
||||
|
||||
return $this->render("index.html");
|
||||
}
|
||||
$transporterEvent = new MailTransporterEvent();
|
||||
$this->dispatcher->dispatch(TheliaEvents::MAILTRANSPORTER_CONFIG, $transporterEvent);
|
||||
|
||||
public function checkPermission()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 2);
|
||||
return $this->render("step-2.html");
|
||||
}
|
||||
|
||||
public function databaseConnection()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 3);
|
||||
return $this->render("step-3.html");
|
||||
}
|
||||
|
||||
public function databaseSelection()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 4);
|
||||
return $this->render("step-4.html");
|
||||
}
|
||||
|
||||
public function generalInformation()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 5);
|
||||
return $this->render("step-5.html");
|
||||
}
|
||||
|
||||
public function thanks()
|
||||
{
|
||||
//$this->verifyStep(2);
|
||||
|
||||
//$permission = new CheckPermission();
|
||||
|
||||
$this->getSession()->set("step", 6);
|
||||
return $this->render("thanks.html");
|
||||
}
|
||||
|
||||
protected function verifyStep($step)
|
||||
{
|
||||
$session = $this->getSession();
|
||||
|
||||
if ($session->has("step")) {
|
||||
$sessionStep = $session->get("step");
|
||||
if($transporterEvent->hasTransporter()) {
|
||||
$transporter = $transporterEvent->getTransporter();
|
||||
} else {
|
||||
return true;
|
||||
if (ConfigQuery::read("smtp.enabled")) {
|
||||
$transporter = $this->configureSmtp();
|
||||
} else {
|
||||
$transporter = \Swift_MailTransport::newInstance();
|
||||
}
|
||||
}
|
||||
|
||||
switch ($step) {
|
||||
case "1" :
|
||||
if ($sessionStep > 1) {
|
||||
$this->redirect("/install/step/2");
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->swiftMailer = new \Swift_Mailer($transporter);
|
||||
}
|
||||
}
|
||||
|
||||
private function configureSmtp()
|
||||
{
|
||||
$smtpTransporter = new \Swift_SmtpTransport();
|
||||
$smtpTransporter->setHost(Configquery::read('smtp.host', 'localhost'))
|
||||
->setPort(ConfigQuery::read('smtp.host'))
|
||||
->setEncryption(ConfigQuery::read('smtp.encryption'))
|
||||
->setUsername(ConfigQuery::read('smtp.username'))
|
||||
->setPassword(ConfigQuery::read('smtp.password'))
|
||||
->setAuthMode(ConfigQuery::read('smtp.authmode'))
|
||||
->setTimeout(ConfigQuery::read('smtp.timeout', 30))
|
||||
->setSourceIp(ConfigQuery::read('smtp.sourceip'))
|
||||
;
|
||||
return $smtpTransporter;
|
||||
}
|
||||
|
||||
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
|
||||
{
|
||||
$this->swiftMailer->send($message, $failedRecipients);
|
||||
}
|
||||
|
||||
public function getSwiftMailer()
|
||||
{
|
||||
return $this->swiftMailer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
10
core/lib/Thelia/Model/AreaDeliveryModule.php
Normal file
10
core/lib/Thelia/Model/AreaDeliveryModule.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\AreaDeliveryModule as BaseAreaDeliveryModule;
|
||||
|
||||
class AreaDeliveryModule extends BaseAreaDeliveryModule
|
||||
{
|
||||
|
||||
}
|
||||
9
core/lib/Thelia/Model/AttributeCategoryQuery.php → core/lib/Thelia/Model/AreaDeliveryModuleQuery.php
Executable file → Normal file
9
core/lib/Thelia/Model/AttributeCategoryQuery.php → core/lib/Thelia/Model/AreaDeliveryModuleQuery.php
Executable file → Normal file
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\AttributeCategoryQuery as BaseAttributeCategoryQuery;
|
||||
use Thelia\Model\Base\AreaDeliveryModuleQuery as BaseAreaDeliveryModuleQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'attribute_category' table.
|
||||
* Skeleton subclass for performing query and update operations on the 'area_delivery_module' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
@@ -15,6 +15,7 @@ use Thelia\Model\Base\AttributeCategoryQuery as BaseAttributeCategoryQuery;
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class AttributeCategoryQuery extends BaseAttributeCategoryQuery {
|
||||
class AreaDeliveryModuleQuery extends BaseAreaDeliveryModuleQuery
|
||||
{
|
||||
|
||||
} // AttributeCategoryQuery
|
||||
} // AreaDeliveryModuleQuery
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\AttributeCategory as BaseAttributeCategory;
|
||||
|
||||
class AttributeCategory extends BaseAttributeCategory {
|
||||
|
||||
}
|
||||
@@ -18,11 +18,11 @@ 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\Country as ChildCountry;
|
||||
use Thelia\Model\CountryQuery as ChildCountryQuery;
|
||||
use Thelia\Model\Delivzone as ChildDelivzone;
|
||||
use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery;
|
||||
use Thelia\Model\Map\AreaTableMap;
|
||||
|
||||
abstract class Area implements ActiveRecordInterface
|
||||
@@ -72,10 +72,10 @@ abstract class Area implements ActiveRecordInterface
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The value for the unit field.
|
||||
* The value for the postage field.
|
||||
* @var double
|
||||
*/
|
||||
protected $unit;
|
||||
protected $postage;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
@@ -96,10 +96,10 @@ abstract class Area implements ActiveRecordInterface
|
||||
protected $collCountriesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildDelivzone[] Collection to store aggregation of ChildDelivzone objects.
|
||||
* @var ObjectCollection|ChildAreaDeliveryModule[] Collection to store aggregation of ChildAreaDeliveryModule objects.
|
||||
*/
|
||||
protected $collDelivzones;
|
||||
protected $collDelivzonesPartial;
|
||||
protected $collAreaDeliveryModules;
|
||||
protected $collAreaDeliveryModulesPartial;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
@@ -119,7 +119,7 @@ abstract class Area implements ActiveRecordInterface
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $delivzonesScheduledForDeletion = null;
|
||||
protected $areaDeliveryModulesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\Area object.
|
||||
@@ -398,14 +398,14 @@ abstract class Area implements ActiveRecordInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [unit] column value.
|
||||
* Get the [postage] column value.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getUnit()
|
||||
public function getPostage()
|
||||
{
|
||||
|
||||
return $this->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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 <code>Delivzone</code> instance. If
|
||||
* <code>obj</code> is an instance of <code>Delivzone</code>, delegates to
|
||||
* <code>equals(Delivzone)</code>. Otherwise, returns <code>false</code>.
|
||||
* Compares this with another <code>AreaDeliveryModule</code> instance. If
|
||||
* <code>obj</code> is an instance of <code>AreaDeliveryModule</code>, delegates to
|
||||
* <code>equals(AreaDeliveryModule)</code>. Otherwise, returns <code>false</code>.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
@@ -12,84 +12,84 @@ use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\FeatureCategory as ChildFeatureCategory;
|
||||
use Thelia\Model\FeatureCategoryQuery as ChildFeatureCategoryQuery;
|
||||
use Thelia\Model\Map\FeatureCategoryTableMap;
|
||||
use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery;
|
||||
use Thelia\Model\Map\AreaDeliveryModuleTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'feature_category' table.
|
||||
* Base class that represents a query for the 'area_delivery_module' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildFeatureCategoryQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildFeatureCategoryQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column
|
||||
* @method ChildFeatureCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column
|
||||
* @method ChildFeatureCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildFeatureCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
* @method ChildAreaDeliveryModuleQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildAreaDeliveryModuleQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column
|
||||
* @method ChildAreaDeliveryModuleQuery orderByDeliveryModuleId($order = Criteria::ASC) Order by the delivery_module_id column
|
||||
* @method ChildAreaDeliveryModuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildAreaDeliveryModuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildFeatureCategoryQuery groupById() Group by the id column
|
||||
* @method ChildFeatureCategoryQuery groupByFeatureId() Group by the feature_id column
|
||||
* @method ChildFeatureCategoryQuery groupByCategoryId() Group by the category_id column
|
||||
* @method ChildFeatureCategoryQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildFeatureCategoryQuery groupByUpdatedAt() Group by the updated_at column
|
||||
* @method ChildAreaDeliveryModuleQuery groupById() Group by the id column
|
||||
* @method ChildAreaDeliveryModuleQuery groupByAreaId() Group by the area_id column
|
||||
* @method ChildAreaDeliveryModuleQuery groupByDeliveryModuleId() Group by the delivery_module_id column
|
||||
* @method ChildAreaDeliveryModuleQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildAreaDeliveryModuleQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
* @method ChildFeatureCategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildFeatureCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildFeatureCategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
* @method ChildAreaDeliveryModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildAreaDeliveryModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildAreaDeliveryModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildFeatureCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
|
||||
* @method ChildFeatureCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
|
||||
* @method ChildFeatureCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
|
||||
* @method ChildAreaDeliveryModuleQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation
|
||||
* @method ChildAreaDeliveryModuleQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation
|
||||
* @method ChildAreaDeliveryModuleQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation
|
||||
*
|
||||
* @method ChildFeatureCategoryQuery leftJoinFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the Feature relation
|
||||
* @method ChildFeatureCategoryQuery rightJoinFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Feature relation
|
||||
* @method ChildFeatureCategoryQuery innerJoinFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the Feature relation
|
||||
* @method ChildAreaDeliveryModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation
|
||||
* @method ChildAreaDeliveryModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation
|
||||
* @method ChildAreaDeliveryModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @method ChildFeatureCategory findOne(ConnectionInterface $con = null) Return the first ChildFeatureCategory matching the query
|
||||
* @method ChildFeatureCategory findOneOrCreate(ConnectionInterface $con = null) Return the first ChildFeatureCategory matching the query, or a new ChildFeatureCategory object populated from the query conditions when no match is found
|
||||
* @method ChildAreaDeliveryModule findOne(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query
|
||||
* @method ChildAreaDeliveryModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query, or a new ChildAreaDeliveryModule object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildFeatureCategory findOneById(int $id) Return the first ChildFeatureCategory filtered by the id column
|
||||
* @method ChildFeatureCategory findOneByFeatureId(int $feature_id) Return the first ChildFeatureCategory filtered by the feature_id column
|
||||
* @method ChildFeatureCategory findOneByCategoryId(int $category_id) Return the first ChildFeatureCategory filtered by the category_id column
|
||||
* @method ChildFeatureCategory findOneByCreatedAt(string $created_at) Return the first ChildFeatureCategory filtered by the created_at column
|
||||
* @method ChildFeatureCategory findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureCategory filtered by the updated_at column
|
||||
* @method ChildAreaDeliveryModule findOneById(int $id) Return the first ChildAreaDeliveryModule filtered by the id column
|
||||
* @method ChildAreaDeliveryModule findOneByAreaId(int $area_id) Return the first ChildAreaDeliveryModule filtered by the area_id column
|
||||
* @method ChildAreaDeliveryModule findOneByDeliveryModuleId(int $delivery_module_id) Return the first ChildAreaDeliveryModule filtered by the delivery_module_id column
|
||||
* @method ChildAreaDeliveryModule findOneByCreatedAt(string $created_at) Return the first ChildAreaDeliveryModule filtered by the created_at column
|
||||
* @method ChildAreaDeliveryModule findOneByUpdatedAt(string $updated_at) Return the first ChildAreaDeliveryModule filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildFeatureCategory objects filtered by the id column
|
||||
* @method array findByFeatureId(int $feature_id) Return ChildFeatureCategory objects filtered by the feature_id column
|
||||
* @method array findByCategoryId(int $category_id) Return ChildFeatureCategory objects filtered by the category_id column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildFeatureCategory objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildFeatureCategory objects filtered by the updated_at column
|
||||
* @method array findById(int $id) Return ChildAreaDeliveryModule objects filtered by the id column
|
||||
* @method array findByAreaId(int $area_id) Return ChildAreaDeliveryModule objects filtered by the area_id column
|
||||
* @method array findByDeliveryModuleId(int $delivery_module_id) Return ChildAreaDeliveryModule objects filtered by the delivery_module_id column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildAreaDeliveryModule objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildAreaDeliveryModule objects filtered by the updated_at column
|
||||
*
|
||||
*/
|
||||
abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
abstract class AreaDeliveryModuleQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\FeatureCategoryQuery object.
|
||||
* Initializes internal state of \Thelia\Model\Base\AreaDeliveryModuleQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\FeatureCategory', $modelAlias = null)
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AreaDeliveryModule', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildFeatureCategoryQuery object.
|
||||
* Returns a new ChildAreaDeliveryModuleQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery
|
||||
* @return ChildAreaDeliveryModuleQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\FeatureCategoryQuery) {
|
||||
if ($criteria instanceof \Thelia\Model\AreaDeliveryModuleQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\FeatureCategoryQuery();
|
||||
$query = new \Thelia\Model\AreaDeliveryModuleQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
@@ -112,19 +112,19 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter
|
||||
* @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
if ((null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME);
|
||||
$con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
@@ -143,11 +143,11 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildFeatureCategory A model object, or null if the key is not found
|
||||
* @return ChildAreaDeliveryModule A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, FEATURE_ID, CATEGORY_ID, CREATED_AT, UPDATED_AT FROM feature_category WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, AREA_ID, DELIVERY_MODULE_ID, CREATED_AT, UPDATED_AT FROM area_delivery_module WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -158,9 +158,9 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildFeatureCategory();
|
||||
$obj = new ChildAreaDeliveryModule();
|
||||
$obj->hydrate($row);
|
||||
FeatureCategoryTableMap::addInstanceToPool($obj, (string) $key);
|
||||
AreaDeliveryModuleTableMap::addInstanceToPool($obj, (string) $key);
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
@@ -173,7 +173,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter
|
||||
* @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
@@ -215,12 +215,12 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::ID, $key, Criteria::EQUAL);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $key, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,12 +228,12 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::ID, $keys, Criteria::IN);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $keys, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,18 +252,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterById($id = null, $comparison = null)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
$useMinMax = false;
|
||||
if (isset($id['min'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -274,39 +274,39 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::ID, $id, $comparison);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the feature_id column
|
||||
* Filter the query on the area_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByFeatureId(1234); // WHERE feature_id = 1234
|
||||
* $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
|
||||
* $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
|
||||
* $query->filterByAreaId(1234); // WHERE area_id = 1234
|
||||
* $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34)
|
||||
* $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByFeature()
|
||||
* @see filterByArea()
|
||||
*
|
||||
* @param mixed $featureId The value to use as filter.
|
||||
* @param mixed $areaId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByFeatureId($featureId = null, $comparison = null)
|
||||
public function filterByAreaId($areaId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($featureId)) {
|
||||
if (is_array($areaId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($featureId['min'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($areaId['min'])) {
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($featureId['max'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($areaId['max'])) {
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -317,39 +317,39 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId, $comparison);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the category_id column
|
||||
* Filter the query on the delivery_module_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCategoryId(1234); // WHERE category_id = 1234
|
||||
* $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
|
||||
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
|
||||
* $query->filterByDeliveryModuleId(1234); // WHERE delivery_module_id = 1234
|
||||
* $query->filterByDeliveryModuleId(array(12, 34)); // WHERE delivery_module_id IN (12, 34)
|
||||
* $query->filterByDeliveryModuleId(array('min' => 12)); // WHERE delivery_module_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCategory()
|
||||
* @see filterByModule()
|
||||
*
|
||||
* @param mixed $categoryId The value to use as filter.
|
||||
* @param mixed $deliveryModuleId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCategoryId($categoryId = null, $comparison = null)
|
||||
public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($categoryId)) {
|
||||
if (is_array($deliveryModuleId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($categoryId['min'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($deliveryModuleId['min'])) {
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($categoryId['max'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($deliveryModuleId['max'])) {
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -360,7 +360,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId, $comparison);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,18 +381,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCreatedAt($createdAt = null, $comparison = null)
|
||||
{
|
||||
if (is_array($createdAt)) {
|
||||
$useMinMax = false;
|
||||
if (isset($createdAt['min'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($createdAt['max'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -403,7 +403,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt, $comparison);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,18 +424,18 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
|
||||
{
|
||||
if (is_array($updatedAt)) {
|
||||
$useMinMax = false;
|
||||
if (isset($updatedAt['min'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($updatedAt['max'])) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -446,46 +446,46 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt, $comparison);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Category object
|
||||
* Filter the query by a related \Thelia\Model\Area object
|
||||
*
|
||||
* @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
|
||||
* @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCategory($category, $comparison = null)
|
||||
public function filterByArea($area, $comparison = null)
|
||||
{
|
||||
if ($category instanceof \Thelia\Model\Category) {
|
||||
if ($area instanceof \Thelia\Model\Area) {
|
||||
return $this
|
||||
->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison);
|
||||
} elseif ($category instanceof ObjectCollection) {
|
||||
->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->getId(), $comparison);
|
||||
} elseif ($area instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
|
||||
throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Category relation
|
||||
* Adds a JOIN clause to the query using the Area relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Category');
|
||||
$relationMap = $tableMap->getRelation('Area');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
@@ -500,14 +500,14 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Category');
|
||||
$this->addJoinObject($join, 'Area');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Category relation Category object
|
||||
* Use the Area relation Area object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
@@ -515,52 +515,52 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
|
||||
* @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCategory($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
|
||||
->joinArea($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Feature object
|
||||
* Filter the query by a related \Thelia\Model\Module object
|
||||
*
|
||||
* @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter
|
||||
* @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByFeature($feature, $comparison = null)
|
||||
public function filterByModule($module, $comparison = null)
|
||||
{
|
||||
if ($feature instanceof \Thelia\Model\Feature) {
|
||||
if ($module instanceof \Thelia\Model\Module) {
|
||||
return $this
|
||||
->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->getId(), $comparison);
|
||||
} elseif ($feature instanceof ObjectCollection) {
|
||||
->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison);
|
||||
} elseif ($module instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection');
|
||||
throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Feature relation
|
||||
* Adds a JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Feature');
|
||||
$relationMap = $tableMap->getRelation('Module');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
@@ -575,14 +575,14 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Feature');
|
||||
$this->addJoinObject($join, 'Module');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Feature relation Feature object
|
||||
* Use the Module relation Module object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
@@ -590,33 +590,33 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query
|
||||
* @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinFeature($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
|
||||
->joinModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildFeatureCategory $featureCategory Object to remove from the list of results
|
||||
* @param ChildAreaDeliveryModule $areaDeliveryModule Object to remove from the list of results
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($featureCategory = null)
|
||||
public function prune($areaDeliveryModule = null)
|
||||
{
|
||||
if ($featureCategory) {
|
||||
$this->addUsingAlias(FeatureCategoryTableMap::ID, $featureCategory->getId(), Criteria::NOT_EQUAL);
|
||||
if ($areaDeliveryModule) {
|
||||
$this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $areaDeliveryModule->getId(), Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the feature_category table.
|
||||
* Deletes all rows from the area_delivery_module table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
@@ -624,7 +624,7 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME);
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
@@ -635,8 +635,8 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
FeatureCategoryTableMap::clearInstancePool();
|
||||
FeatureCategoryTableMap::clearRelatedInstancePool();
|
||||
AreaDeliveryModuleTableMap::clearInstancePool();
|
||||
AreaDeliveryModuleTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
@@ -648,9 +648,9 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildFeatureCategory or Criteria object OR a primary key value.
|
||||
* Performs a DELETE on the database, given a ChildAreaDeliveryModule or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildFeatureCategory object or primary key or array of primary keys
|
||||
* @param mixed $values Criteria or ChildAreaDeliveryModule object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
@@ -661,13 +661,13 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
public function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME);
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(FeatureCategoryTableMap::DATABASE_NAME);
|
||||
$criteria->setDbName(AreaDeliveryModuleTableMap::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
@@ -677,10 +677,10 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
FeatureCategoryTableMap::removeInstanceFromPool($criteria);
|
||||
AreaDeliveryModuleTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
FeatureCategoryTableMap::clearRelatedInstancePool();
|
||||
AreaDeliveryModuleTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
@@ -697,11 +697,11 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
*
|
||||
* @param int $nbDays Maximum age of the latest update in days
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyUpdated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -709,51 +709,51 @@ abstract class FeatureCategoryQuery extends ModelCriteria
|
||||
*
|
||||
* @param int $nbDays Maximum age of in days
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyCreated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date desc
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastUpdatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT);
|
||||
return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date asc
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstUpdatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT);
|
||||
return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date desc
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastCreatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT);
|
||||
return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date asc
|
||||
*
|
||||
* @return ChildFeatureCategoryQuery The current query, for fluid interface
|
||||
* @return ChildAreaDeliveryModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstCreatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT);
|
||||
return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
} // FeatureCategoryQuery
|
||||
} // AreaDeliveryModuleQuery
|
||||
@@ -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:
|
||||
* <code>
|
||||
* $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
|
||||
* </code>
|
||||
*
|
||||
* @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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,759 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\AttributeCategory as ChildAttributeCategory;
|
||||
use Thelia\Model\AttributeCategoryQuery as ChildAttributeCategoryQuery;
|
||||
use Thelia\Model\Map\AttributeCategoryTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'attribute_category' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildAttributeCategoryQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildAttributeCategoryQuery orderByCategoryId($order = Criteria::ASC) Order by the category_id column
|
||||
* @method ChildAttributeCategoryQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column
|
||||
* @method ChildAttributeCategoryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildAttributeCategoryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildAttributeCategoryQuery groupById() Group by the id column
|
||||
* @method ChildAttributeCategoryQuery groupByCategoryId() Group by the category_id column
|
||||
* @method ChildAttributeCategoryQuery groupByAttributeId() Group by the attribute_id column
|
||||
* @method ChildAttributeCategoryQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildAttributeCategoryQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
* @method ChildAttributeCategoryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildAttributeCategoryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildAttributeCategoryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildAttributeCategoryQuery leftJoinCategory($relationAlias = null) Adds a LEFT JOIN clause to the query using the Category relation
|
||||
* @method ChildAttributeCategoryQuery rightJoinCategory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Category relation
|
||||
* @method ChildAttributeCategoryQuery innerJoinCategory($relationAlias = null) Adds a INNER JOIN clause to the query using the Category relation
|
||||
*
|
||||
* @method ChildAttributeCategoryQuery leftJoinAttribute($relationAlias = null) Adds a LEFT JOIN clause to the query using the Attribute relation
|
||||
* @method ChildAttributeCategoryQuery rightJoinAttribute($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Attribute relation
|
||||
* @method ChildAttributeCategoryQuery innerJoinAttribute($relationAlias = null) Adds a INNER JOIN clause to the query using the Attribute relation
|
||||
*
|
||||
* @method ChildAttributeCategory findOne(ConnectionInterface $con = null) Return the first ChildAttributeCategory matching the query
|
||||
* @method ChildAttributeCategory findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAttributeCategory matching the query, or a new ChildAttributeCategory object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildAttributeCategory findOneById(int $id) Return the first ChildAttributeCategory filtered by the id column
|
||||
* @method ChildAttributeCategory findOneByCategoryId(int $category_id) Return the first ChildAttributeCategory filtered by the category_id column
|
||||
* @method ChildAttributeCategory findOneByAttributeId(int $attribute_id) Return the first ChildAttributeCategory filtered by the attribute_id column
|
||||
* @method ChildAttributeCategory findOneByCreatedAt(string $created_at) Return the first ChildAttributeCategory filtered by the created_at column
|
||||
* @method ChildAttributeCategory findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeCategory filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildAttributeCategory objects filtered by the id column
|
||||
* @method array findByCategoryId(int $category_id) Return ChildAttributeCategory objects filtered by the category_id column
|
||||
* @method array findByAttributeId(int $attribute_id) Return ChildAttributeCategory objects filtered by the attribute_id column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildAttributeCategory objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildAttributeCategory objects filtered by the updated_at column
|
||||
*
|
||||
*/
|
||||
abstract class AttributeCategoryQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\AttributeCategoryQuery 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\\AttributeCategory', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildAttributeCategoryQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\AttributeCategoryQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\AttributeCategoryQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(12, $con);
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildAttributeCategory|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildAttributeCategory A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, CATEGORY_ID, ATTRIBUTE_ID, CREATED_AT, UPDATED_AT FROM attribute_category WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildAttributeCategory();
|
||||
$obj->hydrate($row);
|
||||
AttributeCategoryTableMap::addInstanceToPool($obj, (string) $key);
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildAttributeCategory|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(12, 56, 832), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::ID, $key, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::ID, $keys, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterById(1234); // WHERE id = 1234
|
||||
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
|
||||
* $query->filterById(array('min' => 12)); // WHERE id > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $id The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterById($id = null, $comparison = null)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
$useMinMax = false;
|
||||
if (isset($id['min'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the category_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCategoryId(1234); // WHERE category_id = 1234
|
||||
* $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
|
||||
* $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCategory()
|
||||
*
|
||||
* @param mixed $categoryId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCategoryId($categoryId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($categoryId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($categoryId['min'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($categoryId['max'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the attribute_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
|
||||
* $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
|
||||
* $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByAttribute()
|
||||
*
|
||||
* @param mixed $attributeId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByAttributeId($attributeId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($attributeId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($attributeId['min'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($attributeId['max'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
|
||||
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
|
||||
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $createdAt The value to use as filter.
|
||||
* Values can be integers (unix timestamps), DateTime objects, or strings.
|
||||
* Empty strings are treated as NULL.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCreatedAt($createdAt = null, $comparison = null)
|
||||
{
|
||||
if (is_array($createdAt)) {
|
||||
$useMinMax = false;
|
||||
if (isset($createdAt['min'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($createdAt['max'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the updated_at column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
|
||||
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
|
||||
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $updatedAt The value to use as filter.
|
||||
* Values can be integers (unix timestamps), DateTime objects, or strings.
|
||||
* Empty strings are treated as NULL.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
|
||||
{
|
||||
if (is_array($updatedAt)) {
|
||||
$useMinMax = false;
|
||||
if (isset($updatedAt['min'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($updatedAt['max'])) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Category object
|
||||
*
|
||||
* @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCategory($category, $comparison = null)
|
||||
{
|
||||
if ($category instanceof \Thelia\Model\Category) {
|
||||
return $this
|
||||
->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison);
|
||||
} elseif ($category instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Category relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Category');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Category');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Category relation Category object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCategory($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Attribute object
|
||||
*
|
||||
* @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByAttribute($attribute, $comparison = null)
|
||||
{
|
||||
if ($attribute instanceof \Thelia\Model\Attribute) {
|
||||
return $this
|
||||
->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
|
||||
} elseif ($attribute instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Attribute relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Attribute');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Attribute');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Attribute relation Attribute object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinAttribute($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildAttributeCategory $attributeCategory Object to remove from the list of results
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($attributeCategory = null)
|
||||
{
|
||||
if ($attributeCategory) {
|
||||
$this->addUsingAlias(AttributeCategoryTableMap::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the attribute_category table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
AttributeCategoryTableMap::clearInstancePool();
|
||||
AttributeCategoryTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildAttributeCategory or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildAttributeCategory object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(AttributeCategoryTableMap::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
AttributeCategoryTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
AttributeCategoryTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// timestampable behavior
|
||||
|
||||
/**
|
||||
* Filter by the latest updated
|
||||
*
|
||||
* @param int $nbDays Maximum age of the latest update in days
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyUpdated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by the latest created
|
||||
*
|
||||
* @param int $nbDays Maximum age of in days
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyCreated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date desc
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastUpdatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date asc
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstUpdatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date desc
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastCreatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date asc
|
||||
*
|
||||
* @return ChildAttributeCategoryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstCreatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
} // AttributeCategoryQuery
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
* <code>
|
||||
* $query->filterByDefaultFolder(true); // WHERE default_folder = true
|
||||
* $query->filterByDefaultFolder('yes'); // WHERE default_folder = true
|
||||
* </code>
|
||||
*
|
||||
* @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
|
||||
*
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user