This commit is contained in:
Manuel Raynaud
2013-09-30 10:35:34 +02:00
parent 43b5a129f7
commit c65ec67bdf
168 changed files with 577 additions and 818 deletions

View File

@@ -86,14 +86,14 @@ class Address extends BaseAction implements EventSubscriberInterface
->save() ->save()
; ;
if($event->getIsDefault()) { if ($event->getIsDefault()) {
$addressModel->makeItDefault(); $addressModel->makeItDefault();
} }
$event->setAddress($addressModel); $event->setAddress($addressModel);
$con->commit(); $con->commit();
} catch(PropelException $e) { } catch (PropelException $e) {
$con->rollback(); $con->rollback();
throw $e; throw $e;
} }

View File

@@ -33,11 +33,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Attribute\AttributeUpdateEvent; use Thelia\Core\Event\Attribute\AttributeUpdateEvent;
use Thelia\Core\Event\Attribute\AttributeCreateEvent; use Thelia\Core\Event\Attribute\AttributeCreateEvent;
use Thelia\Core\Event\Attribute\AttributeDeleteEvent; use Thelia\Core\Event\Attribute\AttributeDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\AttributeAv;
use Thelia\Model\AttributeAvQuery;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Category\CategoryEvent;
use Thelia\Core\Event\Attribute\AttributeEvent; use Thelia\Core\Event\Attribute\AttributeEvent;
use Thelia\Model\AttributeTemplate; use Thelia\Model\AttributeTemplate;
use Thelia\Model\AttributeTemplateQuery; use Thelia\Model\AttributeTemplateQuery;
@@ -130,7 +126,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface
{ {
$templates = TemplateQuery::create()->find(); $templates = TemplateQuery::create()->find();
foreach($templates as $template) { foreach ($templates as $template) {
$attribute_template = new AttributeTemplate(); $attribute_template = new AttributeTemplate();
@@ -171,4 +167,4 @@ class Attribute extends BaseAction implements EventSubscriberInterface
); );
} }
} }

View File

@@ -33,7 +33,6 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent; use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent;
use Thelia\Core\Event\Attribute\AttributeAvCreateEvent; use Thelia\Core\Event\Attribute\AttributeAvCreateEvent;
use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent; use Thelia\Core\Event\Attribute\AttributeAvDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
class AttributeAv extends BaseAction implements EventSubscriberInterface class AttributeAv extends BaseAction implements EventSubscriberInterface
@@ -115,7 +114,6 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(AttributeAvQuery::create(), $event); return $this->genericUpdatePosition(AttributeAvQuery::create(), $event);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -128,4 +126,4 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface
TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128), TheliaEvents::ATTRIBUTE_AV_UPDATE_POSITION => array("updatePosition", 128),
); );
} }
} }

View File

@@ -24,7 +24,6 @@ namespace Thelia\Action;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Model\AdminLog; use Thelia\Model\AdminLog;
use Propel\Runtime\ActiveQuery\PropelQuery;
use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
@@ -50,7 +49,6 @@ class BaseAction
return $this->container->get('event_dispatcher'); return $this->container->get('event_dispatcher');
} }
/** /**
* Changes object position, selecting absolute ou relative change. * Changes object position, selecting absolute ou relative change.
* *

View File

@@ -23,10 +23,7 @@
namespace Thelia\Action; namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\CachedFileEvent; use Thelia\Core\Event\CachedFileEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL; use Thelia\Tools\URL;
/** /**
@@ -50,7 +47,7 @@ abstract class BaseCachedFile extends BaseAction
/** /**
* @return string root of the file cache directory in web space * @return string root of the file cache directory in web space
*/ */
protected abstract function getCacheDirFromWebRoot(); abstract protected function getCacheDirFromWebRoot();
/** /**
* Clear the file cache. Is a subdirectory is specified, only this directory is cleared. * Clear the file cache. Is a subdirectory is specified, only this directory is cleared.
@@ -104,9 +101,9 @@ abstract class BaseCachedFile extends BaseAction
/** /**
* Return the full path of the cached file * Return the full path of the cached file
* *
* @param string $subdir the subdirectory related to cache base * @param string $subdir the subdirectory related to cache base
* @param string $filename the filename * @param string $filename the filename
* @param string $hashed_options a hash of transformation options, or null if no transformations have been applied * @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. * @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 * @return string the cache directory path relative to Web Root
*/ */
@@ -175,4 +172,4 @@ abstract class BaseCachedFile extends BaseAction
return $path; return $path;
} }
} }

View File

@@ -33,7 +33,6 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Category\CategoryUpdateEvent; use Thelia\Core\Event\Category\CategoryUpdateEvent;
use Thelia\Core\Event\Category\CategoryCreateEvent; use Thelia\Core\Event\Category\CategoryCreateEvent;
use Thelia\Core\Event\Category\CategoryDeleteEvent; use Thelia\Core\Event\Category\CategoryDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent; use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\Category\CategoryAddContentEvent; use Thelia\Core\Event\Category\CategoryAddContentEvent;
@@ -139,8 +138,8 @@ class Category extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(CategoryQuery::create(), $event); return $this->genericUpdatePosition(CategoryQuery::create(), $event);
} }
public function addContent(CategoryAddContentEvent $event) { public function addContent(CategoryAddContentEvent $event)
{
if (CategoryAssociatedContentQuery::create() if (CategoryAssociatedContentQuery::create()
->filterByContentId($event->getContentId()) ->filterByContentId($event->getContentId())
->filterByCategory($event->getCategory())->count() <= 0) { ->filterByCategory($event->getCategory())->count() <= 0) {
@@ -156,8 +155,8 @@ class Category extends BaseAction implements EventSubscriberInterface
} }
} }
public function removeContent(CategoryDeleteContentEvent $event) { public function removeContent(CategoryDeleteContentEvent $event)
{
$content = CategoryAssociatedContentQuery::create() $content = CategoryAssociatedContentQuery::create()
->filterByContentId($event->getContentId()) ->filterByContentId($event->getContentId())
->filterByCategory($event->getCategory())->findOne() ->filterByCategory($event->getCategory())->findOne()
@@ -170,7 +169,6 @@ class Category extends BaseAction implements EventSubscriberInterface
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -31,8 +31,6 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\ContentQuery; use Thelia\Model\ContentQuery;
use Thelia\Model\Content as ContentModel; use Thelia\Model\Content as ContentModel;
use Thelia\Model\FolderQuery;
/** /**
* Class Content * Class Content
@@ -82,11 +80,10 @@ class Content extends BaseAction implements EventSubscriberInterface
public function updatePosition(UpdatePositionEvent $event) public function updatePosition(UpdatePositionEvent $event)
{ {
if(null !== $content = ContentQuery::create()->findPk($event->getObjectId())) { if (null !== $content = ContentQuery::create()->findPk($event->getObjectId())) {
$content->setDispatcher($this->getDispatcher()); $content->setDispatcher($this->getDispatcher());
switch($event->getMode()) switch ($event->getMode()) {
{
case UpdatePositionEvent::POSITION_ABSOLUTE: case UpdatePositionEvent::POSITION_ABSOLUTE:
$content->changeAbsolutePosition($event->getPosition()); $content->changeAbsolutePosition($event->getPosition());
break; break;
@@ -124,7 +121,6 @@ class Content extends BaseAction implements EventSubscriberInterface
} }
} }
/** /**
* Returns an array of event names this subscriber wants to listen to. * Returns an array of event names this subscriber wants to listen to.
* *
@@ -157,4 +153,4 @@ class Content extends BaseAction implements EventSubscriberInterface
); );
} }
} }

View File

@@ -33,11 +33,7 @@ use Thelia\Model\ConfigQuery;
use Thelia\Tools\FileManager; use Thelia\Tools\FileManager;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Imagine\Document\ImagineInterface;
use Imagine\Document\DocumentInterface;
use Imagine\Document\Box;
use Imagine\Document\Color; use Imagine\Document\Color;
use Imagine\Document\Point;
use Thelia\Exception\DocumentException; use Thelia\Exception\DocumentException;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
@@ -80,7 +76,8 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
/** /**
* @return string root of the document cache directory in web space * @return string root of the document cache directory in web space
*/ */
protected function getCacheDirFromWebRoot() { protected function getCacheDirFromWebRoot()
{
return ConfigQuery::read('document_cache_dir_from_web_root', 'cache'); return ConfigQuery::read('document_cache_dir_from_web_root', 'cache');
} }
@@ -95,7 +92,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
* @param DocumentEvent $event Event * @param DocumentEvent $event Event
* *
* @throws \Thelia\Exception\DocumentException * @throws \Thelia\Exception\DocumentException
* @throws \InvalidArgumentException , DocumentException * @throws \InvalidArgumentException , DocumentException
*/ */
public function processDocument(DocumentEvent $event) public function processDocument(DocumentEvent $event)
{ {
@@ -247,7 +244,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
'document' 'document'
) )
); );
} catch(\Exception $e) { } catch (\Exception $e) {
$this->adminLogAppend( $this->adminLogAppend(
$this->container->get('thelia.translator')->trans( $this->container->get('thelia.translator')->trans(
'Fail to delete document for %id% with parent id %parentId% (Exception : %e%)', 'Fail to delete document for %id% with parent id %parentId% (Exception : %e%)',

View File

@@ -33,11 +33,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Feature\FeatureUpdateEvent; use Thelia\Core\Event\Feature\FeatureUpdateEvent;
use Thelia\Core\Event\Feature\FeatureCreateEvent; use Thelia\Core\Event\Feature\FeatureCreateEvent;
use Thelia\Core\Event\Feature\FeatureDeleteEvent; use Thelia\Core\Event\Feature\FeatureDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\FeatureAv;
use Thelia\Model\FeatureAvQuery;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Category\CategoryEvent;
use Thelia\Core\Event\Feature\FeatureEvent; use Thelia\Core\Event\Feature\FeatureEvent;
use Thelia\Model\FeatureTemplate; use Thelia\Model\FeatureTemplate;
use Thelia\Model\FeatureTemplateQuery; use Thelia\Model\FeatureTemplateQuery;
@@ -130,7 +126,7 @@ class Feature extends BaseAction implements EventSubscriberInterface
{ {
$templates = TemplateQuery::create()->find(); $templates = TemplateQuery::create()->find();
foreach($templates as $template) { foreach ($templates as $template) {
$feature_template = new FeatureTemplate(); $feature_template = new FeatureTemplate();
@@ -171,4 +167,4 @@ class Feature extends BaseAction implements EventSubscriberInterface
); );
} }
} }

View File

@@ -33,7 +33,6 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Feature\FeatureAvUpdateEvent; use Thelia\Core\Event\Feature\FeatureAvUpdateEvent;
use Thelia\Core\Event\Feature\FeatureAvCreateEvent; use Thelia\Core\Event\Feature\FeatureAvCreateEvent;
use Thelia\Core\Event\Feature\FeatureAvDeleteEvent; use Thelia\Core\Event\Feature\FeatureAvDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
class FeatureAv extends BaseAction implements EventSubscriberInterface class FeatureAv extends BaseAction implements EventSubscriberInterface
@@ -115,7 +114,6 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(FeatureAvQuery::create(), $event); return $this->genericUpdatePosition(FeatureAvQuery::create(), $event);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -128,4 +126,4 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface
TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128), TheliaEvents::FEATURE_AV_UPDATE_POSITION => array("updatePosition", 128),
); );
} }
} }

View File

