Merge branch 'master' into tax
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -19,9 +19,9 @@ local/media/documents/*
|
||||
local/media/images/*
|
||||
web/assets/*
|
||||
web/cache/*
|
||||
web/.htaccess
|
||||
phpdoc*.log
|
||||
php-cs
|
||||
xhprof/
|
||||
phpunit.phar
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
phpmyadmin
|
||||
|
||||
25
Readme.md
25
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
|
||||
$ git clone 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 --prefer-dist --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",
|
||||
|
||||
@@ -39,6 +39,9 @@ use Thelia\Model\AttributeAvQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryEvent;
|
||||
use Thelia\Core\Event\AttributeEvent;
|
||||
use Thelia\Model\AttributeTemplate;
|
||||
use Thelia\Model\AttributeTemplateQuery;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
|
||||
class Attribute extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
@@ -135,23 +138,33 @@ class Attribute extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(AttributeEvent $event)
|
||||
protected function doAddToAllTemplates(AttributeModel $attribute)
|
||||
{
|
||||
$templates = ProductTemplateAttributeQuery::create()->find();
|
||||
$templates = TemplateQuery::create()->find();
|
||||
|
||||
foreach($templates as $template) {
|
||||
$pat = new ProductTemplateAttribute();
|
||||
|
||||
$pat->setTemplate($template->getId())
|
||||
->setAttributeId($event->getAttribute()->getId())
|
||||
->save();
|
||||
$attribute_template = new AttributeTemplate();
|
||||
|
||||
if (null === AttributeTemplateQuery::create()->filterByAttribute($attribute)->filterByTemplate($template)->findOne()) {
|
||||
$attribute_template
|
||||
->setAttribute($attribute)
|
||||
->setTemplate($template)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(AttributeEvent $event)
|
||||
{
|
||||
$this->doAddToAllTemplates($event->getAttribute());
|
||||
}
|
||||
|
||||
public function removeFromAllTemplates(AttributeEvent $event)
|
||||
{
|
||||
// Delete this attribute from all product templates
|
||||
ProductTemplateAttributeQuery::create()->filterByAttributeId($event->getAttribute()->getId())->delete();
|
||||
AttributeTemplateQuery::create()->filterByAttribute($event->getAttribute())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
->filterByProductSaleElementsId($productSaleElementsId)
|
||||
->findOne();
|
||||
|
||||
$this->doAddItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice);
|
||||
$this->doAddItem($cart, $productId, $productPrice->getProductSaleElements(), $quantity, $productPrice);
|
||||
}
|
||||
|
||||
if ($append && $cartItem !== null) {
|
||||
@@ -166,17 +166,18 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
||||
* @param float $quantity
|
||||
* @param ProductPrice $productPrice
|
||||
*/
|
||||
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, $productSaleElementsId, $quantity, ProductPrice $productPrice)
|
||||
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, \Thelia\Model\ProductSaleElements $productSaleElements, $quantity, ProductPrice $productPrice)
|
||||
{
|
||||
$cartItem = new CartItem();
|
||||
$cartItem->setDisptacher($this->getDispatcher());
|
||||
$cartItem
|
||||
->setCart($cart)
|
||||
->setProductId($productId)
|
||||
->setProductSaleElementsId($productSaleElementsId)
|
||||
->setProductSaleElementsId($productSaleElements->getId())
|
||||
->setQuantity($quantity)
|
||||
->setPrice($productPrice->getPrice())
|
||||
->setPromoPrice($productPrice->getPromoPrice())
|
||||
->setPromo($productSaleElements->getPromo())
|
||||
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30))
|
||||
->save();
|
||||
}
|
||||
|
||||
@@ -24,52 +24,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,85 @@ 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
|
||||
/**
|
||||
* 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
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible($category->getVisible() ? false : true)
|
||||
->setCategory($event->getCategory())
|
||||
->setContentId($event->getContentId())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeContent(CategoryDeleteContentEvent $event) {
|
||||
|
||||
$content = CategoryAssociatedContentQuery::create()
|
||||
->filterByContentId($event->getContentId())
|
||||
->filterByCategory($event->getCategory())->findOne()
|
||||
;
|
||||
|
||||
if ($content !== null) {
|
||||
$content
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes category position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function changePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
if ($event->getMode() == CategoryChangePositionEvent::POSITION_ABSOLUTE)
|
||||
return $this->changeAbsolutePosition($event);
|
||||
else
|
||||
return $this->exchangePosition($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move up or down a category
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
protected function exchangePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
|
||||
if ($category !== null) {
|
||||
|
||||
// The current position of the category
|
||||
$my_position = $category->getPosition();
|
||||
|
||||
// Find category to exchange position with
|
||||
$search = CategoryQuery::create()
|
||||
->filterByParent($category->getParent());
|
||||
|
||||
// Up or down ?
|
||||
if ($event->getMode() == CategoryChangePositionEvent::POSITION_UP) {
|
||||
// Find the category immediately before me
|
||||
$search->filterByPosition(array('max' => $my_position-1))->orderByPosition(Criteria::DESC);
|
||||
} elseif ($event->getMode() == CategoryChangePositionEvent::POSITION_DOWN) {
|
||||
// Find the category immediately after me
|
||||
$search->filterByPosition(array('min' => $my_position+1))->orderByPosition(Criteria::ASC);
|
||||
} else
|
||||
|
||||
return;
|
||||
|
||||
$result = $search->findOne();
|
||||
|
||||
// If we found the proper category, exchange their positions
|
||||
if ($result) {
|
||||
|
||||
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
try {
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setPosition($result->getPosition())
|
||||
->save()
|
||||
;
|
||||
|
||||
$result->setPosition($my_position)->save();
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes category position
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
protected function changeAbsolutePosition(CategoryChangePositionEvent $event)
|
||||
{
|
||||
$category = CategoryQuery::create()->findPk($event->getCategoryId());
|
||||
|
||||
if ($category !== null) {
|
||||
|
||||
// The required position
|
||||
$new_position = $event->getPosition();
|
||||
|
||||
// The current position
|
||||
$current_position = $category->getPosition();
|
||||
|
||||
if ($new_position != null && $new_position > 0 && $new_position != $current_position) {
|
||||
|
||||
// Find categories to offset
|
||||
$search = CategoryQuery::create()->filterByParent($category->getParent());
|
||||
|
||||
if ($new_position > $current_position) {
|
||||
// The new position is after the current position -> we will offset + 1 all categories located between us and the new position
|
||||
$search->filterByPosition(array('min' => 1+$current_position, 'max' => $new_position));
|
||||
|
||||
$delta = -1;
|
||||
} else {
|
||||
// The new position is brefore the current position -> we will offset - 1 all categories located between us and the new position
|
||||
$search->filterByPosition(array('min' => $new_position, 'max' => $current_position - 1));
|
||||
|
||||
$delta = 1;
|
||||
}
|
||||
|
||||
$results = $search->find();
|
||||
|
||||
$cnx = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
|
||||
|
||||
$cnx->beginTransaction();
|
||||
|
||||
try {
|
||||
foreach ($results as $result) {
|
||||
$result->setPosition($result->getPosition() + $delta)->save($cnx);
|
||||
}
|
||||
|
||||
$category
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setPosition($new_position)
|
||||
->save($cnx)
|
||||
;
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber listens to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CATEGORY_CREATE => array("create", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
|
||||
TheliaEvents::CATEGORY_CREATE => array("create", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE => array("update", 128),
|
||||
TheliaEvents::CATEGORY_DELETE => array("delete", 128),
|
||||
TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
TheliaEvents::CATEGORY_CHANGE_POSITION => array("changePosition", 128),
|
||||
|
||||
"action.updateCategoryPositionU" => array("changePositionUp", 128),
|
||||
"action.updateCategoryPositionDown" => array("changePositionDown", 128),
|
||||
"action.updateCategoryPosition" => array("changePosition", 128),
|
||||
TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
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
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
112
core/lib/Thelia/Action/Content.php
Normal file
112
core/lib/Thelia/Action/Content.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?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\Content\ContentCreateEvent;
|
||||
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\Content as ContentModel;
|
||||
use Thelia\Model\FolderQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class Content
|
||||
* @package Thelia\Action
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Content extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
public function create(ContentCreateEvent $event)
|
||||
{
|
||||
$content = new ContentModel();
|
||||
|
||||
$content
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->create($event->getDefaultFolder())
|
||||
;
|
||||
|
||||
$event->setContent($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* process update content
|
||||
*
|
||||
* @param ContentUpdateEvent $event
|
||||
*/
|
||||
public function update(ContentUpdateEvent $event)
|
||||
{
|
||||
if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) {
|
||||
$content->setDispatcher($this->getDispatcher());
|
||||
|
||||
$content
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setContent($content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::CONTENT_CREATE => array("create", 128),
|
||||
TheliaEvents::CONTENT_UPDATE => array("update", 128),
|
||||
TheliaEvents::CONTENT_DELETE => array("delete", 128),
|
||||
TheliaEvents::CONTENT_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
TheliaEvents::CONTENT_UPDATE_POSITION => array("updatePosition", 128),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,10 +23,16 @@
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Constraint\ConstraintFactory;
|
||||
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Coupon\CouponFactory;
|
||||
use Thelia\Coupon\CouponManager;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
use Thelia\Model\Coupon as CouponModel;
|
||||
|
||||
/**
|
||||
@@ -45,7 +51,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
/**
|
||||
* Occurring when a Coupon is about to be created
|
||||
*
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Event
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Coupon
|
||||
*/
|
||||
public function create(CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
@@ -57,7 +63,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
/**
|
||||
* Occurring when a Coupon is about to be updated
|
||||
*
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Event
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Coupon
|
||||
*/
|
||||
public function update(CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
@@ -69,7 +75,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
/**
|
||||
* Occurring when a Coupon rule is about to be updated
|
||||
*
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Event
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Coupon Rule
|
||||
*/
|
||||
public function updateRule(CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
@@ -81,11 +87,43 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
/**
|
||||
* Occurring when a Coupon rule is about to be consumed
|
||||
*
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Event
|
||||
* @param CouponConsumeEvent $event Event consuming Coupon
|
||||
*/
|
||||
public function consume(CouponCreateOrUpdateEvent $event)
|
||||
public function consume(CouponConsumeEvent $event)
|
||||
{
|
||||
// @todo implements
|
||||
$totalDiscount = 0;
|
||||
|
||||
/** @var CouponFactory $couponFactory */
|
||||
$couponFactory = $this->container->get('thelia.coupon.factory');
|
||||
|
||||
/** @var CouponManager $couponManager */
|
||||
$couponManager = $this->container->get('thelia.coupon.manager');
|
||||
|
||||
/** @var CouponInterface $coupon */
|
||||
$coupon = $couponFactory->buildCouponFromCode($event->getCode());
|
||||
|
||||
$isValid = $coupon->isMatching();
|
||||
if ($isValid) {
|
||||
/** @var Request $request */
|
||||
$request = $this->container->get('request');
|
||||
$consumedCoupons = $request->getSession()->getConsumedCoupons();
|
||||
|
||||
if (!isset($consumedCoupons) || !$consumedCoupons) {
|
||||
$consumedCoupons = array();
|
||||
}
|
||||
|
||||
// Prevent accumulation of the same Coupon on a Checkout
|
||||
$consumedCoupons[$event->getCode()] = $event->getCode();
|
||||
|
||||
$request->getSession()->setConsumedCoupons($consumedCoupons);
|
||||
|
||||
$totalDiscount = $couponManager->getDiscount();
|
||||
|
||||
// @todo modify Cart total discount
|
||||
}
|
||||
|
||||
$event->setIsValid($isValid);
|
||||
$event->setDiscount($totalDiscount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,8 +203,6 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
return array(
|
||||
TheliaEvents::COUPON_CREATE => array("create", 128),
|
||||
TheliaEvents::COUPON_UPDATE => array("update", 128),
|
||||
TheliaEvents::COUPON_DISABLE => array("disable", 128),
|
||||
TheliaEvents::COUPON_ENABLE => array("enable", 128),
|
||||
TheliaEvents::COUPON_CONSUME => array("consume", 128),
|
||||
TheliaEvents::COUPON_RULE_UPDATE => array("updateRule", 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),
|
||||
);
|
||||
}
|
||||
}
|
||||
186
core/lib/Thelia/Action/Feature.php
Normal file
186
core/lib/Thelia/Action/Feature.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Model\Feature as FeatureModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\FeatureUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureCreateEvent;
|
||||
use Thelia\Core\Event\FeatureDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\FeatureAv;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryEvent;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
use Thelia\Model\FeatureTemplate;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
|
||||
class Feature extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new feature entry
|
||||
*
|
||||
* @param FeatureCreateEvent $event
|
||||
*/
|
||||
public function create(FeatureCreateEvent $event)
|
||||
{
|
||||
$feature = new FeatureModel();
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setFeature($feature);
|
||||
|
||||
// Add atribute to all product templates if required
|
||||
if ($event->getAddToAllTemplates() != 0) {
|
||||
// TODO: add to all product template
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product feature
|
||||
*
|
||||
* @param FeatureUpdateEvent $event
|
||||
*/
|
||||
public function update(FeatureUpdateEvent $event)
|
||||
{
|
||||
$search = FeatureQuery::create();
|
||||
|
||||
if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setFeature($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product feature entry
|
||||
*
|
||||
* @param FeatureDeleteEvent $event
|
||||
*/
|
||||
public function delete(FeatureDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setFeature($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $feature = FeatureQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$feature->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $feature->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $feature->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $feature->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
protected function doAddToAllTemplates(FeatureModel $feature)
|
||||
{
|
||||
$templates = TemplateQuery::create()->find();
|
||||
|
||||
foreach($templates as $template) {
|
||||
|
||||
$feature_template = new FeatureTemplate();
|
||||
|
||||
if (null === FeatureTemplateQuery::create()->filterByFeature($feature)->filterByTemplate($template)->findOne()) {
|
||||
$feature_template
|
||||
->setFeature($feature)
|
||||
->setTemplate($template)
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addToAllTemplates(FeatureEvent $event)
|
||||
{
|
||||
$this->doAddToAllTemplates($event->getFeature());
|
||||
}
|
||||
|
||||
public function removeFromAllTemplates(FeatureEvent $event)
|
||||
{
|
||||
// Delete this feature from all product templates
|
||||
FeatureTemplateQuery::create()->filterByFeature($event->getFeature())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FEATURE_CREATE => array("create", 128),
|
||||
TheliaEvents::FEATURE_UPDATE => array("update", 128),
|
||||
TheliaEvents::FEATURE_DELETE => array("delete", 128),
|
||||
TheliaEvents::FEATURE_UPDATE_POSITION => array("updatePosition", 128),
|
||||
|
||||
TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES => array("removeFromAllTemplates", 128),
|
||||
TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES => array("addToAllTemplates", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
143
core/lib/Thelia/Action/FeatureAv.php
Normal file
143
core/lib/Thelia/Action/FeatureAv.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Model\FeatureAv as FeatureAvModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureAvCreateEvent;
|
||||
use Thelia\Core\Event\FeatureAvDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
class FeatureAv extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new feature entry
|
||||
*
|
||||
* @param FeatureAvCreateEvent $event
|
||||
*/
|
||||
public function create(FeatureAvCreateEvent $event)
|
||||
{
|
||||
$feature = new FeatureAvModel();
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setFeatureId($event->getFeatureId())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product feature
|
||||
*
|
||||
* @param FeatureAvUpdateEvent $event
|
||||
*/
|
||||
public function update(FeatureAvUpdateEvent $event)
|
||||
{
|
||||
$search = FeatureAvQuery::create();
|
||||
|
||||
if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
|
||||
->save();
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product feature entry
|
||||
*
|
||||
* @param FeatureAvDeleteEvent $event
|
||||
*/
|
||||
public function delete(FeatureAvDeleteEvent $event)
|
||||
{
|
||||
|
||||
if (null !== ($feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId()))) {
|
||||
|
||||
$feature
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setFeatureAv($feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param CategoryChangePositionEvent $event
|
||||
*/
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $feature = FeatureAvQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$feature->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $feature->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $feature->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $feature->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FEATURE_AV_CREATE => array("create", 128),
|
||||
TheliaEvents::FEATURE_AV_UPDATE => array("update", 128),
|
||||
TheliaEvents::FEATURE_AV_DELETE => array("delete", 128),
|
||||
TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
155
core/lib/Thelia/Action/Folder.php
Normal file
155
core/lib/Thelia/Action/Folder.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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\FolderCreateEvent;
|
||||
use Thelia\Core\Event\FolderDeleteEvent;
|
||||
use Thelia\Core\Event\FolderToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\FolderUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\Folder as FolderModel;
|
||||
|
||||
|
||||
/**
|
||||
* Class Folder
|
||||
* @package Thelia\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Folder extends BaseAction implements EventSubscriberInterface {
|
||||
|
||||
|
||||
public function update(FolderUpdateEvent $event)
|
||||
{
|
||||
|
||||
if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) {
|
||||
$folder->setDispatcher($this->getDispatcher());
|
||||
|
||||
$folder
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
->save();
|
||||
;
|
||||
|
||||
$event->setFolder($folder);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(FolderDeleteEvent $event)
|
||||
{
|
||||
if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) {
|
||||
$folder->setDispatcher($this->getDispatcher())
|
||||
->delete();
|
||||
|
||||
$event->setFolder($folder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FolderCreateEvent $event
|
||||
*/
|
||||
public function create(FolderCreateEvent $event)
|
||||
{
|
||||
$folder = new FolderModel();
|
||||
$folder->setDispatcher($this->getDispatcher());
|
||||
|
||||
$folder
|
||||
->setParent($event->getParent())
|
||||
->setVisible($event->getVisible())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->save();
|
||||
|
||||
$event->setFolder($folder);
|
||||
}
|
||||
|
||||
public function toggleVisibility(FolderToggleVisibilityEvent $event)
|
||||
{
|
||||
$folder = $event->getFolder();
|
||||
|
||||
$folder
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setVisible(!$folder->getVisible())
|
||||
->save();
|
||||
|
||||
}
|
||||
|
||||
public function updatePosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if(null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) {
|
||||
$folder->setDispatcher($this->getDispatcher());
|
||||
|
||||
switch($event->getMode())
|
||||
{
|
||||
case UpdatePositionEvent::POSITION_ABSOLUTE:
|
||||
$folder->changeAbsolutePosition($event->getPosition());
|
||||
break;
|
||||
case UpdatePositionEvent::POSITION_DOWN:
|
||||
$folder->movePositionDown();
|
||||
break;
|
||||
case UpdatePositionEvent::POSITION_UP:
|
||||
$folder->movePositionUp();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::FOLDER_CREATE => array("create", 128),
|
||||
TheliaEvents::FOLDER_UPDATE => array("update", 128),
|
||||
TheliaEvents::FOLDER_DELETE => array("delete", 128),
|
||||
TheliaEvents::FOLDER_TOGGLE_VISIBILITY => array("toggleVisibility", 128),
|
||||
|
||||
TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace Thelia\Action;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
@@ -43,6 +44,10 @@ class HttpException extends BaseAction implements EventSubscriberInterface
|
||||
if ($event->getException() instanceof NotFoundHttpException) {
|
||||
$this->display404($event);
|
||||
}
|
||||
|
||||
if($event->getException() instanceof AccessDeniedHttpException) {
|
||||
$this->display403($event);
|
||||
}
|
||||
}
|
||||
|
||||
protected function display404(GetResponseForExceptionEvent $event)
|
||||
|
||||
@@ -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())
|
||||
|
||||
350
core/lib/Thelia/Action/Order.php
Executable file
350
core/lib/Thelia/Action/Order.php
Executable file
@@ -0,0 +1,350 @@
|
||||
<?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 Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\OrderProductAttributeCombination;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\OrderProduct;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
use Thelia\Model\OrderAddress;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\I18n;
|
||||
|
||||
/**
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setInvoiceAddress(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->chosenInvoiceAddress = $event->getInvoiceAddress();
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function setPaymentModule(OrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
|
||||
$order->setPaymentModuleId($event->getPaymentModule());
|
||||
|
||||
$event->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function create(OrderEvent $event)
|
||||
{
|
||||
$con = \Propel\Runtime\Propel::getConnection(
|
||||
OrderTableMap::DATABASE_NAME
|
||||
);
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
$sessionOrder = $event->getOrder();
|
||||
|
||||
/* use a copy to avoid errored reccord in session */
|
||||
$placedOrder = $sessionOrder->copy();
|
||||
$placedOrder->setDispatcher($this->getDispatcher());
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$currency = $this->getSession()->getCurrency();
|
||||
$lang = $this->getSession()->getLang();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress);
|
||||
$taxCountry = $deliveryAddress->getCountry();
|
||||
$invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress);
|
||||
$cart = $this->getSession()->getCart();
|
||||
$cartItems = $cart->getCartItems();
|
||||
|
||||
$paymentModule = ModuleQuery::create()->findPk($placedOrder->getPaymentModuleId());
|
||||
|
||||
/* fulfill order */
|
||||
$placedOrder->setCustomerId($customer->getId());
|
||||
$placedOrder->setCurrencyId($currency->getId());
|
||||
$placedOrder->setCurrencyRate($currency->getRate());
|
||||
$placedOrder->setLangId($lang->getId());
|
||||
|
||||
/* hard save the delivery and invoice addresses */
|
||||
$deliveryOrderAddress = new OrderAddress();
|
||||
$deliveryOrderAddress
|
||||
->setCustomerTitleId($deliveryAddress->getTitleId())
|
||||
->setCompany($deliveryAddress->getCompany())
|
||||
->setFirstname($deliveryAddress->getFirstname())
|
||||
->setLastname($deliveryAddress->getLastname())
|
||||
->setAddress1($deliveryAddress->getAddress1())
|
||||
->setAddress2($deliveryAddress->getAddress2())
|
||||
->setAddress3($deliveryAddress->getAddress3())
|
||||
->setZipcode($deliveryAddress->getZipcode())
|
||||
->setCity($deliveryAddress->getCity())
|
||||
->setPhone($deliveryAddress->getPhone())
|
||||
->setCountryId($deliveryAddress->getCountryId())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
$invoiceOrderAddress = new OrderAddress();
|
||||
$invoiceOrderAddress
|
||||
->setCustomerTitleId($invoiceAddress->getTitleId())
|
||||
->setCompany($invoiceAddress->getCompany())
|
||||
->setFirstname($invoiceAddress->getFirstname())
|
||||
->setLastname($invoiceAddress->getLastname())
|
||||
->setAddress1($invoiceAddress->getAddress1())
|
||||
->setAddress2($invoiceAddress->getAddress2())
|
||||
->setAddress3($invoiceAddress->getAddress3())
|
||||
->setZipcode($invoiceAddress->getZipcode())
|
||||
->setCity($invoiceAddress->getCity())
|
||||
->setPhone($invoiceAddress->getPhone())
|
||||
->setCountryId($invoiceAddress->getCountryId())
|
||||
->save($con)
|
||||
;
|
||||
|
||||
$placedOrder->setDeliveryOrderAddressId($deliveryOrderAddress->getId());
|
||||
$placedOrder->setInvoiceOrderAddressId($invoiceOrderAddress->getId());
|
||||
|
||||
$placedOrder->setStatusId(
|
||||
OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_NOT_PAID)->getId()
|
||||
);
|
||||
|
||||
$placedOrder->save($con);
|
||||
|
||||
/* fulfill order_products and decrease stock */
|
||||
|
||||
foreach($cartItems as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
|
||||
/* get translation */
|
||||
$productI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Product', $product->getId());
|
||||
|
||||
$pse = $cartItem->getProductSaleElements();
|
||||
|
||||
/* check still in stock */
|
||||
if($cartItem->getQuantity() > $pse->getQuantity()) {
|
||||
throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem);
|
||||
}
|
||||
|
||||
/* decrease stock */
|
||||
$pse->setQuantity(
|
||||
$pse->getQuantity() - $cartItem->getQuantity()
|
||||
);
|
||||
$pse->save($con);
|
||||
|
||||
/* get tax */
|
||||
$taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId());
|
||||
|
||||
$taxDetail = $product->getTaxRule()->getTaxDetail(
|
||||
$taxCountry,
|
||||
$cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(),
|
||||
$this->getSession()->getLang()->getLocale()
|
||||
);
|
||||
|
||||
$orderProduct = new OrderProduct();
|
||||
$orderProduct
|
||||
->setOrderId($placedOrder->getId())
|
||||
->setProductRef($product->getRef())
|
||||
->setProductSaleElementsRef($pse->getRef())
|
||||
->setTitle($productI18n->getTitle())
|
||||
->setChapo($productI18n->getChapo())
|
||||
->setDescription($productI18n->getDescription())
|
||||
->setPostscriptum($productI18n->getPostscriptum())
|
||||
->setQuantity($cartItem->getQuantity())
|
||||
->setPrice($cartItem->getPrice())
|
||||
->setPromoPrice($cartItem->getPromoPrice())
|
||||
->setWasNew($pse->getNewness())
|
||||
->setWasInPromo($cartItem->getPromo())
|
||||
->setWeight($pse->getWeight())
|
||||
->setTaxRuleTitle($taxRuleI18n->getTitle())
|
||||
->setTaxRuleDescription($taxRuleI18n->getDescription())
|
||||
;
|
||||
$orderProduct->setDispatcher($this->getDispatcher());
|
||||
$orderProduct->save($con);
|
||||
|
||||
/* fulfill order_product_tax */
|
||||
foreach($taxDetail as $tax) {
|
||||
$tax->setOrderProductId($orderProduct->getId());
|
||||
$tax->save($con);
|
||||
}
|
||||
|
||||
/* fulfill order_attribute_combination and decrease stock */
|
||||
foreach($pse->getAttributeCombinations() as $attributeCombination) {
|
||||
$attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId());
|
||||
$attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId());
|
||||
|
||||
$orderAttributeCombination = new OrderProductAttributeCombination();
|
||||
$orderAttributeCombination
|
||||
->setOrderProductId($orderProduct->getId())
|
||||
->setAttributeTitle($attribute->getTitle())
|
||||
->setAttributeChapo($attribute->getChapo())
|
||||
->setAttributeDescription($attribute->getDescription())
|
||||
->setAttributePostscriptumn($attribute->getPostscriptum())
|
||||
->setAttributeAvTitle($attributeAv->getTitle())
|
||||
->setAttributeAvChapo($attributeAv->getChapo())
|
||||
->setAttributeAvDescription($attributeAv->getDescription())
|
||||
->setAttributeAvPostscriptum($attributeAv->getPostscriptum())
|
||||
;
|
||||
|
||||
$orderAttributeCombination->save($con);
|
||||
}
|
||||
}
|
||||
|
||||
/* discount @todo */
|
||||
|
||||
$con->commit();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder));
|
||||
|
||||
/* clear session */
|
||||
/* but memorize placed order */
|
||||
$sessionOrder = new \Thelia\Model\Order();
|
||||
$event->setOrder($sessionOrder);
|
||||
$event->setPlacedOrder($placedOrder);
|
||||
$this->getSession()->setOrder($sessionOrder);
|
||||
|
||||
/* empty cart @todo */
|
||||
|
||||
/* call pay method */
|
||||
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
$paymentModuleInstance = $paymentModuleReflection->newInstance();
|
||||
|
||||
$paymentModuleInstance->setRequest($this->getRequest());
|
||||
$paymentModuleInstance->setDispatcher($this->getDispatcher());
|
||||
|
||||
$paymentModuleInstance->pay($placedOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function sendOrderEmail(OrderEvent $event)
|
||||
{
|
||||
/* @todo */
|
||||
}
|
||||
|
||||
/**
|
||||
* 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),
|
||||
TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128),
|
||||
TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128),
|
||||
TheliaEvents::ORDER_PAY => array("create", 128),
|
||||
TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the security context
|
||||
*
|
||||
* @return SecurityContext
|
||||
*/
|
||||
protected function getSecurityContext()
|
||||
{
|
||||
return $this->container->get('thelia.securityContext');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected function getRequest()
|
||||
{
|
||||
return $this->container->get('request');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the session from the current request
|
||||
*
|
||||
* @return \Thelia\Core\HttpFoundation\Session\Session
|
||||
*/
|
||||
protected function getSession()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
return $request->getSession();
|
||||
}
|
||||
}
|
||||
271
core/lib/Thelia/Action/Product.php
Normal file
271
core/lib/Thelia/Action/Product.php
Normal file
@@ -0,0 +1,271 @@
|
||||
<?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;
|
||||
use Thelia\Model\AccessoryQuery;
|
||||
use Thelia\Model\Accessory;
|
||||
use Thelia\Core\Event\ProductAddAccessoryEvent;
|
||||
use Thelia\Core\Event\ProductDeleteAccessoryEvent;
|
||||
|
||||
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
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->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
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
}
|
||||
|
||||
public function addAccessory(ProductAddAccessoryEvent $event) {
|
||||
|
||||
if (AccessoryQuery::create()
|
||||
->filterByAccessory($event->getAccessoryId())
|
||||
->filterByProductId($event->getProduct()->getId())->count() <= 0) {
|
||||
|
||||
$accessory = new Accessory();
|
||||
|
||||
$accessory
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setProductId($event->getProduct()->getId())
|
||||
->setAccessory($event->getAccessoryId())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAccessory(ProductDeleteAccessoryEvent $event) {
|
||||
|
||||
$accessory = AccessoryQuery::create()
|
||||
->filterByAccessory($event->getAccessoryId())
|
||||
->filterByProductId($event->getProduct()->getId())->findOne()
|
||||
;
|
||||
|
||||
if ($accessory !== null)
|
||||
$accessory
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes position, selecting absolute ou relative change.
|
||||
*
|
||||
* @param ProductChangePositionEvent $event
|
||||
*/
|
||||
public function updateAccessoryPosition(UpdatePositionEvent $event)
|
||||
{
|
||||
if (null !== $accessory = AccessoryQuery::create()->findPk($event->getObjectId())) {
|
||||
|
||||
$accessory->setDispatcher($this->getDispatcher());
|
||||
|
||||
$mode = $event->getMode();
|
||||
|
||||
if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE)
|
||||
return $accessory->changeAbsolutePosition($event->getPosition());
|
||||
else if ($mode == UpdatePositionEvent::POSITION_UP)
|
||||
return $accessory->movePositionUp();
|
||||
else if ($mode == UpdatePositionEvent::POSITION_DOWN)
|
||||
return $accessory->movePositionDown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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),
|
||||
TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128),
|
||||
|
||||
TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128),
|
||||
TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
190
core/lib/Thelia/Action/Template.php
Normal file
190
core/lib/Thelia/Action/Template.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?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\TemplateQuery;
|
||||
use Thelia\Model\Template as TemplateModel;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
use Thelia\Core\Event\TemplateUpdateEvent;
|
||||
use Thelia\Core\Event\TemplateCreateEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteEvent;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\TemplateAv;
|
||||
use Thelia\Model\TemplateAvQuery;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Event\CategoryEvent;
|
||||
use Thelia\Core\Event\TemplateEvent;
|
||||
use Thelia\Model\TemplateTemplate;
|
||||
use Thelia\Model\TemplateTemplateQuery;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||
use Thelia\Model\AttributeTemplateQuery;
|
||||
use Thelia\Model\AttributeTemplate;
|
||||
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||
use Thelia\Model\FeatureTemplateQuery;
|
||||
use Thelia\Model\FeatureTemplate;
|
||||
|
||||
class Template extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* Create a new template entry
|
||||
*
|
||||
* @param TemplateCreateEvent $event
|
||||
*/
|
||||
public function create(TemplateCreateEvent $event)
|
||||
{
|
||||
$template = new TemplateModel();
|
||||
|
||||
$template
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setName($event->getTemplateName())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
$event->setTemplate($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a product template
|
||||
*
|
||||
* @param TemplateUpdateEvent $event
|
||||
*/
|
||||
public function update(TemplateUpdateEvent $event)
|
||||
{
|
||||
$search = TemplateQuery::create();
|
||||
|
||||
if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) {
|
||||
|
||||
$template
|
||||
->setDispatcher($this->getDispatcher())
|
||||
|
||||
->setLocale($event->getLocale())
|
||||
->setName($event->getTemplateName())
|
||||
->save();
|
||||
|
||||
$event->setTemplate($template);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a product template entry
|
||||
*
|
||||
* @param TemplateDeleteEvent $event
|
||||
*/
|
||||
public function delete(TemplateDeleteEvent $event)
|
||||
{
|
||||
if (null !== ($template = TemplateQuery::create()->findPk($event->getTemplateId()))) {
|
||||
|
||||
// Check if template is used by a product
|
||||
$product_count = ProductQuery::create()->findByTemplateId($template->getId())->count();
|
||||
|
||||
if ($product_count <= 0) {
|
||||
$template
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->delete()
|
||||
;
|
||||
}
|
||||
|
||||
$event->setTemplate($template);
|
||||
|
||||
$event->setProductCount($product_count);
|
||||
}
|
||||
}
|
||||
|
||||
public function addAttribute(TemplateAddAttributeEvent $event) {
|
||||
|
||||
if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||
|
||||
$attribute_template = new AttributeTemplate();
|
||||
|
||||
$attribute_template
|
||||
->setAttributeId($event->getAttributeId())
|
||||
->setTemplate($event->getTemplate())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAttribute(TemplateDeleteAttributeEvent $event) {
|
||||
|
||||
$attribute_template = AttributeTemplateQuery::create()
|
||||
->filterByAttributeId($event->getAttributeId())
|
||||
->filterByTemplate($event->getTemplate())->findOne()
|
||||
;
|
||||
|
||||
if ($attribute_template !== null) $attribute_template->delete();
|
||||
}
|
||||
|
||||
public function addFeature(TemplateAddFeatureEvent $event) {
|
||||
|
||||
if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) {
|
||||
|
||||
$feature_template = new FeatureTemplate();
|
||||
|
||||
$feature_template
|
||||
->setFeatureId($event->getFeatureId())
|
||||
->setTemplate($event->getTemplate())
|
||||
->save()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFeature(TemplateDeleteFeatureEvent $event) {
|
||||
|
||||
$feature_template = FeatureTemplateQuery::create()
|
||||
->filterByFeatureId($event->getFeatureId())
|
||||
->filterByTemplate($event->getTemplate())->findOne()
|
||||
;
|
||||
|
||||
if ($feature_template !== null) $feature_template->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::TEMPLATE_CREATE => array("create", 128),
|
||||
TheliaEvents::TEMPLATE_UPDATE => array("update", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE => array("delete", 128),
|
||||
|
||||
TheliaEvents::TEMPLATE_ADD_ATTRIBUTE => array("addAttribute", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE => array("deleteAttribute", 128),
|
||||
|
||||
TheliaEvents::TEMPLATE_ADD_FEATURE => array("addFeature", 128),
|
||||
TheliaEvents::TEMPLATE_DELETE_FEATURE => array("deleteFeature", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -139,4 +139,6 @@ trait CartTrait
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
abstract public function getDispatcher();
|
||||
}
|
||||
|
||||
@@ -62,26 +62,34 @@ class CacheClear extends ContainerAwareCommand
|
||||
|
||||
$this->clearCache($cacheDir, $output);
|
||||
if (!$input->getOption("without-assets")) {
|
||||
$this->clearCache(THELIA_WEB_DIR . "/assets", $output);
|
||||
$this->clearCache(THELIA_WEB_DIR . "assets", $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function clearCache($dir, OutputInterface $output)
|
||||
{
|
||||
if (!is_writable($dir)) {
|
||||
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $dir));
|
||||
}
|
||||
|
||||
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $dir));
|
||||
|
||||
try {
|
||||
$directoryBrowser = new \DirectoryIterator($dir);
|
||||
} catch(\UnexpectedValueException $e) {
|
||||
// throws same exception code for does not exist and permission denied ...
|
||||
if(!file_exists($dir)) {
|
||||
$output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir));
|
||||
return;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$fs = new Filesystem();
|
||||
try {
|
||||
$fs->remove($dir);
|
||||
|
||||
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
|
||||
} catch (IOException $e) {
|
||||
$output->writeln(sprintf("error during clearing cache : %s", $e->getMessage()));
|
||||
$output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
core/lib/Thelia/Command/ModuleActivateCommand.php
Executable file
90
core/lib/Thelia/Command/ModuleActivateCommand.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?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\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
|
||||
use Thelia\Command\ContainerAwareCommand;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
/**
|
||||
* activates a module
|
||||
*
|
||||
* Class ModuleActivateCommand
|
||||
* @package Thelia\Command
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ModuleActivateCommand extends BaseModuleGenerate
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName("module:activate")
|
||||
->setDescription("Activates a module")
|
||||
->addArgument(
|
||||
"module" ,
|
||||
InputArgument::REQUIRED,
|
||||
"module to activate"
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$moduleCode = $this->formatModuleName($input->getArgument("module"));
|
||||
|
||||
$module = ModuleQuery::create()->findOneByCode($moduleCode);
|
||||
|
||||
if(null === $module) {
|
||||
throw new \RuntimeException(sprintf("module %s not found", $moduleCode));
|
||||
}
|
||||
|
||||
try {
|
||||
new \TheliaDebugBar\TheliaDebugBar();
|
||||
|
||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
||||
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->activate();
|
||||
} catch(\Exception $e) {
|
||||
throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage()));
|
||||
}
|
||||
|
||||
//impossible to change output class in CommandTester...
|
||||
if (method_exists($output, "renderBlock")) {
|
||||
$output->renderBlock(array(
|
||||
'',
|
||||
sprintf("Activation succeed for module %s", $moduleCode),
|
||||
''
|
||||
), "bg=green;fg=black");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"/>
|
||||
@@ -57,21 +67,46 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.template" class="Thelia\Action\Template">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.attribute" class="Thelia\Action\Attribute">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.feature" class="Thelia\Action\Feature">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.featureav" class="Thelia\Action\FeatureAv">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.httpException" class="Thelia\Action\HttpException">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.folder" class="Thelia\Action\Folder">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.content" class="Thelia\Action\Content">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
</services>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -18,27 +18,34 @@
|
||||
<loop class="Thelia\Core\Template\Loop\Currency" name="currency"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Customer" name="customer"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Feature" name="feature"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureAvailability" name="feature_availability"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureAvailability" name="feature-availability"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureValue" name="feature_value"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Folder" name="folder"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Module" name="module"/>
|
||||
<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"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Title" name="title"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Lang" name="lang"/>
|
||||
<loop class="Thelia\Core\Template\Loop\CategoryTree" name="category-tree"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FolderTree" name="folder-tree"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Cart" name="cart"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Image" name="image"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Config" name="config"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Coupon" name="coupon"/>
|
||||
<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"/>
|
||||
@@ -50,13 +57,25 @@
|
||||
<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.admin.folder.creation" class="Thelia\Form\FolderCreationForm"/>
|
||||
<form name="thelia.admin.folder.modification" class="Thelia\Form\FolderModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.content.creation" class="Thelia\Form\ContentCreationForm"/>
|
||||
<form name="thelia.admin.content.modification" class="Thelia\Form\ContentModificationForm"/>
|
||||
|
||||
<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"/>
|
||||
|
||||
@@ -71,7 +90,21 @@
|
||||
<form name="thelia.admin.attribute.creation" class="Thelia\Form\AttributeCreationForm"/>
|
||||
<form name="thelia.admin.attribute.modification" class="Thelia\Form\AttributeModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.feature.creation" class="Thelia\Form\FeatureCreationForm"/>
|
||||
<form name="thelia.admin.feature.modification" class="Thelia\Form\FeatureModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.attributeav.creation" class="Thelia\Form\AttributeAvCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.featureav.creation" class="Thelia\Form\FeatureAvCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
|
||||
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
|
||||
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.profile.modification" class="Thelia\Form\ProfileModificationForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
|
||||
@@ -82,6 +115,7 @@
|
||||
<command class="Thelia\Command\ModuleGenerateCommand"/>
|
||||
<command class="Thelia\Command\ModuleGenerateModelCommand"/>
|
||||
<command class="Thelia\Command\ModuleGenerateSqlCommand"/>
|
||||
<command class="Thelia\Command\ModuleActivateCommand"/>
|
||||
<command class="Thelia\Command\CreateAdminUser"/>
|
||||
<command class="Thelia\Command\ReloadDatabaseCommand"/>
|
||||
</commands>
|
||||
@@ -188,6 +222,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>
|
||||
|
||||
@@ -196,6 +231,7 @@
|
||||
<argument type="service" id="request" />
|
||||
<argument type="service" id="thelia.securityContext" />
|
||||
<argument type="service" id="thelia.parser.context"/>
|
||||
<argument type="service" id="event_dispatcher"/>
|
||||
</service>
|
||||
|
||||
<service id="smarty.plugin.adminUtilities" class="Thelia\Core\Template\Smarty\Plugins\AdminUtilities" scope="request">
|
||||
@@ -230,6 +266,8 @@
|
||||
<service id="thelia.constraint.factory" class="Thelia\Constraint\ConstraintFactory">
|
||||
<argument type="service" id="service_container" />
|
||||
</service>
|
||||
<service id="thelia.constraint.validator" class="Thelia\Constraint\ConstraintValidator">
|
||||
</service>
|
||||
<service id="thelia.constraint.rule.available_for_everyone" class="Thelia\Constraint\Rule\AvailableForEveryoneManager">
|
||||
<argument type="service" id="thelia.adapter" />
|
||||
<tag name="thelia.coupon.addRule"/>
|
||||
@@ -252,6 +290,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>
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\SessionController::checkLoginAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Route to edit admin profile -->
|
||||
<route id="admin.profile.update.view" path="/admin/profile/update" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdminController::updateAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
|
||||
<!-- Route to the catalog controller -->
|
||||
|
||||
@@ -85,7 +91,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,33 +101,164 @@
|
||||
<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>
|
||||
|
||||
<!-- Related content -->
|
||||
|
||||
<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>
|
||||
|
||||
<!-- Product accessories -->
|
||||
|
||||
<route id="admin.products.accessories.add" path="/admin/products/accessory/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::addAccessoryAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.accessories.delete" path="/admin/products/accessory/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::deleteAccessoryAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.product.accessories-content" path="/admin/product/{productId}/available-accessories/{categoryId}.{_format}" methods="GET">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::getAvailableAccessoriesAction</default>
|
||||
<requirement key="_format">xml|json</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.products.update-accessory-position" path="/admin/products/update-accessory-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateAccessoryPositionAction</default>
|
||||
</route>
|
||||
|
||||
<!--Features and attributes -->
|
||||
|
||||
<route id="admin.products.update-attributes-and-features" path="/admin/product/{productId}/update-attributes-and-features">
|
||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateAttributesAndFeaturesAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- Folder routes management -->
|
||||
<route id="admin.folders.default" path="/admin/folders">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.create" path="/admin/folders/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.update" path="/admin/folders/update/{folder_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::updateAction</default>
|
||||
<requirement key="folder_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.toggle-online" path="/admin/folders/toggle-online">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::setToggleVisibilityAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.save" path="/admin/folders/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.delete" path="/admin/folders/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.folders.update-position" path="/admin/folders/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<!-- content routes management -->
|
||||
<route id="admin.folders.create" path="/admin/content/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\ContentController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.content.update" path="admin/content/update/{content_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\ContentController::updateAction</default>
|
||||
<requirement key="content_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.content.save" path="/admin/content/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\ContentController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- Route to the Coupon controller (process Coupon browsing) -->
|
||||
|
||||
<route id="admin.coupon.list" path="/admin/coupon">
|
||||
<route id="admin.coupon.list" path="/admin/coupon/">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::browseAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.create" path="/admin/coupon/create">
|
||||
<route id="admin.coupon.create" path="/admin/coupon/create/">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::createAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}">
|
||||
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}/">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::updateAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}">
|
||||
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}/">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::readAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}">
|
||||
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}/">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::getRuleInputAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.rule.update" path="/admin/coupon/{couponId}/rule/update/">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::updateRulesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.coupon.consume" path="/admin/coupon/consume/{couponCode}/">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::consumeAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Routes to the Config (system variables) controller -->
|
||||
|
||||
@@ -210,6 +347,53 @@
|
||||
</route>
|
||||
|
||||
|
||||
<!-- Product templates management -->
|
||||
|
||||
<route id="admin.configuration.templates.default" path="/admin/configuration/templates">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.create" path="/admin/configuration/templates/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.update" path="/admin/configuration/templates/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.save" path="/admin/configuration/templates/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.delete" path="/admin/configuration/templates/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.list" path="/admin/configuration/templates/features/list">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxFeaturesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.add" path="/admin/configuration/templates/features/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::addFeatureAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.features.delete" path="/admin/configuration/templates/features/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteFeatureAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.list" path="/admin/configuration/templates/attributes/list">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::getAjaxAttributesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.add" path="/admin/configuration/templates/attributes/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::addAttributeAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.templates.attributes.delete" path="/admin/configuration/templates/attributes/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TemplateController::deleteAttributeAction</default>
|
||||
</route>
|
||||
|
||||
|
||||
<!-- attribute and attributes value management -->
|
||||
|
||||
<route id="admin.configuration.attributes.default" path="/admin/configuration/attributes">
|
||||
@@ -267,6 +451,116 @@
|
||||
|
||||
<!-- end attribute and feature routes management -->
|
||||
|
||||
<!-- Countries routes management -->
|
||||
|
||||
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.create" path="/admin/configuration/countries/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.update.view" path="/admin/configuration/countries/update/{country_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end countries routes management -->
|
||||
|
||||
<!-- Shipping zones routes management -->
|
||||
|
||||
<route id="admin.configuration.shipping-zones.default" path="/admin/configuration/shipping_zones">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-zones.update.view" path="/admin/configuration/shipping_zones/update/{shipping_zones_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::updateAction</default>
|
||||
<requirement key="shipping_zones_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
<!-- Shipping zones routes management -->
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.default" path="/admin/configuration/shipping_configuration">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.update.view" path="/admin/configuration/shipping_configuration/update/{shipping_configuration_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::updateAction</default>
|
||||
<requirement key="shipping_configuration_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
|
||||
<!-- feature and features value management -->
|
||||
|
||||
<route id="admin.configuration.features.default" path="/admin/configuration/features">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.create" path="/admin/configuration/features/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.update" path="/admin/configuration/features/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.save" path="/admin/configuration/features/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.delete" path="/admin/configuration/features/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.update-position" path="/admin/configuration/features/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.rem-from-all" path="/admin/configuration/features/remove-from-all-templates">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::removeFromAllTemplates</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features.add-to-all" path="/admin/configuration/features/add-to-all-templates">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureController::addToAllTemplates</default>
|
||||
</route>
|
||||
|
||||
|
||||
<route id="admin.configuration.features-av.create" path="/admin/configuration/features-av/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.update" path="/admin/configuration/features-av/update">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.save" path="/admin/configuration/features-av/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.delete" path="/admin/configuration/features-av/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.features-av.update-position" path="/admin/configuration/features-av/update-position">
|
||||
<default key="_controller">Thelia\Controller\Admin\FeatureAvController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end feature and feature routes management -->
|
||||
|
||||
<!-- Modules rule management -->
|
||||
|
||||
<route id="admin.module" path="/admin/modules">
|
||||
<default key="_controller">Thelia\Controller\Admin\ModuleController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end Modules rule management -->
|
||||
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
<route id="admin.processTemplate" path="/admin/{template}">
|
||||
|
||||
@@ -97,9 +97,9 @@
|
||||
<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>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
|
||||
<route id="cart.delete.process" path="/cart/delete/{cart_item}">
|
||||
@@ -115,9 +115,33 @@
|
||||
<!-- end cart routes -->
|
||||
|
||||
<!-- order management process -->
|
||||
<route id="order.delivery.add" path="/delivery/choose/{delivery_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\DeliveryController::select</default>
|
||||
<requirement key="delivery_id">\d+</requirement>
|
||||
<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::invoice</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>
|
||||
|
||||
<route id="order.payment.process" path="/order/pay">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
</route>
|
||||
|
||||
<route id="order.placed" path="/order/placed/{order_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::orderPlaced</default>
|
||||
<default key="_view">order_placed</default>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
|
||||
@@ -1,15 +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="home" path="/install" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::index</default>
|
||||
</route>
|
||||
|
||||
<route id="home" path="/install/step/2" >
|
||||
<default key="_controller">Thelia\Controller\Install\InstallController::checkPermission</default>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
@@ -25,6 +25,7 @@ namespace Thelia\Constraint;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Thelia\Constraint\Rule\AvailableForEveryoneManager;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
|
||||
use Thelia\Constraint\Rule\CouponRuleInterface;
|
||||
use Thelia\Constraint\Rule\SerializableRule;
|
||||
@@ -74,11 +75,22 @@ class ConstraintFactory
|
||||
*/
|
||||
public function serializeCouponRuleCollection(CouponRuleCollection $collection)
|
||||
{
|
||||
if ($collection->isEmpty()) {
|
||||
/** @var CouponRuleInterface $ruleNoCondition */
|
||||
$ruleNoCondition = $this->container->get(
|
||||
'thelia.constraint.rule.available_for_everyone'
|
||||
);
|
||||
$collection->add($ruleNoCondition);
|
||||
}
|
||||
$serializableRules = array();
|
||||
$rules = $collection->getRules();
|
||||
if ($rules !== null) {
|
||||
/** @var $rule CouponRuleInterface */
|
||||
foreach ($rules as $rule) {
|
||||
// Remove all rule if the "no condition" rule is found
|
||||
// if ($rule->getServiceId() == 'thelia.constraint.rule.available_for_everyone') {
|
||||
// return base64_encode(json_encode(array($rule->getSerializableRule())));
|
||||
// }
|
||||
$serializableRules[] = $rule->getSerializableRule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class ConstraintValidator
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function test(CouponRuleCollection $rules)
|
||||
public function isMatching(CouponRuleCollection $rules)
|
||||
{
|
||||
$isMatching = true;
|
||||
/** @var CouponRuleInterface $rule */
|
||||
@@ -69,10 +69,10 @@ class ConstraintValidator
|
||||
/**
|
||||
* Do variable comparison
|
||||
*
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param mixed $v1 Variable 1
|
||||
* @param string $o Operator
|
||||
* @param mixed $v2 Variable 2
|
||||
*
|
||||
* @param mixed $v2 Variable 2
|
||||
* @throws \Exception
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Thelia\Constraint\Rule;
|
||||
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Constraint\Validator\PriceParam;
|
||||
use Thelia\Constraint\Validator\RuleValidator;
|
||||
@@ -168,13 +167,12 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
|
||||
return false;
|
||||
}
|
||||
|
||||
$constrainValidator = new ConstraintValidator();
|
||||
$constraint1 =$constrainValidator->variableOpComparison(
|
||||
$constraint1 = $this->constraintValidator->variableOpComparison(
|
||||
$this->adapter->getCartTotalPrice(),
|
||||
$this->operators[self::INPUT1],
|
||||
$this->values[self::INPUT1]
|
||||
);
|
||||
$constraint2 =$constrainValidator->variableOpComparison(
|
||||
$constraint2 = $this->constraintValidator->variableOpComparison(
|
||||
$this->adapter->getCheckoutCurrency(),
|
||||
$this->operators[self::INPUT2],
|
||||
$this->values[self::INPUT2]
|
||||
|
||||
@@ -126,8 +126,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
|
||||
*/
|
||||
public function isMatching()
|
||||
{
|
||||
$constrainValidator = new ConstraintValidator();
|
||||
$constraint1 =$constrainValidator->variableOpComparison(
|
||||
$constraint1 = $this->constraintValidator->variableOpComparison(
|
||||
$this->adapter->getNbArticlesInCart(),
|
||||
$this->operators[self::INPUT1],
|
||||
$this->values[self::INPUT1]
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Constraint\Rule;
|
||||
|
||||
use Symfony\Component\Intl\Exception\NotImplementedException;
|
||||
use Thelia\Constraint\ConstraintValidator;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Constraint\Validator\ComparableInterface;
|
||||
@@ -73,6 +74,9 @@ abstract class CouponRuleAbstract implements CouponRuleInterface
|
||||
/** @var array Values set by Admin in BackOffice */
|
||||
protected $values = array();
|
||||
|
||||
/** @var ConstraintValidator Constaints validator */
|
||||
protected $constraintValidator = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -82,6 +86,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
$this->translator = $adapter->getTranslator();
|
||||
$this->constraintValidator = $adapter->getConstraintValidator();
|
||||
}
|
||||
|
||||
// /**
|
||||
|
||||
@@ -133,21 +133,21 @@ abstract class Operators
|
||||
break;
|
||||
case self::INFERIOR_OR_EQUAL:
|
||||
$ret = $translator->trans(
|
||||
'inferior or equals to',
|
||||
'inferior or equal to',
|
||||
array(),
|
||||
'constraint'
|
||||
);
|
||||
break;
|
||||
case self::EQUAL:
|
||||
$ret = $translator->trans(
|
||||
'equals to',
|
||||
'equal to',
|
||||
array(),
|
||||
'constraint'
|
||||
);
|
||||
break;
|
||||
case self::SUPERIOR_OR_EQUAL:
|
||||
$ret = $translator->trans(
|
||||
'superior or equals to',
|
||||
'superior or equal to',
|
||||
array(),
|
||||
'constraint'
|
||||
);
|
||||
|
||||
@@ -210,31 +210,45 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
/**
|
||||
* Put in this method post object creation processing if required.
|
||||
*
|
||||
* @param unknown $createdObject the created object
|
||||
* @param unknown $createEvent the create event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalCreateAction($createdObject)
|
||||
protected function performAdditionalCreateAction($createEvent)
|
||||
{
|
||||
// Nothing to do
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in this method post object update processing if required.
|
||||
*
|
||||
* @param unknown $updatedObject the updated object
|
||||
* @param unknown $updateEvent the update event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updatedObject)
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
// Nothing to do
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in this method post object delete processing if required.
|
||||
*
|
||||
* @param unknown $deletedObject the deleted object
|
||||
* @param unknown $deleteEvent the delete event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalDeleteAction($deletedObject)
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
// Nothing to do
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,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($createdObject);
|
||||
$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
|
||||
@@ -393,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($changedObject);
|
||||
$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
|
||||
@@ -449,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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,9 +492,6 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
|
||||
$changeEvent = $this->createToggleVisibilityEvent($this->getRequest());
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent->setIsDefault(true);
|
||||
|
||||
try {
|
||||
$this->dispatch($this->visibilityToggleEventIdentifier, $changeEvent);
|
||||
} catch (\Exception $ex) {
|
||||
@@ -472,7 +499,7 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToRoute('admin.categories.default');
|
||||
return $this->nullResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -494,8 +521,12 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
$this->adminLogAppend(
|
||||
sprintf("%s %s (ID %s) deleted", ucfirst($this->objectName), $this->getObjectLabel($deletedObject), $this->getObjectId($deletedObject)));
|
||||
}
|
||||
$this->performAdditionalDeleteAction($deletedObject);
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
$response = $this->performAdditionalDeleteAction($deleteEvent);
|
||||
|
||||
if ($response == null)
|
||||
$this->redirectToListTemplate();
|
||||
else
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,19 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Security\Exception\TokenAuthenticationException;
|
||||
|
||||
class AdminController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
return $this->render("home");
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
return $this->render("profile-edit");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
@@ -107,7 +107,7 @@ class AttributeController extends AbstractCrudController
|
||||
*
|
||||
* @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction()
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updatedObject)
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
$attr_values = $this->getRequest()->get('attribute_values', null);
|
||||
|
||||
@@ -123,6 +123,8 @@ class AttributeController extends AbstractCrudController
|
||||
$this->dispatch(TheliaEvents::ATTRIBUTE_AV_UPDATE, $event);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
|
||||
@@ -40,6 +40,8 @@ use Thelia\Form\BaseForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Model\Admin;
|
||||
use Thelia\Core\Security\Token\CookieTokenProvider;
|
||||
|
||||
class BaseAdminController extends BaseController
|
||||
{
|
||||
@@ -302,6 +304,46 @@ class BaseAdminController extends BaseController
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the remember me cookie for the given user.
|
||||
*/
|
||||
protected function createAdminRememberMeCookie(Admin $user)
|
||||
{
|
||||
$ctp = new CookieTokenProvider();
|
||||
|
||||
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');
|
||||
$cookieExpiration = ConfigQuery::read('admin_remember_me_cookie_expiration', 2592000 /* 1 month */);
|
||||
|
||||
$ctp->createCookie($user, $cookieName, $cookieExpiration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rememberme key from the cookie.
|
||||
*
|
||||
* @return string hte key found, or null if no key was found.
|
||||
*/
|
||||
protected function getRememberMeKeyFromCookie()
|
||||
{
|
||||
// Check if we can authenticate the user with a cookie-based token
|
||||
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');
|
||||
|
||||
$ctp = new CookieTokenProvider();
|
||||
|
||||
return $ctp->getKeyFromCookie($this->getRequest(), $cookieName);
|
||||
}
|
||||
|
||||
/** Clear the remember me cookie.
|
||||
*
|
||||
*/
|
||||
protected function clearRememberMeCookie() {
|
||||
|
||||
$ctp = new CookieTokenProvider();
|
||||
|
||||
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');
|
||||
|
||||
$ctp->clearCookie($cookieName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the given template, and returns the result as an Http Response.
|
||||
*
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
|
||||
289
core/lib/Thelia/Controller/Admin/ContentController.php
Normal file
289
core/lib/Thelia/Controller/Admin/ContentController.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\Event\Content\ContentCreateEvent;
|
||||
use Thelia\Core\Event\Content\ContentUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\ContentCreationForm;
|
||||
use Thelia\Form\ContentModificationForm;
|
||||
use Thelia\Model\ContentQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentController extends AbstractCrudController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'content',
|
||||
'manual',
|
||||
'content_order',
|
||||
|
||||
'admin.content.default',
|
||||
'admin.content.create',
|
||||
'admin.content.update',
|
||||
'admin.content.delete',
|
||||
|
||||
TheliaEvents::CONTENT_CREATE,
|
||||
TheliaEvents::CONTENT_UPDATE,
|
||||
TheliaEvents::CONTENT_DELETE,
|
||||
TheliaEvents::CONTENT_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::CONTENT_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the creation form for this object
|
||||
*/
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new ContentCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the update form for this object
|
||||
*/
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new ContentModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the update form for this object, before passing it to the update template
|
||||
*
|
||||
* @param \Thelia\Form\ContentModificationForm $object
|
||||
*/
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ContentModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the creation event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$contentCreateEvent = new ContentCreateEvent();
|
||||
|
||||
$contentCreateEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setDefaultFolder($formData['default_folder'])
|
||||
->setTitle($formData['title'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
return $contentCreateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the update event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$contentUpdateEvent = new ContentUpdateEvent($formData['id']);
|
||||
|
||||
$contentUpdateEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setDefaultFolder($formData['default_folder']);
|
||||
|
||||
return $contentUpdateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the delete event with the provided form data
|
||||
*/
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
// TODO: Implement getDeleteEvent() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the event contains the object, e.g. the action has updated the object in the event.
|
||||
*
|
||||
* @param \Thelia\Core\Event\Content\ContentEvent $event
|
||||
*/
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the created object from an event.
|
||||
*
|
||||
* @param $event \Thelia\Core\Event\Content\ContentEvent
|
||||
*
|
||||
* @return null|\Thelia\Model\Content
|
||||
*/
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an existing object from the database
|
||||
*
|
||||
* @return \Thelia\Model\Content
|
||||
*/
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return ContentQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('content_id', 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object label form the object event (name, title, etc.)
|
||||
*
|
||||
* @param $object \Thelia\Model\Content
|
||||
*
|
||||
* @return string content title
|
||||
*
|
||||
*/
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object ID from the object
|
||||
*
|
||||
* @param $object \Thelia\Model\Content
|
||||
*
|
||||
* @return int content id
|
||||
*/
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getFolderId()
|
||||
{
|
||||
$folderId = $this->getRequest()->get('folder_id', null);
|
||||
|
||||
if(null === $folderId) {
|
||||
$content = $this->getExistingObject();
|
||||
|
||||
if($content) {
|
||||
$folderId = $content->getDefaultFolderId();
|
||||
}
|
||||
}
|
||||
|
||||
return $folderId ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the main list template
|
||||
*
|
||||
* @param unknown $currentOrder, if any, null otherwise.
|
||||
*/
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
$this->getListOrderFromSession('content', 'content_order', 'manual');
|
||||
|
||||
return $this->render('folders',
|
||||
array(
|
||||
'content_order' => $currentOrder,
|
||||
'parent' => $this->getFolderId()
|
||||
));
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'content_id' => $this->getRequest()->get('content_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the edition template
|
||||
*/
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render('content-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the edition template
|
||||
*/
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirect($this->getRoute('admin.content.update', $this->getEditionArguments()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the list template
|
||||
*/
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
'admin.content.default',
|
||||
array('parent' => $this->getFolderId())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent
|
||||
* @return Response|void
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $this->getFolderId())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,35 +21,32 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Front;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class DeliveryController
|
||||
* @package Thelia\Controller\Front
|
||||
* Class CustomerController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class DeliveryController extends BaseFrontController
|
||||
class CountryController extends BaseAdminController
|
||||
{
|
||||
public function select($delivery_id)
|
||||
public function indexAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser() === false) {
|
||||
$this->redirect(URL::getInstance()->getIndexPage());
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$deliveryModule = ModuleQuery::create()
|
||||
->filterById($delivery_id)
|
||||
->filterByActivate(1)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
if ($deliveryModule) {
|
||||
$request->getSession()->setDelivery($delivery_id);
|
||||
} else {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
if (null !== $response = $this->checkAuth("admin.country.view")) return $response;
|
||||
return $this->render("countries", array("display_country" => 20));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update country action
|
||||
*
|
||||
* @param $country_id
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function updateAction($country_id)
|
||||
{
|
||||
return $this->render("country-edit", array(
|
||||
"country_id" => $country_id
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ use Thelia\Constraint\ConstraintFactoryTest;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmount;
|
||||
use Thelia\Constraint\Rule\CouponRuleInterface;
|
||||
use Thelia\Constraint\Validator\PriceParam;
|
||||
use Thelia\Core\Event\Coupon\CouponConsumeEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponEvent;
|
||||
@@ -39,6 +40,7 @@ use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Core\Security\Exception\AuthorizationException;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Coupon\CouponFactory;
|
||||
use Thelia\Coupon\CouponManager;
|
||||
use Thelia\Coupon\CouponRuleCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
@@ -72,7 +74,54 @@ class CouponController extends BaseAdminController
|
||||
{
|
||||
$this->checkAuth('ADMIN', 'admin.coupon.view');
|
||||
|
||||
return $this->render('coupon-list');
|
||||
$args['urlReadCoupon'] = $this->getRoute(
|
||||
'admin.coupon.read',
|
||||
array('couponId' => 'couponId'),
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
$args['urlEditCoupon'] = $this->getRoute(
|
||||
'admin.coupon.update',
|
||||
array('couponId' => 'couponId'),
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
$args['urlCreateCoupon'] = $this->getRoute(
|
||||
'admin.coupon.create',
|
||||
array(),
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
return $this->render('coupon-list', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons read display
|
||||
*
|
||||
* @param int $couponId Coupon Id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function readAction($couponId)
|
||||
{
|
||||
$this->checkAuth('ADMIN', 'admin.coupon.read');
|
||||
|
||||
// Database request repeated in the loop but cached
|
||||
$search = CouponQuery::create();
|
||||
$coupon = $search->findOneById($couponId);
|
||||
|
||||
if ($coupon === null) {
|
||||
return $this->pageNotFound();
|
||||
}
|
||||
|
||||
$args['couponId'] = $couponId;
|
||||
$args['urlEditCoupon'] = $this->getRoute(
|
||||
'admin.coupon.update',
|
||||
array('couponId' => $couponId),
|
||||
Router::ABSOLUTE_URL
|
||||
);
|
||||
|
||||
return $this->render('coupon-read', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +142,7 @@ class CouponController extends BaseAdminController
|
||||
|
||||
$i18n = new I18n();
|
||||
/** @var Lang $lang */
|
||||
$lang = $this->getSession()->get('lang');
|
||||
$lang = $this->getSession()->getLang();
|
||||
$eventToDispatch = TheliaEvents::COUPON_CREATE;
|
||||
|
||||
if ($this->getRequest()->isMethod('POST')) {
|
||||
@@ -108,10 +157,12 @@ class CouponController extends BaseAdminController
|
||||
// If no input for expirationDate, now + 2 months
|
||||
$defaultDate = new \DateTime();
|
||||
$args['defaultDate'] = $defaultDate->modify('+2 month')
|
||||
->format($lang->getDateFormat());
|
||||
->format('Y-m-d');
|
||||
}
|
||||
|
||||
$args['formAction'] = 'admin/coupon/create';
|
||||
$args['dateFormat'] = $this->getSession()->getLang()->getDateFormat();
|
||||
$args['availableCoupons'] = $this->getAvailableCoupons();
|
||||
$args['formAction'] = 'admin/coupon/create/';
|
||||
|
||||
return $this->render(
|
||||
'coupon-create',
|
||||
@@ -135,7 +186,7 @@ class CouponController extends BaseAdminController
|
||||
}
|
||||
|
||||
/** @var Coupon $coupon */
|
||||
$coupon = CouponQuery::create()->findOneById($couponId);
|
||||
$coupon = CouponQuery::create()->findPk($couponId);
|
||||
if (!$coupon) {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
@@ -148,6 +199,7 @@ class CouponController extends BaseAdminController
|
||||
$lang = $this->getSession()->getLang();
|
||||
$eventToDispatch = TheliaEvents::COUPON_UPDATE;
|
||||
|
||||
// Create
|
||||
if ($this->getRequest()->isMethod('POST')) {
|
||||
$this->validateCreateOrUpdateForm(
|
||||
$i18n,
|
||||
@@ -156,9 +208,9 @@ class CouponController extends BaseAdminController
|
||||
'updated',
|
||||
'update'
|
||||
);
|
||||
} else {
|
||||
// Prepare the data that will hydrate the form
|
||||
} else { // Update
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
/** @var ConstraintFactory $constraintFactory */
|
||||
$constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
$rules = $constraintFactory->unserializeCouponRuleCollection(
|
||||
@@ -173,7 +225,7 @@ class CouponController extends BaseAdminController
|
||||
'shortDescription' => $coupon->getShortDescription(),
|
||||
'description' => $coupon->getDescription(),
|
||||
'isEnabled' => ($coupon->getIsEnabled() == 1),
|
||||
'expirationDate' => $coupon->getExpirationDate($lang->getDateFormat()),
|
||||
'expirationDate' => $coupon->getExpirationDate('Y-m-d'),
|
||||
'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1),
|
||||
'isCumulative' => ($coupon->getIsCumulative() == 1),
|
||||
'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1),
|
||||
@@ -202,7 +254,7 @@ class CouponController extends BaseAdminController
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($changeForm);
|
||||
}
|
||||
|
||||
$args['couponCode'] = $coupon->getCode();
|
||||
$args['availableCoupons'] = $this->getAvailableCoupons();
|
||||
$args['availableRules'] = $this->getAvailableRules();
|
||||
$args['urlAjaxGetRuleInput'] = $this->getRoute(
|
||||
@@ -222,123 +274,6 @@ class CouponController extends BaseAdminController
|
||||
return $this->render('coupon-update', $args);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Manage Coupons Rule creation display
|
||||
// *
|
||||
// * @param int $couponId Coupon id
|
||||
// *
|
||||
// * @return \Symfony\Component\HttpFoundation\Response
|
||||
// */
|
||||
// public function createRuleAction($couponId)
|
||||
// {
|
||||
// // Check current user authorization
|
||||
// $response = $this->checkAuth('admin.coupon.update');
|
||||
// if ($response !== null) {
|
||||
// return $response;
|
||||
// }
|
||||
//
|
||||
// /** @var Coupon $coupon */
|
||||
// $coupon = CouponQuery::create()->findOneById($couponId);
|
||||
// if (!$coupon) {
|
||||
// $this->pageNotFound();
|
||||
// }
|
||||
//
|
||||
// // Parameters given to the template
|
||||
// $args = array();
|
||||
//
|
||||
// $i18n = new I18n();
|
||||
// /** @var Lang $lang */
|
||||
// $lang = $this->getSession()->get('lang');
|
||||
// $eventToDispatch = TheliaEvents::COUPON_RULE_CREATE;
|
||||
//
|
||||
// if ($this->getRequest()->isMethod('POST')) {
|
||||
// $this->validateCreateOrUpdateForm(
|
||||
// $i18n,
|
||||
// $lang,
|
||||
// $eventToDispatch,
|
||||
// 'updated',
|
||||
// 'update'
|
||||
// );
|
||||
// } else {
|
||||
// // Prepare the data that will hydrate the form
|
||||
//
|
||||
// /** @var ConstraintFactory $constraintFactory */
|
||||
// $constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
//
|
||||
// $data = array(
|
||||
// 'code' => $coupon->getCode(),
|
||||
// 'title' => $coupon->getTitle(),
|
||||
// 'amount' => $coupon->getAmount(),
|
||||
// 'effect' => $coupon->getType(),
|
||||
// 'shortDescription' => $coupon->getShortDescription(),
|
||||
// 'description' => $coupon->getDescription(),
|
||||
// 'isEnabled' => ($coupon->getIsEnabled() == 1),
|
||||
// 'expirationDate' => $coupon->getExpirationDate($lang->getDateFormat()),
|
||||
// 'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1),
|
||||
// 'isCumulative' => ($coupon->getIsCumulative() == 1),
|
||||
// 'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1),
|
||||
// 'maxUsage' => $coupon->getMaxUsage(),
|
||||
// 'rules' => $constraintFactory->unserializeCouponRuleCollection($coupon->getSerializedRules()),
|
||||
// 'locale' => $coupon->getLocale(),
|
||||
// );
|
||||
//
|
||||
// /** @var CouponAdapterInterface $adapter */
|
||||
// $adapter = $this->container->get('thelia.adapter');
|
||||
// /** @var Translator $translator */
|
||||
// $translator = $this->container->get('thelia.translator');
|
||||
//
|
||||
// $args['rulesObject'] = array();
|
||||
// /** @var CouponRuleInterface $rule */
|
||||
// foreach ($coupon->getRules()->getRules() as $rule) {
|
||||
// $args['rulesObject'][] = array(
|
||||
// 'name' => $rule->getName($translator),
|
||||
// 'tooltip' => $rule->getToolTip($translator),
|
||||
// 'validators' => $rule->getValidators()
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// $args['rules'] = $this->cleanRuleForTemplate($coupon->getRules()->getRules());
|
||||
//
|
||||
// // Setup the object form
|
||||
// $changeForm = new CouponCreationForm($this->getRequest(), 'form', $data);
|
||||
//
|
||||
// // Pass it to the parser
|
||||
// $this->getParserContext()->addForm($changeForm);
|
||||
// }
|
||||
//
|
||||
// $args['formAction'] = 'admin/coupon/update/' . $couponId;
|
||||
//
|
||||
// return $this->render(
|
||||
// 'coupon-update',
|
||||
// $args
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Manage Coupons read display
|
||||
*
|
||||
* @param int $couponId Coupon Id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function readAction($couponId)
|
||||
{
|
||||
$this->checkAuth('ADMIN', 'admin.coupon.read');
|
||||
|
||||
// Database request repeated in the loop but cached
|
||||
$search = CouponQuery::create();
|
||||
$coupon = $search->findOneById($couponId);
|
||||
|
||||
if ($coupon === null) {
|
||||
return $this->pageNotFound();
|
||||
}
|
||||
|
||||
return $this->render('coupon-read', array('couponId' => $couponId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons read display
|
||||
*
|
||||
@@ -350,17 +285,7 @@ class CouponController extends BaseAdminController
|
||||
{
|
||||
$this->checkAuth('ADMIN', 'admin.coupon.read');
|
||||
|
||||
if ($this->isDebug()) {
|
||||
if (!$this->getRequest()->isXmlHttpRequest()) {
|
||||
$this->redirect(
|
||||
$this->getRoute(
|
||||
'admin',
|
||||
array(),
|
||||
Router::ABSOLUTE_URL
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
/** @var ConstraintFactory $constraintFactory */
|
||||
$constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
@@ -391,17 +316,7 @@ class CouponController extends BaseAdminController
|
||||
{
|
||||
$this->checkAuth('ADMIN', 'admin.coupon.read');
|
||||
|
||||
if ($this->isDebug()) {
|
||||
if (!$this->getRequest()->isXmlHttpRequest()) {
|
||||
$this->redirect(
|
||||
$this->getRoute(
|
||||
'admin',
|
||||
array(),
|
||||
Router::ABSOLUTE_URL
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
$search = CouponQuery::create();
|
||||
/** @var Coupon $coupon */
|
||||
@@ -475,6 +390,29 @@ class CouponController extends BaseAdminController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Coupon consuming
|
||||
*
|
||||
* @param string $couponCode Coupon code
|
||||
*
|
||||
*/
|
||||
public function consumeAction($couponCode)
|
||||
{
|
||||
// @todo remove (event dispatcher testing purpose)
|
||||
$couponConsumeEvent = new CouponConsumeEvent($couponCode);
|
||||
$eventToDispatch = TheliaEvents::COUPON_CONSUME;
|
||||
|
||||
// Dispatch Event to the Action
|
||||
$this->dispatch(
|
||||
$eventToDispatch,
|
||||
$couponConsumeEvent
|
||||
);
|
||||
|
||||
var_dump('test', $couponConsumeEvent->getCode(), $couponConsumeEvent->getDiscount(), $couponConsumeEvent->getIsValid());
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Coupon from its form
|
||||
*
|
||||
@@ -535,7 +473,7 @@ class CouponController extends BaseAdminController
|
||||
/**
|
||||
* Validate the CreateOrUpdate form
|
||||
*
|
||||
* @param string $i18n Local code (fr_FR)
|
||||
* @param I18n $i18n Local code (fr_FR)
|
||||
* @param Lang $lang Local variables container
|
||||
* @param string $eventToDispatch Event which will activate actions
|
||||
* @param string $log created|edited
|
||||
@@ -543,7 +481,7 @@ class CouponController extends BaseAdminController
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function validateCreateOrUpdateForm($i18n, $lang, $eventToDispatch, $log, $action)
|
||||
protected function validateCreateOrUpdateForm(I18n $i18n, Lang $lang, $eventToDispatch, $log, $action)
|
||||
{
|
||||
// Create the form from the request
|
||||
$creationForm = new CouponCreationForm($this->getRequest());
|
||||
@@ -563,7 +501,7 @@ class CouponController extends BaseAdminController
|
||||
$data['shortDescription'],
|
||||
$data['description'],
|
||||
$data['isEnabled'],
|
||||
$i18n->getDateTimeFromForm($lang, $data['expirationDate']),
|
||||
\DateTime::createFromFormat('Y-m-d', $data['expirationDate']),
|
||||
$data['isAvailableOnSpecialOffers'],
|
||||
$data['isCumulative'],
|
||||
$data['isRemovingPostage'],
|
||||
@@ -651,17 +589,17 @@ class CouponController extends BaseAdminController
|
||||
/** @var CouponManager $couponManager */
|
||||
$couponManager = $this->container->get('thelia.coupon.manager');
|
||||
$availableCoupons = $couponManager->getAvailableCoupons();
|
||||
$cleanedRules = array();
|
||||
$cleanedCoupons = array();
|
||||
/** @var CouponInterface $availableCoupon */
|
||||
foreach ($availableCoupons as $availableCoupon) {
|
||||
$rule = array();
|
||||
$rule['serviceId'] = $availableCoupon->getServiceId();
|
||||
$rule['name'] = $availableCoupon->getName();
|
||||
$rule['toolTip'] = $availableCoupon->getToolTip();
|
||||
$cleanedRules[] = $rule;
|
||||
$cleanedCoupons[] = $rule;
|
||||
}
|
||||
|
||||
return $cleanedRules;
|
||||
return $cleanedCoupons;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ use Thelia\Form\CurrencyCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages currencies sent by mail
|
||||
* Manages currencies
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
|
||||
196
core/lib/Thelia/Controller/Admin/FeatureAvController.php
Normal file
196
core/lib/Thelia/Controller/Admin/FeatureAvController.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\FeatureAvDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureAvCreateEvent;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Form\FeatureAvModificationForm;
|
||||
use Thelia\Form\FeatureAvCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
|
||||
/**
|
||||
* Manages features-av
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FeatureAvController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'featureav',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
'admin.configuration.features-av.view',
|
||||
'admin.configuration.features-av.create',
|
||||
'admin.configuration.features-av.update',
|
||||
'admin.configuration.features-av.delete',
|
||||
|
||||
TheliaEvents::FEATURE_AV_CREATE,
|
||||
TheliaEvents::FEATURE_AV_UPDATE,
|
||||
TheliaEvents::FEATURE_AV_DELETE,
|
||||
null, // No visibility toggle
|
||||
TheliaEvents::FEATURE_AV_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FeatureAvCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FeatureAvModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new FeatureAvCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setFeatureId($formData['feature_id'])
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new FeatureAvUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData["locale"])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('featureav_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FeatureAvDeleteEvent($this->getRequest()->get('featureav_id'));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFeatureAv();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new FeatureAvModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFeatureAv() ? $event->getFeatureAv() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return FeatureAvQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('featureav_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getViewArguments()
|
||||
{
|
||||
return array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'order' => $this->getCurrentListOrder()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render(
|
||||
'feature-edit',
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render('feature-edit', $this->getViewArguments());
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
$this->getViewArguments()
|
||||
);
|
||||
}
|
||||
}
|
||||
289
core/lib/Thelia/Controller/Admin/FeatureController.php
Normal file
289
core/lib/Thelia/Controller/Admin/FeatureController.php
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\FeatureDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\FeatureUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureCreateEvent;
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Form\FeatureModificationForm;
|
||||
use Thelia\Form\FeatureCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Model\FeatureAv;
|
||||
use Thelia\Model\FeatureAvQuery;
|
||||
use Thelia\Core\Event\FeatureAvUpdateEvent;
|
||||
use Thelia\Core\Event\FeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages features
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FeatureController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'feature',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
'admin.configuration.features.view',
|
||||
'admin.configuration.features.create',
|
||||
'admin.configuration.features.update',
|
||||
'admin.configuration.features.delete',
|
||||
|
||||
TheliaEvents::FEATURE_CREATE,
|
||||
TheliaEvents::FEATURE_UPDATE,
|
||||
TheliaEvents::FEATURE_DELETE,
|
||||
null, // No visibility toggle
|
||||
TheliaEvents::FEATURE_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FeatureCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FeatureModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new FeatureCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setTitle($formData['title'])
|
||||
->setLocale($formData["locale"])
|
||||
->setAddToAllTemplates($formData['add_to_all'])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new FeatureUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData["locale"])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
;
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the features values (fix it in future version to integrate it in the feature form as a collection)
|
||||
*
|
||||
* @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction()
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
$attr_values = $this->getRequest()->get('feature_values', null);
|
||||
|
||||
if ($attr_values !== null) {
|
||||
|
||||
foreach($attr_values as $id => $value) {
|
||||
|
||||
$event = new FeatureAvUpdateEvent($id);
|
||||
|
||||
$event->setTitle($value);
|
||||
$event->setLocale($this->getCurrentEditionLocale());
|
||||
|
||||
$this->dispatch(TheliaEvents::FEATURE_AV_UPDATE, $event);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
|
||||
{
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('feature_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FeatureDeleteEvent($this->getRequest()->get('feature_id'));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFeature();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum()
|
||||
);
|
||||
|
||||
// Setup features values
|
||||
/*
|
||||
* FIXME : doesn't work. "We get a This form should not contain extra fields." error
|
||||
$attr_av_list = FeatureAvQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByFeatureId($object->getId())
|
||||
->find();
|
||||
|
||||
$attr_array = array();
|
||||
|
||||
foreach($attr_av_list as $attr_av) {
|
||||
$attr_array[$attr_av->getId()] = $attr_av->getTitle();
|
||||
}
|
||||
|
||||
$data['feature_values'] = $attr_array;
|
||||
*/
|
||||
|
||||
// Setup the object form
|
||||
return new FeatureModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFeature() ? $event->getFeature() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return FeatureQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('feature_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
return $this->render('features', array('order' => $currentOrder));
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render(
|
||||
'feature-edit',
|
||||
array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'featureav_order' => $this->getFeatureAvListOrder()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.features.update",
|
||||
array(
|
||||
'feature_id' => $this->getRequest()->get('feature_id'),
|
||||
'featureav_order' => $this->getFeatureAvListOrder()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.features.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Feature value list order.
|
||||
*
|
||||
* @return string the current list order
|
||||
*/
|
||||
protected function getFeatureAvListOrder()
|
||||
{
|
||||
return $this->getListOrderFromSession(
|
||||
'featureav',
|
||||
'featureav_order',
|
||||
'manual'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or Remove from all product templates
|
||||
*/
|
||||
protected function addRemoveFromAllTemplates($eventType)
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.features.update")) return $response;
|
||||
|
||||
try {
|
||||
if (null !== $object = $this->getExistingObject()) {
|
||||
|
||||
$event = new FeatureEvent($object);
|
||||
|
||||
$this->dispatch($eventType, $event);
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToListTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove from all product templates
|
||||
*/
|
||||
public function removeFromAllTemplates()
|
||||
{
|
||||
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_REMOVE_FROM_ALL_TEMPLATES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to all product templates
|
||||
*/
|
||||
public function addToAllTemplates()
|
||||
{
|
||||
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES);
|
||||
}
|
||||
}
|
||||
328
core/lib/Thelia/Controller/Admin/FolderController.php
Normal file
328
core/lib/Thelia/Controller/Admin/FolderController.php
Normal file
@@ -0,0 +1,328 @@
|
||||
<?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\FolderCreateEvent;
|
||||
use Thelia\Core\Event\FolderDeleteEvent;
|
||||
use Thelia\Core\Event\FolderToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\FolderUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Form\FolderCreationForm;
|
||||
use Thelia\Form\FolderModificationForm;
|
||||
use Thelia\Model\FolderQuery;
|
||||
|
||||
/**
|
||||
* Class FolderController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderController extends AbstractCrudController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'folder',
|
||||
'manual',
|
||||
'folder_order',
|
||||
|
||||
'admin.folder.default',
|
||||
'admin.folder.create',
|
||||
'admin.folder.update',
|
||||
'admin.folder.delete',
|
||||
|
||||
TheliaEvents::FOLDER_CREATE,
|
||||
TheliaEvents::FOLDER_UPDATE,
|
||||
TheliaEvents::FOLDER_DELETE,
|
||||
TheliaEvents::FOLDER_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::FOLDER_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the creation form for this object
|
||||
*/
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new FolderCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the update form for this object
|
||||
*/
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new FolderModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the update form for this object, before passing it to the update template
|
||||
*
|
||||
* @param \Thelia\Model\Folder $object
|
||||
*/
|
||||
protected function hydrateObjectForm($object) {
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'parent' => $object->getParent()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new FolderModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the creation event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$creationEvent = new FolderCreateEvent();
|
||||
|
||||
$creationEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setVisible($formData['visible'])
|
||||
->setParent($formData['parent']);
|
||||
|
||||
return $creationEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the update event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$updateEvent = new FolderUpdateEvent($formData['id']);
|
||||
|
||||
$updateEvent
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setUrl($formData['url'])
|
||||
->setParent($formData['parent'])
|
||||
;
|
||||
|
||||
return $updateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the delete event with the provided form data
|
||||
*/
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new FolderDeleteEvent($this->getRequest()->get('folder_id'), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FolderToggleVisibilityEvent|void
|
||||
*/
|
||||
protected function createToggleVisibilityEvent()
|
||||
{
|
||||
return new FolderToggleVisibilityEvent($this->getExistingObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $positionChangeMode
|
||||
* @param $positionValue
|
||||
* @return UpdatePositionEvent|void
|
||||
*/
|
||||
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) {
|
||||
|
||||
return new UpdatePositionEvent(
|
||||
$this->getRequest()->get('folder_id', null),
|
||||
$positionChangeMode,
|
||||
$positionValue
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the event contains the object, e.g. the action has updated the object in the event.
|
||||
*
|
||||
* @param \Thelia\Core\Event\FolderEvent $event
|
||||
*/
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasFolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the created object from an event.
|
||||
*
|
||||
* @param $event \Thelia\Core\Event\FolderEvent $event
|
||||
*
|
||||
* @return null|\Thelia\Model\Folder
|
||||
*/
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasFolder() ? $event->getFolder() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an existing object from the database
|
||||
*/
|
||||
protected function getExistingObject() {
|
||||
return FolderQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('folder_id', 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object label form the object event (name, title, etc.)
|
||||
*
|
||||
* @param unknown $object
|
||||
*/
|
||||
protected function getObjectLabel($object) {
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object ID from the object
|
||||
*
|
||||
* @param unknown $object
|
||||
*/
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the main list template
|
||||
*
|
||||
* @param unknown $currentOrder, if any, null otherwise.
|
||||
*/
|
||||
protected function renderListTemplate($currentOrder) {
|
||||
|
||||
// Get content order
|
||||
$content_order = $this->getListOrderFromSession('content', 'content_order', 'manual');
|
||||
|
||||
return $this->render('folders',
|
||||
array(
|
||||
'folder_order' => $currentOrder,
|
||||
'content_order' => $content_order,
|
||||
'parent' => $this->getRequest()->get('parent', 0)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render the edition template
|
||||
*/
|
||||
protected function renderEditionTemplate() {
|
||||
|
||||
return $this->render('folder-edit', $this->getEditionArguments());
|
||||
}
|
||||
|
||||
protected function getEditionArguments()
|
||||
{
|
||||
return array(
|
||||
'folder_id' => $this->getRequest()->get('folder_id', 0),
|
||||
'current_tab' => $this->getRequest()->get('current_tab', 'general')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\FolderUpdateEvent $updateEvent
|
||||
* @return Response|void
|
||||
*/
|
||||
protected function performAdditionalUpdateAction($updateEvent)
|
||||
{
|
||||
if ($this->getRequest()->get('save_mode') != 'stay') {
|
||||
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $updateEvent->getFolder()->getParent())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in this method post object delete processing if required.
|
||||
*
|
||||
* @param \Thelia\Core\Event\FolderDeleteEvent $deleteEvent the delete event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $deleteEvent->getFolder()->getParent())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $event \Thelia\Core\Event\UpdatePositionEvent
|
||||
* @return null|Response
|
||||
*/
|
||||
protected function performAdditionalUpdatePositionAction($event)
|
||||
{
|
||||
|
||||
$folder = FolderQuery::create()->findPk($event->getObjectId());
|
||||
|
||||
if ($folder != null) {
|
||||
// Redirect to parent category list
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $folder->getParent())
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the edition template
|
||||
*/
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirect($this->getRoute('admin.folders.update', $this->getEditionArguments()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the list template
|
||||
*/
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
'admin.folders.default',
|
||||
array('parent' => $this->getRequest()->get('parent', 0))
|
||||
);
|
||||
}
|
||||
}
|
||||
46
core/lib/Thelia/Controller/Admin/ModuleController.php
Normal file
46
core/lib/Thelia/Controller/Admin/ModuleController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class ModuleController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ModuleController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.module.view")) return $response;
|
||||
return $this->render("modules", array("display_module" => 20));
|
||||
}
|
||||
|
||||
public function updateAction($module_id)
|
||||
{
|
||||
|
||||
return $this->render("module-edit", array(
|
||||
"module_id" => $module_id
|
||||
));
|
||||
}
|
||||
}
|
||||
477
core/lib/Thelia/Controller/Admin/ProductController.php
Normal file
477
core/lib/Thelia/Controller/Admin/ProductController.php
Normal file
@@ -0,0 +1,477 @@
|
||||
<?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;
|
||||
use Thelia\Model\AccessoryQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Core\Event\ProductAddAccessoryEvent;
|
||||
use Thelia\Core\Event\ProductDeleteAccessoryEvent;
|
||||
|
||||
/**
|
||||
* 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),
|
||||
'accessory_category_id'=> $this->getRequest()->get('accessory_category_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())
|
||||
);
|
||||
}
|
||||
|
||||
// -- Related content management -------------------------------------------
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
// -- Accessories management ----------------------------------------------
|
||||
|
||||
public function getAvailableAccessoriesAction($productId, $categoryId)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
$categories = CategoryQuery::create()->filterById($categoryId)->find();
|
||||
|
||||
if ($categories !== null) {
|
||||
|
||||
$list = ProductQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->filterByCategory($categories, Criteria::IN)
|
||||
->filterById(AccessoryQuery::create()->select('accessory')->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 addAccessoryAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$accessory_id = intval($this->getRequest()->get('accessory_id'));
|
||||
|
||||
if ($accessory_id > 0) {
|
||||
|
||||
$event = new ProductAddAccessoryEvent(
|
||||
$this->getExistingObject(),
|
||||
$accessory_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteAccessoryAction()
|
||||
{
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
||||
|
||||
$accessory_id = intval($this->getRequest()->get('accessory_id'));
|
||||
|
||||
if ($accessory_id > 0) {
|
||||
|
||||
$event = new ProductDeleteAccessoryEvent(
|
||||
$this->getExistingObject(),
|
||||
$accessory_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update accessory position (only for objects whichsupport that)
|
||||
*/
|
||||
public function updateAccessoryPositionAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth('admin.products.update')) return $response;
|
||||
|
||||
try {
|
||||
$mode = $this->getRequest()->get('mode', null);
|
||||
|
||||
if ($mode == 'up')
|
||||
$mode = UpdatePositionEvent::POSITION_UP;
|
||||
else if ($mode == 'down')
|
||||
$mode = UpdatePositionEvent::POSITION_DOWN;
|
||||
else
|
||||
$mode = UpdatePositionEvent::POSITION_ABSOLUTE;
|
||||
|
||||
$position = $this->getRequest()->get('position', null);
|
||||
|
||||
$event = new UpdatePositionEvent($mode, $position);
|
||||
|
||||
$this->dispatch(TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION, $event);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,11 +30,44 @@ use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
|
||||
use Thelia\Core\Security\UserProvider\TokenProvider;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Thelia\Core\Security\UserProvider\CookieTokenProvider;
|
||||
use Thelia\Core\Security\Exception\TokenAuthenticationException;
|
||||
|
||||
class SessionController extends BaseAdminController
|
||||
{
|
||||
public function showLoginAction()
|
||||
{
|
||||
// Check if we can authenticate the user with a cookie-based token
|
||||
if (null !== $key = $this->getRememberMeKeyFromCookie()) {
|
||||
|
||||
// Create the authenticator
|
||||
$authenticator = new AdminTokenAuthenticator($key);
|
||||
|
||||
try {
|
||||
// If have found a user, store it in the security context
|
||||
$user = $authenticator->getAuthentifiedUser();
|
||||
|
||||
$this->getSecurityContext()->setAdminUser($user);
|
||||
|
||||
$this->adminLogAppend("Successful token authentication");
|
||||
|
||||
// Update the cookie
|
||||
$cookie = $this->createAdminRememberMeCookie($user);
|
||||
|
||||
// Render the home page
|
||||
return $this->render("home");
|
||||
}
|
||||
catch (TokenAuthenticationException $ex) {
|
||||
$this->adminLogAppend("Token based authentication failed.");
|
||||
|
||||
// Clear the cookie
|
||||
$this->clearRememberMeCookie();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render("login");
|
||||
}
|
||||
|
||||
@@ -44,6 +77,9 @@ class SessionController extends BaseAdminController
|
||||
|
||||
$this->getSecurityContext()->clearAdminUser();
|
||||
|
||||
// Clear the remember me cookie, if any
|
||||
$this->clearRememberMeCookie();
|
||||
|
||||
// Go back to login page.
|
||||
$this->redirectToRoute('admin.login');
|
||||
}
|
||||
@@ -68,10 +104,19 @@ class SessionController extends BaseAdminController
|
||||
// Log authentication success
|
||||
AdminLog::append("Authentication successful", $request, $user);
|
||||
|
||||
/**
|
||||
* FIXME: we have tou find a way to send cookie
|
||||
*/
|
||||
if (intval($adminLoginForm->getForm()->get('remember_me')->getData()) > 0) {
|
||||
// If a remember me field if present and set in the form, create
|
||||
// the cookie thant store "remember me" information
|
||||
$this->createAdminRememberMeCookie($user);
|
||||
}
|
||||
|
||||
$this->dispatch(TheliaEvents::ADMIN_LOGIN);
|
||||
|
||||
// Redirect to the success URL
|
||||
return Redirect::exec($adminLoginForm->getSuccessUrl());
|
||||
// Redirect to the success URL, passing the cookie if one exists.
|
||||
$this->redirect($adminLoginForm->getSuccessUrl());
|
||||
|
||||
} catch (FormValidationException $ex) {
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class ShippingConfigurationController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingConfigurationController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response;
|
||||
return $this->render("shipping-configuration", array("display_shipping_configuration" => 20));
|
||||
}
|
||||
|
||||
public function updateAction($shipping_configuration_id)
|
||||
{
|
||||
|
||||
return $this->render("shipping-configuration-edit", array(
|
||||
"shipping_configuration_id" => $shipping_configuration_id
|
||||
));
|
||||
}
|
||||
}
|
||||
46
core/lib/Thelia/Controller/Admin/ShippingZoneController.php
Normal file
46
core/lib/Thelia/Controller/Admin/ShippingZoneController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class ShippingZoneController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZoneController extends BaseAdminController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
|
||||
return $this->render("shipping-zones", array("display_shipping_zone" => 20));
|
||||
}
|
||||
|
||||
public function updateAction($shipping_zones_id)
|
||||
{
|
||||
|
||||
return $this->render("shipping-zones-edit", array(
|
||||
"shipping_zones_id" => $shipping_zones_id
|
||||
));
|
||||
}
|
||||
}
|
||||
302
core/lib/Thelia/Controller/Admin/TemplateController.php
Normal file
302
core/lib/Thelia/Controller/Admin/TemplateController.php
Normal file
@@ -0,0 +1,302 @@
|
||||
<?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\TemplateDeleteEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\TemplateUpdateEvent;
|
||||
use Thelia\Core\Event\TemplateCreateEvent;
|
||||
use Thelia\Model\TemplateQuery;
|
||||
use Thelia\Form\TemplateModificationForm;
|
||||
use Thelia\Form\TemplateCreationForm;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Model\TemplateAv;
|
||||
use Thelia\Model\TemplateAvQuery;
|
||||
use Thelia\Core\Event\TemplateAvUpdateEvent;
|
||||
use Thelia\Core\Event\TemplateEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateAddAttributeEvent;
|
||||
use Thelia\Core\Event\TemplateAddFeatureEvent;
|
||||
use Thelia\Core\Event\TemplateDeleteFeatureEvent;
|
||||
|
||||
/**
|
||||
* Manages product templates
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class TemplateController extends AbstractCrudController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'template',
|
||||
null,
|
||||
null,
|
||||
|
||||
'admin.configuration.templates.view',
|
||||
'admin.configuration.templates.create',
|
||||
'admin.configuration.templates.update',
|
||||
'admin.configuration.templates.delete',
|
||||
|
||||
TheliaEvents::TEMPLATE_CREATE,
|
||||
TheliaEvents::TEMPLATE_UPDATE,
|
||||
TheliaEvents::TEMPLATE_DELETE,
|
||||
null, // No visibility toggle
|
||||
null // No position update
|
||||
);
|
||||
}
|
||||
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new TemplateCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new TemplateModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$createEvent = new TemplateCreateEvent();
|
||||
|
||||
$createEvent
|
||||
->setTemplateName($formData['name'])
|
||||
->setLocale($formData["locale"])
|
||||
;
|
||||
|
||||
return $createEvent;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$changeEvent = new TemplateUpdateEvent($formData['id']);
|
||||
|
||||
// Create and dispatch the change event
|
||||
$changeEvent
|
||||
->setLocale($formData["locale"])
|
||||
->setTemplateName($formData['name'])
|
||||
;
|
||||
|
||||
// Add feature and attributes list
|
||||
|
||||
return $changeEvent;
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new TemplateDeleteEvent($this->getRequest()->get('template_id'));
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasTemplate();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'name' => $object->getName()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new TemplateModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasTemplate() ? $event->getTemplate() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return TemplateQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('template_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getName();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
return $this->render('templates', array('order' => $currentOrder));
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render(
|
||||
'template-edit',
|
||||
array(
|
||||
'template_id' => $this->getRequest()->get('template_id'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.templates.update",
|
||||
array(
|
||||
'template_id' => $this->getRequest()->get('template_id'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.templates.default');
|
||||
}
|
||||
|
||||
// Process delete failure, which may occurs if template is in use.
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
if ($deleteEvent->getProductCount() > 0) {
|
||||
|
||||
$this->getParserContext()->setGeneralError(
|
||||
$this->getTranslator()->trans(
|
||||
"This template is in use in some of your products, and cannot be deleted. Delete it from all your products and try again."
|
||||
)
|
||||
);
|
||||
|
||||
return $this->renderList();
|
||||
}
|
||||
|
||||
// Normal delete processing
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAjaxFeaturesAction() {
|
||||
return $this->render(
|
||||
'ajax/template-feature-list',
|
||||
array('template_id' => $this->getRequest()->get('template_id'))
|
||||
);
|
||||
}
|
||||
|
||||
public function getAjaxAttributesAction() {
|
||||
return $this->render(
|
||||
'ajax/template-attribute-list',
|
||||
array('template_id' => $this->getRequest()->get('template_id'))
|
||||
);
|
||||
}
|
||||
|
||||
public function addAttributeAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
|
||||
|
||||
$attribute_id = intval($this->getRequest()->get('attribute_id'));
|
||||
|
||||
if ($attribute_id > 0) {
|
||||
$event = new TemplateAddAttributeEvent(
|
||||
$this->getExistingObject(),
|
||||
$attribute_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_ADD_ATTRIBUTE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteAttributeAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
|
||||
|
||||
$event = new TemplateDeleteAttributeEvent(
|
||||
$this->getExistingObject(),
|
||||
intval($this->getRequest()->get('attribute_id'))
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_ATTRIBUTE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function addFeatureAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
|
||||
|
||||
$feature_id = intval($this->getRequest()->get('feature_id'));
|
||||
|
||||
if ($feature_id > 0) {
|
||||
$event = new TemplateAddFeatureEvent(
|
||||
$this->getExistingObject(),
|
||||
$feature_id
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_ADD_FEATURE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function deleteFeatureAction() {
|
||||
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
|
||||
|
||||
$event = new TemplateDeleteFeatureEvent(
|
||||
$this->getExistingObject(),
|
||||
intval($this->getRequest()->get('feature_id'))
|
||||
);
|
||||
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::TEMPLATE_DELETE_FEATURE, $event);
|
||||
} catch (\Exception $ex) {
|
||||
// Any error
|
||||
return $this->errorPage($ex);
|
||||
}
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
@@ -127,7 +136,7 @@ class BaseController extends ContainerAware
|
||||
/**
|
||||
* Returns the session from the current request
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Session\SessionInterface
|
||||
* @return \Thelia\Core\HttpFoundation\Session\Session
|
||||
*/
|
||||
protected function getSession()
|
||||
{
|
||||
@@ -198,9 +207,9 @@ class BaseController extends ContainerAware
|
||||
*
|
||||
* @param string $url
|
||||
*/
|
||||
public function redirect($url, $status = 302)
|
||||
public function redirect($url, $status = 302, $cookies = array())
|
||||
{
|
||||
Redirect::exec($url, $status);
|
||||
Redirect::exec($url, $status, $cookies);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class AddressController extends BaseFrontController
|
||||
*/
|
||||
public function generateModalAction($address_id)
|
||||
{
|
||||
|
||||
$this->checkAuth();
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
@@ -62,6 +63,7 @@ class AddressController extends BaseFrontController
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
|
||||
$this->checkAuth();
|
||||
|
||||
$addressCreate = new AddressCreateForm($this->getRequest());
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace Thelia\Controller\Front;
|
||||
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Controller\BaseController;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class BaseFrontController extends BaseController
|
||||
@@ -57,4 +59,28 @@ 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() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) {
|
||||
$this->redirectToRoute("order.delivery");
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkValidInvoice()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
|
||||
$this->redirectToRoute("order.invoice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
246
core/lib/Thelia/Controller/Front/OrderController.php
Executable file
246
core/lib/Thelia/Controller/Front/OrderController.php
Executable file
@@ -0,0 +1,246 @@
|
||||
<?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\Exception\TheliaProcessException;
|
||||
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\Base\OrderQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
|
||||
/* get postage amount */
|
||||
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
|
||||
$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 invoice()
|
||||
{
|
||||
$this->checkAuth();
|
||||
$this->checkCartNotEmpty();
|
||||
$this->checkValidDelivery();
|
||||
|
||||
$message = false;
|
||||
|
||||
$orderPayment = new OrderPayment($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($orderPayment, "post");
|
||||
|
||||
$invoiceAddressId = $form->get("invoice-address")->getData();
|
||||
$paymentModuleId = $form->get("payment-module")->getData();
|
||||
|
||||
/* check that the invoice address belongs to the current customer */
|
||||
$invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId);
|
||||
if($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
|
||||
throw new \Exception("Invoice address does not belong to the current customer");
|
||||
}
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
$orderEvent->setInvoiceAddress($invoiceAddressId);
|
||||
$orderEvent->setPaymentModule($paymentModuleId);
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_INVOICE_ADDRESS, $orderEvent);
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_PAYMENT_MODULE, $orderEvent);
|
||||
|
||||
$this->redirectToRoute("order.payment.process");
|
||||
|
||||
} 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 payment process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$orderPayment->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($orderPayment)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function pay()
|
||||
{
|
||||
/* check customer */
|
||||
$this->checkAuth();
|
||||
|
||||
/* check cart count */
|
||||
$this->checkCartNotEmpty();
|
||||
|
||||
/* check delivery address and module */
|
||||
$this->checkValidDelivery();
|
||||
|
||||
/* check invoice address and payment module */
|
||||
$this->checkValidInvoice();
|
||||
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent);
|
||||
|
||||
$placedOrder = $orderEvent->getPlacedOrder();
|
||||
|
||||
if(null !== $placedOrder && null !== $placedOrder->getId()) {
|
||||
/* order has been placed */
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId()))));
|
||||
} else {
|
||||
/* order has not been placed */
|
||||
$this->redirectToRoute("cart.view");
|
||||
}
|
||||
}
|
||||
|
||||
public function orderPlaced($order_id)
|
||||
{
|
||||
/* check if the placed order matched the customer */
|
||||
$placedOrder = OrderQuery::create()->findPk(
|
||||
$this->getRequest()->attributes->get('order_id')
|
||||
);
|
||||
|
||||
if(null === $placedOrder) {
|
||||
throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder);
|
||||
}
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) {
|
||||
throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder);
|
||||
}
|
||||
|
||||
$this->getParserContext()->set("placed_order_id", $placedOrder->getId());
|
||||
}
|
||||
|
||||
protected function getOrderEvent()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/AccessoryEvent.php
Normal file
54
core/lib/Thelia/Core/Event/AccessoryEvent.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\Accessory;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class AccessoryEvent extends ActionEvent
|
||||
{
|
||||
public $accessory = null;
|
||||
|
||||
public function __construct(Accessory $accessory = null)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
}
|
||||
|
||||
public function hasAccessory()
|
||||
{
|
||||
return ! is_null($this->accessory);
|
||||
}
|
||||
|
||||
public function getAccessory()
|
||||
{
|
||||
return $this->accessory;
|
||||
}
|
||||
|
||||
public function setAccessory(Accessory $accessory)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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\CategoryAssociatedContent;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CategoryAssociatedContentEvent extends ActionEvent
|
||||
{
|
||||
public $content = null;
|
||||
|
||||
public function __construct(CategoryAssociatedContent $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function hasCategoryAssociatedContent()
|
||||
{
|
||||
return ! is_null($this->content);
|
||||
}
|
||||
|
||||
public function getCategoryAssociatedContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setCategoryAssociatedContent(CategoryAssociatedContent $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
124
core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php
Normal file
124
core/lib/Thelia/Core/Event/Content/ContentCreateEvent.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?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\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentCreateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentCreateEvent extends ContentEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $default_folder;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $default_folder
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultFolder($default_folder)
|
||||
{
|
||||
$this->default_folder = $default_folder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultFolder()
|
||||
{
|
||||
return $this->default_folder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
73
core/lib/Thelia/Core/Event/Content/ContentEvent.php
Normal file
73
core/lib/Thelia/Core/Event/Content/ContentEvent.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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\Content;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Content
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
function __construct(Content $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Content $content
|
||||
*/
|
||||
public function setContent(Content $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Content
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if content exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasContent()
|
||||
{
|
||||
return null !== $this->content;
|
||||
}
|
||||
}
|
||||
150
core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php
Normal file
150
core/lib/Thelia/Core/Event/Content/ContentUpdateEvent.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?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\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Class ContentUpdateEvent
|
||||
* @package Thelia\Core\Event\Content
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentUpdateEvent extends ContentCreateEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
|
||||
function __construct($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $content_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -22,6 +22,8 @@
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Coupon;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Coupon\CouponRuleCollection;
|
||||
use Thelia\Model\Coupon;
|
||||
|
||||
/**
|
||||
@@ -29,75 +31,112 @@ use Thelia\Model\Coupon;
|
||||
* Date: 8/29/13
|
||||
* Time: 3:45 PM
|
||||
*
|
||||
* Occurring when a Coupon is disabled
|
||||
* Occurring when a Coupon is consumed
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class CouponDisableEvent extends ActionEvent
|
||||
class CouponConsumeEvent extends ActionEvent
|
||||
{
|
||||
/** @var int Coupon id */
|
||||
protected $couponId;
|
||||
/** @var string Coupon code */
|
||||
protected $code = null;
|
||||
|
||||
/** @var Coupon Coupon being disabled */
|
||||
protected $disabledCoupon;
|
||||
/** @var float Total discount given by this coupon */
|
||||
protected $discount = 0;
|
||||
|
||||
/** @var bool If Coupon is valid or if Customer meets coupon conditions */
|
||||
protected $isValid = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Coupon Id
|
||||
* @param string $code Coupon code
|
||||
* @param float $discount Total discount given by this coupon
|
||||
* @param bool $isValid If Coupon is valid or
|
||||
* if Customer meets coupon conditions
|
||||
*/
|
||||
public function __construct($id)
|
||||
function __construct($code, $discount = null, $isValid = null)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->code = $code;
|
||||
$this->discount = $discount;
|
||||
$this->isValid = $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon id
|
||||
* Set Coupon code
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon id
|
||||
*
|
||||
* @param int $id Coupon id
|
||||
* @param string $code Coupon code
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon being disabled
|
||||
* Get Coupon code
|
||||
*
|
||||
* @return Coupon
|
||||
* @return string
|
||||
*/
|
||||
public function getDisabledCoupon()
|
||||
public function getCode()
|
||||
{
|
||||
return $this->disabledCoupon;
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon to be disabled
|
||||
* Set total discount given by this coupon
|
||||
*
|
||||
* @param Coupon $disabledCoupon Coupon to disable
|
||||
* @param float $discount Total discount given by this coupon
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDisabledCoupon(Coupon $disabledCoupon)
|
||||
public function setDiscount($discount)
|
||||
{
|
||||
$this->disabledCoupon = $disabledCoupon;
|
||||
$this->discount = $discount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total discount given by this coupon
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getDiscount()
|
||||
{
|
||||
return $this->discount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if Coupon is valid or if Customer meets coupon conditions
|
||||
*
|
||||
* @param boolean $isValid if Coupon is valid or
|
||||
* if Customer meets coupon conditions
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsValid($isValid)
|
||||
{
|
||||
$this->isValid = $isValid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if Coupon is valid or if Customer meets coupon conditions
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsValid()
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
68
core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php
Normal file
68
core/lib/Thelia/Core/Event/FeatureAvCreateEvent.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureAvCreateEvent extends FeatureAvEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $feature_id;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
46
core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php
Normal file
46
core/lib/Thelia/Core/Event/FeatureAvDeleteEvent.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureAvDeleteEvent extends FeatureAvEvent
|
||||
{
|
||||
protected $featureAv_id;
|
||||
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
}
|
||||
|
||||
public function getFeatureAvId()
|
||||
{
|
||||
return $this->featureAv_id;
|
||||
}
|
||||
|
||||
public function setFeatureAvId($featureAv_id)
|
||||
{
|
||||
$this->featureAv_id = $featureAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/FeatureAvEvent.php
Normal file
52
core/lib/Thelia/Core/Event/FeatureAvEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\FeatureAv;
|
||||
|
||||
class FeatureAvEvent extends ActionEvent
|
||||
{
|
||||
protected $featureAv = null;
|
||||
|
||||
public function __construct(FeatureAv $featureAv = null)
|
||||
{
|
||||
$this->featureAv = $featureAv;
|
||||
}
|
||||
|
||||
public function hasFeatureAv()
|
||||
{
|
||||
return ! is_null($this->featureAv);
|
||||
}
|
||||
|
||||
public function getFeatureAv()
|
||||
{
|
||||
return $this->featureAv;
|
||||
}
|
||||
|
||||
public function setFeatureAv($featureAv)
|
||||
{
|
||||
$this->featureAv = $featureAv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
86
core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php
Normal file
86
core/lib/Thelia/Core/Event/FeatureAvUpdateEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureAvUpdateEvent extends FeatureAvCreateEvent
|
||||
{
|
||||
protected $featureAv_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
public function __construct($featureAv_id)
|
||||
{
|
||||
$this->setFeatureAvId($featureAv_id);
|
||||
}
|
||||
|
||||
public function getFeatureAvId()
|
||||
{
|
||||
return $this->featureAv_id;
|
||||
}
|
||||
|
||||
public function setFeatureAvId($featureAv_id)
|
||||
{
|
||||
$this->featureAv_id = $featureAv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
68
core/lib/Thelia/Core/Event/FeatureCreateEvent.php
Normal file
68
core/lib/Thelia/Core/Event/FeatureCreateEvent.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureCreateEvent extends FeatureEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $locale;
|
||||
protected $add_to_all_templates;
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddToAllTemplates()
|
||||
{
|
||||
return $this->add_to_all_templates;
|
||||
}
|
||||
|
||||
public function setAddToAllTemplates($add_to_all_templates)
|
||||
{
|
||||
$this->add_to_all_templates = $add_to_all_templates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
46
core/lib/Thelia/Core/Event/FeatureDeleteEvent.php
Normal file
46
core/lib/Thelia/Core/Event/FeatureDeleteEvent.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureDeleteEvent extends FeatureEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Core/Event/FeatureEvent.php
Normal file
52
core/lib/Thelia/Core/Event/FeatureEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Feature;
|
||||
|
||||
class FeatureEvent extends ActionEvent
|
||||
{
|
||||
protected $feature = null;
|
||||
|
||||
public function __construct(Feature $feature = null)
|
||||
{
|
||||
$this->feature = $feature;
|
||||
}
|
||||
|
||||
public function hasFeature()
|
||||
{
|
||||
return ! is_null($this->feature);
|
||||
}
|
||||
|
||||
public function getFeature()
|
||||
{
|
||||
return $this->feature;
|
||||
}
|
||||
|
||||
public function setFeature($feature)
|
||||
{
|
||||
$this->feature = $feature;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
86
core/lib/Thelia/Core/Event/FeatureUpdateEvent.php
Normal file
86
core/lib/Thelia/Core/Event/FeatureUpdateEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
class FeatureUpdateEvent extends FeatureCreateEvent
|
||||
{
|
||||
protected $feature_id;
|
||||
|
||||
protected $description;
|
||||
protected $chapo;
|
||||
protected $postscriptum;
|
||||
|
||||
public function __construct($feature_id)
|
||||
{
|
||||
$this->setFeatureId($feature_id);
|
||||
}
|
||||
|
||||
public function getFeatureId()
|
||||
{
|
||||
return $this->feature_id;
|
||||
}
|
||||
|
||||
public function setFeatureId($feature_id)
|
||||
{
|
||||
$this->feature_id = $feature_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
120
core/lib/Thelia/Core/Event/FolderCreateEvent.php
Normal file
120
core/lib/Thelia/Core/Event/FolderCreateEvent.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?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 FolderCreateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderCreateEvent extends FolderEvent {
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $parent
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,39 +21,44 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Install;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Controller\BaseController;
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class BaseInstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* Class FolderDeleteEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class BaseInstallController extends BaseController
|
||||
{
|
||||
class FolderDeleteEvent extends FolderEvent{
|
||||
|
||||
/**
|
||||
* @return a ParserInterface instance parser
|
||||
* @var int folder id
|
||||
*/
|
||||
protected function getParser()
|
||||
protected $folder_id;
|
||||
|
||||
/**
|
||||
* @param int $folder_id
|
||||
*/
|
||||
function __construct($folder_id)
|
||||
{
|
||||
$parser = $this->container->get("thelia.parser");
|
||||
|
||||
// Define the template thant shoud be used
|
||||
$parser->setTemplate("install");
|
||||
|
||||
return $parser;
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
public function render($templateName, $args = array())
|
||||
/**
|
||||
* @param int $folder_id
|
||||
*/
|
||||
public function setFolderId($folder_id)
|
||||
{
|
||||
return new Response($this->renderRaw($templateName, $args));
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
public function renderRaw($templateName, $args = array())
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFolderId()
|
||||
{
|
||||
$data = $this->getParser()->render($templateName, $args);
|
||||
|
||||
return $data;
|
||||
return $this->folder_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,48 +21,53 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Install;
|
||||
use Thelia\Install\CheckPermission;
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Folder;
|
||||
|
||||
|
||||
/**
|
||||
* Class InstallController
|
||||
* @package Thelia\Controller\Install
|
||||
* Class FolderEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class InstallController extends BaseInstallController
|
||||
{
|
||||
public function index()
|
||||
class FolderEvent extends ActionEvent {
|
||||
|
||||
/**
|
||||
* @var \Thelia\Model\Folder
|
||||
*/
|
||||
protected $folder;
|
||||
|
||||
function __construct(Folder $folder = null)
|
||||
{
|
||||
$this->verifyStep(1);
|
||||
|
||||
$this->getSession()->set("step", 1);
|
||||
|
||||
$this->render("index.html");
|
||||
$this->folder = $folder;
|
||||
}
|
||||
|
||||
public function checkPermission()
|
||||
/**
|
||||
* @param \Thelia\Model\Folder $folder
|
||||
*/
|
||||
public function setFolder(Folder $folder)
|
||||
{
|
||||
$this->verifyStep(2);
|
||||
$this->folder = $folder;
|
||||
|
||||
$permission = new CheckPermission();
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function verifyStep($step)
|
||||
/**
|
||||
* @return \Thelia\Model\Folder
|
||||
*/
|
||||
public function getFolder()
|
||||
{
|
||||
$session = $this->getSession();
|
||||
|
||||
if ($session->has("step")) {
|
||||
$sessionStep = $session->get("step");
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ($step) {
|
||||
case "1" :
|
||||
if ($sessionStep > 1) {
|
||||
$this->redirect("/install/step/2");
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $this->folder;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test if a folder object exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFolder()
|
||||
{
|
||||
return null !== $this->folder;
|
||||
}
|
||||
|
||||
}
|
||||
34
core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php
Normal file
34
core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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 FolderToggleVisibilityEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderToggleVisibilityEvent extends FolderEvent {
|
||||
|
||||
}
|
||||
136
core/lib/Thelia/Core/Event/FolderUpdateEvent.php
Normal file
136
core/lib/Thelia/Core/Event/FolderUpdateEvent.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?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 FolderUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderUpdateEvent extends FolderCreateEvent {
|
||||
protected $folder_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
|
||||
function __construct($folder_id)
|
||||
{
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $folder_id
|
||||
*/
|
||||
public function setFolderId($folder_id)
|
||||
{
|
||||
$this->folder_id = $folder_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFolderId()
|
||||
{
|
||||
return $this->folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
}
|
||||
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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 GenerateRewrittenUrlEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class GenerateRewrittenUrlEvent extends ActionEvent {
|
||||
|
||||
protected $object;
|
||||
protected $locale;
|
||||
|
||||
protected $url;
|
||||
|
||||
public function __construct($object, $locale)
|
||||
{
|
||||
$this->object;
|
||||
$this->locale;
|
||||
}
|
||||
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function isRewritten()
|
||||
{
|
||||
return null !== $this->url;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
52
core/lib/Thelia/Core/Event/MailTransporterEvent.php
Normal file
52
core/lib/Thelia/Core/Event/MailTransporterEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class MailTransporterEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class MailTransporterEvent extends ActionEvent {
|
||||
/**
|
||||
* @var \Swift_Transport
|
||||
*/
|
||||
protected $transporter;
|
||||
|
||||
public function setMailerTransporter(\Swift_Transport $transporter)
|
||||
{
|
||||
$this->transporter = $transporter;
|
||||
}
|
||||
|
||||
public function getTransporter()
|
||||
{
|
||||
return $this->transporter;
|
||||
}
|
||||
|
||||
public function hasTransporter()
|
||||
{
|
||||
return null !== $this->transporter;
|
||||
}
|
||||
}
|
||||
174
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
174
core/lib/Thelia/Core/Event/OrderEvent.php
Executable file
@@ -0,0 +1,174 @@
|
||||
<?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 $placedOrder = null;
|
||||
protected $invoiceAddress = null;
|
||||
protected $deliveryAddress = null;
|
||||
protected $deliveryModule = null;
|
||||
protected $paymentModule = null;
|
||||
protected $postage = null;
|
||||
protected $ref = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->setOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function setOrder(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function setPlacedOrder(Order $order)
|
||||
{
|
||||
$this->placedOrder = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $address
|
||||
*/
|
||||
public function setInvoiceAddress($address)
|
||||
{
|
||||
$this->invoiceAddress = $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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ref
|
||||
*/
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
public function getPlacedOrder()
|
||||
{
|
||||
return $this->placedOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.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 ProductAddAccessoryEvent extends ProductEvent
|
||||
{
|
||||
protected $accessory_id;
|
||||
|
||||
public function __construct(Product $product, $accessory_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
|
||||
public function getAccessoryId()
|
||||
{
|
||||
return $this->accessory_id;
|
||||
}
|
||||
|
||||
public function setAccessoryId($accessory_id)
|
||||
{
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php
Normal file
54
core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.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\ProductAssociatedContent;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ProductAssociatedContentEvent extends ActionEvent
|
||||
{
|
||||
public $content = null;
|
||||
|
||||
public function __construct(ProductAssociatedContent $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function hasProductAssociatedContent()
|
||||
{
|
||||
return ! is_null($this->content);
|
||||
}
|
||||
|
||||
public function getProductAssociatedContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setProductAssociatedContent(ProductAssociatedContent $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
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/ProductDeleteAccessoryEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.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 ProductDeleteAccessoryEvent extends ProductEvent
|
||||
{
|
||||
protected $accessory_id;
|
||||
|
||||
public function __construct(Product $product, $accessory_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
|
||||
public function getAccessoryId()
|
||||
{
|
||||
return $this->accessory_id;
|
||||
}
|
||||
|
||||
public function setAccessoryId($accessory_id)
|
||||
{
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user