diff --git a/core/lib/Thelia/Action/Address.php b/core/lib/Thelia/Action/Address.php index d5e245b97..9e278d899 100644 --- a/core/lib/Thelia/Action/Address.php +++ b/core/lib/Thelia/Action/Address.php @@ -36,7 +36,7 @@ use Thelia\Model\Map\AddressTableMap; * @package Thelia\Action * @author Manuel Raynaud */ -class Address implements EventSubscriberInterface +class Address extends BaseAction implements EventSubscriberInterface { public function create(AddressCreateOrUpdateEvent $event) diff --git a/core/lib/Thelia/Action/Administrator.php b/core/lib/Thelia/Action/Administrator.php index bbd4e3336..77078df0b 100644 --- a/core/lib/Thelia/Action/Administrator.php +++ b/core/lib/Thelia/Action/Administrator.php @@ -30,7 +30,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Admin as AdminModel; use Thelia\Model\AdminQuery; -class Administrator implements EventSubscriberInterface +class Administrator extends BaseAction implements EventSubscriberInterface { /** * @param AdministratorEvent $event diff --git a/core/lib/Thelia/Action/Area.php b/core/lib/Thelia/Action/Area.php index 92eb75634..51d9ef04d 100644 --- a/core/lib/Thelia/Action/Area.php +++ b/core/lib/Thelia/Action/Area.php @@ -31,7 +31,7 @@ use Thelia\Core\Event\Area\AreaUpdatePostageEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\AreaQuery; use Thelia\Model\CountryQuery; -use Thelia\Action\BaseAction; + use Thelia\Model\Area as AreaModel; /** @@ -45,7 +45,7 @@ class Area extends BaseAction implements EventSubscriberInterface public function addCountry(AreaAddCountryEvent $event) { if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) { - $country->setDispatcher($this->getDispatcher()); + $country->setDispatcher($event->getDispatcher()); $country->setAreaId($event->getAreaId()) ->save(); @@ -56,7 +56,7 @@ class Area extends BaseAction implements EventSubscriberInterface public function removeCountry(AreaRemoveCountryEvent $event) { if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) { - $country->setDispatcher($this->getDispatcher()); + $country->setDispatcher($event->getDispatcher()); $country->setAreaId(null) ->save(); } @@ -65,7 +65,7 @@ class Area extends BaseAction implements EventSubscriberInterface public function updatePostage(AreaUpdatePostageEvent $event) { if (null !== $area = AreaQuery::create()->findPk($event->getAreaId())) { - $area->setDispatcher($this->getDispatcher()); + $area->setDispatcher($event->getDispatcher()); $area ->setPostage($event->getPostage()) ->save(); @@ -77,7 +77,7 @@ class Area extends BaseAction implements EventSubscriberInterface public function delete(AreaDeleteEvent $event) { if (null !== $area = AreaQuery::create()->findPk($event->getAreaId())) { - $area->setDispatcher($this->getDispatcher()); + $area->setDispatcher($event->getDispatcher()); $area->delete(); $event->setArea($area); @@ -89,7 +89,7 @@ class Area extends BaseAction implements EventSubscriberInterface $area = new AreaModel(); $area - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setName($event->getAreaName()) ->save(); diff --git a/core/lib/Thelia/Action/Attribute.php b/core/lib/Thelia/Action/Attribute.php index 4591c2ea5..5372f1ec7 100644 --- a/core/lib/Thelia/Action/Attribute.php +++ b/core/lib/Thelia/Action/Attribute.php @@ -51,7 +51,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface $attribute = new AttributeModel(); $attribute - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -78,7 +78,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface if (null !== $attribute = AttributeQuery::create()->findPk($event->getAttributeId())) { $attribute - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -103,7 +103,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) { $attribute - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; @@ -118,7 +118,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(AttributeQuery::create(), $event); + $this->genericUpdatePosition(AttributeQuery::create(), $event); } protected function doAddToAllTemplates(AttributeModel $attribute) diff --git a/core/lib/Thelia/Action/AttributeAv.php b/core/lib/Thelia/Action/AttributeAv.php index f5d320f03..5c3fdebc4 100644 --- a/core/lib/Thelia/Action/AttributeAv.php +++ b/core/lib/Thelia/Action/AttributeAv.php @@ -47,7 +47,7 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface $attribute = new AttributeAvModel(); $attribute - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setAttributeId($event->getAttributeId()) ->setLocale($event->getLocale()) @@ -70,7 +70,7 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId())) { $attribute - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -95,7 +95,7 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface if (null !== ($attribute = AttributeAvQuery::create()->findPk($event->getAttributeAvId()))) { $attribute - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; @@ -110,7 +110,7 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(AttributeAvQuery::create(), $event); + $this->genericUpdatePosition(AttributeAvQuery::create(), $event); } /** diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index c376a78b7..8da1e1ce5 100644 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -33,26 +33,6 @@ use Thelia\Form\Exception\FormValidationException; class BaseAction { - /** - * @var The container - */ - protected $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * Return the event dispatcher, - * - * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface - */ - public function getDispatcher() - { - return $this->container->get('event_dispatcher'); - } - /** * Changes object position, selecting absolute ou relative change. * @@ -65,16 +45,16 @@ class BaseAction { if (null !== $object = $query->findPk($event->getObjectId())) { - $object->setDispatcher($this->getDispatcher()); + $object->setDispatcher($event->getDispatcher()); $mode = $event->getMode(); if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $object->changeAbsolutePosition($event->getPosition()); + $object->changeAbsolutePosition($event->getPosition()); else if ($mode == UpdatePositionEvent::POSITION_UP) - return $object->movePositionUp(); + $object->movePositionUp(); else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $object->movePositionDown(); + $object->movePositionDown(); } } @@ -84,14 +64,15 @@ class BaseAction * @param ModelCriteria $query * @param UpdateSeoEvent $event * - * @return mixed + * @return mixed an SEOxxx object + * @throws FormValidationException if a rewritten URL cannot be created */ protected function genericUpdateSeo(ModelCriteria $query, UpdateSeoEvent $event) { if (null !== $object = $query->findPk($event->getObjectId())) { $object - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setMetaTitle($event->getMetaTitle()) @@ -109,9 +90,8 @@ class BaseAction } $event->setObject($object); - - return $object; } - } -} + return $object; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index dbaf3409b..25c2604c6 100644 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -23,7 +23,8 @@ namespace Thelia\Action; -use Symfony\Component\HttpFoundation\Request; + +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Cart\CartEvent; use Thelia\Core\Event\TheliaEvents; @@ -67,7 +68,7 @@ class Cart extends BaseAction implements EventSubscriberInterface ->findOne(); $event->setCartItem( - $this->doAddItem($cart, $productId, $productPrice->getProductSaleElements(), $quantity, $productPrice) + $this->doAddItem($event->getDispatcher(), $cart, $productId, $productPrice->getProductSaleElements(), $quantity, $productPrice) ); } @@ -130,7 +131,7 @@ class Cart extends BaseAction implements EventSubscriberInterface if ($cartItem) { $event->setCartItem( - $this->updateQuantity($cartItem, $quantity) + $this->updateQuantity($event->getDispatcher(), $cartItem, $quantity) ); } } @@ -174,9 +175,9 @@ class Cart extends BaseAction implements EventSubscriberInterface * * @return CartItem */ - protected function updateQuantity(CartItem $cartItem, $quantity) + protected function updateQuantity(EventDispatcherInterface $dispatcher, CartItem $cartItem, $quantity) { - $cartItem->setDisptacher($this->getDispatcher()); + $cartItem->setDisptacher($dispatcher); $cartItem->updateQuantity($quantity) ->save(); @@ -194,10 +195,10 @@ class Cart extends BaseAction implements EventSubscriberInterface * * @return CartItem */ - protected function doAddItem(\Thelia\Model\Cart $cart, $productId, \Thelia\Model\ProductSaleElements $productSaleElements, $quantity, ProductPrice $productPrice) + protected function doAddItem(EventDispatcherInterface $dispatcher, \Thelia\Model\Cart $cart, $productId, \Thelia\Model\ProductSaleElements $productSaleElements, $quantity, ProductPrice $productPrice) { $cartItem = new CartItem(); - $cartItem->setDisptacher($this->getDispatcher()); + $cartItem->setDisptacher($dispatcher); $cartItem ->setCart($cart) ->setProductId($productId) diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 9d895c7de..dfdeeb3b7 100644 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -53,12 +53,12 @@ class Category extends BaseAction implements EventSubscriberInterface $category = new CategoryModel(); $category - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) - ->setTitle($event->getTitle()) ->setParent($event->getParent()) ->setVisible($event->getVisible()) + ->setTitle($event->getTitle()) ->save() ; @@ -76,7 +76,7 @@ class Category extends BaseAction implements EventSubscriberInterface if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { $category - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -115,7 +115,7 @@ class Category extends BaseAction implements EventSubscriberInterface if (null !== $category = CategoryQuery::create()->findPk($event->getCategoryId())) { $category - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; @@ -133,7 +133,7 @@ class Category extends BaseAction implements EventSubscriberInterface $category = $event->getCategory(); $category - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setVisible($category->getVisible() ? false : true) ->save() ; @@ -146,7 +146,7 @@ class Category extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(CategoryQuery::create(), $event); + $this->genericUpdatePosition(CategoryQuery::create(), $event); } public function addContent(CategoryAddContentEvent $event) @@ -158,7 +158,7 @@ class Category extends BaseAction implements EventSubscriberInterface $content = new CategoryAssociatedContent(); $content - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setCategory($event->getCategory()) ->setContentId($event->getContentId()) ->save() @@ -175,7 +175,7 @@ class Category extends BaseAction implements EventSubscriberInterface if ($content !== null) { $content - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete(); } } diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php index b1c714a0e..377eb17f6 100644 --- a/core/lib/Thelia/Action/Config.php +++ b/core/lib/Thelia/Action/Config.php @@ -41,7 +41,7 @@ class Config extends BaseAction implements EventSubscriberInterface { $config = new ConfigModel(); - $config->setDispatcher($this->getDispatcher()) + $config->setDispatcher($event->getDispatcher()) ->setName($event->getEventName()) ->setValue($event->getValue()) ->setLocale($event->getLocale()) @@ -65,7 +65,7 @@ class Config extends BaseAction implements EventSubscriberInterface if ($event->getValue() !== $config->getValue()) { - $config->setDispatcher($this->getDispatcher())->setValue($event->getValue())->save(); + $config->setDispatcher($event->getDispatcher())->setValue($event->getValue())->save(); $event->setConfig($config); } @@ -82,7 +82,7 @@ class Config extends BaseAction implements EventSubscriberInterface if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) { - $config->setDispatcher($this->getDispatcher()) + $config->setDispatcher($event->getDispatcher()) ->setName($event->getEventName()) ->setValue($event->getValue()) ->setHidden($event->getHidden()) @@ -110,7 +110,7 @@ class Config extends BaseAction implements EventSubscriberInterface if (!$config->getSecured()) { - $config->setDispatcher($this->getDispatcher())->delete(); + $config->setDispatcher($event->getDispatcher())->delete(); $event->setConfig($config); } diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php index 986698220..98a094f7b 100644 --- a/core/lib/Thelia/Action/Content.php +++ b/core/lib/Thelia/Action/Content.php @@ -68,7 +68,7 @@ class Content extends BaseAction implements EventSubscriberInterface public function update(ContentUpdateEvent $event) { if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) { - $content->setDispatcher($this->getDispatcher()); + $content->setDispatcher($event->getDispatcher()); $content ->setVisible($event->getVisible()) @@ -100,21 +100,7 @@ class Content extends BaseAction implements EventSubscriberInterface public function updatePosition(UpdatePositionEvent $event) { - if (null !== $content = ContentQuery::create()->findPk($event->getObjectId())) { - $content->setDispatcher($this->getDispatcher()); - - switch ($event->getMode()) { - case UpdatePositionEvent::POSITION_ABSOLUTE: - $content->changeAbsolutePosition($event->getPosition()); - break; - case UpdatePositionEvent::POSITION_DOWN: - $content->movePositionDown(); - break; - case UpdatePositionEvent::POSITION_UP: - $content->movePositionUp(); - break; - } - } + $this->genericUpdatePosition(ContentQuery::create(), $event); } public function toggleVisibility(ContentToggleVisibilityEvent $event) @@ -122,7 +108,7 @@ class Content extends BaseAction implements EventSubscriberInterface $content = $event->getContent(); $content - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setVisible(!$content->getVisible()) ->save(); @@ -135,7 +121,7 @@ class Content extends BaseAction implements EventSubscriberInterface if (null !== $content = ContentQuery::create()->findPk($event->getContentId())) { $defaultFolderId = $content->getDefaultFolderId(); - $content->setDispatcher($this->getDispatcher()) + $content->setDispatcher($event->getDispatcher()) ->delete(); $event->setDefaultFolderId($defaultFolderId); diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 8751dae3b..088185168 100644 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -23,6 +23,8 @@ namespace Thelia\Action; +use Propel\Runtime\ServiceContainer\ServiceContainerInterface; +use Symfony\Component\DependencyInjection\Container; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Condition\ConditionFactory; use Thelia\Condition\Implementation\ConditionInterface; @@ -49,6 +51,34 @@ use Thelia\Model\OrderCoupon; class Coupon extends BaseAction implements EventSubscriberInterface { /** + * @var \Thelia\Core\HttpFoundation\Request + */ + protected $request; + + /** @var CouponFactory $couponFactory */ + protected $couponFactory; + + /** @var CouponManager $couponManager */ + protected $couponManager; + + /** @var ConditionInterface $noConditionRule */ + protected $noConditionRule; + + /** @var ConditionFactory $conditionFactory */ + protected $conditionFactory; + + public function __construct(Request $request, + CouponFactory $couponFactory, CouponManager $couponManager, + ConditionInterface $noConditionRule, ConditionFactory $conditionFactory) + { + $this->request = $request; + $this->couponFactory = $couponFactory; + $this->couponManager = $couponManager; + $this->noConditionRule = $noConditionRule; + $this->conditionFactory = $conditionFactory; + } + + /** * Occurring when a Coupon is about to be created * * @param CouponCreateOrUpdateEvent $event Event creation or update Coupon @@ -94,21 +124,13 @@ class Coupon extends BaseAction implements EventSubscriberInterface $totalDiscount = 0; $isValid = false; - /** @var CouponFactory $couponFactory */ - $couponFactory = $this->container->get('thelia.coupon.factory'); - - /** @var CouponManager $couponManager */ - $couponManager = $this->container->get('thelia.coupon.manager'); - /** @var CouponInterface $coupon */ - $coupon = $couponFactory->buildCouponFromCode($event->getCode()); + $coupon = $this->couponFactory->buildCouponFromCode($event->getCode()); if ($coupon) { $isValid = $coupon->isMatching(); if ($isValid) { - /** @var Request $request */ - $request = $this->container->get('request'); - $consumedCoupons = $request->getSession()->getConsumedCoupons(); + $consumedCoupons = $this->request->getSession()->getConsumedCoupons(); if (!isset($consumedCoupons) || !$consumedCoupons) { $consumedCoupons = array(); @@ -117,16 +139,16 @@ class Coupon extends BaseAction implements EventSubscriberInterface // Prevent accumulation of the same Coupon on a Checkout $consumedCoupons[$event->getCode()] = $event->getCode(); - $request->getSession()->setConsumedCoupons($consumedCoupons); + $this->request->getSession()->setConsumedCoupons($consumedCoupons); - $totalDiscount = $couponManager->getDiscount(); + $totalDiscount = $this->couponManager->getDiscount(); - $request + $this->request ->getSession() ->getCart() ->setDiscount($totalDiscount) ->save(); - $request + $this->request ->getSession() ->getOrder() ->setDiscount($totalDiscount) @@ -148,13 +170,13 @@ class Coupon extends BaseAction implements EventSubscriberInterface */ protected function createOrUpdate(CouponModel $coupon, CouponCreateOrUpdateEvent $event) { - $coupon->setDispatcher($this->getDispatcher()); + $coupon->setDispatcher($event->getDispatcher()); // Set default condition if none found /** @var ConditionInterface $noConditionRule */ - $noConditionRule = $this->container->get('thelia.condition.match_for_everyone'); + $noConditionRule = $this->getContainer()->get('thelia.condition.match_for_everyone'); /** @var ConditionFactory $conditionFactory */ - $conditionFactory = $this->container->get('thelia.condition.factory'); + $conditionFactory = $this->getContainer()->get('thelia.condition.factory'); $couponRuleCollection = new ConditionCollection(); $couponRuleCollection[] = $noConditionRule; $defaultSerializedRule = $conditionFactory->serializeConditionCollection( @@ -190,10 +212,10 @@ class Coupon extends BaseAction implements EventSubscriberInterface */ protected function createOrUpdateCondition(CouponModel $coupon, CouponCreateOrUpdateEvent $event) { - $coupon->setDispatcher($this->getDispatcher()); + $coupon->setDispatcher($event->getDispatcher()); /** @var ConditionFactory $conditionFactory */ - $conditionFactory = $this->container->get('thelia.condition.factory'); + $conditionFactory = $this->getContainer()->get('thelia.condition.factory'); $coupon->createOrUpdateConditions( $conditionFactory->serializeConditionCollection($event->getConditions()), @@ -208,10 +230,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface */ public function testFreePostage(OrderEvent $event) { - /** @var CouponManager $couponManager */ - $couponManager = $this->container->get('thelia.coupon.manager'); - - if ($couponManager->isCouponRemovingPostage()) { + if ($this->couponManager->isCouponRemovingPostage()) { $order = $event->getOrder(); $order->setPostage(0); @@ -227,21 +246,16 @@ class Coupon extends BaseAction implements EventSubscriberInterface */ public function afterOrder(OrderEvent $event) { - $request = $this->container->get('request'); - - /** @var CouponManager $couponManager */ - $couponManager = $this->container->get('thelia.coupon.manager'); - - $consumedCoupons = $request->getSession()->getConsumedCoupons(); + $consumedCoupons = $this->request->getSession()->getConsumedCoupons(); if (is_array($consumedCoupons)) { foreach ($consumedCoupons as $couponCode) { $couponQuery = CouponQuery::create(); $couponModel = $couponQuery->findOneByCode($couponCode); - $couponModel->setLocale($request->getSession()->getLang()->getLocale()); + $couponModel->setLocale($this->request->getSession()->getLang()->getLocale()); /* decrease coupon quantity */ - $couponManager->decrementQuantity($couponModel); + $this->couponManager->decrementQuantity($couponModel); /* memorize coupon */ $orderCoupon = new OrderCoupon(); @@ -264,7 +278,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface } } - $request->getSession()->setConsumedCoupons(array()); + $this->request->getSession()->setConsumedCoupons(array()); } /** diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 92ce23f99..5e391c2bc 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -23,6 +23,7 @@ namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Model\CurrencyQuery; @@ -48,7 +49,7 @@ class Currency extends BaseAction implements EventSubscriberInterface $currency = new CurrencyModel(); $currency - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setName($event->getCurrencyName()) @@ -74,7 +75,7 @@ class Currency extends BaseAction implements EventSubscriberInterface if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) { $currency - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setName($event->getCurrencyName()) @@ -104,7 +105,7 @@ class Currency extends BaseAction implements EventSubscriberInterface CurrencyQuery::create()->filterByByDefault(true)->update(array('ByDefault' => false)); $currency - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setByDefault($event->getIsDefault()) ->save() ; @@ -125,7 +126,7 @@ class Currency extends BaseAction implements EventSubscriberInterface if (null !== ($currency = CurrencyQuery::create()->findPk($event->getCurrencyId()))) { $currency - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; @@ -133,7 +134,7 @@ class Currency extends BaseAction implements EventSubscriberInterface } } - public function updateRates() + public function updateRates(EventDispatcherInterface $dispatcher) { $rates_url = ConfigQuery::read('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml'); @@ -147,7 +148,7 @@ class Currency extends BaseAction implements EventSubscriberInterface if (null !== $currency = CurrencyQuery::create()->findOneByCode($code)) { $currency - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($dispatcher) ->setRate($rate) ->save() ; @@ -165,7 +166,7 @@ class Currency extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(CurrencyQuery::create(), $event); + $this->genericUpdatePosition(CurrencyQuery::create(), $event); } /** diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 84dc8f97f..d02f895d4 100644 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -40,7 +40,7 @@ use Thelia\Core\Event\Customer\CustomerLoginEvent; * @package Thelia\Action * @author Manuel Raynaud */ -class Customer implements EventSubscriberInterface +class Customer extends BaseAction implements EventSubscriberInterface { protected $securityContext; @@ -143,7 +143,7 @@ class Customer implements EventSubscriberInterface /** * Return the security context * - * @return Thelia\Core\Security\SecurityContext + * @return \Thelia\Core\Security\SecurityContext */ protected function getSecurityContext() { diff --git a/core/lib/Thelia/Action/Document.php b/core/lib/Thelia/Action/Document.php index 0e3b4a854..4605ee7c9 100644 --- a/core/lib/Thelia/Action/Document.php +++ b/core/lib/Thelia/Action/Document.php @@ -34,7 +34,6 @@ use Thelia\Model\ConfigQuery; use Thelia\Tools\FileManager; use Thelia\Tools\URL; -use Imagine\Document\Color; use Thelia\Exception\DocumentException; use Thelia\Core\Event\TheliaEvents; @@ -53,19 +52,6 @@ use Thelia\Core\Event\TheliaEvents; * A copy (or symbolic link, by default) of the original document is always created in the cache, so that the full * resolution document is always available. * - * Various document processing options are available : - * - * - resizing, with border, crop, or by keeping document aspect ratio - * - rotation, in degrees, positive or negative - * - background color, applyed to empty background when creating borders or rotating - * - effects. The effects are applied in the specified order. The following effects are available: - * - gamma:value : change the document Gamma to the specified value. Example: gamma:0.7 - * - grayscale or greyscale: switch document to grayscale - * - colorize:color : apply a color mask to the document. Exemple: colorize:#ff2244 - * - negative : transform the document in its negative equivalent - * - vflip or vertical_flip : vertical flip - * - hflip or horizontal_flip : horizontal flip - * * If a problem occurs, an DocumentException may be thrown. * * @package Thelia\Action @@ -198,7 +184,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface public function updatePosition(UpdateFilePositionEvent $event) { - return $this->genericUpdatePosition($event->getQuery(), $event); + $this->genericUpdatePosition($event->getQuery(), $event); } /** diff --git a/core/lib/Thelia/Action/Feature.php b/core/lib/Thelia/Action/Feature.php index e46239695..f2cda8e24 100644 --- a/core/lib/Thelia/Action/Feature.php +++ b/core/lib/Thelia/Action/Feature.php @@ -51,7 +51,7 @@ class Feature extends BaseAction implements EventSubscriberInterface $feature = new FeatureModel(); $feature - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -78,7 +78,7 @@ class Feature extends BaseAction implements EventSubscriberInterface if (null !== $feature = FeatureQuery::create()->findPk($event->getFeatureId())) { $feature - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -103,7 +103,7 @@ class Feature extends BaseAction implements EventSubscriberInterface if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) { $feature - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; @@ -114,11 +114,11 @@ class Feature extends BaseAction implements EventSubscriberInterface /** * Changes position, selecting absolute ou relative change. * - * @param CategoryChangePositionEvent $event + * @param UpdatePositionEvent $event */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(FeatureQuery::create(), $event); + $this->genericUpdatePosition(FeatureQuery::create(), $event); } protected function doAddToAllTemplates(FeatureModel $feature) diff --git a/core/lib/Thelia/Action/FeatureAv.php b/core/lib/Thelia/Action/FeatureAv.php index b88c97324..9a97c871b 100644 --- a/core/lib/Thelia/Action/FeatureAv.php +++ b/core/lib/Thelia/Action/FeatureAv.php @@ -47,7 +47,7 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface $feature = new FeatureAvModel(); $feature - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setFeatureId($event->getFeatureId()) ->setLocale($event->getLocale()) @@ -70,7 +70,7 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface if (null !== $feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId())) { $feature - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -95,7 +95,7 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface if (null !== ($feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId()))) { $feature - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; @@ -106,11 +106,11 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface /** * Changes position, selecting absolute ou relative change. * - * @param CategoryChangePositionEvent $event + * @param UpdatePositionEvent $event */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(FeatureAvQuery::create(), $event); + $this->genericUpdatePosition(FeatureAvQuery::create(), $event); } /** diff --git a/core/lib/Thelia/Action/Folder.php b/core/lib/Thelia/Action/Folder.php index 2eece4095..7483c08b6 100644 --- a/core/lib/Thelia/Action/Folder.php +++ b/core/lib/Thelia/Action/Folder.php @@ -44,7 +44,7 @@ class Folder extends BaseAction implements EventSubscriberInterface { if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { - $folder->setDispatcher($this->getDispatcher()); + $folder->setDispatcher($event->getDispatcher()); $folder ->setParent($event->getParent()) @@ -76,7 +76,7 @@ class Folder extends BaseAction implements EventSubscriberInterface public function delete(FolderDeleteEvent $event) { if (null !== $folder = FolderQuery::create()->findPk($event->getFolderId())) { - $folder->setDispatcher($this->getDispatcher()) + $folder->setDispatcher($event->getDispatcher()) ->delete(); $event->setFolder($folder); @@ -89,7 +89,7 @@ class Folder extends BaseAction implements EventSubscriberInterface public function create(FolderCreateEvent $event) { $folder = new FolderModel(); - $folder->setDispatcher($this->getDispatcher()); + $folder->setDispatcher($event->getDispatcher()); $folder ->setParent($event->getParent()) @@ -106,7 +106,7 @@ class Folder extends BaseAction implements EventSubscriberInterface $folder = $event->getFolder(); $folder - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setVisible(!$folder->getVisible()) ->save(); @@ -117,7 +117,7 @@ class Folder extends BaseAction implements EventSubscriberInterface public function updatePosition(UpdatePositionEvent $event) { if (null !== $folder = FolderQuery::create()->findPk($event->getObjectId())) { - $folder->setDispatcher($this->getDispatcher()); + $folder->setDispatcher($event->getDispatcher()); switch ($event->getMode()) { case UpdatePositionEvent::POSITION_ABSOLUTE: diff --git a/core/lib/Thelia/Action/HttpException.php b/core/lib/Thelia/Action/HttpException.php index b875eb49b..ad1df93ab 100644 --- a/core/lib/Thelia/Action/HttpException.php +++ b/core/lib/Thelia/Action/HttpException.php @@ -29,6 +29,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\KernelEvents; +use Thelia\Core\Template\ParserInterface; use Thelia\Model\ConfigQuery; use Thelia\Core\Template\TemplateHelper; @@ -40,6 +41,16 @@ use Thelia\Core\Template\TemplateHelper; */ class HttpException extends BaseAction implements EventSubscriberInterface { + /** + * @var ParserInterface + */ + protected $parser; + + public function __construct(ParserInterface $parser) + { + $this->parser = $parser; + } + public function checkHttpException(GetResponseForExceptionEvent $event) { if ($event->getException() instanceof NotFoundHttpException) { @@ -53,14 +64,12 @@ class HttpException extends BaseAction implements EventSubscriberInterface protected function display404(GetResponseForExceptionEvent $event) { - $parser = $this->container->get("thelia.parser"); - // Define the template thant shoud be used - $parser->setTemplateDefinition(TemplateHelper::getInstance()->getActiveFrontTemplate()); + $this->parser->setTemplateDefinition(TemplateHelper::getInstance()->getActiveFrontTemplate()); //$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView()); - $response = new Response($parser->render(ConfigQuery::getPageNotFoundView()), 404); + $response = new Response($this->parser->render(ConfigQuery::getPageNotFoundView()), 404); $event->setResponse($response); } diff --git a/core/lib/Thelia/Action/Image.php b/core/lib/Thelia/Action/Image.php index 7272f9579..7b5ef0138 100644 --- a/core/lib/Thelia/Action/Image.php +++ b/core/lib/Thelia/Action/Image.php @@ -304,7 +304,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface public function updatePosition(UpdateFilePositionEvent $event) { - return $this->genericUpdatePosition($event->getQuery(), $event); + $this->genericUpdatePosition($event->getQuery(), $event); } /** @@ -416,7 +416,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface /** * Create a new Imagine object using current driver configuration * - * @return \Imagine\ImagineInterface + * @return ImagineInterface */ protected function createImagineInstance() { diff --git a/core/lib/Thelia/Action/Lang.php b/core/lib/Thelia/Action/Lang.php index 3acb62b29..20fde397a 100644 --- a/core/lib/Thelia/Action/Lang.php +++ b/core/lib/Thelia/Action/Lang.php @@ -45,7 +45,7 @@ class Lang extends BaseAction implements EventSubscriberInterface public function update(LangUpdateEvent $event) { if (null !== $lang = LangQuery::create()->findPk($event->getId())) { - $lang->setDispatcher($this->getDispatcher()); + $lang->setDispatcher($event->getDispatcher()); $lang->setTitle($event->getTitle()) ->setLocale($event->getLocale()) @@ -61,7 +61,7 @@ class Lang extends BaseAction implements EventSubscriberInterface public function toggleDefault(LangToggleDefaultEvent $event) { if (null !== $lang = LangQuery::create()->findPk($event->getLangId())) { - $lang->setDispatcher($this->getDispatcher()); + $lang->setDispatcher($event->getDispatcher()); $lang->toggleDefault(); @@ -74,7 +74,7 @@ class Lang extends BaseAction implements EventSubscriberInterface $lang = new LangModel(); $lang - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setTitle($event->getTitle()) ->setCode($event->getCode()) ->setLocale($event->getLocale()) @@ -88,7 +88,7 @@ class Lang extends BaseAction implements EventSubscriberInterface public function delete(LangDeleteEvent $event) { if (null !== $lang = LangQuery::create()->findPk($event->getLangId())) { - $lang->setDispatcher($this->getDispatcher()) + $lang->setDispatcher($event->getDispatcher()) ->delete(); $event->setLang($lang); diff --git a/core/lib/Thelia/Action/Message.php b/core/lib/Thelia/Action/Message.php index 045769e58..de9de9cbb 100644 --- a/core/lib/Thelia/Action/Message.php +++ b/core/lib/Thelia/Action/Message.php @@ -46,7 +46,7 @@ class Message extends BaseAction implements EventSubscriberInterface $message = new MessageModel(); $message - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setName($event->getMessageName()) @@ -72,7 +72,7 @@ class Message extends BaseAction implements EventSubscriberInterface if (null !== $message = MessageQuery::create()->findPk($event->getMessageId())) { $message - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setName($event->getMessageName()) ->setSecured($event->getSecured()) @@ -107,7 +107,7 @@ class Message extends BaseAction implements EventSubscriberInterface if (null !== ($message = MessageQuery::create()->findPk($event->getMessageId()))) { $message - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 5ce36c459..4468c7bce 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -23,12 +23,15 @@ namespace Thelia\Action; use Propel\Runtime\Propel; +use Propel\Runtime\ServiceContainer\ServiceContainerInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Filesystem\Filesystem; use Thelia\Core\Event\Cache\CacheEvent; use Thelia\Core\Event\Module\ModuleDeleteEvent; use Thelia\Core\Event\Module\ModuleEvent; use Thelia\Core\Event\Module\ModuleToggleActivationEvent; +use Thelia\Core\Event\Module\OrderPaymentEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Map\ModuleTableMap; use Thelia\Model\ModuleQuery; @@ -44,6 +47,15 @@ use Thelia\Core\Translation\Translator; */ class Module extends BaseAction implements EventSubscriberInterface { + /** + * @var \Propel\Runtime\ServiceContainer\ServiceContainerInterface + */ + protected $container; + + public function __construct(ServiceContainerInterface $container) + { + $this->container = $container; + } public function toggleActivation(ModuleToggleActivationEvent $event) { @@ -53,7 +65,7 @@ class Module extends BaseAction implements EventSubscriberInterface $moduleInstance = $moduleClass->newInstance(); if ( method_exists($moduleInstance, 'setContainer')) { - $moduleInstance->setContainer($this->container); + $moduleInstance->setContainer($this->getContainer()); if ($module->getActivate() == BaseModule::IS_ACTIVATED) { $moduleInstance->deActivate($module); } else { @@ -63,7 +75,7 @@ class Module extends BaseAction implements EventSubscriberInterface $event->setModule($module); - $this->cacheClear(); + $this->cacheClear($event->getDispatcher()); } } @@ -86,7 +98,7 @@ class Module extends BaseAction implements EventSubscriberInterface $reflected = new \ReflectionClass($module->getFullNamespace()); $instance = $reflected->newInstance(); - $instance->setContainer($this->container); + $instance->setContainer($this->getContainer()); $path = dirname($reflected->getFileName()); @@ -108,7 +120,7 @@ class Module extends BaseAction implements EventSubscriberInterface $con->commit(); $event->setModule($module); - $this->cacheClear(); + $this->cacheClear($event->getDispatcher()); } catch (\Exception $e) { $con->rollBack(); @@ -125,7 +137,7 @@ class Module extends BaseAction implements EventSubscriberInterface if (null !== $module = ModuleQuery::create()->findPk($event->getId())) { $module - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) ->setChapo($event->getChapo()) @@ -139,21 +151,51 @@ class Module extends BaseAction implements EventSubscriberInterface } } + /** + * Call the payment method of the payment module of the given order + * + * @param OrderPaymentEvent $event + * @throws \RuntimeException if no payment module can be found. + */ + public function pay(OrderPaymentEvent $event) { + + $order = $event->getOrder(); + + /* call pay method */ + if (null === $paymentModule = ModuleQuery::create()->findPk($order->getPaymentModuleId())) { + throw new \RuntimeException( + Translator::getInstance()->trans( + "Failed to find a payment Module with ID=%mid for order ID=%oid", + array( + "%mid" => $order->getPaymentModuleId(), + "%oid" => $order->getId() + )) + ); + } + + $paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode())); + + $paymentModuleInstance->pay($order); + } + /** * Changes position, selecting absolute ou relative change. * - * @param CategoryChangePositionEvent $event + * @param UpdatePositionEvent $event */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(ModuleQuery::create(), $event); + $this->genericUpdatePosition(ModuleQuery::create(), $event); } - protected function cacheClear() + protected function cacheClear(EventDispatcherInterface $dispatcher) { - $cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir')); + $cacheEvent = new CacheEvent( + $dispatcher, + $this->getContainer()->getParameter('kernel.cache_dir') + ); - $this->getDispatcher()->dispatch(TheliaEvents::CACHE_CLEAR, $cacheEvent); + $dispatcher->dispatch(TheliaEvents::CACHE_CLEAR, $cacheEvent); } /** @@ -183,6 +225,7 @@ class Module extends BaseAction implements EventSubscriberInterface TheliaEvents::MODULE_UPDATE_POSITION => array('updatePosition', 128), TheliaEvents::MODULE_DELETE => array('delete', 128), TheliaEvents::MODULE_UPDATE => array('update', 128), + TheliaEvents::MODULE_PAY => array('pay', 128), ); } } diff --git a/core/lib/Thelia/Action/Newsletter.php b/core/lib/Thelia/Action/Newsletter.php index aeb26f3d6..4130dd00b 100644 --- a/core/lib/Thelia/Action/Newsletter.php +++ b/core/lib/Thelia/Action/Newsletter.php @@ -25,7 +25,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Newsletter\NewsletterEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Action\BaseAction; + use Thelia\Model\NewsletterQuery; use Thelia\Model\Newsletter as NewsletterModel; diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 000e5b2c3..d217bfbf8 100644 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -23,14 +23,20 @@ namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Cart\CartTrait; use Thelia\Core\Event\Cart\CartEvent; +use Thelia\Core\Event\Module\OrderPaymentEvent; use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\Order\OrderManualEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\Security\SecurityContext; +use Thelia\Core\Template\ParserInterface; use Thelia\Exception\TheliaProcessException; +use Thelia\Mailer\MailerFactory; use Thelia\Model\AddressQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\ConfigQuery; @@ -39,7 +45,6 @@ use Thelia\Model\Customer as CustomerModel; use Thelia\Model\Lang; use Thelia\Model\Map\OrderTableMap; use Thelia\Model\MessageQuery; -use Thelia\Model\ModuleQuery; use Thelia\Model\Order as ModelOrder; use Thelia\Model\OrderAddress; use Thelia\Model\OrderProduct; @@ -58,6 +63,31 @@ class Order extends BaseAction implements EventSubscriberInterface { use CartTrait; + /** + * @var \Thelia\Core\HttpFoundation\Request + */ + protected $request; + /** + * @var MailerFactory + */ + protected $mailer; + /** + * @var ParserInterface + */ + protected $parser; + /** + * @var SecurityContext + */ + protected $securityContext; + + public function __construct(Request $request, ParserInterface $parser, MailerFactory $mailer, SecurityContext $securityContext) + { + $this->request = $request; + $this->parser = $parser; + $this->mailer = $mailer; + $this->securityContext = $securityContext; + } + /** * @param \Thelia\Core\Event\Order\OrderEvent $event */ @@ -118,7 +148,7 @@ class Order extends BaseAction implements EventSubscriberInterface $event->setOrder($order); } - protected function createOrder(ModelOrder $sessionOrder, Currency $currency, Lang $lang, CartModel $cart, CustomerModel $customer) + protected function createOrder(EventDispatcherInterface $dispatcher, ModelOrder $sessionOrder, Currency $currency, Lang $lang, CartModel $cart, CustomerModel $customer) { $con = \Propel\Runtime\Propel::getConnection( OrderTableMap::DATABASE_NAME @@ -128,7 +158,7 @@ class Order extends BaseAction implements EventSubscriberInterface /* use a copy to avoid errored record in session */ $placedOrder = $sessionOrder->copy(); - $placedOrder->setDispatcher($this->getDispatcher()); + $placedOrder->setDispatcher($dispatcher); $deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress); $taxCountry = $deliveryAddress->getCountry(); @@ -238,7 +268,7 @@ class Order extends BaseAction implements EventSubscriberInterface ->setTaxRuleTitle($taxRuleI18n->getTitle()) ->setTaxRuleDescription($taxRuleI18n->getDescription()) ->setEanCode($pse->getEanCode()) - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($dispatcher) ->save($con) ; @@ -279,6 +309,7 @@ class Order extends BaseAction implements EventSubscriberInterface public function createManual(OrderManualEvent $event) { $placedOrder = $this->createOrder( + $event->getDispatcher(), $event->getOrder(), $event->getCurrency(), $event->getLang(), @@ -297,14 +328,15 @@ class Order extends BaseAction implements EventSubscriberInterface $session = $this->getSession(); $placedOrder = $this->createOrder( + $event->getDispatcher(), $event->getOrder(), $session->getCurrency(), $session->getLang(), $session->getCart(), - $this->getSecurityContext()->getCustomerUser() + $this->securityContext->getCustomerUser() ); - $this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); + $event->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); /* clear session */ $session @@ -317,14 +349,16 @@ class Order extends BaseAction implements EventSubscriberInterface $event->setPlacedOrder($placedOrder); /* empty cart */ - $this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest()))); + $dispatcher = $event->getDispatcher(); + + $dispatcher->dispatch( + TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($dispatcher, $this->request))); + /* call pay method */ + $payEvent = new OrderPaymentEvent($placedOrder); - $paymentModule = ModuleQuery::create()->findPk($placedOrder->getPaymentModuleId()); - - $paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode())); - $paymentModuleInstance->pay($placedOrder); + $dispatcher->dispatch(TheliaEvents::MODULE_PAY, $payEvent); } /** @@ -347,10 +381,8 @@ class Order extends BaseAction implements EventSubscriberInterface $order = $event->getOrder(); $customer = $order->getCustomer(); - $parser = $this->container->get("thelia.parser"); - - $parser->assign('order_id', $order->getId()); - $parser->assign('order_ref', $order->getRef()); + $this->parser->assign('order_id', $order->getId()); + $this->parser->assign('order_ref', $order->getRef()); $message ->setLocale($order->getLang()->getLocale()); @@ -361,7 +393,7 @@ class Order extends BaseAction implements EventSubscriberInterface ; // Build subject and body - $message->build($parser, $instance); + $message->build($this->parser, $instance); $this->getMailer()->send($instance); } @@ -375,9 +407,7 @@ class Order extends BaseAction implements EventSubscriberInterface */ public function getMailer() { - $mailer = $this->container->get('mailer'); - - return $mailer->getSwiftMailer(); + return $this->mailer->getSwiftMailer(); } /** @@ -468,24 +498,6 @@ class Order extends BaseAction implements EventSubscriberInterface ); } - /** - * Return the security context - * - * @return SecurityContext - */ - protected function getSecurityContext() - { - return $this->container->get('thelia.securityContext'); - } - - /** - * @return \Symfony\Component\HttpFoundation\Request - */ - protected function getRequest() - { - return $this->container->get('request'); - } - /** * Returns the session from the current request * @@ -493,8 +505,6 @@ class Order extends BaseAction implements EventSubscriberInterface */ protected function getSession() { - $request = $this->getRequest(); - - return $request->getSession(); + return $this->request->getSession(); } } diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index a2c24a163..dd01265e9 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -70,7 +70,7 @@ class Product extends BaseAction implements EventSubscriberInterface $product = new ProductModel(); $product - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setRef($event->getRef()) ->setTitle($event->getTitle()) @@ -102,7 +102,7 @@ class Product extends BaseAction implements EventSubscriberInterface if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { $product - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -141,7 +141,7 @@ class Product extends BaseAction implements EventSubscriberInterface if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { $product - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; @@ -159,7 +159,7 @@ class Product extends BaseAction implements EventSubscriberInterface $product = $event->getProduct(); $product - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setVisible($product->getVisible() ? false : true) ->save() ; @@ -172,7 +172,7 @@ class Product extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - return $this->genericUpdatePosition(ProductQuery::create(), $event); + $this->genericUpdatePosition(ProductQuery::create(), $event); } public function addContent(ProductAddContentEvent $event) @@ -184,7 +184,7 @@ class Product extends BaseAction implements EventSubscriberInterface $content = new ProductAssociatedContent(); $content - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setProduct($event->getProduct()) ->setContentId($event->getContentId()) ->save() @@ -201,7 +201,7 @@ class Product extends BaseAction implements EventSubscriberInterface if ($content !== null) $content - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; } @@ -243,7 +243,7 @@ class Product extends BaseAction implements EventSubscriberInterface $accessory = new Accessory(); $accessory - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setProductId($event->getProduct()->getId()) ->setAccessory($event->getAccessoryId()) ->save() @@ -260,7 +260,7 @@ class Product extends BaseAction implements EventSubscriberInterface if ($accessory !== null) $accessory - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; } @@ -353,7 +353,7 @@ class Product extends BaseAction implements EventSubscriberInterface $featureProduct = new FeatureProduct(); $featureProduct - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setProductId($event->getProductId()) ->setFeatureId($event->getFeatureId()) diff --git a/core/lib/Thelia/Action/ProductSaleElement.php b/core/lib/Thelia/Action/ProductSaleElement.php index bfe2d5bb1..56d033419 100644 --- a/core/lib/Thelia/Action/ProductSaleElement.php +++ b/core/lib/Thelia/Action/ProductSaleElement.php @@ -37,7 +37,7 @@ use Thelia\Core\Event\ProductSaleElement\ProductSaleElementUpdateEvent; use Thelia\Model\ProductPriceQuery; use Propel\Runtime\Propel; use Thelia\Model\AttributeAvQuery; -use Thelia\Model\Currency; + use Thelia\Model\Map\AttributeCombinationTableMap; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Event\Product\ProductCombinationGenerationEvent; diff --git a/core/lib/Thelia/Action/Profile.php b/core/lib/Thelia/Action/Profile.php index a35a0d250..c264b1439 100644 --- a/core/lib/Thelia/Action/Profile.php +++ b/core/lib/Thelia/Action/Profile.php @@ -46,7 +46,7 @@ class Profile extends BaseAction implements EventSubscriberInterface $profile = new ProfileModel(); $profile - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setCode($event->getCode()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) @@ -68,7 +68,7 @@ class Profile extends BaseAction implements EventSubscriberInterface if (null !== $profile = ProfileQuery::create()->findPk($event->getId())) { $profile - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) ->setChapo($event->getChapo()) diff --git a/core/lib/Thelia/Action/Tax.php b/core/lib/Thelia/Action/Tax.php index 5189bf9db..87c78fe6e 100644 --- a/core/lib/Thelia/Action/Tax.php +++ b/core/lib/Thelia/Action/Tax.php @@ -39,7 +39,7 @@ class Tax extends BaseAction implements EventSubscriberInterface $tax = new TaxModel(); $tax - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setRequirements($event->getRequirements()) ->setType($event->getType()) ->setLocale($event->getLocale()) @@ -60,7 +60,7 @@ class Tax extends BaseAction implements EventSubscriberInterface if (null !== $tax = TaxQuery::create()->findPk($event->getId())) { $tax - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setRequirements($event->getRequirements()) ->setType($event->getType()) ->setLocale($event->getLocale()) diff --git a/core/lib/Thelia/Action/TaxRule.php b/core/lib/Thelia/Action/TaxRule.php index a5368a400..992a8d1a1 100644 --- a/core/lib/Thelia/Action/TaxRule.php +++ b/core/lib/Thelia/Action/TaxRule.php @@ -42,7 +42,7 @@ class TaxRule extends BaseAction implements EventSubscriberInterface $taxRule = new TaxRuleModel(); $taxRule - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) ->setDescription($event->getDescription()) @@ -61,7 +61,7 @@ class TaxRule extends BaseAction implements EventSubscriberInterface if (null !== $taxRule = TaxRuleQuery::create()->findPk($event->getId())) { $taxRule - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) ->setDescription($event->getDescription()) diff --git a/core/lib/Thelia/Action/Template.php b/core/lib/Thelia/Action/Template.php index cce146ec3..16493e94c 100644 --- a/core/lib/Thelia/Action/Template.php +++ b/core/lib/Thelia/Action/Template.php @@ -56,7 +56,7 @@ class Template extends BaseAction implements EventSubscriberInterface $template = new TemplateModel(); $template - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setName($event->getTemplateName()) @@ -78,7 +78,7 @@ class Template extends BaseAction implements EventSubscriberInterface if (null !== $template = TemplateQuery::create()->findPk($event->getTemplateId())) { $template - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->setLocale($event->getLocale()) ->setName($event->getTemplateName()) @@ -102,7 +102,7 @@ class Template extends BaseAction implements EventSubscriberInterface if ($product_count <= 0) { $template - ->setDispatcher($this->getDispatcher()) + ->setDispatcher($event->getDispatcher()) ->delete() ; } diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php index 116a26da9..e7c946a67 100644 --- a/core/lib/Thelia/Cart/CartTrait.php +++ b/core/lib/Thelia/Cart/CartTrait.php @@ -22,6 +22,7 @@ /*************************************************************************************/ namespace Thelia\Cart; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\ConfigQuery; @@ -44,10 +45,11 @@ trait CartTrait * * search if cart already exists in session. If not try to create a new one or duplicate an old one. * + * @param EventDispatcherInterface $dispatcher the event dispatcher * @param \Symfony\Component\HttpFoundation\Request $request * @return \Thelia\Model\Cart */ - public function getCart(Request $request) + public function getCart(EventDispatcherInterface $dispatcher, Request $request) { $session = $request->getSession(); @@ -68,12 +70,12 @@ trait CartTrait if ($customer) { if ($cart->getCustomerId() != $customer->getId()) { //le customer du panier n'est pas le mm que celui connecté, il faut cloner le panier sans le customer_id - $cart = $this->duplicateCart($cart, $session, $customer); + $cart = $this->duplicateCart($dispatcher, $cart, $session, $customer); } } else { if ($cart->getCustomerId() != null) { //il faut dupliquer le panier sans le customer_id - $cart = $this->duplicateCart($cart, $session); + $cart = $this->duplicateCart($dispatcher, $cart, $session); } } @@ -116,13 +118,14 @@ trait CartTrait * @param \Thelia\Model\Customer $customer * @return \Thelia\Model\Cart */ - protected function duplicateCart(CartModel $cart, Session $session, Customer $customer = null) + protected function duplicateCart(EventDispatcherInterface $dispatcher, CartModel $cart, Session $session, Customer $customer = null) { $newCart = $cart->duplicate($this->generateCookie(), $customer); $session->setCart($newCart->getId()); $cartEvent = new CartEvent($newCart); - $this->getDispatcher()->dispatch(TheliaEvents::CART_DUPLICATE, $cartEvent); + + $dispatcher->dispatch(TheliaEvents::CART_DUPLICATE, $cartEvent); return $cartEvent->getCart(); } @@ -139,6 +142,4 @@ trait CartTrait return $id; } - - abstract public function getDispatcher(); } diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index 3b56cbf00..a2cd7ee2f 100644 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -26,10 +26,10 @@ namespace Thelia\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Filesystem\Filesystem; + use Symfony\Component\Filesystem\Exception\IOException; -use Thelia\Command\ContainerAwareCommand; + use Thelia\Core\Event\Cache\CacheEvent; use Thelia\Core\Event\TheliaEvents; diff --git a/core/lib/Thelia/Command/ClearImageCache.php b/core/lib/Thelia/Command/ClearImageCache.php index 8401e47f3..053533469 100644 --- a/core/lib/Thelia/Command/ClearImageCache.php +++ b/core/lib/Thelia/Command/ClearImageCache.php @@ -23,7 +23,7 @@ namespace Thelia\Command; -use Thelia\Command\ContainerAwareCommand; + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; diff --git a/core/lib/Thelia/Command/CreateAdminUser.php b/core/lib/Thelia/Command/CreateAdminUser.php index bbc4f9ad0..f935221dc 100644 --- a/core/lib/Thelia/Command/CreateAdminUser.php +++ b/core/lib/Thelia/Command/CreateAdminUser.php @@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Thelia\Command\ContainerAwareCommand; + use Thelia\Model\Admin; class CreateAdminUser extends ContainerAwareCommand diff --git a/core/lib/Thelia/Command/GenerateResources.php b/core/lib/Thelia/Command/GenerateResources.php index 124648b2a..3db889ddb 100644 --- a/core/lib/Thelia/Command/GenerateResources.php +++ b/core/lib/Thelia/Command/GenerateResources.php @@ -27,9 +27,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Thelia\Command\ContainerAwareCommand; + use Thelia\Core\Security\Resource\AdminResources; -use Thelia\Model\Admin; + use Thelia\Model\Map\ResourceI18nTableMap; use Thelia\Model\Map\ResourceTableMap; diff --git a/core/lib/Thelia/Command/Install.php b/core/lib/Thelia/Command/Install.php index 4cff782ad..fd6237d8e 100644 --- a/core/lib/Thelia/Command/Install.php +++ b/core/lib/Thelia/Command/Install.php @@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; -use Thelia\Command\ContainerAwareCommand; + use Thelia\Install\CheckPermission; use Thelia\Install\Database; diff --git a/core/lib/Thelia/Command/ModuleGenerateCommand.php b/core/lib/Thelia/Command/ModuleGenerateCommand.php index c6d8bf13f..8a610b991 100644 --- a/core/lib/Thelia/Command/ModuleGenerateCommand.php +++ b/core/lib/Thelia/Command/ModuleGenerateCommand.php @@ -97,7 +97,7 @@ class ModuleGenerateCommand extends BaseModuleGenerate file_put_contents($this->moduleDirectory . DIRECTORY_SEPARATOR . "Config". DIRECTORY_SEPARATOR . "module.xml", $moduleContent); - $classContent = file_get_contents($skeletonDir . "Class.php"); + $classContent = file_get_contents($skeletonDir . "Class.php.template"); $classContent = str_replace("%%CLASSNAME%%", $this->module, $classContent); $classContent = str_replace("%%NAMESPACE%%", $this->module, $classContent); diff --git a/core/lib/Thelia/Command/ReloadDatabaseCommand.php b/core/lib/Thelia/Command/ReloadDatabaseCommand.php index 20aad0265..0bd76c9e5 100644 --- a/core/lib/Thelia/Command/ReloadDatabaseCommand.php +++ b/core/lib/Thelia/Command/ReloadDatabaseCommand.php @@ -24,7 +24,7 @@ namespace Thelia\Command; use Propel\Runtime\Propel; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Output\OutputInterface; use Thelia\Install\Database; diff --git a/core/lib/Thelia/Command/Skeleton/Module/Class.php b/core/lib/Thelia/Command/Skeleton/Module/Class.php.template similarity index 98% rename from core/lib/Thelia/Command/Skeleton/Module/Class.php rename to core/lib/Thelia/Command/Skeleton/Module/Class.php.template index 41fcfadbb..0b221bd8c 100644 --- a/core/lib/Thelia/Command/Skeleton/Module/Class.php +++ b/core/lib/Thelia/Command/Skeleton/Module/Class.php.template @@ -23,7 +23,6 @@ namespace %%NAMESPACE%%; -use Thelia\Module\BaseModule; class %%CLASSNAME%% extends BaseModule { diff --git a/core/lib/Thelia/Condition/ConditionEvaluator.php b/core/lib/Thelia/Condition/ConditionEvaluator.php index dd606fcd0..a08ab912a 100644 --- a/core/lib/Thelia/Condition/ConditionEvaluator.php +++ b/core/lib/Thelia/Condition/ConditionEvaluator.php @@ -24,8 +24,7 @@ namespace Thelia\Condition; use Thelia\Condition\Implementation\ConditionInterface; -use Thelia\Condition\Operators; -use Thelia\Condition\ConditionCollection; + /** * Validate Conditions diff --git a/core/lib/Thelia/Condition/ConditionFactory.php b/core/lib/Thelia/Condition/ConditionFactory.php index 72079fcc7..9d388a33e 100644 --- a/core/lib/Thelia/Condition/ConditionFactory.php +++ b/core/lib/Thelia/Condition/ConditionFactory.php @@ -26,7 +26,7 @@ namespace Thelia\Condition; use Symfony\Component\DependencyInjection\ContainerInterface; use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Coupon\FacadeInterface; -use Thelia\Condition\ConditionCollection; + /** * Manage how Condition could interact with the current application state (Thelia) diff --git a/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php index 48ec8ed1e..9b5b218f2 100644 --- a/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php +++ b/core/lib/Thelia/Condition/Implementation/ConditionAbstract.php @@ -23,7 +23,7 @@ namespace Thelia\Condition\Implementation; -use Symfony\Component\Intl\Exception\NotImplementedException; + use Thelia\Condition\ConditionEvaluator; use Thelia\Condition\Operators; use Thelia\Condition\SerializableCondition; diff --git a/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php index 48b7c250b..74570cc41 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForEveryone.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Thelia\Condition\Implementation\ConditionAbstract; + /** * Allow every one, perform no check diff --git a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php index 7cbdd32df..ec42d5d86 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmount.php @@ -23,7 +23,7 @@ namespace Thelia\Condition\Implementation; -use Thelia\Condition\Implementation\ConditionAbstract; + use Thelia\Condition\Operators; use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Model\Currency; diff --git a/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php index f1123b57b..ab0fe481a 100644 --- a/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForXArticles.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Thelia\Condition\Implementation\ConditionAbstract; + use Thelia\Condition\Operators; use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Exception\InvalidConditionValueException; diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 8f1f50531..514ff5ceb 100644 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -6,6 +6,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -15,161 +44,114 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index 52b70f0a2..75da59ec3 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -33,7 +33,7 @@ use Thelia\Model\AttributeQuery; use Thelia\Form\AttributeModificationForm; use Thelia\Form\AttributeCreationForm; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Model\AttributeAv; + use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent; use Thelia\Core\Event\Attribute\AttributeEvent; diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 830d7bd3f..43d3bbdc9 100644 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -34,7 +34,7 @@ use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Tools\URL; use Thelia\Tools\Redirect; use Thelia\Model\AdminLog; -use Thelia\Model\Lang; + use Thelia\Model\LangQuery; use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 8dcba2cbe..a6581cca7 100644 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\HttpFoundation\Response; + use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Category\CategoryDeleteEvent; use Thelia\Core\Event\TheliaEvents; diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index a901d4c6b..2368e630a 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -30,8 +30,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Form\CustomerCreateForm; use Thelia\Form\CustomerUpdateForm; use Thelia\Model\CustomerQuery; -use Thelia\Tools\Password; -use Thelia\Model\Address; + /** * Class CustomerController diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php index 4cbbd8527..1a149e248 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -33,7 +33,7 @@ use Thelia\Model\FeatureQuery; use Thelia\Form\FeatureModificationForm; use Thelia\Form\FeatureCreationForm; use Thelia\Core\Event\UpdatePositionEvent; -use Thelia\Model\FeatureAv; + use Thelia\Core\Event\Feature\FeatureAvUpdateEvent; use Thelia\Core\Event\Feature\FeatureEvent; diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php index 97713a589..1d7c080c4 100644 --- a/core/lib/Thelia/Controller/Admin/OrderController.php +++ b/core/lib/Thelia/Controller/Admin/OrderController.php @@ -23,7 +23,7 @@ namespace Thelia\Controller\Admin; -use Thelia\Core\HttpFoundation\Response; + use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderEvent; @@ -67,10 +67,8 @@ class OrderController extends BaseAdminController $message = null; try { - if ($order_id !== null) { - $order_id = $order_id; - } else { - $order_id = $this->getRequest()->get("order_id"); + if ($order_id === null) { + $order_id = $this->getRequest()->get("order_id"); } $order = OrderQuery::create()->findPk($order_id); diff --git a/core/lib/Thelia/Controller/Admin/SessionController.php b/core/lib/Thelia/Controller/Admin/SessionController.php index 78394fa19..03e626812 100644 --- a/core/lib/Thelia/Controller/Admin/SessionController.php +++ b/core/lib/Thelia/Controller/Admin/SessionController.php @@ -31,11 +31,11 @@ use Thelia\Model\AdminLog; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Model\Lang; use Thelia\Model\LangQuery; -use Thelia\Tools\URL; -use Thelia\Tools\Redirect; + + use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Security\Authentication\AdminTokenAuthenticator; -use Symfony\Component\HttpFoundation\Cookie; + use Thelia\Core\Security\Exception\TokenAuthenticationException; class SessionController extends BaseAdminController diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 848d5514e..452fd87d0 100644 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -32,15 +32,15 @@ use Symfony\Component\Routing\Exception\InvalidParameterException; use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Router; -use Thelia\Core\Security\SecurityContext; + use Thelia\Core\Template\TemplateHelper; use Thelia\Core\Translation\Translator; use Thelia\Model\OrderQuery; -use Thelia\Tools\URL; + use Thelia\Tools\Redirect; use Thelia\Core\Template\ParserContext; use Thelia\Core\Event\ActionEvent; -use Symfony\Component\EventDispatcher\EventDispatcher; + use Thelia\Form\BaseForm; use Thelia\Form\Exception\FormValidationException; use Symfony\Component\EventDispatcher\Event; diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index 3e70364d4..d0c6b52f6 100644 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -28,7 +28,7 @@ use Thelia\Core\HttpFoundation\Response; use Thelia\Core\Template\TemplateHelper; use Thelia\Model\AddressQuery; use Thelia\Model\ModuleQuery; -use Thelia\Tools\Redirect; + use Thelia\Tools\URL; class BaseFrontController extends BaseController diff --git a/core/lib/Thelia/Controller/Front/DefaultController.php b/core/lib/Thelia/Controller/Front/DefaultController.php index 0466e4dd4..bd2b31fa5 100644 --- a/core/lib/Thelia/Controller/Front/DefaultController.php +++ b/core/lib/Thelia/Controller/Front/DefaultController.php @@ -24,7 +24,7 @@ namespace Thelia\Controller\Front; use Symfony\Component\HttpFoundation\Request; use Thelia\Model\ConfigQuery; -use Thelia\Tools\Redirect; + use Thelia\Tools\URL; /** diff --git a/core/lib/Thelia/Core/Event/Order/OrderPaymentEvent.php b/core/lib/Thelia/Core/Event/Order/OrderPaymentEvent.php new file mode 100644 index 000000000..780d5a12c --- /dev/null +++ b/core/lib/Thelia/Core/Event/Order/OrderPaymentEvent.php @@ -0,0 +1,53 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Module; + +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Module; +use Thelia\Model\Order; + +/** + * Class PaymentEvent + * @package Thelia\Core\Event\Module + * @author Franck Allimant + */ +class OrderPaymentEvent extends ActionEvent +{ + /** + * @var Order + */ + protected $order; + + public function __construct(Order $order) { + $this->order = $order; + } + + /** + * @return \Thelia\Model\Order + */ + public function getOrder() + { + return $this->order; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 4691fd36d..24cb3eec6 100644 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -706,6 +706,10 @@ final class TheliaEvents const MODULE_UPDATE = 'thelia.module.update'; const MODULE_DELETE = 'thelia.module.delete'; + /* Invoke payment module */ + + const MODULE_PAY = 'thelia.module.pay'; + /** * sent for clearing cache */ diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 948fd1267..59484eed3 100644 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -31,11 +31,11 @@ use Symfony\Component\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Response; use Symfony\Component\Routing\Router; use Thelia\Core\Template\Exception\ResourceNotFoundException; -use Thelia\Core\Template\ParserInterface; + use Thelia\Core\Template\TemplateHelper; use Thelia\Exception\OrderException; use Thelia\Tools\Redirect; -use Thelia\Tools\URL; + use Thelia\Core\Security\Exception\AuthenticationException; /** diff --git a/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php index 9b5205319..00201c0f1 100644 --- a/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/AdminUsernamePasswordFormAuthenticator.php @@ -25,10 +25,10 @@ namespace Thelia\Core\Security\Authentication; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Form\Form; + use Thelia\Core\Security\UserProvider\AdminUserProvider; -use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator; + use Thelia\Form\AdminLogin; class AdminUsernamePasswordFormAuthenticator extends UsernamePasswordFormAuthenticator diff --git a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php index cd3dd0800..7da54e26b 100644 --- a/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/CustomerUsernamePasswordFormAuthenticator.php @@ -25,7 +25,7 @@ namespace Thelia\Core\Security\Authentication; use Symfony\Component\HttpFoundation\Request; -use Thelia\Core\Security\Authentication\UsernamePasswordFormAuthenticator; + use Thelia\Form\CustomerLogin; use Thelia\Core\Security\UserProvider\CustomerUserProvider; diff --git a/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php index e00ae4375..c348628ab 100644 --- a/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/TokenAuthenticator.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Security\Authentication; -use Thelia\Core\Security\Authentication\AuthenticatorInterface; + use Thelia\Core\Security\UserProvider\TokenUserProvider; use Thelia\Core\Security\Exception\TokenAuthenticationException; diff --git a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php index d9a223430..2b85bb7f3 100644 --- a/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php +++ b/core/lib/Thelia/Core/Security/Authentication/UsernamePasswordFormAuthenticator.php @@ -23,10 +23,10 @@ namespace Thelia\Core\Security\Authentication; -use Thelia\Core\Security\Authentication\AuthenticatorInterface; + use Symfony\Component\HttpFoundation\Request; use Thelia\Core\Security\UserProvider\UserProviderInterface; -use Symfony\Component\Form\Form; + use Thelia\Core\Security\Exception\WrongPasswordException; use Thelia\Core\Security\Exception\UsernameNotFoundException; use Symfony\Component\Validator\Exception\ValidatorException; diff --git a/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php index a6147fca4..c7ee4207a 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/AdminUserProvider.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Security\UserProvider; -use Thelia\Model\Admin; + use Thelia\Model\AdminQuery; class AdminUserProvider implements UserProviderInterface diff --git a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php index ccc15c3c7..730bdcfeb 100644 --- a/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php +++ b/core/lib/Thelia/Core/Security/UserProvider/CustomerUserProvider.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Security\UserProvider; -use Thelia\Action\Customer; + use Thelia\Model\CustomerQuery; class CustomerUserProvider implements UserProviderInterface { diff --git a/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php b/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php index aff1d9188..000716c9a 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseI18nLoop.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Template\Element; -use Symfony\Component\HttpFoundation\Request; + use Thelia\Core\Template\Loop\Argument\Argument; use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Model\Tools\ModelCriteriaTools; diff --git a/core/lib/Thelia/Core/Template/Element/LoopResult.php b/core/lib/Thelia/Core/Template/Element/LoopResult.php index af24a4bda..a8e093d9b 100644 --- a/core/lib/Thelia/Core/Template/Element/LoopResult.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResult.php @@ -25,7 +25,7 @@ namespace Thelia\Core\Template\Element; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Util\PropelModelPager; -use Thelia\Core\Template\Element\LoopResultRow; + class LoopResult implements \Iterator { diff --git a/core/lib/Thelia/Core/Template/Loop/Accessory.php b/core/lib/Thelia/Core/Template/Loop/Accessory.php index de08f1f5b..45be652e4 100644 --- a/core/lib/Thelia/Core/Template/Loop/Accessory.php +++ b/core/lib/Thelia/Core/Template/Loop/Accessory.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Template\Loop; -use Thelia\Core\Template\Loop\Product; + use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\LoopResult; diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 3cfedd5d3..535f47c2a 100644 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Template\Loop; -use Thelia\Core\Template\Loop\Content; + use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\LoopResult; diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 2ad8ae8a2..02a3fada6 100644 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -15,7 +15,7 @@ use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; -use Thelia\TaxEngine\TaxEngine; + use Thelia\Type; class Cart extends BaseLoop implements ArraySearchLoopInterface @@ -55,7 +55,7 @@ class Cart extends BaseLoop implements ArraySearchLoopInterface public function buildArray() { - $cart = $this->getCart($this->request); + $cart = $this->getCart($this->getDispatcher(), $this->request); if (null === $cart) { return array(); diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php index 87f00a7ec..67bf0fbd3 100644 --- a/core/lib/Thelia/Core/Template/Loop/Delivery.php +++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php @@ -29,7 +29,7 @@ use Thelia\Exception\OrderException; use Thelia\Model\CountryQuery; use Thelia\Module\BaseModule; use Thelia\Module\DeliveryModuleInterface; -use Thelia\TaxEngine\TaxEngine; + /** * Class Delivery diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index c3e48dc8e..c6d049651 100644 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -31,7 +31,7 @@ use Thelia\Core\Template\Element\PropelSearchLoopInterface; use Thelia\Core\Template\Element\SearchLoopInterface; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; -use Thelia\Model\Base\Customer; + use Thelia\Model\CustomerQuery; use Thelia\Model\Map\CustomerTableMap; use Thelia\Model\Map\OrderAddressTableMap; diff --git a/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php b/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php index 13335d4c8..a9779ab15 100644 --- a/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php +++ b/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php @@ -24,7 +24,7 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Condition\ConditionFactory; + use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 99689fbd2..8bcf76e4d 100644 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -43,7 +43,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; use Thelia\Model\Map\ProductTableMap; use Thelia\Model\ProductCategoryQuery; use Thelia\Model\ProductQuery; -use Thelia\TaxEngine\TaxEngine; + use Thelia\Type\TypeCollection; use Thelia\Type; diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index 8e2aa03dd..e873faaf2 100644 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -36,7 +36,7 @@ use Thelia\Exception\TaxEngineException; use Thelia\Model\Base\ProductSaleElementsQuery; use Thelia\Model\CurrencyQuery; use Thelia\Model\Map\ProductSaleElementsTableMap; -use Thelia\TaxEngine\TaxEngine; + use Thelia\Type\TypeCollection; use Thelia\Type; diff --git a/core/lib/Thelia/Core/Template/ParserInterface.php b/core/lib/Thelia/Core/Template/ParserInterface.php index 22badf688..9ec99360c 100644 --- a/core/lib/Thelia/Core/Template/ParserInterface.php +++ b/core/lib/Thelia/Core/Template/ParserInterface.php @@ -58,4 +58,12 @@ interface ParserInterface * @return array: an array of defined templates directories for the given template type */ public function getTemplateDirectories($templateType); + + /** + * Create a variable that will be available in the templates + * + * @param $variable the vatiable name + * @param $value the value of the variable + */ + public function assign($variable, $value); } diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php index 18e771336..46440cc52 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php +++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php @@ -23,7 +23,7 @@ namespace Thelia\Core\Template\Smarty\Assets; -use Thelia\Core\Template\TemplateDefinition; + use Thelia\Tools\URL; use Thelia\Core\Template\Assets\AssetManagerInterface; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 13ee8e852..bdc477551 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -37,7 +37,7 @@ use Thelia\Model\CountryQuery; use Thelia\Model\CurrencyQuery; use Thelia\Model\FolderQuery; use Thelia\Model\OrderQuery; -use Thelia\Model\Product; + use Thelia\Model\ProductQuery; use Thelia\Model\Tools\ModelCriteriaTools; use Thelia\TaxEngine\TaxEngine; @@ -190,7 +190,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin self::$dataAccessCache['currentCountry'] = $taxCountry; } - $cart = $this->getCart($this->request); + $cart = $this->getCart($this->getDispatcher(), $this->request); $result = ""; switch ($params["attr"]) { case "count_item": diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 9a1279da9..fac094dd6 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -24,7 +24,7 @@ namespace Thelia\Core\Template\Smarty\Plugins; use Symfony\Component\Form\FormView; use Thelia\Core\Form\Type\TheliaType; -use Thelia\Form\BaseForm; + use Thelia\Core\Template\Element\Exception\ElementNotFoundException; use Symfony\Component\HttpFoundation\Request; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 251ae9b9c..cffd16479 100644 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -7,10 +7,10 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface; use \Smarty; -use Thelia\Core\HttpFoundation\Response; + use Thelia\Core\Template\ParserInterface; -use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; + use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\TemplateDefinition; diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index cc85ad632..9eb47b5ef 100644 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -47,7 +47,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Config\DatabaseConfiguration; use Thelia\Config\DefinePropel; use Thelia\Core\Template\TemplateDefinition; -use Thelia\Core\TheliaContainerBuilder; + use Thelia\Core\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Config\FileLocator; diff --git a/core/lib/Thelia/Coupon/BaseFacade.php b/core/lib/Thelia/Coupon/BaseFacade.php index d1f1d22a6..4e7e7de13 100644 --- a/core/lib/Thelia/Coupon/BaseFacade.php +++ b/core/lib/Thelia/Coupon/BaseFacade.php @@ -71,7 +71,7 @@ class BaseFacade implements FacadeInterface */ public function getCart() { - return $this->getCartFromTrait($this->getRequest()); + return $this->getCartFromTrait($this->getDispatcher(), $this->getRequest()); } /** diff --git a/core/lib/Thelia/Coupon/Type/CouponAbstract.php b/core/lib/Thelia/Coupon/Type/CouponAbstract.php index ac4893478..23247e658 100644 --- a/core/lib/Thelia/Coupon/Type/CouponAbstract.php +++ b/core/lib/Thelia/Coupon/Type/CouponAbstract.php @@ -28,7 +28,7 @@ use Thelia\Core\Translation\Translator; use Thelia\Coupon\FacadeInterface; use Thelia\Condition\ConditionCollection; use Thelia\Condition\ConditionOrganizerInterface; -use Thelia\Exception\InvalidConditionException; + /** * Assist in writing a CouponInterface diff --git a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php index 3158fd2b2..df28b6a11 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXAmount.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXAmount.php @@ -23,7 +23,7 @@ namespace Thelia\Coupon\Type; -use Thelia\Coupon\Type\CouponAbstract; + /** * Allow to remove an amount from the checkout total diff --git a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php index b6c13df1a..023df3b27 100644 --- a/core/lib/Thelia/Coupon/Type/RemoveXPercent.php +++ b/core/lib/Thelia/Coupon/Type/RemoveXPercent.php @@ -24,8 +24,7 @@ namespace Thelia\Coupon\Type; use Thelia\Coupon\FacadeInterface; -use Thelia\Coupon\Type\CouponAbstract; -use Thelia\Exception\MissingFacadeException; + /** * @package Coupon diff --git a/core/lib/Thelia/Form/AdministratorCreationForm.php b/core/lib/Thelia/Form/AdministratorCreationForm.php index f2a7e2452..9ad3e3421 100644 --- a/core/lib/Thelia/Form/AdministratorCreationForm.php +++ b/core/lib/Thelia/Form/AdministratorCreationForm.php @@ -23,7 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Translation\Translator; use Thelia\Model\AdminQuery; diff --git a/core/lib/Thelia/Form/Area/AreaModificationForm.php b/core/lib/Thelia/Form/Area/AreaModificationForm.php index 03f4b2e46..a2a5ff12e 100644 --- a/core/lib/Thelia/Form/Area/AreaModificationForm.php +++ b/core/lib/Thelia/Form/Area/AreaModificationForm.php @@ -23,7 +23,7 @@ namespace Thelia\Form\Area; use Symfony\Component\Validator\Constraints\GreaterThan; -use Thelia\Form\Area\AreaCreateForm; + /** * Class AreaModificationForm diff --git a/core/lib/Thelia/Form/CustomerCreateForm.php b/core/lib/Thelia/Form/CustomerCreateForm.php index e8582bf6c..b1984e8d4 100644 --- a/core/lib/Thelia/Form/CustomerCreateForm.php +++ b/core/lib/Thelia/Form/CustomerCreateForm.php @@ -23,7 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Model\ConfigQuery; use Thelia\Model\CustomerQuery; diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index 66b5c34ef..cc0c1fd82 100644 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -23,8 +23,8 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\Constraints\Email; + + use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Translation\Translator; diff --git a/core/lib/Thelia/Form/Image/DocumentModification.php b/core/lib/Thelia/Form/Image/DocumentModification.php index dbb85f5b3..267f3068d 100644 --- a/core/lib/Thelia/Form/Image/DocumentModification.php +++ b/core/lib/Thelia/Form/Image/DocumentModification.php @@ -22,7 +22,7 @@ /*************************************************************************************/ namespace Thelia\Form\Image; -use Symfony\Component\Validator\Constraints\Image; + use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Core\Translation\Translator; use Thelia\Form\BaseForm; diff --git a/core/lib/Thelia/Form/MailingSystemModificationForm.php b/core/lib/Thelia/Form/MailingSystemModificationForm.php index 144037a50..c30025bd1 100644 --- a/core/lib/Thelia/Form/MailingSystemModificationForm.php +++ b/core/lib/Thelia/Form/MailingSystemModificationForm.php @@ -22,9 +22,9 @@ /*************************************************************************************/ namespace Thelia\Form; -use Symfony\Component\Validator\ExecutionContextInterface; + use Thelia\Core\Translation\Translator; -use Thelia\Model\ProfileQuery; + /** * Class MailingSystemModificationForm diff --git a/core/lib/Thelia/Form/ProductCombinationGenerationForm.php b/core/lib/Thelia/Form/ProductCombinationGenerationForm.php index 1ca633ccd..82df0e09a 100644 --- a/core/lib/Thelia/Form/ProductCombinationGenerationForm.php +++ b/core/lib/Thelia/Form/ProductCombinationGenerationForm.php @@ -23,7 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; -use Thelia\Model\Currency; + use Thelia\Core\Translation\Translator; class ProductCombinationGenerationForm extends BaseForm diff --git a/core/lib/Thelia/Form/ProfileUpdateModuleAccessForm.php b/core/lib/Thelia/Form/ProfileUpdateModuleAccessForm.php index 488c22d42..2f7331cb9 100644 --- a/core/lib/Thelia/Form/ProfileUpdateModuleAccessForm.php +++ b/core/lib/Thelia/Form/ProfileUpdateModuleAccessForm.php @@ -23,7 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Security\AccessManager; use Thelia\Model\ProfileQuery; diff --git a/core/lib/Thelia/Form/ProfileUpdateResourceAccessForm.php b/core/lib/Thelia/Form/ProfileUpdateResourceAccessForm.php index 69a982ac6..f4ce79414 100644 --- a/core/lib/Thelia/Form/ProfileUpdateResourceAccessForm.php +++ b/core/lib/Thelia/Form/ProfileUpdateResourceAccessForm.php @@ -23,7 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Constraints\NotBlank; + use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Security\AccessManager; use Thelia\Model\ProfileQuery; diff --git a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php index b35aad12f..f204e7254 100644 --- a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php +++ b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php @@ -56,9 +56,6 @@ trait StandardDescriptionFieldsTrait new NotBlank() ), "label" => Translator::getInstance()->trans("Title"), - "label_attr" => array( - "for" => "title" - ), "label_attr" => array("for" => "title_field") ) ); diff --git a/core/lib/Thelia/Install/CheckPermission.php b/core/lib/Thelia/Install/CheckPermission.php index 38b6049dc..6ce7cb7c1 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -398,10 +398,13 @@ class CheckPermission extends BaseInstall // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024; + break; case 'm': $val *= 1024; + break; case 'k': $val *= 1024; + break; } return $val; diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php b/core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php index dfd225347..4bb5e73d5 100644 --- a/core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php @@ -23,7 +23,7 @@ namespace Thelia\Log\Destination; -use Thelia\Log\AbstractTlogDestination; + use Thelia\Log\TlogDestinationConfig; use Thelia\Core\Translation\Translator; diff --git a/core/lib/Thelia/Model/Address.php b/core/lib/Thelia/Model/Address.php index b4d5bc29a..20bf10bd8 100644 --- a/core/lib/Thelia/Model/Address.php +++ b/core/lib/Thelia/Model/Address.php @@ -3,11 +3,11 @@ namespace Thelia\Model; use Propel\Runtime\Connection\ConnectionInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; + use Thelia\Core\Event\Address\AddressEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Address as BaseAddress; -use Thelia\Model\AddressQuery; + class Address extends BaseAddress { use \Thelia\Model\Tools\ModelEventDispatcherTrait; diff --git a/core/lib/Thelia/Model/AttributeAv.php b/core/lib/Thelia/Model/AttributeAv.php index 8059b217e..bb0694eb5 100644 --- a/core/lib/Thelia/Model/AttributeAv.php +++ b/core/lib/Thelia/Model/AttributeAv.php @@ -6,7 +6,7 @@ use Thelia\Model\Base\AttributeAv as BaseAttributeAv; use Thelia\Core\Event\Attribute\AttributeAvEvent; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Event\TheliaEvents; -use Propel\Runtime\ActiveQuery\Criteria; + class AttributeAv extends BaseAttributeAv { diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 5139057f4..0c30f2acf 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -3,11 +3,10 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; + use Thelia\Model\Base\Cart as BaseCart; -use Thelia\Model\ProductSaleElementsQuery; -use Thelia\Model\ProductPriceQuery; -use Thelia\Model\CartItemQuery; + + use Thelia\TaxEngine\Calculator; class Cart extends BaseCart diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index ef72c070c..4e533f79d 100644 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -6,7 +6,7 @@ use Propel\Runtime\Connection\ConnectionInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; -use Thelia\Model\ConfigQuery; + use Thelia\Core\Event\Cart\CartEvent; use Thelia\TaxEngine\Calculator; diff --git a/core/lib/Thelia/Model/CartQuery.php b/core/lib/Thelia/Model/CartQuery.php index 1d51262d2..fcb9a82da 100644 --- a/core/lib/Thelia/Model/CartQuery.php +++ b/core/lib/Thelia/Model/CartQuery.php @@ -3,7 +3,7 @@ namespace Thelia\Model; use Thelia\Model\Base\CartQuery as BaseCartQuery; -use Symfony\Component\HttpFoundation\Request; + /** * Skeleton subclass for performing query and update operations on the 'cart' table. diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php index 020dd8c92..d6ac1c394 100644 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -4,9 +4,8 @@ namespace Thelia\Model; use Thelia\Core\Event\Category\CategoryEvent; use Thelia\Model\Base\Category as BaseCategory; -use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Model\ProductCategoryQuery; -use Thelia\Tools\URL; + + use Thelia\Core\Event\TheliaEvents; use Propel\Runtime\Connection\ConnectionInterface; diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php index 378350bf1..1a0b7a5fc 100644 --- a/core/lib/Thelia/Model/CategoryImage.php +++ b/core/lib/Thelia/Model/CategoryImage.php @@ -2,8 +2,7 @@ namespace Thelia\Model; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpFoundation\File\UploadedFile; + use Thelia\Model\Base\CategoryImage as BaseCategoryImage; use Propel\Runtime\Connection\ConnectionInterface; diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php index 3a002e6d1..d8ce9457a 100644 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -6,9 +6,9 @@ use Propel\Runtime\Propel; use Thelia\Core\Event\Content\ContentEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Content as BaseContent; -use Thelia\Model\ContentFolderQuery; + use Thelia\Model\Map\ContentTableMap; -use Thelia\Tools\URL; + use Propel\Runtime\Connection\ConnectionInterface; class Content extends BaseContent diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 39ace0648..127a69a82 100644 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -3,11 +3,11 @@ namespace Thelia\Model; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\AddressQuery; + use Thelia\Model\Base\Customer as BaseCustomer; use Thelia\Model\Exception\InvalidArgumentException; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; + use Thelia\Core\Event\CustomRefEvent; use Thelia\Core\Event\TheliaEvents; diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php index b267ce5f1..1189a44e4 100644 --- a/core/lib/Thelia/Model/Folder.php +++ b/core/lib/Thelia/Model/Folder.php @@ -5,7 +5,7 @@ namespace Thelia\Model; use Thelia\Core\Event\Folder\FolderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Folder as BaseFolder; -use Thelia\Tools\URL; + use Propel\Runtime\Connection\ConnectionInterface; class Folder extends BaseFolder diff --git a/core/lib/Thelia/Model/Lang.php b/core/lib/Thelia/Model/Lang.php index e7b83ead4..f4f524e97 100644 --- a/core/lib/Thelia/Model/Lang.php +++ b/core/lib/Thelia/Model/Lang.php @@ -11,7 +11,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Template\TemplateHelper; use Thelia\Core\Translation\Translator; use Thelia\Model\Base\Lang as BaseLang; -use Thelia\Model\LangQuery; + use Thelia\Model\Map\LangTableMap; class Lang extends BaseLang { diff --git a/core/lib/Thelia/Model/Module.php b/core/lib/Thelia/Model/Module.php index bfae1001a..957ced4ab 100644 --- a/core/lib/Thelia/Model/Module.php +++ b/core/lib/Thelia/Model/Module.php @@ -5,7 +5,7 @@ namespace Thelia\Model; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\Module as BaseModule; use Thelia\Model\Tools\ModelEventDispatcherTrait; -use Thelia\Core\Event\TheliaEvents; + class Module extends BaseModule { diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index cadcda30e..4add32a45 100644 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -4,15 +4,13 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Propel; + use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Order as BaseOrder; use Thelia\Model\Base\OrderProductTaxQuery; use Thelia\Model\Map\OrderProductTaxTableMap; -use Thelia\Model\OrderProductQuery; -use Thelia\Model\Map\OrderTableMap; -use \PDO; + class Order extends BaseOrder { diff --git a/core/lib/Thelia/Model/OrderQuery.php b/core/lib/Thelia/Model/OrderQuery.php index 5e5f77f07..d027af528 100644 --- a/core/lib/Thelia/Model/OrderQuery.php +++ b/core/lib/Thelia/Model/OrderQuery.php @@ -4,10 +4,10 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Join; -use Propel\Runtime\Exception\PropelException; -use Propel\Runtime\Propel; + + use Thelia\Model\Base\OrderQuery as BaseOrderQuery; -use \PDO; + use Thelia\Model\Map\OrderTableMap; /** diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 5bcc56b46..d636c64a4 100644 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -4,7 +4,7 @@ namespace Thelia\Model; use Propel\Runtime\Exception\PropelException; use Thelia\Model\Base\Product as BaseProduct; -use Thelia\Tools\URL; + use Thelia\TaxEngine\Calculator; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Core\Event\TheliaEvents; @@ -12,7 +12,7 @@ use Thelia\Core\Event\Product\ProductEvent; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Propel; use Thelia\Model\Map\ProductTableMap; -use Thelia\Model\ProductSaleElementsQuery; + class Product extends BaseProduct { diff --git a/core/lib/Thelia/Model/RewritingUrl.php b/core/lib/Thelia/Model/RewritingUrl.php index a13777c41..a8fc84d28 100644 --- a/core/lib/Thelia/Model/RewritingUrl.php +++ b/core/lib/Thelia/Model/RewritingUrl.php @@ -5,7 +5,7 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Connection\ConnectionInterface; use Thelia\Model\Base\RewritingUrl as BaseRewritingUrl; -use Thelia\Model\RewritingUrlQuery; + class RewritingUrl extends BaseRewritingUrl { diff --git a/core/lib/Thelia/Model/TaxRuleQuery.php b/core/lib/Thelia/Model/TaxRuleQuery.php index d68ad7ef2..064ec467a 100644 --- a/core/lib/Thelia/Model/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/TaxRuleQuery.php @@ -5,7 +5,7 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Model\Base\TaxRuleQuery as BaseTaxRuleQuery; use Thelia\Model\Map\TaxRuleCountryTableMap; -use Thelia\Model\Map\TaxTableMap; + /** * Skeleton subclass for performing query and update operations on the 'tax_rule' table. diff --git a/core/lib/Thelia/TaxEngine/TaxEngine.php b/core/lib/Thelia/TaxEngine/TaxEngine.php index bfa447d23..62a8b2f68 100644 --- a/core/lib/Thelia/TaxEngine/TaxEngine.php +++ b/core/lib/Thelia/TaxEngine/TaxEngine.php @@ -57,8 +57,8 @@ class TaxEngine * Add a directroy which contains tax types classes. The tax engine * will scan this directory, and add all the tax type classes. * - * @param unknown $namespace the namespace of the classes in the directory - * @param unknown $path_to_tax_type_classes the path to the directory + * @param string $namespace the namespace of the classes in the directory + * @param string $path_to_tax_type_classes the path to the directory */ public function addTaxTypeDirectory($namespace, $path_to_tax_type_classes) { diff --git a/core/lib/Thelia/Tests/Action/AddressTest.php b/core/lib/Thelia/Tests/Action/AddressTest.php index b570959e0..ba567bb60 100644 --- a/core/lib/Thelia/Tests/Action/AddressTest.php +++ b/core/lib/Thelia/Tests/Action/AddressTest.php @@ -26,7 +26,7 @@ namespace Thelia\Tests\Action; use Thelia\Action\Address; use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent; use Thelia\Model\Base\CustomerQuery; -use Thelia\Tests\Action\BaseAction; + /** * diff --git a/core/lib/Thelia/Tests/Action/ContentTest.php b/core/lib/Thelia/Tests/Action/ContentTest.php index 1eca7d2ea..08e41815b 100644 --- a/core/lib/Thelia/Tests/Action/ContentTest.php +++ b/core/lib/Thelia/Tests/Action/ContentTest.php @@ -23,6 +23,7 @@ namespace Thelia\Tests\Action; use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Action\Content; use Thelia\Core\Event\Content\ContentAddFolderEvent; use Thelia\Core\Event\Content\ContentCreateEvent; @@ -44,6 +45,15 @@ use Thelia\Tests\TestCaseWithURLToolSetup; */ class ContentTest extends TestCaseWithURLToolSetup { + /** + * @var EventDispatcherInterface + */ + protected $dispatcher; + + public function setUp() + { + $this->dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + } public function getUpdateEvent(&$content) { @@ -52,6 +62,7 @@ class ContentTest extends TestCaseWithURLToolSetup } $event = new ContentUpdateEvent($content->getId()); + $event->setDispatcher($this->dispatcher); $event ->setVisible(1) ->setLocale($content->getLocale()) @@ -78,6 +89,7 @@ class ContentTest extends TestCaseWithURLToolSetup $folder = $this->getRandomFolder(); $event = new ContentCreateEvent(); + $event->setDispatcher($this->dispatcher); $event ->setVisible(1) ->setLocale('en_US') @@ -103,6 +115,7 @@ class ContentTest extends TestCaseWithURLToolSetup $folder = $this->getRandomFolder(); $event = new ContentUpdateEvent($content->getId()); + $event->setDispatcher($this->dispatcher); $event ->setVisible(1) ->setLocale('en_US') @@ -132,6 +145,7 @@ class ContentTest extends TestCaseWithURLToolSetup $content = $this->getRandomContent(); $event = new ContentDeleteEvent($content->getId()); + $event->setDispatcher($this->dispatcher); $contentAction = new Content($this->getContainer()); $contentAction->delete($event); @@ -150,6 +164,7 @@ class ContentTest extends TestCaseWithURLToolSetup $visibility = $content->getVisible(); $event = new ContentToggleVisibilityEvent($content); + $event->setDispatcher($this->dispatcher); $contentAction = new Content($this->getContainer()); $contentAction->toggleVisibility($event); @@ -173,6 +188,7 @@ class ContentTest extends TestCaseWithURLToolSetup $newPosition = $content->getPosition()-1; $event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_UP); + $event->setDispatcher($this->dispatcher); $contentAction = new Content($this->getContainer()); $contentAction->updatePosition($event); @@ -195,6 +211,7 @@ class ContentTest extends TestCaseWithURLToolSetup $newPosition = $content->getPosition()+1; $event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_DOWN); + $event->setDispatcher($this->dispatcher); $contentAction = new Content($this->getContainer()); $contentAction->updatePosition($event); @@ -215,6 +232,7 @@ class ContentTest extends TestCaseWithURLToolSetup } $event = new UpdatePositionEvent($content->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, 1); + $event->setDispatcher($this->dispatcher); $contentAction = new Content($this->getContainer()); $contentAction->updatePosition($event); @@ -237,6 +255,7 @@ class ContentTest extends TestCaseWithURLToolSetup } while ($test->count() > 0); $event = new ContentAddFolderEvent($content, $folder->getId()); + $event->setDispatcher($this->dispatcher); $contentAction = new Content($this->getContainer()); $contentAction->addFolder($event); @@ -260,6 +279,7 @@ class ContentTest extends TestCaseWithURLToolSetup public function testRemoveFolder(ContentFolder $association) { $event = new ContentRemoveFolderEvent($association->getContent(), $association->getFolder()->getId()); + $event->setDispatcher($this->dispatcher); $contentAction = new Content($this->getContainer()); $contentAction->removeFolder($event); diff --git a/core/lib/Thelia/Tests/Action/FolderTest.php b/core/lib/Thelia/Tests/Action/FolderTest.php index cbf9a7c1e..96e07ed52 100644 --- a/core/lib/Thelia/Tests/Action/FolderTest.php +++ b/core/lib/Thelia/Tests/Action/FolderTest.php @@ -43,6 +43,16 @@ class FolderTest extends TestCaseWithURLToolSetup { use RewrittenUrlTestTrait; + /** + * @var EventDispatcherInterface + */ + protected $dispatcher; + + public function setUp() + { + $this->dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + } + public function getUpdateEvent(&$folder) { if (!$folder instanceof \Thelia\Model\Folder) { @@ -50,6 +60,7 @@ class FolderTest extends TestCaseWithURLToolSetup } $event = new FolderUpdateEvent($folder->getId()); + $event->setDispatcher($this->dispatcher); $event ->setVisible(1) ->setLocale($folder->getLocale()) @@ -70,7 +81,7 @@ class FolderTest extends TestCaseWithURLToolSetup } $event = new UpdateSeoEvent($folder->getId()); - + $event->setDispatcher($this->dispatcher); $event ->setLocale($folder->getLocale()) ->setMetaTitle($folder->getMetaTitle()) @@ -82,14 +93,14 @@ class FolderTest extends TestCaseWithURLToolSetup public function processUpdateSeoAction($event) { - $contentAction = new Folder($this->getContainer()); + $contentAction = new Folder(); return $contentAction->updateSeo($event); } public function processUpdateAction($event) { - $contentAction = new Folder($this->getContainer()); + $contentAction = new Folder(); $contentAction->update($event); return $event->getFolder(); @@ -103,13 +114,14 @@ class FolderTest extends TestCaseWithURLToolSetup { $event = new FolderCreateEvent(); + $event->setDispatcher($this->dispatcher); $event ->setParent(0) ->setVisible(1) ->setLocale('en_US') ->setTitle('folder creation test'); - $folderAction = new Folder($this->getContainer()); + $folderAction = new Folder(); $folderAction->create($event); @@ -131,7 +143,7 @@ class FolderTest extends TestCaseWithURLToolSetup $visible = !$folder->getVisible(); $event = new FolderUpdateEvent($folder->getId()); - + $event->setDispatcher($this->dispatcher); $event ->setLocale('en_US') ->setTitle('test update folder') @@ -142,7 +154,7 @@ class FolderTest extends TestCaseWithURLToolSetup ->setParent(0) ; - $folderAction = new Folder($this->getContainer()); + $folderAction = new Folder(); $folderAction->update($event); $updatedFolder = $event->getFolder(); @@ -165,8 +177,8 @@ class FolderTest extends TestCaseWithURLToolSetup $folder = $this->getRandomFolder(); $event = new FolderDeleteEvent($folder->getId()); - - $folderAction = new Folder($this->getContainer()); + $event->setDispatcher($this->dispatcher); + $folderAction = new Folder(); $folderAction->delete($event); $deletedFolder = $event->getFolder(); @@ -185,8 +197,9 @@ class FolderTest extends TestCaseWithURLToolSetup $visible = $folder->getVisible(); $event = new FolderToggleVisibilityEvent($folder); + $event->setDispatcher($this->dispatcher); - $folderAction = new Folder($this->getContainer()); + $folderAction = new Folder(); $folderAction->toggleVisibility($event); $updatedFolder = $event->getFolder(); @@ -208,8 +221,9 @@ class FolderTest extends TestCaseWithURLToolSetup $newPosition = $folder->getPosition()-1; $event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_UP); + $event->setDispatcher($this->dispatcher); - $folderAction = new Folder($this->getContainer()); + $folderAction = new Folder(); $folderAction->updatePosition($event); $updatedFolder = FolderQuery::create()->findPk($folder->getId()); @@ -239,8 +253,9 @@ class FolderTest extends TestCaseWithURLToolSetup $newPosition = $folder->getPosition()+1; $event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_DOWN); + $event->setDispatcher($this->dispatcher); - $folderAction = new Folder($this->getContainer()); + $folderAction = new Folder(); $folderAction->updatePosition($event); $updatedFolder = FolderQuery::create()->findPk($folder->getId()); @@ -259,8 +274,9 @@ class FolderTest extends TestCaseWithURLToolSetup } $event = new UpdatePositionEvent($folder->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, 1); + $event->setDispatcher($this->dispatcher); - $folderAction = new Folder($this->getContainer()); + $folderAction = new Folder(); $folderAction->updatePosition($event); $updatedFolder = FolderQuery::create()->findPk($folder->getId()); diff --git a/core/lib/Thelia/Tests/Action/OrderTest.php b/core/lib/Thelia/Tests/Action/OrderTest.php index f2fd00a32..41cd7cbac 100644 --- a/core/lib/Thelia/Tests/Action/OrderTest.php +++ b/core/lib/Thelia/Tests/Action/OrderTest.php @@ -30,11 +30,14 @@ use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Core\Security\SecurityContext; +use Thelia\Core\Template\ParserContext; +use Thelia\Core\Template\Smarty\SmartyParser; +use Thelia\Mailer\MailerFactory; use Thelia\Model\AddressQuery; use Thelia\Model\Base\OrderAddressQuery; use Thelia\Model\Base\OrderProductQuery; use Thelia\Model\Base\OrderQuery; -use Thelia\Model\OrderAddress; + use Thelia\Model\OrderStatus; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\Cart; @@ -85,25 +88,42 @@ class OrderTest extends \PHPUnit_Framework_TestCase */ protected $cartItems; + /** + * @var SecurityContext + */ + protected $securityContext; + + protected $request; + public function setUp() { - $container = new ContainerBuilder(); $session = new Session(new MockArraySessionStorage()); - $request = new Request(); + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); - $request->setSession($session); + $this->request = new Request(); + $this->request->setSession($session); - $container->set("event_dispatcher", $dispatcher); - $container->set('request', $request); - $container->set('thelia.securityContext', new SecurityContext($request)); + $this->securityContext = new SecurityContext($this->request); - $this->container = $container; + $this->container = new ContainerBuilder(); + + $this->container->set("event_dispatcher", $dispatcher); + $this->container->set('request', $this->request); $this->orderEvent = new OrderEvent(new OrderModel()); - $this->orderAction = new Order($this->container); + $this->orderEvent->setDispatcher($dispatcher); + + // public function __construct(Request $this->request, ParserInterface $parser, MailerFactory $mailer, SecurityContext $securityContext) + + $this->orderAction = new Order( + $this->request, + new SmartyParser($this->request, $dispatcher, new ParserContext($this->request)), + new MailerFactory($dispatcher), + $this->securityContext + ); /* load customer */ $this->customer = $this->loadCustomer(); @@ -123,7 +143,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase return null; } - $this->container->get('thelia.securityContext')->setCustomerUser($customer); + $this->securityContext->setCustomerUser($customer); return $customer; } @@ -172,7 +192,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase $this->cartItems[] = $cartItem; } - $this->container->get('request')->getSession()->setCart($cart->getId()); + $this->request->getSession()->setCart($cart->getId()); return $cart; } @@ -319,7 +339,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase $this->assertEquals(OrderStatus::CODE_NOT_PAID, $placedOrder->getOrderStatus()->getCode(), 'status does not match'); /* check lang */ - $this->assertEquals($this->container->get('request')->getSession()->getLang()->getId(), $placedOrder->getLangId(), 'lang does not match'); + $this->assertEquals($this->request->getSession()->getLang()->getId(), $placedOrder->getLangId(), 'lang does not match'); /* check ordered product */ foreach ($this->cartItems as $index => $cartItem) { diff --git a/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php b/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php index 3d5e757d1..4891e8b96 100644 --- a/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php +++ b/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php @@ -29,6 +29,7 @@ trait RewrittenUrlTestTrait { $object = null; $event = $this->getUpdateSeoEvent($object); + $event->setDispatcher($this->dispatcher); /* get an existing url */ $existingUrl = RewritingUrlQuery::create() @@ -50,6 +51,7 @@ trait RewrittenUrlTestTrait { $object = null; $event = $this->getUpdateSeoEvent($object); + $event->setDispatcher($this->dispatcher); $currentUrl = $object->getRewrittenUrl($object->getLocale()); diff --git a/core/lib/Thelia/Tests/Cart/CartTraitTest.php b/core/lib/Thelia/Tests/Cart/CartTraitTest.php index 039e4448e..a1531e2a1 100755 --- a/core/lib/Thelia/Tests/Cart/CartTraitTest.php +++ b/core/lib/Thelia/Tests/Cart/CartTraitTest.php @@ -47,6 +47,8 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase protected $uniqid; + protected $dispatcher; + public function getContainer() { $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); @@ -67,6 +69,8 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase $this->uniqid = uniqid('', true); + $this->dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + $this->cartTrait = new MockCartTrait($this->uniqid, $this->getContainer()); } @@ -79,7 +83,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase { $cartTrait = $this->cartTrait; - $cart = $cartTrait->getCart($this->request); + $cart = $cartTrait->getCart($this->dispatcher, $this->request); $this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart'); $this->assertNull($cart->getCustomerId()); @@ -109,7 +113,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase $request->getSession()->setCustomerUser($customer); - $cart = $cartTrait->getCart($request); + $cart = $cartTrait->getCart($this->dispatcher, $request); $this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart'); $this->assertNotNull($cart->getCustomerId()); $this->assertEquals($customer->getId(), $cart->getCustomerId()); @@ -137,7 +141,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase $request->cookies->set("thelia_cart", $uniqid); - $getCart = $cartTrait->getCart($request); + $getCart = $cartTrait->getCart($this->dispatcher, $request); $this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart'); $this->assertNull($getCart->getCustomerId()); $this->assertNull($getCart->getAddressDeliveryId()); @@ -159,7 +163,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase $token = "WrongToken"; $request->cookies->set("thelia_cart", $token); - $cart = $cartTrait->getCart($request); + $cart = $cartTrait->getCart($this->dispatcher, $request); $this->assertInstanceOf("Thelia\Model\Cart", $cart, '$cart must be an instance of cart model Thelia\Model\Cart'); $this->assertNull($cart->getCustomerId()); $this->assertNull($cart->getAddressDeliveryId()); @@ -196,7 +200,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase $request->getSession()->setCustomerUser($customer); - $getCart = $cartTrait->getCart($request); + $getCart = $cartTrait->getCart($this->dispatcher, $request); $this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart'); $this->assertNotNull($getCart->getCustomerId()); $this->assertNull($getCart->getAddressDeliveryId()); @@ -234,7 +238,7 @@ class CartTraitTest extends \PHPUnit_Framework_TestCase $request->getSession()->setCustomerUser($customer); - $getCart = $cartTrait->getCart($request); + $getCart = $cartTrait->getCart($this->dispatcher, $request); $this->assertInstanceOf("Thelia\Model\Cart", $getCart, '$cart must be an instance of cart model Thelia\Model\Cart'); $this->assertNotNull($getCart->getCustomerId()); $this->assertNull($getCart->getAddressDeliveryId()); diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php index a370dbd9a..95c49ce58 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php @@ -24,7 +24,7 @@ namespace Thelia\Condition\Implementation; use Thelia\Condition\ConditionEvaluator; -use Thelia\Condition\Operators; + use Thelia\Coupon\FacadeInterface; use Thelia\Model\Currency; diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php index 2d741eb92..cd6d67364 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php @@ -28,7 +28,7 @@ use Thelia\Condition\ConditionFactory; use Thelia\Condition\Operators; use Thelia\Condition\ConditionCollection; use Thelia\Coupon\FacadeInterface; -use Thelia\Exception\InvalidConditionValueException; + use Thelia\Model\Currency; use Thelia\Model\CurrencyQuery; diff --git a/core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php b/core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php index d7437efb9..8de88328b 100755 --- a/core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php +++ b/core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php @@ -2,7 +2,7 @@ namespace Thelia\Tests\Core\HttpFoundation; -use Thelia\Core\HttpFoundation\Request; + /** * the the helpers addinf in Request class diff --git a/core/lib/Thelia/Tests/Tools/FileManagerTest.php b/core/lib/Thelia/Tests/Tools/FileManagerTest.php index 0c0f0e4e7..35573a2ac 100644 --- a/core/lib/Thelia/Tests/Tools/FileManagerTest.php +++ b/core/lib/Thelia/Tests/Tools/FileManagerTest.php @@ -11,9 +11,8 @@ namespace Thelia\Tests\Tools; use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; -use Thelia\Core\Translation\Translator; -use Thelia\Exception\ImageException; -use Thelia\Model\Admin; + + use Thelia\Model\CategoryQuery; use Thelia\Model\ContentQuery; use Thelia\Model\FolderQuery; diff --git a/core/lib/Thelia/Tools/FileManager.php b/core/lib/Thelia/Tools/FileManager.php index 89365c49e..330019f99 100644 --- a/core/lib/Thelia/Tools/FileManager.php +++ b/core/lib/Thelia/Tools/FileManager.php @@ -22,12 +22,12 @@ /**********************************************************************************/ namespace Thelia\Tools; -use Symfony\Component\DependencyInjection\ContainerInterface; + use Symfony\Component\HttpFoundation\File\UploadedFile; use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; use Thelia\Core\HttpFoundation\Request; -use Thelia\Core\Translation\Translator; + use Thelia\Exception\ImageException; use Thelia\Form\CategoryDocumentModification; use Thelia\Form\CategoryImageModification; diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index cf593bf06..575ec545a 100644 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -29,7 +29,7 @@ use Thelia\Rewriting\RewritingRetriever; use Thelia\Core\HttpFoundation\Request; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\Routing\RequestContext; + class URL { diff --git a/core/lib/Thelia/Type/FloatToFloatArrayType.php b/core/lib/Thelia/Type/FloatToFloatArrayType.php index f55997f55..08a310ef0 100644 --- a/core/lib/Thelia/Type/FloatToFloatArrayType.php +++ b/core/lib/Thelia/Type/FloatToFloatArrayType.php @@ -41,8 +41,8 @@ class FloatToFloatArrayType extends BaseType return false; - foreach ($value as $key => $value) { - if ( filter_var($key, FILTER_VALIDATE_FLOAT) === false || filter_var($value, FILTER_VALIDATE_FLOAT) === false ) { + foreach ($value as $key => $val) { + if ( filter_var($key, FILTER_VALIDATE_FLOAT) === false || filter_var($val, FILTER_VALIDATE_FLOAT) === false ) { return false; } } diff --git a/local/modules/Front/Controller/CartController.php b/local/modules/Front/Controller/CartController.php index 5750cb306..5985dedb5 100644 --- a/local/modules/Front/Controller/CartController.php +++ b/local/modules/Front/Controller/CartController.php @@ -121,7 +121,7 @@ class CartController extends BaseFrontController */ protected function getCartEvent() { - $cart = $this->getCart($this->getRequest()); + $cart = $this->getCart($this->getDispatcher(), $this->getRequest()); return new CartEvent($cart); } diff --git a/local/modules/Front/Controller/CustomerController.php b/local/modules/Front/Controller/CustomerController.php index 2b2d38696..e66a6e2a8 100644 --- a/local/modules/Front/Controller/CustomerController.php +++ b/local/modules/Front/Controller/CustomerController.php @@ -125,7 +125,7 @@ class CustomerController extends BaseFrontController $this->processLogin($customerCreateEvent->getCustomer()); - $cart = $this->getCart($this->getRequest()); + $cart = $this->getCart($this->getDispatcher(), $this->getRequest()); if ($cart->getCartItems()->count() > 0) { $this->redirectToRoute('cart.view'); } else { diff --git a/local/modules/TheliaDebugBar/Config/config.xml b/local/modules/TheliaDebugBar/Config/config.xml index 564c17e66..28a560de9 100644 --- a/local/modules/TheliaDebugBar/Config/config.xml +++ b/local/modules/TheliaDebugBar/Config/config.xml @@ -39,7 +39,9 @@ - + + %kernel.debug% + diff --git a/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php b/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php index 5ea75a1df..190844e40 100644 --- a/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php +++ b/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php @@ -24,12 +24,11 @@ namespace TheliaDebugBar\Listeners; use DebugBar\DataCollector\MemoryCollector; -use DebugBar\DataCollector\MessagesCollector; use DebugBar\DataCollector\PhpInfoCollector; +use DebugBar\DebugBar; use TheliaDebugBar\DataCollector\PropelCollector; use DebugBar\DataCollector\TimeDataCollector; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; use Thelia\Action\BaseAction; use Thelia\Core\Event\TheliaEvents; @@ -41,21 +40,28 @@ use Thelia\Core\Event\TheliaEvents; */ class DebugBarListeners extends BaseAction implements EventSubscriberInterface { + protected $debugBar; + protected $debugMode; + + public function __construct(DebugBar $debugbar, $debugMode) + { + $this->debugBar = $debugbar; + $this->debugMode = $debugMode; + } + public function initDebugBar() { - $debugBar = $this->container->get("debugBar"); - $alternativelogger = null; - if($this->container->getParameter('kernel.debug')) { + if($this->debugMode) { $alternativelogger = \Thelia\Log\Tlog::getInstance(); } - $debugBar->addCollector(new PhpInfoCollector()); - //$debugBar->addCollector(new MessagesCollector()); - //$debugBar->addCollector(new RequestDataCollector()); - $debugBar->addCollector(new TimeDataCollector()); - $debugBar->addCollector(new MemoryCollector()); - $debugBar->addCollector(new PropelCollector($alternativelogger)); + $this->debugBar->addCollector(new PhpInfoCollector()); + //$this->debugBar->addCollector(new MessagesCollector()); + //$this->debugBar->addCollector(new RequestDataCollector()); + $this->debugBar->addCollector(new TimeDataCollector()); + $this->debugBar->addCollector(new MemoryCollector()); + $this->debugBar->addCollector(new PropelCollector($alternativelogger)); } /**