@@ -32,15 +32,13 @@ use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\FolderQuery; use Thelia\Model\FolderQuery;
use Thelia\Model\Folder as FolderModel; use Thelia\Model\Folder as FolderModel;
/** /**
* Class Folder * Class Folder
* @package Thelia\Action * @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class Folder extends BaseAction implements EventSubscriberInterface { class Folder extends BaseAction implements EventSubscriberInterface
{
public function update(FolderUpdateEvent $event) public function update(FolderUpdateEvent $event)
{ {
@@ -103,11 +101,10 @@ class Folder extends BaseAction implements EventSubscriberInterface {
public function updatePosition(UpdatePositionEvent $event) public function updatePosition(UpdatePositionEvent $event)
{ {
if(null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) { if (null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) {
$folder->setDispatcher($this->getDispatcher()); $folder->setDispatcher($this->getDispatcher());
switch($event->getMode()) switch ($event->getMode()) {
{
case UpdatePositionEvent::POSITION_ABSOLUTE: case UpdatePositionEvent::POSITION_ABSOLUTE:
$folder->changeAbsolutePosition($event->getPosition()); $folder->changeAbsolutePosition($event->getPosition());
break; break;
@@ -152,4 +149,4 @@ class Folder extends BaseAction implements EventSubscriberInterface {
TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128), TheliaEvents::FOLDER_UPDATE_POSITION => array("updatePosition", 128),
); );
} }
} }

View File

@@ -45,7 +45,7 @@ class HttpException extends BaseAction implements EventSubscriberInterface
$this->display404($event); $this->display404($event);
} }
if($event->getException() instanceof AccessDeniedHttpException) { if ($event->getException() instanceof AccessDeniedHttpException) {
$this->display403($event); $this->display403($event);
} }
} }

View File

@@ -23,19 +23,12 @@
namespace Thelia\Action; namespace Thelia\Action;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\ImagesCreateOrUpdateEvent;
use Thelia\Core\Event\Image\ImageDeleteEvent; use Thelia\Core\Event\Image\ImageDeleteEvent;
use Thelia\Core\Event\Image\ImageEvent; use Thelia\Core\Event\Image\ImageEvent;
use Thelia\Model\CategoryImage;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Model\ContentImage;
use Thelia\Model\FolderImage;
use Thelia\Model\ProductImage;
use Thelia\Tools\FileManager; use Thelia\Tools\FileManager;
use Thelia\Tools\URL; use Thelia\Tools\URL;
@@ -88,12 +81,11 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
const EXACT_RATIO_WITH_CROP = 2; const EXACT_RATIO_WITH_CROP = 2;
const KEEP_IMAGE_RATIO = 3; const KEEP_IMAGE_RATIO = 3;
/** /**
* @return string root of the image cache directory in web space * @return string root of the image cache directory in web space
*/ */
protected function getCacheDirFromWebRoot() { protected function getCacheDirFromWebRoot()
{
return ConfigQuery::read('image_cache_dir_from_web_root', 'cache'); return ConfigQuery::read('image_cache_dir_from_web_root', 'cache');
} }
@@ -106,8 +98,8 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
* *
* This method updates the cache_file_path and file_url attributes of the event * This method updates the cache_file_path and file_url attributes of the event
* *
* @param \Thelia\Core\Event\Image\ImageEvent $event * @param \Thelia\Core\Event\Image\ImageEvent $event
* @throws \InvalidArgumentException, ImageException * @throws \InvalidArgumentException, ImageException
*/ */
public function processImage(ImageEvent $event) public function processImage(ImageEvent $event)
{ {
@@ -358,7 +350,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
'image' 'image'
) )
); );
} catch(\Exception $e){ } catch (\Exception $e) {
$this->adminLogAppend( $this->adminLogAppend(
$this->container->get('thelia.translator')->trans( $this->container->get('thelia.translator')->trans(
'Fail to delete image for %id% with parent id %parentId% (Exception : %e%)', 'Fail to delete image for %id% with parent id %parentId% (Exception : %e%)',

View File

@@ -23,13 +23,11 @@
namespace Thelia\Action; namespace Thelia\Action;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Exception\OrderException;
use Thelia\Exception\TheliaProcessException; use Thelia\Exception\TheliaProcessException;
use Thelia\Model\AddressQuery; use Thelia\Model\AddressQuery;
use Thelia\Model\OrderProductAttributeCombination; use Thelia\Model\OrderProductAttributeCombination;
@@ -39,7 +37,6 @@ use Thelia\Model\OrderStatus;
use Thelia\Model\Map\OrderTableMap; use Thelia\Model\Map\OrderTableMap;
use Thelia\Model\OrderAddress; use Thelia\Model\OrderAddress;
use Thelia\Model\OrderStatusQuery; use Thelia\Model\OrderStatusQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\I18n; use Thelia\Tools\I18n;
/** /**
@@ -177,7 +174,7 @@ class Order extends BaseAction implements EventSubscriberInterface
/* fulfill order_products and decrease stock */ /* fulfill order_products and decrease stock */
foreach($cartItems as $cartItem) { foreach ($cartItems as $cartItem) {
$product = $cartItem->getProduct(); $product = $cartItem->getProduct();
/* get translation */ /* get translation */
@@ -186,7 +183,7 @@ class Order extends BaseAction implements EventSubscriberInterface
$pse = $cartItem->getProductSaleElements(); $pse = $cartItem->getProductSaleElements();
/* check still in stock */ /* check still in stock */
if($cartItem->getQuantity() > $pse->getQuantity()) { if ($cartItem->getQuantity() > $pse->getQuantity()) {
throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem); throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem);
} }
@@ -228,13 +225,13 @@ class Order extends BaseAction implements EventSubscriberInterface
$orderProduct->save($con); $orderProduct->save($con);
/* fulfill order_product_tax */ /* fulfill order_product_tax */
foreach($taxDetail as $tax) { foreach ($taxDetail as $tax) {
$tax->setOrderProductId($orderProduct->getId()); $tax->setOrderProductId($orderProduct->getId());
$tax->save($con); $tax->save($con);
} }
/* fulfill order_attribute_combination and decrease stock */ /* fulfill order_attribute_combination and decrease stock */
foreach($pse->getAttributeCombinations() as $attributeCombination) { foreach ($pse->getAttributeCombinations() as $attributeCombination) {
$attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId()); $attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId());
$attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId()); $attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId());

View File

@@ -33,7 +33,6 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Product\ProductUpdateEvent; use Thelia\Core\Event\Product\ProductUpdateEvent;
use Thelia\Core\Event\Product\ProductCreateEvent; use Thelia\Core\Event\Product\ProductCreateEvent;
use Thelia\Core\Event\Product\ProductDeleteEvent; use Thelia\Core\Event\Product\ProductDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; use Thelia\Core\Event\Product\ProductToggleVisibilityEvent;
use Thelia\Core\Event\Product\ProductAddContentEvent; use Thelia\Core\Event\Product\ProductAddContentEvent;
@@ -41,21 +40,16 @@ use Thelia\Core\Event\Product\ProductDeleteContentEvent;
use Thelia\Model\ProductAssociatedContent; use Thelia\Model\ProductAssociatedContent;
use Thelia\Model\ProductAssociatedContentQuery; use Thelia\Model\ProductAssociatedContentQuery;
use Thelia\Model\ProductCategory; use Thelia\Model\ProductCategory;
use Thelia\Model\TaxRule;
use Thelia\Model\TaxRuleQuery; use Thelia\Model\TaxRuleQuery;
use Thelia\Model\TaxQuery;
use Thelia\Model\AccessoryQuery; use Thelia\Model\AccessoryQuery;
use Thelia\Model\Accessory; use Thelia\Model\Accessory;
use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent; use Thelia\Core\Event\FeatureProduct\FeatureProductUpdateEvent;
use Thelia\Model\FeatureProduct; use Thelia\Model\FeatureProduct;
use Thelia\Model\FeatureQuery;
use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent; use Thelia\Core\Event\FeatureProduct\FeatureProductDeleteEvent;
use Thelia\Model\FeatureProductQuery; use Thelia\Model\FeatureProductQuery;
use Thelia\Model\ProductCategoryQuery; use Thelia\Model\ProductCategoryQuery;
use Thelia\Core\Event\Product\ProductSetTemplateEvent; use Thelia\Core\Event\Product\ProductSetTemplateEvent;
use Thelia\Model\AttributeCombinationQuery;
use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductSaleElementsQuery;
use Propel\Runtime\ActiveQuery\PropelQuery;
use Thelia\Core\Event\Product\ProductDeleteCategoryEvent; use Thelia\Core\Event\Product\ProductDeleteCategoryEvent;
use Thelia\Core\Event\Product\ProductAddCategoryEvent; use Thelia\Core\Event\Product\ProductAddCategoryEvent;
use Thelia\Model\AttributeAvQuery; use Thelia\Model\AttributeAvQuery;
@@ -181,8 +175,8 @@ class Product extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(ProductQuery::create(), $event); return $this->genericUpdatePosition(ProductQuery::create(), $event);
} }
public function addContent(ProductAddContentEvent $event) { public function addContent(ProductAddContentEvent $event)
{
if (ProductAssociatedContentQuery::create() if (ProductAssociatedContentQuery::create()
->filterByContentId($event->getContentId()) ->filterByContentId($event->getContentId())
->filterByProduct($event->getProduct())->count() <= 0) { ->filterByProduct($event->getProduct())->count() <= 0) {
@@ -198,8 +192,8 @@ class Product extends BaseAction implements EventSubscriberInterface
} }
} }
public function removeContent(ProductDeleteContentEvent $event) { public function removeContent(ProductDeleteContentEvent $event)
{
$content = ProductAssociatedContentQuery::create() $content = ProductAssociatedContentQuery::create()
->filterByContentId($event->getContentId()) ->filterByContentId($event->getContentId())
->filterByProduct($event->getProduct())->findOne() ->filterByProduct($event->getProduct())->findOne()
@@ -212,8 +206,8 @@ class Product extends BaseAction implements EventSubscriberInterface
; ;
} }
public function addCategory(ProductAddCategoryEvent $event) { public function addCategory(ProductAddCategoryEvent $event)
{
if (ProductCategoryQuery::create() if (ProductCategoryQuery::create()
->filterByProduct($event->getProduct()) ->filterByProduct($event->getProduct())
->filterByCategoryId($event->getCategoryId()) ->filterByCategoryId($event->getCategoryId())
@@ -230,8 +224,8 @@ class Product extends BaseAction implements EventSubscriberInterface
} }
} }
public function removeCategory(ProductDeleteCategoryEvent $event) { public function removeCategory(ProductDeleteCategoryEvent $event)
{
$productCategory = ProductCategoryQuery::create() $productCategory = ProductCategoryQuery::create()
->filterByProduct($event->getProduct()) ->filterByProduct($event->getProduct())
->filterByCategoryId($event->getCategoryId()) ->filterByCategoryId($event->getCategoryId())
@@ -240,8 +234,8 @@ class Product extends BaseAction implements EventSubscriberInterface
if ($productCategory != null) $productCategory->delete(); if ($productCategory != null) $productCategory->delete();
} }
public function addAccessory(ProductAddAccessoryEvent $event) { public function addAccessory(ProductAddAccessoryEvent $event)
{
if (AccessoryQuery::create() if (AccessoryQuery::create()
->filterByAccessory($event->getAccessoryId()) ->filterByAccessory($event->getAccessoryId())
->filterByProductId($event->getProduct()->getId())->count() <= 0) { ->filterByProductId($event->getProduct()->getId())->count() <= 0) {
@@ -257,8 +251,8 @@ class Product extends BaseAction implements EventSubscriberInterface
} }
} }
public function removeAccessory(ProductDeleteAccessoryEvent $event) { public function removeAccessory(ProductDeleteAccessoryEvent $event)
{
$accessory = AccessoryQuery::create() $accessory = AccessoryQuery::create()
->filterByAccessory($event->getAccessoryId()) ->filterByAccessory($event->getAccessoryId())
->filterByProductId($event->getProduct()->getId())->findOne() ->filterByProductId($event->getProduct()->getId())->findOne()
@@ -271,8 +265,8 @@ class Product extends BaseAction implements EventSubscriberInterface
; ;
} }
public function setProductTemplate(ProductSetTemplateEvent $event) { public function setProductTemplate(ProductSetTemplateEvent $event)
{
$product = $event->getProduct(); $product = $event->getProduct();
// Delete all product feature relations // Delete all product feature relations
@@ -310,8 +304,8 @@ class Product extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(ProductAssociatedContentQuery::create(), $event); return $this->genericUpdatePosition(ProductAssociatedContentQuery::create(), $event);
} }
public function updateFeatureProductValue(FeatureProductUpdateEvent $event) { public function updateFeatureProductValue(FeatureProductUpdateEvent $event)
{
// If the feature is not free text, it may have one ore more values. // If the feature is not free text, it may have one ore more values.
// If the value exists, we do not change it // If the value exists, we do not change it
// If the value does not exists, we create it. // If the value does not exists, we create it.
@@ -343,8 +337,7 @@ class Product extends BaseAction implements EventSubscriberInterface
if ($event->getIsTextValue() == true) { if ($event->getIsTextValue() == true) {
$featureProduct->setFreeTextValue($event->getFeatureValue()); $featureProduct->setFreeTextValue($event->getFeatureValue());
} } else {
else {
$featureProduct->setFeatureAvId($event->getFeatureValue()); $featureProduct->setFeatureAvId($event->getFeatureValue());
} }
@@ -353,8 +346,8 @@ class Product extends BaseAction implements EventSubscriberInterface
$event->setFeatureProduct($featureProduct); $event->setFeatureProduct($featureProduct);
} }
public function deleteFeatureProductValue(FeatureProductDeleteEvent $event) { public function deleteFeatureProductValue(FeatureProductDeleteEvent $event)
{
$featureProduct = FeatureProductQuery::create() $featureProduct = FeatureProductQuery::create()
->filterByProductId($event->getProductId()) ->filterByProductId($event->getProductId())
->filterByFeatureId($event->getFeatureId()) ->filterByFeatureId($event->getFeatureId())
@@ -362,8 +355,8 @@ class Product extends BaseAction implements EventSubscriberInterface
; ;
} }
public function createProductCombination(ProductCreateCombinationEvent $event) { public function createProductCombination(ProductCreateCombinationEvent $event)
{
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME); $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
$con->beginTransaction(); $con->beginTransaction();
@@ -399,7 +392,7 @@ class Product extends BaseAction implements EventSubscriberInterface
if (count($combinationAttributes) > 0) { if (count($combinationAttributes) > 0) {
foreach($combinationAttributes as $attributeAvId) { foreach ($combinationAttributes as $attributeAvId) {
$attributeAv = AttributeAvQuery::create()->findPk($attributeAvId); $attributeAv = AttributeAvQuery::create()->findPk($attributeAvId);
@@ -417,8 +410,7 @@ class Product extends BaseAction implements EventSubscriberInterface
// Store all the stuff ! // Store all the stuff !
$con->commit(); $con->commit();
} } catch (\Exception $ex) {
catch(\Exception $ex) {
$con->rollback(); $con->rollback();
@@ -426,8 +418,8 @@ class Product extends BaseAction implements EventSubscriberInterface
} }
} }
public function deleteProductCombination(ProductDeleteCombinationEvent $event) { public function deleteProductCombination(ProductDeleteCombinationEvent $event)
{
if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) { if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) {
$pse->delete(); $pse->delete();
} }

View File

@@ -33,14 +33,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Template\TemplateUpdateEvent; use Thelia\Core\Event\Template\TemplateUpdateEvent;
use Thelia\Core\Event\Template\TemplateCreateEvent; use Thelia\Core\Event\Template\TemplateCreateEvent;
use Thelia\Core\Event\Template\TemplateDeleteEvent; use Thelia\Core\Event\Template\TemplateDeleteEvent;
use Thelia\Model\ConfigQuery;
use Thelia\Model\TemplateAv;
use Thelia\Model\TemplateAvQuery;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Category\CategoryEvent;
use Thelia\Core\Event\Template\TemplateEvent;
use Thelia\Model\TemplateTemplate;
use Thelia\Model\TemplateTemplateQuery;
use Thelia\Model\ProductQuery; use Thelia\Model\ProductQuery;
use Thelia\Core\Event\Template\TemplateAddAttributeEvent; use Thelia\Core\Event\Template\TemplateAddAttributeEvent;
use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent; use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent;
@@ -121,8 +114,8 @@ class Template extends BaseAction implements EventSubscriberInterface
} }
} }
public function addAttribute(TemplateAddAttributeEvent $event) { public function addAttribute(TemplateAddAttributeEvent $event)
{
if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) { if (null === AttributeTemplateQuery::create()->filterByAttributeId($event->getAttributeId())->filterByTemplate($event->getTemplate())->findOne()) {
$attribute_template = new AttributeTemplate(); $attribute_template = new AttributeTemplate();
@@ -155,8 +148,8 @@ class Template extends BaseAction implements EventSubscriberInterface
return $this->genericUpdatePosition(FeatureTemplateQuery::create(), $event); return $this->genericUpdatePosition(FeatureTemplateQuery::create(), $event);
} }
public function deleteAttribute(TemplateDeleteAttributeEvent $event) { public function deleteAttribute(TemplateDeleteAttributeEvent $event)
{
$attribute_template = AttributeTemplateQuery::create() $attribute_template = AttributeTemplateQuery::create()
->filterByAttributeId($event->getAttributeId()) ->filterByAttributeId($event->getAttributeId())
->filterByTemplate($event->getTemplate())->findOne() ->filterByTemplate($event->getTemplate())->findOne()
@@ -165,8 +158,8 @@ class Template extends BaseAction implements EventSubscriberInterface
if ($attribute_template !== null) $attribute_template->delete(); if ($attribute_template !== null) $attribute_template->delete();
} }
public function addFeature(TemplateAddFeatureEvent $event) { public function addFeature(TemplateAddFeatureEvent $event)
{
if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) { if (null === FeatureTemplateQuery::create()->filterByFeatureId($event->getFeatureId())->filterByTemplate($event->getTemplate())->findOne()) {
$feature_template = new FeatureTemplate(); $feature_template = new FeatureTemplate();
@@ -179,8 +172,8 @@ class Template extends BaseAction implements EventSubscriberInterface
} }
} }
public function deleteFeature(TemplateDeleteFeatureEvent $event) { public function deleteFeature(TemplateDeleteFeatureEvent $event)
{
$feature_template = FeatureTemplateQuery::create() $feature_template = FeatureTemplateQuery::create()
->filterByFeatureId($event->getFeatureId()) ->filterByFeatureId($event->getFeatureId())
->filterByTemplate($event->getTemplate())->findOne() ->filterByTemplate($event->getTemplate())->findOne()
@@ -210,4 +203,4 @@ class Template extends BaseAction implements EventSubscriberInterface
); );
} }
} }

View File

@@ -73,10 +73,11 @@ class CacheClear extends ContainerAwareCommand
try { try {
$directoryBrowser = new \DirectoryIterator($dir); $directoryBrowser = new \DirectoryIterator($dir);
} catch(\UnexpectedValueException $e) { } catch (\UnexpectedValueException $e) {
// throws same exception code for does not exist and permission denied ... // throws same exception code for does not exist and permission denied ...
if(!file_exists($dir)) { if (!file_exists($dir)) {
$output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir)); $output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir));
return; return;
} }

View File

