Removes container from all Thelia actions, but Modules (#198)

This commit is contained in:
Franck Allimant
2014-01-31 20:04:25 +01:00
parent dfd34bad49
commit 89653f452b
132 changed files with 603 additions and 467 deletions

View File

@@ -36,7 +36,7 @@ use Thelia\Model\Map\AddressTableMap;
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Address implements EventSubscriberInterface
class Address extends BaseAction implements EventSubscriberInterface
{
public function create(AddressCreateOrUpdateEvent $event)

View File

@@ -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

View File

@@ -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();

View File

@@ -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)

View File

@@ -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);
}
/**

View File

@@ -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;
}
}

View File

@@ -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)

View File

@@ -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();
}
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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());
}
/**

View File

@@ -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);
}
/**

View File

@@ -40,7 +40,7 @@ use Thelia\Core\Event\Customer\CustomerLoginEvent;
* @package Thelia\Action
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
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()
{

View File

@@ -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);
}
/**

View File

@@ -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)

View File

@@ -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);
}
/**

View File

@@ -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:

View File

@@ -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);
}

View File

@@ -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()
{

View File

@@ -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);

View File

@@ -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()
;

View File

@@ -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),
);
}
}

View File

@@ -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;

View File

@@ -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();
}
}

View File

@@ -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())

View File

@@ -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;

View File

@@ -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())

View File

@@ -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())

View File

@@ -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())

View File

@@ -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()
;
}

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -23,7 +23,7 @@
namespace Thelia\Command;
use Thelia\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -23,7 +23,6 @@
namespace %%NAMESPACE%%;
use Thelia\Module\BaseModule;
class %%CLASSNAME%% extends BaseModule
{

View File

@@ -24,8 +24,7 @@
namespace Thelia\Condition;
use Thelia\Condition\Implementation\ConditionInterface;
use Thelia\Condition\Operators;
use Thelia\Condition\ConditionCollection;
/**
* Validate Conditions

View File

@@ -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)

View File

@@ -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;

View File

@@ -24,7 +24,7 @@
namespace Thelia\Condition\Implementation;
use InvalidArgumentException;
use Thelia\Condition\Implementation\ConditionAbstract;
/**
* Allow every one, perform no check

View File

@@ -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;

View File

@@ -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;

View File

@@ -6,6 +6,35 @@
<services>
<service id="thelia.action.module" class="Thelia\Action\Module">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.order" class="Thelia\Action\Order" scope="request">
<argument type="service" id="request"/>
<argument type="service" id="thelia.parser"/>
<argument type="service" id="mailer"/>
<argument type="service" id="thelia.securityContext"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.coupon" class="Thelia\Action\Coupon" scope="request">
<argument type="service" id="request"/>
<argument type="service" id="thelia.coupon.factory"/>
<argument type="service" id="thelia.coupon.manager"/>
<argument type="service" id="thelia.condition.match_for_everyone"/>
<argument type="service" id="thelia.condition.factory"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.httpException" class="Thelia\Action\HttpException" scope="request">
<argument type="service" id="thelia.parser"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.address" class="Thelia\Action\Address">
<tag name="kernel.event_subscriber"/>
</service>
@@ -15,161 +44,114 @@
</service>
<service id="thelia.action.cart" class="Thelia\Action\Cart">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.order" class="Thelia\Action\Order">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.customer" class="Thelia\Action\Customer" scope="request">
<argument type="service" id="thelia.securityContext"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.image" class="Thelia\Action\Image">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.document" class="Thelia\Action\Document">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.category" class="Thelia\Action\Category">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.product" class="Thelia\Action\Product">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.product_sale_element" class="Thelia\Action\ProductSaleElement">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.config" class="Thelia\Action\Config">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.message" class="Thelia\Action\Message">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.coupon" class="Thelia\Action\Coupon">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.currency" class="Thelia\Action\Currency">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.template" class="Thelia\Action\Template">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.attribute" class="Thelia\Action\Attribute">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.feature" class="Thelia\Action\Feature">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.featureav" class="Thelia\Action\FeatureAv">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.httpException" class="Thelia\Action\HttpException">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.folder" class="Thelia\Action\Folder">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.taxrule" class="Thelia\Action\TaxRule">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.tax" class="Thelia\Action\Tax">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.content" class="Thelia\Action\Content">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.pdf" class="Thelia\Action\Pdf">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.country" class="Thelia\Action\Country">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.area" class="Thelia\Action\Area">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.shippingZone" class="Thelia\Action\ShippingZone">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.module" class="Thelia\Action\Module">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.cache" class="Thelia\Action\Cache">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.profile" class="Thelia\Action\Profile">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.mailing_system" class="Thelia\Action\MailingSystem">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.newsletter" class="Thelia\Action\Newsletter">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="thelia.action.lang" class="Thelia\Action\Lang">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
/**

View File

@@ -0,0 +1,53 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event\Module;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Module;
use Thelia\Model\Order;
/**
* Class PaymentEvent
* @package Thelia\Core\Event\Module
* @author Franck Allimant <franck@cqfdev.fr>
*/
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;
}
}

View File

@@ -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
*/

View File

@@ -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;
/**

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -23,7 +23,7 @@
namespace Thelia\Core\Security\UserProvider;
use Thelia\Model\Admin;
use Thelia\Model\AdminQuery;
class AdminUserProvider implements UserProviderInterface

View File

@@ -23,7 +23,7 @@
namespace Thelia\Core\Security\UserProvider;
use Thelia\Action\Customer;
use Thelia\Model\CustomerQuery;
class CustomerUserProvider implements UserProviderInterface
{

View File

@@ -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;

View File

@@ -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
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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":

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -71,7 +71,7 @@ class BaseFacade implements FacadeInterface
*/
public function getCart()
{
return $this->getCartFromTrait($this->getRequest());
return $this->getCartFromTrait($this->getDispatcher(), $this->getRequest());
}
/**

View File

@@ -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

View File

@@ -23,7 +23,7 @@
namespace Thelia\Coupon\Type;
use Thelia\Coupon\Type\CouponAbstract;
/**
* Allow to remove an amount from the checkout total

View File

@@ -24,8 +24,7 @@
namespace Thelia\Coupon\Type;
use Thelia\Coupon\FacadeInterface;
use Thelia\Coupon\Type\CouponAbstract;
use Thelia\Exception\MissingFacadeException;
/**
* @package Coupon

View File

@@ -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;

View File

@@ -23,7 +23,7 @@
namespace Thelia\Form\Area;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Thelia\Form\Area\AreaCreateForm;
/**
* Class AreaModificationForm

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -22,9 +22,9 @@
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ProfileQuery;
/**
* Class MailingSystemModificationForm

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -56,9 +56,6 @@ trait StandardDescriptionFieldsTrait
new NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title"
),
"label_attr" => array("for" => "title_field")
)
);

View File

@@ -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;

View File

@@ -23,7 +23,7 @@
namespace Thelia\Log\Destination;
use Thelia\Log\AbstractTlogDestination;
use Thelia\Log\TlogDestinationConfig;
use Thelia\Core\Translation\Translator;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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

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