@@ -25,12 +25,9 @@ namespace Thelia\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOException;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Model\ModuleQuery; use Thelia\Model\ModuleQuery;
/** /**
@@ -62,7 +59,7 @@ class ModuleActivateCommand extends BaseModuleGenerate
$module = ModuleQuery::create()->findOneByCode($moduleCode); $module = ModuleQuery::create()->findOneByCode($moduleCode);
if(null === $module) { if (null === $module) {
throw new \RuntimeException(sprintf("module %s not found", $moduleCode)); throw new \RuntimeException(sprintf("module %s not found", $moduleCode));
} }
@@ -74,7 +71,7 @@ class ModuleActivateCommand extends BaseModuleGenerate
$moduleInstance = $moduleReflection->newInstance(); $moduleInstance = $moduleReflection->newInstance();
$moduleInstance->activate(); $moduleInstance->activate();
} catch(\Exception $e) { } catch (\Exception $e) {
throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage())); throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage()));
} }

View File

@@ -56,7 +56,7 @@ class ReloadDatabaseCommand extends BaseModuleGenerate
$tables = $connection->query("SHOW TABLES"); $tables = $connection->query("SHOW TABLES");
$connection->query("SET FOREIGN_KEY_CHECKS = 0"); $connection->query("SET FOREIGN_KEY_CHECKS = 0");
foreach($tables as $table) { foreach ($tables as $table) {
$connection->query(sprintf("DROP TABLE `%s`", $table[0])); $connection->query(sprintf("DROP TABLE `%s`", $table[0]));
} }
$connection->query("SET FOREIGN_KEY_CHECKS = 1"); $connection->query("SET FOREIGN_KEY_CHECKS = 1");

View File

@@ -25,7 +25,6 @@ namespace Thelia\Controller\Admin;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ToggleVisibilityEvent;
/** /**
* An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object. * An abstract CRUD controller for Thelia ADMIN, to manage basic CRUD operations on a givent object.
@@ -53,14 +52,13 @@ abstract class AbstractCrudController extends BaseAdminController
protected $visibilityToggleEventIdentifier; protected $visibilityToggleEventIdentifier;
protected $changePositionEventIdentifier; protected $changePositionEventIdentifier;
/** /**
* @param string $objectName the lower case object name. Example. "message" * @param string $objectName the lower case object name. Example. "message"
* *
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual * @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
* @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable) * @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable)
* *
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view" * @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create" * @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update" * @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete" * @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
@@ -70,7 +68,7 @@ abstract class AbstractCrudController extends BaseAdminController
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE * @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
* *
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
*/ */
public function __construct( public function __construct(
$objectName, $objectName,
@@ -109,94 +107,93 @@ abstract class AbstractCrudController extends BaseAdminController
/** /**
* Return the creation form for this object * Return the creation form for this object
*/ */
protected abstract function getCreationForm(); abstract protected function getCreationForm();
/** /**
* Return the update form for this object * Return the update form for this object
*/ */
protected abstract function getUpdateForm(); abstract protected function getUpdateForm();
/** /**
* Hydrate the update form for this object, before passing it to the update template * Hydrate the update form for this object, before passing it to the update template
* *
* @param unknown $object * @param unknown $object
*/ */
protected abstract function hydrateObjectForm($object); abstract protected function hydrateObjectForm($object);
/** /**
* Creates the creation event with the provided form data * Creates the creation event with the provided form data
* *
* @param unknown $formData * @param unknown $formData
*/ */
protected abstract function getCreationEvent($formData); abstract protected function getCreationEvent($formData);
/** /**
* Creates the update event with the provided form data * Creates the update event with the provided form data
* *
* @param unknown $formData * @param unknown $formData
*/ */
protected abstract function getUpdateEvent($formData); abstract protected function getUpdateEvent($formData);
/** /**
* Creates the delete event with the provided form data * Creates the delete event with the provided form data
*/ */
protected abstract function getDeleteEvent(); abstract protected function getDeleteEvent();
/** /**
* Return true if the event contains the object, e.g. the action has updated the object in the event. * Return true if the event contains the object, e.g. the action has updated the object in the event.
* *
* @param unknown $event * @param unknown $event
*/ */
protected abstract function eventContainsObject($event); abstract protected function eventContainsObject($event);
/** /**
* Get the created object from an event. * Get the created object from an event.
* *
* @param unknown $createEvent * @param unknown $createEvent
*/ */
protected abstract function getObjectFromEvent($event); abstract protected function getObjectFromEvent($event);
/** /**
* Load an existing object from the database * Load an existing object from the database
*/ */
protected abstract function getExistingObject(); abstract protected function getExistingObject();
/** /**
* Returns the object label form the object event (name, title, etc.) * Returns the object label form the object event (name, title, etc.)
* *
* @param unknown $object * @param unknown $object
*/ */
protected abstract function getObjectLabel($object); abstract protected function getObjectLabel($object);
/** /**
* Returns the object ID from the object * Returns the object ID from the object
* *
* @param unknown $object * @param unknown $object
*/ */
protected abstract function getObjectId($object); abstract protected function getObjectId($object);
/** /**
* Render the main list template * Render the main list template
* *
* @param unknown $currentOrder, if any, null otherwise. * @param unknown $currentOrder, if any, null otherwise.
*/ */
protected abstract function renderListTemplate($currentOrder); abstract protected function renderListTemplate($currentOrder);
/** /**
* Render the edition template * Render the edition template
*/ */
protected abstract function renderEditionTemplate(); abstract protected function renderEditionTemplate();
/** /**
* Redirect to the edition template * Redirect to the edition template
*/ */
protected abstract function redirectToEditionTemplate(); abstract protected function redirectToEditionTemplate();
/** /**
* Redirect to the list template * Redirect to the list template
*/ */
protected abstract function redirectToListTemplate(); abstract protected function redirectToListTemplate();
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{ {
@@ -211,7 +208,7 @@ abstract class AbstractCrudController extends BaseAdminController
/** /**
* Put in this method post object creation processing if required. * Put in this method post object creation processing if required.
* *
* @param unknown $createEvent the create event * @param unknown $createEvent the create event
* @return Response a response, or null to continue normal processing * @return Response a response, or null to continue normal processing
*/ */
protected function performAdditionalCreateAction($createEvent) protected function performAdditionalCreateAction($createEvent)
@@ -222,7 +219,7 @@ abstract class AbstractCrudController extends BaseAdminController
/** /**
* Put in this method post object update processing if required. * Put in this method post object update processing if required.
* *
* @param unknown $updateEvent the update event * @param unknown $updateEvent the update event
* @return Response a response, or null to continue normal processing * @return Response a response, or null to continue normal processing
*/ */
protected function performAdditionalUpdateAction($updateEvent) protected function performAdditionalUpdateAction($updateEvent)
@@ -233,7 +230,7 @@ abstract class AbstractCrudController extends BaseAdminController
/** /**
* Put in this method post object delete processing if required. * Put in this method post object delete processing if required.
* *
* @param unknown $deleteEvent the delete event * @param unknown $deleteEvent the delete event
* @return Response a response, or null to continue normal processing * @return Response a response, or null to continue normal processing
*/ */
protected function performAdditionalDeleteAction($deleteEvent) protected function performAdditionalDeleteAction($deleteEvent)
@@ -244,7 +241,7 @@ abstract class AbstractCrudController extends BaseAdminController
/** /**
* Put in this method post object position change processing if required. * Put in this method post object position change processing if required.
* *
* @param unknown $deleteEvent the delete event * @param unknown $deleteEvent the delete event
* @return Response a response, or null to continue normal processing * @return Response a response, or null to continue normal processing
*/ */
protected function performAdditionalUpdatePositionAction($positionChangeEvent) protected function performAdditionalUpdatePositionAction($positionChangeEvent)
@@ -282,7 +279,6 @@ abstract class AbstractCrudController extends BaseAdminController
public function defaultAction() public function defaultAction()
{ {
if (null !== $response = $this->checkAuth($this->viewPermissionIdentifier)) return $response; if (null !== $response = $this->checkAuth($this->viewPermissionIdentifier)) return $response;
return $this->renderList(); return $this->renderList();
} }
@@ -323,22 +319,19 @@ abstract class AbstractCrudController extends BaseAdminController
$response = $this->performAdditionalCreateAction($createEvent); $response = $this->performAdditionalCreateAction($createEvent);
if ($response == null) { if ($response == null) {
// Substitute _ID_ in the URL with the ID of the created object // Substitute _ID_ in the URL with the ID of the created object
$successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl()); $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());
// Redirect to the success URL // Redirect to the success URL
$this->redirect($successUrl); $this->redirect($successUrl);
} } else {
else {
return $response; return $response;
} }
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex->getMessage(); $error_msg = $ex->getMessage();
} }
@@ -423,16 +416,13 @@ abstract class AbstractCrudController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl()); $this->redirect($changeForm->getSuccessUrl());
} } else {
else {
return $response; return $response;
} }
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex->getMessage(); $error_msg = $ex->getMessage();
} }
@@ -469,8 +459,7 @@ abstract class AbstractCrudController extends BaseAdminController
$event = $this->createUpdatePositionEvent($mode, $position); $event = $this->createUpdatePositionEvent($mode, $position);
$this->dispatch($this->changePositionEventIdentifier, $event); $this->dispatch($this->changePositionEventIdentifier, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -479,14 +468,13 @@ abstract class AbstractCrudController extends BaseAdminController
if ($response == null) { if ($response == null) {
$this->redirectToListTemplate(); $this->redirectToListTemplate();
} } else {
else {
return $response; return $response;
} }
} }
protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true) { protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true)
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
@@ -507,8 +495,7 @@ abstract class AbstractCrudController extends BaseAdminController
$event = new UpdatePositionEvent($object->getId(), $mode, $position); $event = new UpdatePositionEvent($object->getId(), $mode, $position);
$this->dispatch($eventName, $event); $this->dispatch($eventName, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }

View File

@@ -23,10 +23,6 @@
namespace Thelia\Controller\Admin; namespace Thelia\Controller\Admin;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Security\Exception\TokenAuthenticationException;
class AdminController extends BaseAdminController class AdminController extends BaseAdminController
{ {
public function indexAction() public function indexAction()
@@ -36,6 +32,6 @@ class AdminController extends BaseAdminController
public function updateAction() public function updateAction()
{ {
return $this->render("profile-edit"); return $this->render("profile-edit");
} }
} }

View File

@@ -193,4 +193,4 @@ class AttributeAvController extends AbstractCrudController
$this->getViewArguments() $this->getViewArguments()
); );
} }
} }

View File

@@ -113,7 +113,7 @@ class AttributeController extends AbstractCrudController
if ($attr_values !== null) { if ($attr_values !== null) {
foreach($attr_values as $id => $value) { foreach ($attr_values as $id => $value) {
$event = new AttributeAvUpdateEvent($id); $event = new AttributeAvUpdateEvent($id);
@@ -168,7 +168,7 @@ class AttributeController extends AbstractCrudController
$attr_array = array(); $attr_array = array();
foreach($attr_av_list as $attr_av) { foreach ($attr_av_list as $attr_av) {
$attr_array[$attr_av->getId()] = $attr_av->getTitle(); $attr_array[$attr_av->getId()] = $attr_av->getTitle();
} }
@@ -262,8 +262,7 @@ class AttributeController extends AbstractCrudController
$this->dispatch($eventType, $event); $this->dispatch($eventType, $event);
} }
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -286,4 +285,4 @@ class AttributeController extends AbstractCrudController
{ {
return $this->addRemoveFromAllTemplates(TheliaEvents::ATTRIBUTE_ADD_TO_ALL_TEMPLATES); return $this->addRemoveFromAllTemplates(TheliaEvents::ATTRIBUTE_ADD_TO_ALL_TEMPLATES);
} }
} }

View File

@@ -293,20 +293,19 @@ class BaseAdminController extends BaseController
return $this->getCurrentEditionLang()->getLocale(); return $this->getCurrentEditionLang()->getLocale();
} }
/** /**
* Return the current list order identifier for a given object name, * Return the current list order identifier for a given object name,
* updating in using the current request. * updating in using the current request.
* *
* @param unknown $objectName the object name (e.g. 'attribute', 'message') * @param unknown $objectName the object name (e.g. 'attribute', 'message')
* @param unknown $requestParameterName the name of the request parameter that defines the list order * @param unknown $requestParameterName the name of the request parameter that defines the list order
* @param unknown $defaultListOrder the default order to use, if none is defined * @param unknown $defaultListOrder the default order to use, if none is defined
* @param string $updateSession if true, the session will be updated with the current order. * @param string $updateSession if true, the session will be updated with the current order.
* *
* @return String the current liste order. * @return String the current liste order.
*/ */
protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true) { protected function getListOrderFromSession($objectName, $requestParameterName, $defaultListOrder, $updateSession = true)
{
$order = $defaultListOrder; $order = $defaultListOrder;
$orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName); $orderSessionIdentifier = sprintf("admin.%s.currentListOrder", $objectName);
@@ -318,7 +317,6 @@ class BaseAdminController extends BaseController
); );
if ($updateSession) $this->getSession()->set($orderSessionIdentifier, $order); if ($updateSession) $this->getSession()->set($orderSessionIdentifier, $order);
return $order; return $order;
} }
@@ -353,8 +351,8 @@ class BaseAdminController extends BaseController
/** Clear the remember me cookie. /** Clear the remember me cookie.
* *
*/ */
protected function clearRememberMeCookie() { protected function clearRememberMeCookie()
{
$ctp = new CookieTokenProvider(); $ctp = new CookieTokenProvider();
$cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn'); $cookieName = ConfigQuery::read('admin_remember_me_cookie_name', 'armcn');

View File

@@ -24,7 +24,6 @@
namespace Thelia\Controller\Admin; namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Thelia\Log\Tlog;
use Thelia\Core\Event\Category\CategoryDeleteEvent; use Thelia\Core\Event\Category\CategoryDeleteEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Category\CategoryUpdateEvent; use Thelia\Core\Event\Category\CategoryUpdateEvent;
@@ -36,7 +35,6 @@ use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent; use Thelia\Core\Event\Category\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\Category\CategoryDeleteContentEvent; use Thelia\Core\Event\Category\CategoryDeleteContentEvent;
use Thelia\Core\Event\Category\CategoryAddContentEvent; use Thelia\Core\Event\Category\CategoryAddContentEvent;
use Thelia\Model\CategoryAssociatedContent;
use Thelia\Model\FolderQuery; use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery; use Thelia\Model\ContentQuery;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
@@ -49,7 +47,8 @@ use Thelia\Model\CategoryAssociatedContentQuery;
*/ */
class CategoryController extends AbstractCrudController class CategoryController extends AbstractCrudController
{ {
public function __construct() { public function __construct()
{
parent::__construct( parent::__construct(
'category', 'category',
'manual', 'manual',
@@ -68,15 +67,18 @@ class CategoryController extends AbstractCrudController
); );
} }
protected function getCreationForm() { protected function getCreationForm()
{
return new CategoryCreationForm($this->getRequest()); return new CategoryCreationForm($this->getRequest());
} }
protected function getUpdateForm() { protected function getUpdateForm()
{
return new CategoryModificationForm($this->getRequest()); return new CategoryModificationForm($this->getRequest());
} }
protected function getCreationEvent($formData) { protected function getCreationEvent($formData)
{
$createEvent = new CategoryCreateEvent(); $createEvent = new CategoryCreateEvent();
$createEvent $createEvent
@@ -89,7 +91,8 @@ class CategoryController extends AbstractCrudController
return $createEvent; return $createEvent;
} }
protected function getUpdateEvent($formData) { protected function getUpdateEvent($formData)
{
$changeEvent = new CategoryUpdateEvent($formData['id']); $changeEvent = new CategoryUpdateEvent($formData['id']);
// Create and dispatch the change event // Create and dispatch the change event
@@ -107,8 +110,8 @@ class CategoryController extends AbstractCrudController
return $changeEvent; return $changeEvent;
} }
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent( return new UpdatePositionEvent(
$this->getRequest()->get('category_id', null), $this->getRequest()->get('category_id', null),
$positionChangeMode, $positionChangeMode,
@@ -116,16 +119,18 @@ class CategoryController extends AbstractCrudController
); );
} }
protected function getDeleteEvent() { protected function getDeleteEvent()
{
return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0)); return new CategoryDeleteEvent($this->getRequest()->get('category_id', 0));
} }
protected function eventContainsObject($event) { protected function eventContainsObject($event)
{
return $event->hasCategory(); return $event->hasCategory();
} }
protected function hydrateObjectForm($object) { protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form // Prepare the data that will hydrate the form
$data = array( $data = array(
'id' => $object->getId(), 'id' => $object->getId(),
@@ -143,21 +148,25 @@ class CategoryController extends AbstractCrudController
return new CategoryModificationForm($this->getRequest(), "form", $data); return new CategoryModificationForm($this->getRequest(), "form", $data);
} }
protected function getObjectFromEvent($event) { protected function getObjectFromEvent($event)
{
return $event->hasCategory() ? $event->getCategory() : null; return $event->hasCategory() ? $event->getCategory() : null;
} }
protected function getExistingObject() { protected function getExistingObject()
{
return CategoryQuery::create() return CategoryQuery::create()
->joinWithI18n($this->getCurrentEditionLocale()) ->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('category_id', 0)); ->findOneById($this->getRequest()->get('category_id', 0));
} }
protected function getObjectLabel($object) { protected function getObjectLabel($object)
{
return $object->getTitle(); return $object->getTitle();
} }
protected function getObjectId($object) { protected function getObjectId($object)
{
return $object->getId(); return $object->getId();
} }
@@ -170,8 +179,8 @@ class CategoryController extends AbstractCrudController
); );
} }
protected function renderListTemplate($currentOrder) { protected function renderListTemplate($currentOrder)
{
// Get product order // Get product order
$product_order = $this->getListOrderFromSession('product', 'product_order', 'manual'); $product_order = $this->getListOrderFromSession('product', 'product_order', 'manual');
@@ -183,19 +192,21 @@ class CategoryController extends AbstractCrudController
)); ));
} }
protected function redirectToListTemplate() { protected function redirectToListTemplate()
{
$this->redirectToRoute( $this->redirectToRoute(
'admin.categories.default', 'admin.categories.default',
array('category_id' => $this->getRequest()->get('category_id', 0)) array('category_id' => $this->getRequest()->get('category_id', 0))
); );
} }
protected function renderEditionTemplate() { protected function renderEditionTemplate()
{
return $this->render('category-edit', $this->getEditionArguments()); return $this->render('category-edit', $this->getEditionArguments());
} }
protected function redirectToEditionTemplate() { protected function redirectToEditionTemplate()
{
$this->redirectToRoute("admin.categories.update", $this->getEditionArguments()); $this->redirectToRoute("admin.categories.update", $this->getEditionArguments());
} }
@@ -257,8 +268,8 @@ class CategoryController extends AbstractCrudController
return null; return null;
} }
public function getAvailableRelatedContentAction($categoryId, $folderId) { public function getAvailableRelatedContentAction($categoryId, $folderId)
{
$result = array(); $result = array();
$folders = FolderQuery::create()->filterById($folderId)->find(); $folders = FolderQuery::create()->filterById($folderId)->find();
@@ -273,7 +284,7 @@ class CategoryController extends AbstractCrudController
; ;
if ($list !== null) { if ($list !== null) {
foreach($list as $item) { foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); $result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
} }
} }
@@ -282,8 +293,8 @@ class CategoryController extends AbstractCrudController
return $this->jsonResponse(json_encode($result)); return $this->jsonResponse(json_encode($result));
} }
public function addRelatedContentAction() { public function addRelatedContentAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -298,8 +309,7 @@ class CategoryController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -341,8 +351,8 @@ class CategoryController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
public function deleteRelatedContentAction() { public function deleteRelatedContentAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -357,8 +367,7 @@ class CategoryController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event); $this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Event\Config\ConfigCreateEvent;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Form\ConfigModificationForm; use Thelia\Form\ConfigModificationForm;
use Thelia\Form\ConfigCreationForm; use Thelia\Form\ConfigCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
/** /**
* Manages variables * Manages variables
@@ -39,7 +38,8 @@ use Thelia\Core\Event\UpdatePositionEvent;
*/ */
class ConfigController extends AbstractCrudController class ConfigController extends AbstractCrudController
{ {
public function __construct() { public function __construct()
{
parent::__construct( parent::__construct(
'variable', 'variable',
'name', 'name',
@@ -58,15 +58,18 @@ class ConfigController extends AbstractCrudController
); );
} }
protected function getCreationForm() { protected function getCreationForm()
{
return new ConfigCreationForm($this->getRequest()); return new ConfigCreationForm($this->getRequest());
} }
protected function getUpdateForm() { protected function getUpdateForm()
{
return new ConfigModificationForm($this->getRequest()); return new ConfigModificationForm($this->getRequest());
} }
protected function getCreationEvent($data) { protected function getCreationEvent($data)
{
$createEvent = new ConfigCreateEvent(); $createEvent = new ConfigCreateEvent();
$createEvent $createEvent
@@ -78,11 +81,11 @@ class ConfigController extends AbstractCrudController
->setSecured($data['secured']) ->setSecured($data['secured'])
; ;
return $createEvent; return $createEvent;
} }
protected function getUpdateEvent($data) { protected function getUpdateEvent($data)
{
$changeEvent = new ConfigUpdateEvent($data['id']); $changeEvent = new ConfigUpdateEvent($data['id']);
// Create and dispatch the change event // Create and dispatch the change event
@@ -101,16 +104,18 @@ class ConfigController extends AbstractCrudController
return $changeEvent; return $changeEvent;
} }
protected function getDeleteEvent() { protected function getDeleteEvent()
{
return new ConfigDeleteEvent($this->getRequest()->get('variable_id')); return new ConfigDeleteEvent($this->getRequest()->get('variable_id'));
} }
protected function eventContainsObject($event) { protected function eventContainsObject($event)
{
return $event->hasConfig(); return $event->hasConfig();
} }
protected function hydrateObjectForm($object) { protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form // Prepare the data that will hydrate the form
$data = array( $data = array(
'id' => $object->getId(), 'id' => $object->getId(),
@@ -129,40 +134,48 @@ class ConfigController extends AbstractCrudController
return new ConfigModificationForm($this->getRequest(), "form", $data); return new ConfigModificationForm($this->getRequest(), "form", $data);
} }
protected function getObjectFromEvent($event) { protected function getObjectFromEvent($event)
{
return $event->hasConfig() ? $event->getConfig() : null; return $event->hasConfig() ? $event->getConfig() : null;
} }
protected function getExistingObject() { protected function getExistingObject()
{
return ConfigQuery::create() return ConfigQuery::create()
->joinWithI18n($this->getCurrentEditionLocale()) ->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('variable_id')); ->findOneById($this->getRequest()->get('variable_id'));
} }
protected function getObjectLabel($object) { protected function getObjectLabel($object)
{
return $object->getName(); return $object->getName();
} }
protected function getObjectId($object) { protected function getObjectId($object)
{
return $object->getId(); return $object->getId();
} }
protected function renderListTemplate($currentOrder) { protected function renderListTemplate($currentOrder)
{
return $this->render('variables', array('order' => $currentOrder)); return $this->render('variables', array('order' => $currentOrder));
} }
protected function renderEditionTemplate() { protected function renderEditionTemplate()
{
return $this->render('variable-edit', array('variable_id' => $this->getRequest()->get('variable_id'))); return $this->render('variable-edit', array('variable_id' => $this->getRequest()->get('variable_id')));
} }
protected function redirectToEditionTemplate() { protected function redirectToEditionTemplate()
{
$this->redirectToRoute( $this->redirectToRoute(
"admin.configuration.variables.update", "admin.configuration.variables.update",
array('variable_id' => $this->getRequest()->get('variable_id')) array('variable_id' => $this->getRequest()->get('variable_id'))
); );
} }
protected function redirectToListTemplate() { protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.variables.default'); $this->redirectToRoute('admin.configuration.variables.default');
} }
@@ -188,4 +201,4 @@ class ConfigController extends AbstractCrudController
$this->redirectToRoute('admin.configuration.variables.default'); $this->redirectToRoute('admin.configuration.variables.default');
} }
} }

View File

@@ -32,7 +32,6 @@ use Thelia\Form\ContentCreationForm;
use Thelia\Form\ContentModificationForm; use Thelia\Form\ContentModificationForm;
use Thelia\Model\ContentQuery; use Thelia\Model\ContentQuery;
/** /**
* Class ContentController * Class ContentController
* @package Thelia\Controller\Admin * @package Thelia\Controller\Admin
@@ -212,10 +211,10 @@ class ContentController extends AbstractCrudController
{ {
$folderId = $this->getRequest()->get('folder_id', null); $folderId = $this->getRequest()->get('folder_id', null);
if(null === $folderId) { if (null === $folderId) {
$content = $this->getExistingObject(); $content = $this->getExistingObject();
if($content) { if ($content) {
$folderId = $content->getDefaultFolderId(); $folderId = $content->getDefaultFolderId();
} }
} }
@@ -275,7 +274,7 @@ class ContentController extends AbstractCrudController
} }
/** /**
* @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent * @param \Thelia\Core\Event\Content\ContentUpdateEvent $updateEvent
* @return Response|void * @return Response|void
*/ */
protected function performAdditionalUpdateAction($updateEvent) protected function performAdditionalUpdateAction($updateEvent)
@@ -293,8 +292,8 @@ class ContentController extends AbstractCrudController
/** /**
* Put in this method post object delete processing if required. * Put in this method post object delete processing if required.
* *
* @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event * @param \Thelia\Core\Event\Content\ContentDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing * @return Response a response, or null to continue normal processing
*/ */
protected function performAdditionalDeleteAction($deleteEvent) protected function performAdditionalDeleteAction($deleteEvent)
{ {
@@ -344,4 +343,4 @@ class ContentController extends AbstractCrudController
{ {
return new ContentToggleVisibilityEvent($this->getExistingObject()); return new ContentToggleVisibilityEvent($this->getExistingObject());
} }
} }

View File

@@ -43,10 +43,10 @@ class CountryController extends BaseAdminController
* @return mixed|\Symfony\Component\HttpFoundation\Response * @return mixed|\Symfony\Component\HttpFoundation\Response
*/ */
public function updateAction($country_id) public function updateAction($country_id)
{ {
return $this->render("country-edit", array( return $this->render("country-edit", array(
"country_id" => $country_id "country_id" => $country_id
)); ));
} }
} }

View File

@@ -31,7 +31,6 @@ use Thelia\Core\Event\Condition\ConditionCreateOrUpdateEvent;
use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponConsumeEvent;
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Coupon\CouponManager; use Thelia\Coupon\CouponManager;
use Thelia\Coupon\ConditionCollection; use Thelia\Coupon\ConditionCollection;
use Thelia\Coupon\Type\CouponInterface; use Thelia\Coupon\Type\CouponInterface;
@@ -299,7 +298,6 @@ var_dump($coupon->getIsRemovingPostage());;
); );
} }
/** /**
* Manage Coupons read display * Manage Coupons read display
* *
@@ -613,6 +611,4 @@ var_dump($coupon->getIsRemovingPostage());;
// } // }
// } // }
} }

View File

@@ -39,7 +39,8 @@ use Thelia\Core\Event\UpdatePositionEvent;
*/ */
class CurrencyController extends AbstractCrudController class CurrencyController extends AbstractCrudController
{ {
public function __construct() { public function __construct()
{
parent::__construct( parent::__construct(
'currency', 'currency',
'manual', 'manual',
@@ -58,15 +59,18 @@ class CurrencyController extends AbstractCrudController
); );
} }
protected function getCreationForm() { protected function getCreationForm()
{
return new CurrencyCreationForm($this->getRequest()); return new CurrencyCreationForm($this->getRequest());
} }
protected function getUpdateForm() { protected function getUpdateForm()
{
return new CurrencyModificationForm($this->getRequest()); return new CurrencyModificationForm($this->getRequest());
} }
protected function getCreationEvent($formData) { protected function getCreationEvent($formData)
{
$createEvent = new CurrencyCreateEvent(); $createEvent = new CurrencyCreateEvent();
$createEvent $createEvent
@@ -80,7 +84,8 @@ class CurrencyController extends AbstractCrudController
return $createEvent; return $createEvent;
} }
protected function getUpdateEvent($formData) { protected function getUpdateEvent($formData)
{
$changeEvent = new CurrencyUpdateEvent($formData['id']); $changeEvent = new CurrencyUpdateEvent($formData['id']);
// Create and dispatch the change event // Create and dispatch the change event
@@ -95,8 +100,8 @@ class CurrencyController extends AbstractCrudController
return $changeEvent; return $changeEvent;
} }
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent( return new UpdatePositionEvent(
$this->getRequest()->get('currency_id', null), $this->getRequest()->get('currency_id', null),
$positionChangeMode, $positionChangeMode,
@@ -104,16 +109,18 @@ class CurrencyController extends AbstractCrudController
); );
} }
protected function getDeleteEvent() { protected function getDeleteEvent()
{
return new CurrencyDeleteEvent($this->getRequest()->get('currency_id')); return new CurrencyDeleteEvent($this->getRequest()->get('currency_id'));
} }
protected function eventContainsObject($event) { protected function eventContainsObject($event)
{
return $event->hasCurrency(); return $event->hasCurrency();
} }
protected function hydrateObjectForm($object) { protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form // Prepare the data that will hydrate the form
$data = array( $data = array(
'id' => $object->getId(), 'id' => $object->getId(),
@@ -128,44 +135,51 @@ class CurrencyController extends AbstractCrudController
return new CurrencyModificationForm($this->getRequest(), "form", $data); return new CurrencyModificationForm($this->getRequest(), "form", $data);
} }
protected function getObjectFromEvent($event) { protected function getObjectFromEvent($event)
{
return $event->hasCurrency() ? $event->getCurrency() : null; return $event->hasCurrency() ? $event->getCurrency() : null;
} }
protected function getExistingObject() { protected function getExistingObject()
{
return CurrencyQuery::create() return CurrencyQuery::create()
->joinWithI18n($this->getCurrentEditionLocale()) ->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('currency_id')); ->findOneById($this->getRequest()->get('currency_id'));
} }
protected function getObjectLabel($object) { protected function getObjectLabel($object)
{
return $object->getName(); return $object->getName();
} }
protected function getObjectId($object) { protected function getObjectId($object)
{
return $object->getId(); return $object->getId();
} }
protected function renderListTemplate($currentOrder) { protected function renderListTemplate($currentOrder)
{
return $this->render('currencies', array('order' => $currentOrder)); return $this->render('currencies', array('order' => $currentOrder));
} }
protected function renderEditionTemplate() { protected function renderEditionTemplate()
{
return $this->render('currency-edit', array('currency_id' => $this->getRequest()->get('currency_id'))); return $this->render('currency-edit', array('currency_id' => $this->getRequest()->get('currency_id')));
} }
protected function redirectToEditionTemplate() { protected function redirectToEditionTemplate()
{
$this->redirectToRoute( $this->redirectToRoute(
"admin.configuration.currencies.update", "admin.configuration.currencies.update",
array('currency_id' => $this->getRequest()->get('currency_id')) array('currency_id' => $this->getRequest()->get('currency_id'))
); );
} }
protected function redirectToListTemplate() { protected function redirectToListTemplate()
{
$this->redirectToRoute('admin.configuration.currencies.default'); $this->redirectToRoute('admin.configuration.currencies.default');
} }
/** /**
* Update currencies rates * Update currencies rates
*/ */

View File

@@ -48,10 +48,9 @@ class CustomerController extends BaseAdminController
public function viewAction($customer_id) public function viewAction($customer_id)
{ {
if (null !== $response = $this->checkAuth("admin.customer.view")) return $response; if (null !== $response = $this->checkAuth("admin.customer.view")) return $response;
return $this->render("customer-edit", array(
return $this->render("customer-edit", array( "customer_id" => $customer_id
"customer_id" => $customer_id ));
));
} }
/** /**
@@ -71,7 +70,7 @@ class CustomerController extends BaseAdminController
try { try {
$customer = CustomerQuery::create()->findPk($customer_id); $customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) { if (null === $customer) {
throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id)); throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id));
} }
@@ -86,7 +85,7 @@ class CustomerController extends BaseAdminController
$this->adminLogAppend(sprintf("Customer with Ref %s (ID %d) modified", $customerUpdated->getRef() , $customerUpdated->getId())); $this->adminLogAppend(sprintf("Customer with Ref %s (ID %d) modified", $customerUpdated->getRef() , $customerUpdated->getId()));
if($this->getRequest()->get("save_mode") == "close") { if ($this->getRequest()->get("save_mode") == "close") {
$this->redirectToRoute("admin.customers"); $this->redirectToRoute("admin.customers");
} else { } else {
$this->redirectSuccess($customerModification); $this->redirectSuccess($customerModification);
@@ -126,14 +125,14 @@ class CustomerController extends BaseAdminController
$customer_id = $this->getRequest()->get("customer_id"); $customer_id = $this->getRequest()->get("customer_id");
$customer = CustomerQuery::create()->findPk($customer_id); $customer = CustomerQuery::create()->findPk($customer_id);
if(null === $customer) { if (null === $customer) {
throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exist")); throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exist"));
} }
$event = new CustomerEvent($customer); $event = new CustomerEvent($customer);
$this->dispatch(TheliaEvents::CUSTOMER_DELETEACCOUNT, $event); $this->dispatch(TheliaEvents::CUSTOMER_DELETEACCOUNT, $event);
} catch(\Exception $e) { } catch (\Exception $e) {
$message = $e->getMessage(); $message = $e->getMessage();
} }
@@ -178,4 +177,4 @@ class CustomerController extends BaseAdminController
return $customerCreateEvent; return $customerCreateEvent;
} }
} }

View File

@@ -193,4 +193,4 @@ class FeatureAvController extends AbstractCrudController
$this->getViewArguments() $this->getViewArguments()
); );
} }
} }

View File

@@ -113,7 +113,7 @@ class FeatureController extends AbstractCrudController
if ($attr_values !== null) { if ($attr_values !== null) {
foreach($attr_values as $id => $value) { foreach ($attr_values as $id => $value) {
$event = new FeatureAvUpdateEvent($id); $event = new FeatureAvUpdateEvent($id);
@@ -168,7 +168,7 @@ class FeatureController extends AbstractCrudController
$attr_array = array(); $attr_array = array();
foreach($attr_av_list as $attr_av) { foreach ($attr_av_list as $attr_av) {
$attr_array[$attr_av->getId()] = $attr_av->getTitle(); $attr_array[$attr_av->getId()] = $attr_av->getTitle();
} }
@@ -262,8 +262,7 @@ class FeatureController extends AbstractCrudController
$this->dispatch($eventType, $event); $this->dispatch($eventType, $event);
} }
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -286,4 +285,4 @@ class FeatureController extends AbstractCrudController
{ {
return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES); return $this->addRemoveFromAllTemplates(TheliaEvents::FEATURE_ADD_TO_ALL_TEMPLATES);
} }
} }

View File

@@ -25,15 +25,12 @@ namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Exception\PropelException;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Document\DocumentDeleteEvent; use Thelia\Core\Event\Document\DocumentDeleteEvent;
use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent;
use Thelia\Core\Event\Image\ImageDeleteEvent; use Thelia\Core\Event\Image\ImageDeleteEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
use Thelia\Model\CategoryDocument; use Thelia\Model\CategoryDocument;
@@ -62,7 +59,6 @@ use Thelia\Tools\Rest\ResponseRest;
class FileController extends BaseAdminController class FileController extends BaseAdminController
{ {
/** /**
* Manage how a image collection has to be saved * Manage how a image collection has to be saved
* *
@@ -126,14 +122,12 @@ class FileController extends BaseAdminController
$imageCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded); $imageCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
$imageCreateOrUpdateEvent->setParentName($parentModel->getTitle()); $imageCreateOrUpdateEvent->setParentName($parentModel->getTitle());
// Dispatch Event to the Action // Dispatch Event to the Action
$this->dispatch( $this->dispatch(
TheliaEvents::IMAGE_SAVE, TheliaEvents::IMAGE_SAVE,
$imageCreateOrUpdateEvent $imageCreateOrUpdateEvent
); );
return new ResponseRest(array('status' => true, 'message' => '')); return new ResponseRest(array('status' => true, 'message' => ''));
} }
} }
@@ -192,14 +186,12 @@ class FileController extends BaseAdminController
$documentCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded); $documentCreateOrUpdateEvent->setUploadedFile($fileBeingUploaded);
$documentCreateOrUpdateEvent->setParentName($parentModel->getTitle()); $documentCreateOrUpdateEvent->setParentName($parentModel->getTitle());
// Dispatch Event to the Action // Dispatch Event to the Action
$this->dispatch( $this->dispatch(
TheliaEvents::DOCUMENT_SAVE, TheliaEvents::DOCUMENT_SAVE,
$documentCreateOrUpdateEvent $documentCreateOrUpdateEvent
); );
return new ResponseRest(array('status' => true, 'message' => '')); return new ResponseRest(array('status' => true, 'message' => ''));
} }
} }
@@ -676,5 +668,4 @@ class FileController extends BaseAdminController
return $documentCreateEvent; return $documentCreateEvent;
} }
} }

View File

@@ -81,8 +81,8 @@ class FolderController extends AbstractCrudController
* *
* @param \Thelia\Model\Folder $object * @param \Thelia\Model\Folder $object
*/ */
protected function hydrateObjectForm($object) { protected function hydrateObjectForm($object)
{
// Prepare the data that will hydrate the form // Prepare the data that will hydrate the form
$data = array( $data = array(
'id' => $object->getId(), 'id' => $object->getId(),
@@ -162,8 +162,8 @@ class FolderController extends AbstractCrudController
* @param $positionValue * @param $positionValue
* @return UpdatePositionEvent|void * @return UpdatePositionEvent|void
*/ */
protected function createUpdatePositionEvent($positionChangeMode, $positionValue) { protected function createUpdatePositionEvent($positionChangeMode, $positionValue)
{
return new UpdatePositionEvent( return new UpdatePositionEvent(
$this->getRequest()->get('folder_id', null), $this->getRequest()->get('folder_id', null),
$positionChangeMode, $positionChangeMode,
@@ -196,7 +196,8 @@ class FolderController extends AbstractCrudController
/** /**
* Load an existing object from the database * Load an existing object from the database
*/ */
protected function getExistingObject() { protected function getExistingObject()
{
return FolderQuery::create() return FolderQuery::create()
->joinWithI18n($this->getCurrentEditionLocale()) ->joinWithI18n($this->getCurrentEditionLocale())
->findOneById($this->getRequest()->get('folder_id', 0)); ->findOneById($this->getRequest()->get('folder_id', 0));
@@ -207,7 +208,8 @@ class FolderController extends AbstractCrudController
* *
* @param unknown $object * @param unknown $object
*/ */
protected function getObjectLabel($object) { protected function getObjectLabel($object)
{
return $object->getTitle(); return $object->getTitle();
} }
@@ -226,8 +228,8 @@ class FolderController extends AbstractCrudController
* *
* @param unknown $currentOrder, if any, null otherwise. * @param unknown $currentOrder, if any, null otherwise.
*/ */
protected function renderListTemplate($currentOrder) { protected function renderListTemplate($currentOrder)
{
// Get content order // Get content order
$content_order = $this->getListOrderFromSession('content', 'content_order', 'manual'); $content_order = $this->getListOrderFromSession('content', 'content_order', 'manual');
@@ -239,12 +241,11 @@ class FolderController extends AbstractCrudController
)); ));
} }
/** /**
* Render the edition template * Render the edition template
*/ */
protected function renderEditionTemplate() { protected function renderEditionTemplate()
{
return $this->render('folder-edit', $this->getEditionArguments()); return $this->render('folder-edit', $this->getEditionArguments());
} }
@@ -257,7 +258,7 @@ class FolderController extends AbstractCrudController
} }
/** /**
* @param \Thelia\Core\Event\Folder\FolderUpdateEvent $updateEvent * @param \Thelia\Core\Event\Folder\FolderUpdateEvent $updateEvent
* @return Response|void * @return Response|void
*/ */
protected function performAdditionalUpdateAction($updateEvent) protected function performAdditionalUpdateAction($updateEvent)
@@ -275,8 +276,8 @@ class FolderController extends AbstractCrudController
/** /**
* Put in this method post object delete processing if required. * Put in this method post object delete processing if required.
* *
* @param \Thelia\Core\Event\Folder\FolderDeleteEvent $deleteEvent the delete event * @param \Thelia\Core\Event\Folder\FolderDeleteEvent $deleteEvent the delete event
* @return Response a response, or null to continue normal processing * @return Response a response, or null to continue normal processing
*/ */
protected function performAdditionalDeleteAction($deleteEvent) protected function performAdditionalDeleteAction($deleteEvent)
{ {
@@ -325,4 +326,4 @@ class FolderController extends AbstractCrudController
array('parent' => $this->getRequest()->get('parent', 0)) array('parent' => $this->getRequest()->get('parent', 0))
); );
} }
} }

View File

@@ -35,12 +35,11 @@ class ModuleController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.module.view")) return $response; if (null !== $response = $this->checkAuth("admin.module.view")) return $response;
return $this->render("modules", array("display_module" => 20)); return $this->render("modules", array("display_module" => 20));
} }
public function updateAction($module_id) public function updateAction($module_id)
{ {
return $this->render("module-edit", array(
return $this->render("module-edit", array( "module_id" => $module_id
"module_id" => $module_id ));
));
} }
} }

View File

@@ -26,7 +26,6 @@ namespace Thelia\Controller\Admin;
use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Translation\Translator;
use Thelia\Form\OrderUpdateAddress; use Thelia\Form\OrderUpdateAddress;
use Thelia\Model\Base\OrderAddressQuery; use Thelia\Model\Base\OrderAddressQuery;
use Thelia\Model\OrderQuery; use Thelia\Model\OrderQuery;
@@ -48,10 +47,9 @@ class OrderController extends BaseAdminController
public function viewAction($order_id) public function viewAction($order_id)
{ {
return $this->render("order-edit", array(
return $this->render("order-edit", array( "order_id" => $order_id
"order_id" => $order_id ));
));
} }
public function updateStatus($order_id = null) public function updateStatus($order_id = null)
@@ -61,7 +59,7 @@ class OrderController extends BaseAdminController
$message = null; $message = null;
try { try {
if($order_id !== null) { if ($order_id !== null) {
$order_id = $order_id; $order_id = $order_id;
} else { } else {
$order_id = $this->getRequest()->get("order_id"); $order_id = $this->getRequest()->get("order_id");
@@ -72,10 +70,10 @@ class OrderController extends BaseAdminController
$statusId = $this->getRequest()->request->get("status_id"); $statusId = $this->getRequest()->request->get("status_id");
$status = OrderStatusQuery::create()->findPk($statusId); $status = OrderStatusQuery::create()->findPk($statusId);
if(null === $order) { if (null === $order) {
throw new \InvalidArgumentException("The order you want to update status does not exist"); throw new \InvalidArgumentException("The order you want to update status does not exist");
} }
if(null === $status) { if (null === $status) {
throw new \InvalidArgumentException("The status you want to set to the order does not exist"); throw new \InvalidArgumentException("The status you want to set to the order does not exist");
} }
@@ -83,7 +81,7 @@ class OrderController extends BaseAdminController
$event->setStatus($statusId); $event->setStatus($statusId);
$this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
} catch(\Exception $e) { } catch (\Exception $e) {
$message = $e->getMessage(); $message = $e->getMessage();
} }
@@ -95,7 +93,7 @@ class OrderController extends BaseAdminController
$browsedPage = $this->getRequest()->get("order_page"); $browsedPage = $this->getRequest()->get("order_page");
if($browsedPage) { if ($browsedPage) {
$params["order_page"] = $browsedPage; $params["order_page"] = $browsedPage;
$this->redirectToRoute("admin.order.list", $params); $this->redirectToRoute("admin.order.list", $params);
} else { } else {
@@ -116,7 +114,7 @@ class OrderController extends BaseAdminController
$deliveryRef = $this->getRequest()->get("delivery_ref"); $deliveryRef = $this->getRequest()->get("delivery_ref");
if(null === $order) { if (null === $order) {
throw new \InvalidArgumentException("The order you want to update status does not exist"); throw new \InvalidArgumentException("The order you want to update status does not exist");
} }
@@ -124,7 +122,7 @@ class OrderController extends BaseAdminController
$event->setDeliveryRef($deliveryRef); $event->setDeliveryRef($deliveryRef);
$this->dispatch(TheliaEvents::ORDER_UPDATE_DELIVERY_REF, $event); $this->dispatch(TheliaEvents::ORDER_UPDATE_DELIVERY_REF, $event);
} catch(\Exception $e) { } catch (\Exception $e) {
$message = $e->getMessage(); $message = $e->getMessage();
} }
@@ -151,7 +149,7 @@ class OrderController extends BaseAdminController
try { try {
$order = OrderQuery::create()->findPk($order_id); $order = OrderQuery::create()->findPk($order_id);
if(null === $order) { if (null === $order) {
throw new \InvalidArgumentException("The order you want to update does not exist"); throw new \InvalidArgumentException("The order you want to update does not exist");
} }
@@ -159,7 +157,7 @@ class OrderController extends BaseAdminController
$orderAddress = OrderAddressQuery::create()->findPk($form->get("id")->getData()); $orderAddress = OrderAddressQuery::create()->findPk($form->get("id")->getData());
if($orderAddress->getId() !== $order->getInvoiceOrderAddressId() && $orderAddress->getId() !== $order->getDeliveryOrderAddressId()) { if ($orderAddress->getId() !== $order->getInvoiceOrderAddressId() && $orderAddress->getId() !== $order->getDeliveryOrderAddressId()) {
throw new \InvalidArgumentException("The order address you want to update does not belong to the current order not exist"); throw new \InvalidArgumentException("The order address you want to update does not belong to the current order not exist");
} }
@@ -180,7 +178,7 @@ class OrderController extends BaseAdminController
$event->setOrder($order); $event->setOrder($order);
$this->dispatch(TheliaEvents::ORDER_UPDATE_ADDRESS, $event); $this->dispatch(TheliaEvents::ORDER_UPDATE_ADDRESS, $event);
} catch(\Exception $e) { } catch (\Exception $e) {
$message = $e->getMessage(); $message = $e->getMessage();
} }
@@ -195,4 +193,4 @@ class OrderController extends BaseAdminController
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params))); $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", $params)));
} }
} }

View File

@@ -34,7 +34,6 @@ use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Product\ProductToggleVisibilityEvent; use Thelia\Core\Event\Product\ProductToggleVisibilityEvent;
use Thelia\Core\Event\Product\ProductDeleteContentEvent; use Thelia\Core\Event\Product\ProductDeleteContentEvent;
use Thelia\Core\Event\Product\ProductAddContentEvent; use Thelia\Core\Event\Product\ProductAddContentEvent;
use Thelia\Model\ProductAssociatedContent;
use Thelia\Model\FolderQuery; use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery; use Thelia\Model\ContentQuery;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
@@ -76,8 +75,8 @@ class ProductController extends AbstractCrudController
/** /**
* Attributes ajax tab loading * Attributes ajax tab loading
*/ */
public function loadAttributesAjaxTabAction() { public function loadAttributesAjaxTabAction()
{
return $this->render( return $this->render(
'ajax/product-attributes-tab', 'ajax/product-attributes-tab',
array( array(
@@ -89,8 +88,8 @@ class ProductController extends AbstractCrudController
/** /**
* Related information ajax tab loading * Related information ajax tab loading
*/ */
public function loadRelatedAjaxTabAction() { public function loadRelatedAjaxTabAction()
{
return $this->render( return $this->render(
'ajax/product-related-tab', 'ajax/product-related-tab',
array( array(
@@ -229,7 +228,8 @@ class ProductController extends AbstractCrudController
); );
} }
protected function getCategoryId() { protected function getCategoryId()
{
// Trouver le category_id, soit depuis la reques, souit depuis le produit courant // Trouver le category_id, soit depuis la reques, souit depuis le produit courant
$category_id = $this->getRequest()->get('category_id', null); $category_id = $this->getRequest()->get('category_id', null);
@@ -340,7 +340,7 @@ class ProductController extends AbstractCrudController
; ;
if ($list !== null) { if ($list !== null) {
foreach($list as $item) { foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); $result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
} }
} }
@@ -366,8 +366,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event); $this->dispatch(TheliaEvents::PRODUCT_ADD_CONTENT, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -393,8 +392,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event); $this->dispatch(TheliaEvents::PRODUCT_REMOVE_CONTENT, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -403,7 +401,6 @@ class ProductController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
// -- Accessories management ---------------------------------------------- // -- Accessories management ----------------------------------------------
public function getAvailableAccessoriesAction($productId, $categoryId) public function getAvailableAccessoriesAction($productId, $categoryId)
@@ -422,7 +419,7 @@ class ProductController extends AbstractCrudController
; ;
if ($list !== null) { if ($list !== null) {
foreach($list as $item) { foreach ($list as $item) {
$result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); $result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
} }
} }
@@ -447,8 +444,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event); $this->dispatch(TheliaEvents::PRODUCT_ADD_ACCESSORY, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -473,8 +469,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event); $this->dispatch(TheliaEvents::PRODUCT_REMOVE_ACCESSORY, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -514,7 +509,8 @@ class ProductController extends AbstractCrudController
* *
* @param unknown $productId * @param unknown $productId
*/ */
public function setProductTemplateAction($productId) { public function setProductTemplateAction($productId)
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth('admin.products.update')) return $response; if (null !== $response = $this->checkAuth('admin.products.update')) return $response;
@@ -536,8 +532,8 @@ class ProductController extends AbstractCrudController
/** /**
* Update product attributes and features * Update product attributes and features
*/ */
public function updateAttributesAndFeaturesAction($productId) { public function updateAttributesAndFeaturesAction($productId)
{
$product = ProductQuery::create()->findPk($productId); $product = ProductQuery::create()->findPk($productId);
if ($product != null) { if ($product != null) {
@@ -556,7 +552,7 @@ class ProductController extends AbstractCrudController
// Update all features values, starting with feature av. values // Update all features values, starting with feature av. values
$featureValues = $this->getRequest()->get('feature_value', array()); $featureValues = $this->getRequest()->get('feature_value', array());
foreach($featureValues as $featureId => $featureValueList) { foreach ($featureValues as $featureId => $featureValueList) {
// Delete all features av. for this feature. // Delete all features av. for this feature.
$event = new FeatureProductDeleteEvent($productId, $featureId); $event = new FeatureProductDeleteEvent($productId, $featureId);
@@ -564,7 +560,7 @@ class ProductController extends AbstractCrudController
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event); $this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event);
// Add then all selected values // Add then all selected values
foreach($featureValueList as $featureValue) { foreach ($featureValueList as $featureValue) {
$event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue); $event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue);
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event); $this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event);
@@ -576,7 +572,7 @@ class ProductController extends AbstractCrudController
// Update then features text values // Update then features text values
$featureTextValues = $this->getRequest()->get('feature_text_value', array()); $featureTextValues = $this->getRequest()->get('feature_text_value', array());
foreach($featureTextValues as $featureId => $featureValue) { foreach ($featureTextValues as $featureId => $featureValue) {
// considere empty text as empty feature value (e.g., we will delete it) // considere empty text as empty feature value (e.g., we will delete it)
if (empty($featureValue)) continue; if (empty($featureValue)) continue;
@@ -589,7 +585,7 @@ class ProductController extends AbstractCrudController
} }
// Delete features which don't have any values // Delete features which don't have any values
foreach($allFeatures as $feature) { foreach ($allFeatures as $feature) {
if (! in_array($feature->getId(), $updatedFeatures)) { if (! in_array($feature->getId(), $updatedFeatures)) {
$event = new FeatureProductDeleteEvent($productId, $feature->getId()); $event = new FeatureProductDeleteEvent($productId, $feature->getId());
@@ -610,8 +606,8 @@ class ProductController extends AbstractCrudController
$this->redirectToListTemplate(); $this->redirectToListTemplate();
} }
public function addAdditionalCategoryAction() { public function addAdditionalCategoryAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response; if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -626,8 +622,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_CATEGORY, $event); $this->dispatch(TheliaEvents::PRODUCT_ADD_CATEGORY, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -636,8 +631,8 @@ class ProductController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
public function deleteAdditionalCategoryAction() { public function deleteAdditionalCategoryAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response; if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -652,8 +647,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_REMOVE_CATEGORY, $event); $this->dispatch(TheliaEvents::PRODUCT_REMOVE_CATEGORY, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -664,8 +658,8 @@ class ProductController extends AbstractCrudController
// -- Product combination management --------------------------------------- // -- Product combination management ---------------------------------------
public function getAttributeValuesAction($productId, $attributeId) { public function getAttributeValuesAction($productId, $attributeId)
{
$result = array(); $result = array();
// Get attribute for this product // Get attribute for this product
@@ -680,7 +674,7 @@ class ProductController extends AbstractCrudController
; ;
if ($values !== null) { if ($values !== null) {
foreach($values as $value) { foreach ($values as $value) {
$result[] = array('id' => $value->getId(), 'title' => $value->getTitle()); $result[] = array('id' => $value->getId(), 'title' => $value->getTitle());
} }
} }
@@ -689,8 +683,8 @@ class ProductController extends AbstractCrudController
return $this->jsonResponse(json_encode($result)); return $this->jsonResponse(json_encode($result));
} }
public function addAttributeValueToCombinationAction($productId, $attributeAvId, $combination) { public function addAttributeValueToCombinationAction($productId, $attributeAvId, $combination)
{
$result = array(); $result = array();
// Get attribute for this product // Get attribute for this product
@@ -734,8 +728,8 @@ class ProductController extends AbstractCrudController
/** /**
* A a new combination to a product * A a new combination to a product
*/ */
public function addCombinationAction() { public function addCombinationAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response; if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -747,8 +741,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_ADD_COMBINATION, $event); $this->dispatch(TheliaEvents::PRODUCT_ADD_COMBINATION, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -760,8 +753,8 @@ class ProductController extends AbstractCrudController
/** /**
* A a new combination to a product * A a new combination to a product
*/ */
public function deleteCombinationAction() { public function deleteCombinationAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.products.update")) return $response; if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
@@ -772,8 +765,7 @@ class ProductController extends AbstractCrudController
try { try {
$this->dispatch(TheliaEvents::PRODUCT_DELETE_COMBINATION, $event); $this->dispatch(TheliaEvents::PRODUCT_DELETE_COMBINATION, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }

View File

@@ -31,9 +31,7 @@ use Thelia\Tools\URL;
use Thelia\Tools\Redirect; use Thelia\Tools\Redirect;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\Authentication\AdminTokenAuthenticator; use Thelia\Core\Security\Authentication\AdminTokenAuthenticator;
use Thelia\Core\Security\UserProvider\TokenProvider;
use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Cookie;
use Thelia\Core\Security\UserProvider\CookieTokenProvider;
use Thelia\Core\Security\Exception\TokenAuthenticationException; use Thelia\Core\Security\Exception\TokenAuthenticationException;
class SessionController extends BaseAdminController class SessionController extends BaseAdminController
@@ -59,8 +57,7 @@ class SessionController extends BaseAdminController
// Render the home page // Render the home page
return $this->render("home"); return $this->render("home");
} } catch (TokenAuthenticationException $ex) {
catch (TokenAuthenticationException $ex) {
$this->adminLogAppend("Token based authentication failed."); $this->adminLogAppend("Token based authentication failed.");
// Clear the cookie // Clear the cookie

View File

@@ -35,12 +35,11 @@ class ShippingConfigurationController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response; if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response;
return $this->render("shipping-configuration", array("display_shipping_configuration" => 20)); return $this->render("shipping-configuration", array("display_shipping_configuration" => 20));
} }
public function updateAction($shipping_configuration_id) public function updateAction($shipping_configuration_id)
{ {
return $this->render("shipping-configuration-edit", array( return $this->render("shipping-configuration-edit", array(
"shipping_configuration_id" => $shipping_configuration_id "shipping_configuration_id" => $shipping_configuration_id
)); ));
} }
} }

View File

@@ -35,12 +35,11 @@ class ShippingZoneController extends BaseAdminController
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response; if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
return $this->render("shipping-zones", array("display_shipping_zone" => 20)); return $this->render("shipping-zones", array("display_shipping_zone" => 20));
} }
public function updateAction($shipping_zones_id) public function updateAction($shipping_zones_id)
{ {
return $this->render("shipping-zones-edit", array(
return $this->render("shipping-zones-edit", array( "shipping_zones_id" => $shipping_zones_id
"shipping_zones_id" => $shipping_zones_id ));
));
} }
} }

View File

@@ -30,10 +30,6 @@ use Thelia\Core\Event\Template\TemplateCreateEvent;
use Thelia\Model\TemplateQuery; use Thelia\Model\TemplateQuery;
use Thelia\Form\TemplateModificationForm; use Thelia\Form\TemplateModificationForm;
use Thelia\Form\TemplateCreationForm; use Thelia\Form\TemplateCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Model\TemplateAv;
use Thelia\Model\TemplateAvQuery;
use Thelia\Core\Event\Template\TemplateEvent;
use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent; use Thelia\Core\Event\Template\TemplateDeleteAttributeEvent;
use Thelia\Core\Event\Template\TemplateAddAttributeEvent; use Thelia\Core\Event\Template\TemplateAddAttributeEvent;
use Thelia\Core\Event\Template\TemplateAddFeatureEvent; use Thelia\Core\Event\Template\TemplateAddFeatureEvent;
@@ -41,7 +37,6 @@ use Thelia\Core\Event\Template\TemplateDeleteFeatureEvent;
use Thelia\Model\FeatureTemplateQuery; use Thelia\Model\FeatureTemplateQuery;
use Thelia\Model\AttributeTemplateQuery; use Thelia\Model\AttributeTemplateQuery;
/** /**
* Manages product templates * Manages product templates
* *
@@ -102,7 +97,6 @@ class TemplateController extends AbstractCrudController
; ;
// Add feature and attributes list // Add feature and attributes list
return $changeEvent; return $changeEvent;
} }
@@ -199,22 +193,24 @@ class TemplateController extends AbstractCrudController
return null; return null;
} }
public function getAjaxFeaturesAction() { public function getAjaxFeaturesAction()
{
return $this->render( return $this->render(
'ajax/template-feature-list', 'ajax/template-feature-list',
array('template_id' => $this->getRequest()->get('template_id')) array('template_id' => $this->getRequest()->get('template_id'))
); );
} }
public function getAjaxAttributesAction() { public function getAjaxAttributesAction()
{
return $this->render( return $this->render(
'ajax/template-attribute-list', 'ajax/template-attribute-list',
array('template_id' => $this->getRequest()->get('template_id')) array('template_id' => $this->getRequest()->get('template_id'))
); );
} }
public function addAttributeAction() { public function addAttributeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.add")) return $response;
@@ -237,8 +233,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
public function deleteAttributeAction() { public function deleteAttributeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.template.attribute.delete")) return $response;
@@ -257,8 +253,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
public function updateAttributePositionAction() { public function updateAttributePositionAction()
{
// Find attribute_template // Find attribute_template
$attributeTemplate = AttributeTemplateQuery::create() $attributeTemplate = AttributeTemplateQuery::create()
->filterByTemplateId($this->getRequest()->get('template_id', null)) ->filterByTemplateId($this->getRequest()->get('template_id', null))
@@ -272,8 +268,8 @@ class TemplateController extends AbstractCrudController
); );
} }
public function addFeatureAction() { public function addFeatureAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.template.feature.add")) return $response;
@@ -296,8 +292,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
public function deleteFeatureAction() { public function deleteFeatureAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.template.feature.delete")) return $response;
@@ -316,8 +312,8 @@ class TemplateController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
public function updateFeaturePositionAction() { public function updateFeaturePositionAction()
{
// Find feature_template // Find feature_template
$featureTemplate = FeatureTemplateQuery::create() $featureTemplate = FeatureTemplateQuery::create()
->filterByTemplateId($this->getRequest()->get('template_id', null)) ->filterByTemplateId($this->getRequest()->get('template_id', null))
@@ -330,4 +326,4 @@ class TemplateController extends AbstractCrudController
TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION
); );
} }
} }

View File

@@ -286,7 +286,7 @@ class BaseController extends ContainerAware
*/ */
protected function checkXmlHttpRequest() protected function checkXmlHttpRequest()
{ {
if(false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) { if (false === $this->getRequest()->isXmlHttpRequest() && false === $this->isDebug()) {
$this->accessDenied(); $this->accessDenied();
} }
} }
@@ -300,6 +300,7 @@ class BaseController extends ContainerAware
public function getMailer() public function getMailer()
{ {
$mailer = $this->container->get('mailer'); $mailer = $this->container->get('mailer');
return $mailer->getSwiftMailer(); return $mailer->getSwiftMailer();
} }
} }

View File

@@ -30,7 +30,6 @@ use Thelia\Form\AddressUpdateForm;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\AddressQuery; use Thelia\Model\AddressQuery;
use Thelia\Model\Customer; use Thelia\Model\Customer;
use Thelia\Tools\URL;
/** /**
* Class AddressController * Class AddressController
@@ -51,10 +50,8 @@ class AddressController extends BaseFrontController
$this->checkAuth(); $this->checkAuth();
$this->checkXmlHttpRequest(); $this->checkXmlHttpRequest();
} }
/** /**
* Create controller. * Create controller.
* Check if customer is logged in * Check if customer is logged in
@@ -103,7 +100,7 @@ class AddressController extends BaseFrontController
$customer = $this->getSecurityContext()->getCustomerUser(); $customer = $this->getSecurityContext()->getCustomerUser();
$address = AddressQuery::create()->findPk($address_id); $address = AddressQuery::create()->findPk($address_id);
if(!$address || $customer->getId() != $address->getCustomerId()) { if (!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home"); $this->redirectToRoute("home");
} }
@@ -117,7 +114,6 @@ class AddressController extends BaseFrontController
$addressUpdate = new AddressUpdateForm($request); $addressUpdate = new AddressUpdateForm($request);
try { try {
$customer = $this->getSecurityContext()->getCustomerUser(); $customer = $this->getSecurityContext()->getCustomerUser();
@@ -164,7 +160,7 @@ class AddressController extends BaseFrontController
$customer = $this->getSecurityContext()->getCustomerUser(); $customer = $this->getSecurityContext()->getCustomerUser();
$address = AddressQuery::create()->findPk($address_id); $address = AddressQuery::create()->findPk($address_id);
if(!$address || $customer->getId() != $address->getCustomerId()) { if (!$address || $customer->getId() != $address->getCustomerId()) {
$this->redirectToRoute("home"); $this->redirectToRoute("home");
} }

View File

@@ -55,7 +55,7 @@ class BaseFrontController extends BaseController
public function checkAuth() public function checkAuth()
{ {
if($this->getSecurityContext()->hasCustomerUser() === false) { if ($this->getSecurityContext()->hasCustomerUser() === false) {
$this->redirectToRoute("customer.login.view"); $this->redirectToRoute("customer.login.view");
} }
} }
@@ -63,7 +63,7 @@ class BaseFrontController extends BaseController
protected function checkCartNotEmpty() protected function checkCartNotEmpty()
{ {
$cart = $this->getSession()->getCart(); $cart = $this->getSession()->getCart();
if($cart===null || $cart->countCartItems() == 0) { if ($cart===null || $cart->countCartItems() == 0) {
$this->redirectToRoute("cart.view"); $this->redirectToRoute("cart.view");
} }
} }
@@ -71,7 +71,7 @@ class BaseFrontController extends BaseController
protected function checkValidDelivery() protected function checkValidDelivery()
{ {
$order = $this->getSession()->getOrder(); $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())) { 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"); $this->redirectToRoute("order.delivery");
} }
} }
@@ -79,7 +79,7 @@ class BaseFrontController extends BaseController
protected function checkValidInvoice() protected function checkValidInvoice()
{ {
$order = $this->getSession()->getOrder(); $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())) { 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"); $this->redirectToRoute("order.invoice");
} }
} }

View File

@@ -104,7 +104,7 @@ class CustomerController extends BaseFrontController
$this->processLogin($customerCreateEvent->getCustomer()); $this->processLogin($customerCreateEvent->getCustomer());
$cart = $this->getCart($this->getRequest()); $cart = $this->getCart($this->getRequest());
if($cart->getCartItems()->count() > 0) { if ($cart->getCartItems()->count() > 0) {
$this->redirectToRoute("cart.view"); $this->redirectToRoute("cart.view");
} else { } else {
$this->redirectSuccess($customerCreation); $this->redirectSuccess($customerCreation);

View File

@@ -34,7 +34,6 @@ use Thelia\Log\Tlog;
use Thelia\Model\AddressQuery; use Thelia\Model\AddressQuery;
use Thelia\Model\AreaDeliveryModuleQuery; use Thelia\Model\AreaDeliveryModuleQuery;
use Thelia\Model\Base\OrderQuery; use Thelia\Model\Base\OrderQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\ModuleQuery; use Thelia\Model\ModuleQuery;
use Thelia\Model\Order; use Thelia\Model\Order;
use Thelia\Tools\URL; use Thelia\Tools\URL;
@@ -69,7 +68,7 @@ class OrderController extends BaseFrontController
/* check that the delivery address belongs to the current customer */ /* check that the delivery address belongs to the current customer */
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { if ($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
throw new \Exception("Delivery address does not belong to the current customer"); throw new \Exception("Delivery address does not belong to the current customer");
} }
@@ -139,7 +138,7 @@ class OrderController extends BaseFrontController
/* check that the invoice address belongs to the current customer */ /* check that the invoice address belongs to the current customer */
$invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId); $invoiceAddress = AddressQuery::create()->findPk($invoiceAddressId);
if($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { if ($invoiceAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
throw new \Exception("Invoice address does not belong to the current customer"); throw new \Exception("Invoice address does not belong to the current customer");
} }
@@ -193,7 +192,7 @@ class OrderController extends BaseFrontController
$placedOrder = $orderEvent->getPlacedOrder(); $placedOrder = $orderEvent->getPlacedOrder();
if(null !== $placedOrder && null !== $placedOrder->getId()) { if (null !== $placedOrder && null !== $placedOrder->getId()) {
/* order has been placed */ /* order has been placed */
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId())))); $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId()))));
} else { } else {
@@ -209,13 +208,13 @@ class OrderController extends BaseFrontController
$this->getRequest()->attributes->get('order_id') $this->getRequest()->attributes->get('order_id')
); );
if(null === $placedOrder) { if (null === $placedOrder) {
throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder); throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder);
} }
$customer = $this->getSecurityContext()->getCustomerUser(); $customer = $this->getSecurityContext()->getCustomerUser();
if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) { 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); throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder);
} }

View File

@@ -244,8 +244,6 @@ class AddressCreateOrUpdateEvent extends ActionEvent
return $this->isDefault; return $this->isDefault;
} }
/** /**
* @param \Thelia\Model\Customer $customer * @param \Thelia\Model\Customer $customer
*/ */

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content; namespace Thelia\Core\Event\Content;
/** /**
* Class ContentCreateEvent * Class ContentCreateEvent
* @package Thelia\Core\Event\Content * @package Thelia\Core\Event\Content
@@ -76,9 +75,6 @@ class ContentCreateEvent extends ContentEvent
return $this->default_folder; return $this->default_folder;
} }
/** /**
* @param mixed $visible * @param mixed $visible
* *
@@ -119,6 +115,4 @@ class ContentCreateEvent extends ContentEvent
return $this->title; return $this->title;
} }
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content; namespace Thelia\Core\Event\Content;
/** /**
* Class ContentDeleteEvent * Class ContentDeleteEvent
* @package Thelia\Core\Event\Content * @package Thelia\Core\Event\Content
@@ -35,7 +34,7 @@ class ContentDeleteEvent extends ContentEvent
protected $folder_id; protected $folder_id;
function __construct($content_id) public function __construct($content_id)
{ {
$this->content_id = $content_id; $this->content_id = $content_id;
} }
@@ -70,5 +69,4 @@ class ContentDeleteEvent extends ContentEvent
return $this->folder_id; return $this->folder_id;
} }
}
}

View File

@@ -25,7 +25,6 @@ namespace Thelia\Core\Event\Content;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Content; use Thelia\Model\Content;
/** /**
* Class ContentEvent * Class ContentEvent
* @package Thelia\Core\Event\Content * @package Thelia\Core\Event\Content
@@ -38,7 +37,7 @@ class ContentEvent extends ActionEvent
*/ */
protected $content; protected $content;
function __construct(Content $content = null) public function __construct(Content $content = null)
{ {
$this->content = $content; $this->content = $content;
} }
@@ -70,4 +69,4 @@ class ContentEvent extends ActionEvent
{ {
return null !== $this->content; return null !== $this->content;
} }
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content; namespace Thelia\Core\Event\Content;
/** /**
* Class ContentToggleVisibilityEvent * Class ContentToggleVisibilityEvent
* @package Thelia\Core\Event\Content * @package Thelia\Core\Event\Content
@@ -32,4 +31,4 @@ namespace Thelia\Core\Event\Content;
class ContentToggleVisibilityEvent extends ContentEvent class ContentToggleVisibilityEvent extends ContentEvent
{ {
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event\Content; namespace Thelia\Core\Event\Content;
/** /**
* Class ContentUpdateEvent * Class ContentUpdateEvent
* @package Thelia\Core\Event\Content * @package Thelia\Core\Event\Content
@@ -39,7 +38,7 @@ class ContentUpdateEvent extends ContentCreateEvent
protected $url; protected $url;
function __construct($content_id) public function __construct($content_id)
{ {
$this->content_id = $content_id; $this->content_id = $content_id;
} }
@@ -144,7 +143,4 @@ class ContentUpdateEvent extends ContentCreateEvent
return $this->url; return $this->url;
} }
}
}

View File

@@ -59,7 +59,7 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
protected $customer; protected $customer;
/** /**
* @param int $title the title customer id * @param int $title the title customer id
* @param string $firstname * @param string $firstname
* @param string $lastname * @param string $lastname
* @param string $address1 * @param string $address1
@@ -69,13 +69,13 @@ class CustomerCreateOrUpdateEvent extends ActionEvent
* @param string $cellphone * @param string $cellphone
* @param string $zipcode * @param string $zipcode
* @param string $city * @param string $city
* @param int $country the country id * @param int $country the country id
* @param string $email * @param string $email
* @param string $password plain password, don't put hash password, it will hashes again * @param string $password plain password, don't put hash password, it will hashes again
* @param $lang * @param $lang
* @param int $reseller if customer is a reseller * @param int $reseller if customer is a reseller
* @param int $sponsor customer's id sponsor * @param int $sponsor customer's id sponsor
* @param float $discount * @param float $discount
* @param string $company * @param string $company
*/ */
public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount, $company) public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount, $company)

View File

@@ -66,7 +66,7 @@ class DocumentCreateOrUpdateEvent extends ActionEvent
* *
* @param string $documentType Document type * @param string $documentType Document type
* ex : FileManager::TYPE_CATEGORY * ex : FileManager::TYPE_CATEGORY
* @param int $parentId Document parent id * @param int $parentId Document parent id
*/ */
public function __construct($documentType, $parentId) public function __construct($documentType, $parentId)
{ {
@@ -214,5 +214,4 @@ class DocumentCreateOrUpdateEvent extends ActionEvent
return $this->oldModelDocument; return $this->oldModelDocument;
} }
} }

View File

@@ -109,5 +109,4 @@ class DocumentDeleteEvent extends ActionEvent
return $this->documentToDelete; return $this->documentToDelete;
} }
} }

View File

@@ -50,4 +50,4 @@ class FeatureProductEvent extends ActionEvent
return $this; return $this;
} }
} }

View File

@@ -24,13 +24,13 @@
namespace Thelia\Core\Event\Folder; namespace Thelia\Core\Event\Folder;
use Thelia\Core\Event\Folder\FolderEvent; use Thelia\Core\Event\Folder\FolderEvent;
/** /**
* Class FolderCreateEvent * Class FolderCreateEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class FolderCreateEvent extends FolderEvent { class FolderCreateEvent extends FolderEvent
{
protected $title; protected $title;
protected $parent; protected $parent;
protected $locale; protected $locale;
@@ -117,5 +117,4 @@ class FolderCreateEvent extends FolderEvent {
return $this->visible; return $this->visible;
} }
}
}

View File

@@ -24,14 +24,13 @@
namespace Thelia\Core\Event\Folder; namespace Thelia\Core\Event\Folder;
use Thelia\Core\Event\Folder\FolderEvent; use Thelia\Core\Event\Folder\FolderEvent;
/** /**
* Class FolderDeleteEvent * Class FolderDeleteEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class FolderDeleteEvent extends FolderEvent{ class FolderDeleteEvent extends FolderEvent
{
/** /**
* @var int folder id * @var int folder id
*/ */
@@ -40,7 +39,7 @@ class FolderDeleteEvent extends FolderEvent{
/** /**
* @param int $folder_id * @param int $folder_id
*/ */
function __construct($folder_id) public function __construct($folder_id)
{ {
$this->folder_id = $folder_id; $this->folder_id = $folder_id;
} }
@@ -61,5 +60,4 @@ class FolderDeleteEvent extends FolderEvent{
return $this->folder_id; return $this->folder_id;
} }
}
}

View File

@@ -25,20 +25,19 @@ namespace Thelia\Core\Event\Folder;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Folder; use Thelia\Model\Folder;
/** /**
* Class FolderEvent * Class FolderEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class FolderEvent extends ActionEvent { class FolderEvent extends ActionEvent
{
/** /**
* @var \Thelia\Model\Folder * @var \Thelia\Model\Folder
*/ */
protected $folder; protected $folder;
function __construct(Folder $folder = null) public function __construct(Folder $folder = null)
{ {
$this->folder = $folder; $this->folder = $folder;
} }
@@ -71,4 +70,4 @@ class FolderEvent extends ActionEvent {
return null !== $this->folder; return null !== $this->folder;
} }
} }

View File

@@ -24,12 +24,11 @@
namespace Thelia\Core\Event\Folder; namespace Thelia\Core\Event\Folder;
use Thelia\Core\Event\Folder\FolderEvent; use Thelia\Core\Event\Folder\FolderEvent;
/** /**
* Class FolderToggleVisibilityEvent * Class FolderToggleVisibilityEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class FolderToggleVisibilityEvent extends FolderEvent { class FolderToggleVisibilityEvent extends FolderEvent
{
} }

View File

@@ -24,13 +24,13 @@
namespace Thelia\Core\Event\Folder; namespace Thelia\Core\Event\Folder;
use Thelia\Core\Event\Folder\FolderCreateEvent; use Thelia\Core\Event\Folder\FolderCreateEvent;
/** /**
* Class FolderUpdateEvent * Class FolderUpdateEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class FolderUpdateEvent extends FolderCreateEvent { class FolderUpdateEvent extends FolderCreateEvent
{
protected $folder_id; protected $folder_id;
protected $chapo; protected $chapo;
@@ -39,7 +39,7 @@ class FolderUpdateEvent extends FolderCreateEvent {
protected $url; protected $url;
function __construct($folder_id) public function __construct($folder_id)
{ {
$this->folder_id = $folder_id; $this->folder_id = $folder_id;
} }
@@ -134,4 +134,4 @@ class FolderUpdateEvent extends FolderCreateEvent {
return $this->url; return $this->url;
} }
} }

View File

@@ -23,14 +23,13 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
/** /**
* Class GenerateRewrittenUrlEvent * Class GenerateRewrittenUrlEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class GenerateRewrittenUrlEvent extends ActionEvent { class GenerateRewrittenUrlEvent extends ActionEvent
{
protected $object; protected $object;
protected $locale; protected $locale;
@@ -57,4 +56,4 @@ class GenerateRewrittenUrlEvent extends ActionEvent {
return $this->url; return $this->url;
} }
} }

View File

@@ -60,9 +60,9 @@ class ImageCreateOrUpdateEvent extends ActionEvent
/** /**
* Constructor * Constructor
* *
* @param string $imageType Image type * @param string $imageType Image type
* ex : FileManager::TYPE_CATEGORY * ex : FileManager::TYPE_CATEGORY
* @param int $parentId Image parent id * @param int $parentId Image parent id
*/ */
public function __construct($imageType, $parentId) public function __construct($imageType, $parentId)
{ {
@@ -210,5 +210,4 @@ class ImageCreateOrUpdateEvent extends ActionEvent
return $this->oldModelImage; return $this->oldModelImage;
} }
} }

View File

@@ -52,7 +52,7 @@ class ImageDeleteEvent extends ActionEvent
* Constructor * Constructor
* *
* @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted * @param CategoryImage|ProductImage|ContentImage|FolderImage $imageToDelete Image about to be deleted
* @param string $imageType Image type * @param string $imageType Image type
* ex : FileManager::TYPE_CATEGORY * ex : FileManager::TYPE_CATEGORY
*/ */
public function __construct($imageToDelete, $imageType) public function __construct($imageToDelete, $imageType)
@@ -109,5 +109,4 @@ class ImageDeleteEvent extends ActionEvent
return $this->imageToDelete; return $this->imageToDelete;
} }
} }

View File

@@ -23,14 +23,13 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
/** /**
* Class LostPasswordEvent * Class LostPasswordEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class LostPasswordEvent extends ActionEvent { class LostPasswordEvent extends ActionEvent
{
protected $email; protected $email;
public function __construct($email) public function __construct($email)
@@ -46,6 +45,4 @@ class LostPasswordEvent extends ActionEvent {
return $this->email; return $this->email;
} }
}
}

View File

@@ -23,13 +23,13 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
/** /**
* Class MailTransporterEvent * Class MailTransporterEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class MailTransporterEvent extends ActionEvent { class MailTransporterEvent extends ActionEvent
{
/** /**
* @var \Swift_Transport * @var \Swift_Transport
*/ */
@@ -49,4 +49,4 @@ class MailTransporterEvent extends ActionEvent {
{ {
return null !== $this->transporter; return null !== $this->transporter;
} }
} }

View File

@@ -46,6 +46,7 @@ class ProductCreateEvent extends ProductEvent
public function setRef($ref) public function setRef($ref)
{ {
$this->ref = $ref; $this->ref = $ref;
return $this; return $this;
} }
@@ -57,6 +58,7 @@ class ProductCreateEvent extends ProductEvent
public function setTitle($title) public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
return $this; return $this;
} }
@@ -68,6 +70,7 @@ class ProductCreateEvent extends ProductEvent
public function setLocale($locale) public function setLocale($locale)
{ {
$this->locale = $locale; $this->locale = $locale;
return $this; return $this;
} }
@@ -79,6 +82,7 @@ class ProductCreateEvent extends ProductEvent
public function setDefaultCategory($default_category) public function setDefaultCategory($default_category)
{ {
$this->default_category = $default_category; $this->default_category = $default_category;
return $this; return $this;
} }
@@ -90,6 +94,7 @@ class ProductCreateEvent extends ProductEvent
public function setVisible($visible) public function setVisible($visible)
{ {
$this->visible = $visible; $this->visible = $visible;
return $this; return $this;
} }
@@ -101,6 +106,7 @@ class ProductCreateEvent extends ProductEvent
public function setBasePrice($basePrice) public function setBasePrice($basePrice)
{ {
$this->basePrice = $basePrice; $this->basePrice = $basePrice;
return $this; return $this;
} }
@@ -112,6 +118,7 @@ class ProductCreateEvent extends ProductEvent
public function setBaseWeight($baseWeight) public function setBaseWeight($baseWeight)
{ {
$this->baseWeight = $baseWeight; $this->baseWeight = $baseWeight;
return $this; return $this;
} }
@@ -123,6 +130,7 @@ class ProductCreateEvent extends ProductEvent
public function setTaxRuleId($taxRuleId) public function setTaxRuleId($taxRuleId)
{ {
$this->taxRuleId = $taxRuleId; $this->taxRuleId = $taxRuleId;
return $this; return $this;
} }
@@ -134,6 +142,7 @@ class ProductCreateEvent extends ProductEvent
public function setCurrencyId($currencyId) public function setCurrencyId($currencyId)
{ {
$this->currencyId = $currencyId; $this->currencyId = $currencyId;
return $this; return $this;
} }
} }

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Event\Product; namespace Thelia\Core\Event\Product;
use Thelia\Core\Event\ProductEvent; use Thelia\Core\Event\ProductEvent;
use Thelia\Model\Product; use Thelia\Model\Product;
use Thelia\Core\Event\ActionEvent;
class ProductSetTemplateEvent extends ProductEvent class ProductSetTemplateEvent extends ProductEvent
{ {

View File

@@ -57,6 +57,7 @@ class TemplateUpdateEvent extends TemplateCreateEvent
public function setFeatureList($feature_list) public function setFeatureList($feature_list)
{ {
$this->feature_list = $feature_list; $this->feature_list = $feature_list;
return $this; return $this;
} }
@@ -68,6 +69,7 @@ class TemplateUpdateEvent extends TemplateCreateEvent
public function setAttributeList($attribute_list) public function setAttributeList($attribute_list)
{ {
$this->attribute_list = $attribute_list; $this->attribute_list = $attribute_list;
return $this; return $this;
} }
} }

View File

@@ -331,7 +331,6 @@ final class TheliaEvents
const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate"; const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate";
const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate"; const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate";
/** /**
* Sent on image processing * Sent on image processing
*/ */
@@ -571,7 +570,6 @@ final class TheliaEvents
const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv"; const BEFORE_DELETEATTRIBUTE_AV = "action.before_deleteAttributeAv";
const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv"; const AFTER_DELETEATTRIBUTE_AV = "action.after_deleteAttributeAv";
// -- Features values management ---------------------------------------- // -- Features values management ----------------------------------------
const FEATURE_AV_CREATE = "action.createFeatureAv"; const FEATURE_AV_CREATE = "action.createFeatureAv";

View File

@@ -100,7 +100,7 @@ class ViewListener implements EventSubscriberInterface
// Redirect to the login template // Redirect to the login template
Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate())); Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate()));
} catch (OrderException $e) { } catch (OrderException $e) {
switch($e->getCode()) { switch ($e->getCode()) {
case OrderException::CART_EMPTY: case OrderException::CART_EMPTY:
// Redirect to the cart template // Redirect to the cart template
Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL)); Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL));

View File

@@ -51,10 +51,10 @@ class Session extends BaseSession
public function getLang($forceDefault = true) public function getLang($forceDefault = true)
{ {
$lang = $this->get("thelia.current.lang"); $lang = $this->get("thelia.current.lang");
if(null === $lang && $forceDefault) if (null === $lang && $forceDefault) {
{
$lang = Lang::getDefaultLanguage(); $lang = Lang::getDefaultLanguage();
} }
return $lang; return $lang;
} }
@@ -74,10 +74,10 @@ class Session extends BaseSession
{ {
$currency = $this->get("thelia.current.currency"); $currency = $this->get("thelia.current.currency");
if(null === $currency && $forceDefault) if (null === $currency && $forceDefault) {
{
$currency = Currency::getDefaultCurrency(); $currency = Currency::getDefaultCurrency();
} }
return $currency; return $currency;
} }
@@ -108,6 +108,7 @@ class Session extends BaseSession
if (null === $lang) { if (null === $lang) {
$lang = Lang::getDefaultLanguage(); $lang = Lang::getDefaultLanguage();
} }
return $lang; return $lang;
} }
@@ -187,7 +188,7 @@ class Session extends BaseSession
$cart = null; $cart = null;
if ($cart_id) { if ($cart_id) {
$cart = CartQuery::create()->findPk($cart_id); $cart = CartQuery::create()->findPk($cart_id);
if($cart) { if ($cart) {
try { try {
$this->verifyValidCart($cart); $this->verifyValidCart($cart);
} catch (InvalidCartException $e) { } catch (InvalidCartException $e) {
@@ -230,7 +231,6 @@ class Session extends BaseSession
// -- Order ------------------------------------------------------------------ // -- Order ------------------------------------------------------------------
public function setOrder(Order $order) public function setOrder(Order $order)
{ {
$this->set("thelia.order", $order); $this->set("thelia.order", $order);
@@ -246,7 +246,6 @@ class Session extends BaseSession
return $this->get("thelia.order"); return $this->get("thelia.order");
} }
/** /**
* Set consumed coupons by the Customer * Set consumed coupons by the Customer
* *

View File

@@ -20,15 +20,15 @@
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\HttpKernel\Exceptions; namespace Thelia\Core\HttpKernel\Exception;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException as BaseNotFountHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException as BaseNotFountHttpException;
/** /**
* Class NotFountHttpException * Class NotFountHttpException
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class NotFountHttpException extends BaseNotFountHttpException { class NotFountHttpException extends BaseNotFountHttpException
{
protected $adminContext = false; protected $adminContext = false;
public function __construct($message = null, \Exception $previous = null, $code = 0, $adminContext = false) public function __construct($message = null, \Exception $previous = null, $code = 0, $adminContext = false)
@@ -43,4 +43,4 @@ class NotFountHttpException extends BaseNotFountHttpException {
return $this->adminContext === true; return $this->adminContext === true;
} }
} }

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Security\Authentication; namespace Thelia\Core\Security\Authentication;
use Thelia\Core\Security\Authentication\AuthenticatorInterface; use Thelia\Core\Security\Authentication\AuthenticatorInterface;
use Thelia\Core\Security\UserProvider\UserProviderInterface;
use Thelia\Core\Security\UserProvider\TokenUserProvider; use Thelia\Core\Security\UserProvider\TokenUserProvider;
use Thelia\Core\Security\Exception\TokenAuthenticationException; use Thelia\Core\Security\Exception\TokenAuthenticationException;
@@ -51,7 +50,6 @@ class TokenAuthenticator implements AuthenticatorInterface
$user = $this->userProvider->getUser($keyData); $user = $this->userProvider->getUser($keyData);
if ($user === null) throw new TokenAuthenticationException("No user matches the provided token"); if ($user === null) throw new TokenAuthenticationException("No user matches the provided token");
return $user; return $user;
} }
} }

View File

@@ -6,8 +6,8 @@ use Thelia\Core\Security\User\UserInterface;
class TokenProvider class TokenProvider
{ {
public function encodeKey(UserInterface $user) { public function encodeKey(UserInterface $user)
{
// Always set a new token in the user environment // Always set a new token in the user environment
$user->setToken(uniqid()); $user->setToken(uniqid());
@@ -15,7 +15,8 @@ class TokenProvider
array($user->getUsername(), $user->getToken(), $user->getSerial()))); array($user->getUsername(), $user->getToken(), $user->getSerial())));
} }
public function decodeKey($key) { public function decodeKey($key)
{
$data = unserialize(base64_decode($key)); $data = unserialize(base64_decode($key));
return array( return array(

View File

@@ -68,4 +68,4 @@ interface UserInterface
* Set a serial number int the user data (used by remember me authnetication system) * Set a serial number int the user data (used by remember me authnetication system)
*/ */
public function setSerial($serial); public function setSerial($serial);
} }

View File

@@ -23,13 +23,12 @@
namespace Thelia\Core\Security\UserProvider; namespace Thelia\Core\Security\UserProvider;
use Thelia\Model\Admin;
use Thelia\Model\AdminQuery; use Thelia\Model\AdminQuery;
class AdminTokenUserProvider extends TokenUserProvider class AdminTokenUserProvider extends TokenUserProvider
{ {
public function getUser($dataArray) { public function getUser($dataArray)
{
return AdminQuery::create() return AdminQuery::create()
->filterByLogin($dataArray['username']) ->filterByLogin($dataArray['username'])
->filterByRememberMeSerial($dataArray['serial']) ->filterByRememberMeSerial($dataArray['serial'])

View File

@@ -23,17 +23,16 @@
namespace Thelia\Core\Security\UserProvider; namespace Thelia\Core\Security\UserProvider;
use Thelia\Action\Customer;
use Thelia\Model\CustomerQuery; use Thelia\Model\CustomerQuery;
class CustomerTokenUserProvider extends TokenUserProvider class CustomerTokenUserProvider extends TokenUserProvider
{ {
public function getUser($dataArray) { public function getUser($dataArray)
{
return CustomerQuery::create() return CustomerQuery::create()
->filterByEmail($dataArray['username']) ->filterByEmail($dataArray['username'])
->filterByRememberMeSerial($dataArray['serial']) ->filterByRememberMeSerial($dataArray['serial'])
->filterByRememberMeToken($dataArray['token']) ->filterByRememberMeToken($dataArray['token'])
->findOne(); ->findOne();
} }
} }

View File

@@ -35,4 +35,4 @@ class CustomerUserProvider implements UserProviderInterface
return $customer; return $customer;
} }
} }

View File

@@ -23,10 +23,9 @@
namespace Thelia\Core\Security\UserProvider; namespace Thelia\Core\Security\UserProvider;
use Thelia\Core\Security\User\UserInterface;
use Thelia\Core\Security\Token\TokenProvider; use Thelia\Core\Security\Token\TokenProvider;
abstract class TokenUserProvider extends TokenProvider implements UserProviderInterface abstract class TokenUserProvider extends TokenProvider implements UserProviderInterface
{ {
public abstract function getUser($key); abstract public function getUser($key);
} }

View File

@@ -117,7 +117,7 @@ class Accessory extends Product
$loopResult = parent::exec($pagination); $loopResult = parent::exec($pagination);
foreach($loopResult as $loopResultRow) { foreach ($loopResult as $loopResultRow) {
$accessoryProductId = $loopResultRow->get('ID'); $accessoryProductId = $loopResultRow->get('ID');

View File

@@ -112,7 +112,7 @@ class Address extends BaseLoop
if ($default === true) { if ($default === true) {
$search->filterByIsDefault(1, Criteria::EQUAL); $search->filterByIsDefault(1, Criteria::EQUAL);
} else if($default === false) { } elseif ($default === false) {
$search->filterByIsDefault(0, Criteria::EQUAL); $search->filterByIsDefault(0, Criteria::EQUAL);
} }

View File

@@ -60,10 +60,10 @@ class Argument
{ {
$x = $value === null; $x = $value === null;
if($value === null) { if ($value === null) {
$this->value = null; $this->value = null;
} else { } else {
if(false === $value) { if (false === $value) {
/* (string) $value = "" */ /* (string) $value = "" */
$this->value = 0; $this->value = 0;
} else { } else {

View File

@@ -159,7 +159,7 @@ class AssociatedContent extends Content
$loopResult = parent::exec($pagination); $loopResult = parent::exec($pagination);
foreach($loopResult as $loopResultRow) { foreach ($loopResult as $loopResultRow) {
$relatedContentId = $loopResultRow->get('ID'); $relatedContentId = $loopResultRow->get('ID');

View File

@@ -31,17 +31,12 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\CategoryQuery;
use Thelia\Model\Base\ProductCategoryQuery;
use Thelia\Model\Base\AttributeQuery; use Thelia\Model\Base\AttributeQuery;
use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
use Thelia\Model\ProductQuery; use Thelia\Model\ProductQuery;
use Thelia\Model\TemplateQuery; use Thelia\Model\TemplateQuery;
use Thelia\Model\AttributeTemplateQuery; use Thelia\Model\AttributeTemplateQuery;
use Thelia\Core\Translation\Translator;
use Thelia\Model\Map\AttributeTemplateTableMap; use Thelia\Model\Map\AttributeTemplateTableMap;
/** /**
* *
@@ -121,7 +116,7 @@ class Attribute extends BaseI18nLoop
// Create template array // Create template array
if ($template == null) $template = array(); if ($template == null) $template = array();
foreach($products as $product) { foreach ($products as $product) {
$tpl_id = $product->getTemplateId(); $tpl_id = $product->getTemplateId();
if (! is_null($tpl_id)) $template[] = $tpl_id; if (! is_null($tpl_id)) $template[] = $tpl_id;
@@ -138,8 +133,7 @@ class Attribute extends BaseI18nLoop
; ;
$use_attribute_pos = false; $use_attribute_pos = false;
} } elseif (null !== $exclude_template) {
else if (null !== $exclude_template) {
// Join with attribute_template table to get position // Join with attribute_template table to get position
$exclude_attributes = AttributeTemplateQuery::create()->filterByTemplateId($exclude_template)->select('attribute_id')->find(); $exclude_attributes = AttributeTemplateQuery::create()->filterByTemplateId($exclude_template)->select('attribute_id')->find();

View File

@@ -37,7 +37,6 @@ use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\Coupon as MCoupon; use Thelia\Model\Coupon as MCoupon;
use Thelia\Model\CouponQuery; use Thelia\Model\CouponQuery;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/** /**
* Created by JetBrains PhpStorm. * Created by JetBrains PhpStorm.

View File

@@ -57,9 +57,9 @@ class Delivery extends BaseSpecificModule
$search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL); $search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL);
$countryId = $this->getCountry(); $countryId = $this->getCountry();
if(null !== $countryId) { if (null !== $countryId) {
$country = CountryQuery::create()->findPk($countryId); $country = CountryQuery::create()->findPk($countryId);
if(null === $country) { if (null === $country) {
throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop'); throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop');
} }
} else { } else {

View File

@@ -265,8 +265,7 @@ class Document extends BaseI18nLoop
; ;
$loopResult->addRow($loopResultRow); $loopResult->addRow($loopResultRow);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Ignore the result and log an error // Ignore the result and log an error
Tlog::getInstance()->addError("Failed to process document in document loop: ", $this->args); Tlog::getInstance()->addError("Failed to process document in document loop: ", $this->args);
} }

View File

@@ -31,11 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\CategoryQuery;
use Thelia\Model\FeatureI18nQuery; use Thelia\Model\FeatureI18nQuery;
use Thelia\Model\ProductCategoryQuery;
use Thelia\Model\FeatureQuery; use Thelia\Model\FeatureQuery;
use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Model\ProductQuery; use Thelia\Model\ProductQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
@@ -124,7 +121,7 @@ class Feature extends BaseI18nLoop
// Create template array // Create template array
if ($template == null) $template = array(); if ($template == null) $template = array();
foreach($products as $product) { foreach ($products as $product) {
$tpl_id = $product->getTemplateId(); $tpl_id = $product->getTemplateId();
if (! is_null($tpl_id)) $template[] = $tpl_id; if (! is_null($tpl_id)) $template[] = $tpl_id;
@@ -164,7 +161,7 @@ class Feature extends BaseI18nLoop
->select('id') ->select('id')
->find(); ->find();
if($features) { if ($features) {
$search->filterById( $search->filterById(
$features, $features,
Criteria::IN Criteria::IN
@@ -204,7 +201,6 @@ class Feature extends BaseI18nLoop
} }
/* perform search */ /* perform search */
$features = $this->search($search, $pagination); $features = $this->search($search, $pagination);

View File

@@ -318,8 +318,7 @@ class Image extends BaseI18nLoop
; ;
$loopResult->addRow($loopResultRow); $loopResult->addRow($loopResultRow);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Ignore the result and log an error // Ignore the result and log an error
Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args); Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args);
} }

View File

@@ -103,7 +103,7 @@ class Module extends BaseI18nLoop
$active = $this->getActive(); $active = $this->getActive();
if($active !== Type\BooleanOrBothType::ANY) { if ($active !== Type\BooleanOrBothType::ANY) {
$search->filterByActivate($active ? 1 : 0, Criteria::EQUAL); $search->filterByActivate($active ? 1 : 0, Criteria::EQUAL);
} }

View File

@@ -31,10 +31,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\AddressQuery;
use Thelia\Model\OrderAddressQuery; use Thelia\Model\OrderAddressQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/** /**
* *

View File

@@ -31,13 +31,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Exception\TaxEngineException;
use Thelia\Model\Base\OrderProductQuery; use Thelia\Model\Base\OrderProductQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Map\OrderProductTableMap;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/** /**
* *
@@ -76,7 +70,6 @@ class OrderProduct extends BaseLoop
->withColumn('SUM(`opt`.PROMO_AMOUNT)', 'TOTAL_PROMO_TAX') ->withColumn('SUM(`opt`.PROMO_AMOUNT)', 'TOTAL_PROMO_TAX')
->groupById(); ->groupById();
$order = $this->getOrder(); $order = $this->getOrder();
$search->filterByOrderId($order, Criteria::EQUAL); $search->filterByOrderId($order, Criteria::EQUAL);

View File

@@ -32,8 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\OrderProductAttributeCombinationQuery; use Thelia\Model\Base\OrderProductAttributeCombinationQuery;
use Thelia\Model\Map\AttributeAvTableMap;
use Thelia\Model\Map\AttributeTableMap;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;

View File

@@ -25,7 +25,6 @@ namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Module\BaseModule; use Thelia\Module\BaseModule;
/** /**

View File

@@ -138,9 +138,9 @@ class Product extends BaseI18nLoop
public function exec(&$pagination) public function exec(&$pagination)
{ {
$currencyId = $this->getCurrency(); $currencyId = $this->getCurrency();
if(null !== $currencyId) { if (null !== $currencyId) {
$currency = CurrencyQuery::create()->findOneById($currencyId); $currency = CurrencyQuery::create()->findOneById($currencyId);
if(null === $currency) { if (null === $currency) {
throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop');
} }
} else { } else {
@@ -610,7 +610,7 @@ class Product extends BaseI18nLoop
$taxedPrice = $product->getTaxedPrice( $taxedPrice = $product->getTaxedPrice(
$taxCountry $taxCountry
); );
} catch(TaxEngineException $e) { } catch (TaxEngineException $e) {
$taxedPrice = null; $taxedPrice = null;
} }

View File

@@ -158,7 +158,7 @@ class ProductSaleElements extends BaseLoop
$taxedPrice = $PSEValue->getTaxedPrice( $taxedPrice = $PSEValue->getTaxedPrice(
$taxCountry $taxCountry
); );
} catch(TaxEngineException $e) { } catch (TaxEngineException $e) {
$taxedPrice = null; $taxedPrice = null;
} }
$promoPrice = $PSEValue->getPromoPrice(); $promoPrice = $PSEValue->getPromoPrice();
@@ -166,7 +166,7 @@ class ProductSaleElements extends BaseLoop
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice( $taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
$taxCountry $taxCountry
); );
} catch(TaxEngineException $e) { } catch (TaxEngineException $e) {
$taxedPromoPrice = null; $taxedPromoPrice = null;
} }

View File

@@ -132,4 +132,4 @@ class TaxRule extends BaseI18nLoop
return $loopResult; return $loopResult;
} }
} }

View File

@@ -31,13 +31,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\CategoryQuery;
use Thelia\Model\Base\ProductCategoryQuery;
use Thelia\Model\Base\TemplateQuery; use Thelia\Model\Base\TemplateQuery;
use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/** /**
* *
@@ -111,4 +106,4 @@ class Template extends BaseI18nLoop
return $loopResult; return $loopResult;
} }
} }

Some files were not shown because too many files have changed in this diff Show More