Merge branch 'optim'
Conflicts: core/lib/Thelia/Action/Order.php
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -29,3 +29,4 @@ phpmyadmin
|
||||
templates/default-esi
|
||||
local/modules/TemplateEsiModule
|
||||
composer.phar
|
||||
web/.htaccess
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#2.0.0-beta5
|
||||
- Remove container from BaseAction.
|
||||
- fix sending mail on order creation
|
||||
|
||||
#2.0.0-beta4
|
||||
- Tinymce is now a dedicated module. You need to activate it.
|
||||
- Fix PDF creation. Bug #180
|
||||
|
||||
@@ -69,7 +69,7 @@ class Address extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event)
|
||||
{
|
||||
$addressModel->setDispatcher($this->getDispatcher());
|
||||
$addressModel->setDispatcher($event->getDispatcher());
|
||||
$con = Propel::getWriteConnection(AddressTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
try {
|
||||
|
||||
@@ -40,7 +40,7 @@ class Administrator extends BaseAction implements EventSubscriberInterface
|
||||
$administrator = new AdminModel();
|
||||
|
||||
$administrator
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setDispatcher($event->getDispatcher())
|
||||
->setFirstname($event->getFirstname())
|
||||
->setLastname($event->getLastname())
|
||||
->setLogin($event->getLogin())
|
||||
@@ -62,7 +62,7 @@ class Administrator extends BaseAction implements EventSubscriberInterface
|
||||
if (null !== $administrator = AdminQuery::create()->findPk($event->getId())) {
|
||||
|
||||
$administrator
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setDispatcher($event->getDispatcher())
|
||||
->setFirstname($event->getFirstname())
|
||||
->setLastname($event->getLastname())
|
||||
->setLogin($event->getLogin())
|
||||
|
||||
@@ -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,9 @@ class Area extends BaseAction implements EventSubscriberInterface
|
||||
public function removeCountry(AreaRemoveCountryEvent $event)
|
||||
{
|
||||
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
|
||||
$country->setDispatcher($this->getDispatcher());
|
||||
$event->setArea($country->getArea());
|
||||
|
||||
$country->setDispatcher($event->getDispatcher());
|
||||
$country->setAreaId(null)
|
||||
->save();
|
||||
}
|
||||
@@ -65,7 +67,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 +79,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 +91,7 @@ class Area extends BaseAction implements EventSubscriberInterface
|
||||
$area = new AreaModel();
|
||||
|
||||
$area
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setDispatcher($event->getDispatcher())
|
||||
->setName($event->getAreaName())
|
||||
->save();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Model\Customer as CustomerModel;
|
||||
use Thelia\Core\Event\Customer\CustomerLoginEvent;
|
||||
|
||||
@@ -41,6 +42,12 @@ use Thelia\Core\Event\Customer\CustomerLoginEvent;
|
||||
*/
|
||||
class Customer extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
protected $securityContext;
|
||||
|
||||
public function __construct(SecurityContext $securityContext)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
}
|
||||
|
||||
public function create(CustomerCreateOrUpdateEvent $event)
|
||||
{
|
||||
@@ -65,7 +72,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$customer = $event->getCustomer();
|
||||
|
||||
$customer->setDispatcher($this->getDispatcher());
|
||||
$customer->setDispatcher($event->getDispatcher());
|
||||
|
||||
$customer
|
||||
->setTitleId($event->getTitle())
|
||||
@@ -91,7 +98,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
private function createOrUpdateCustomer(CustomerModel $customer, CustomerCreateOrUpdateEvent $event)
|
||||
{
|
||||
$customer->setDispatcher($this->getDispatcher());
|
||||
$customer->setDispatcher($event->getDispatcher());
|
||||
|
||||
$customer->createOrUpdate(
|
||||
$event->getTitle(),
|
||||
@@ -120,7 +127,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
public function login(CustomerLoginEvent $event)
|
||||
{
|
||||
$this->getSecurityContext()->setCustomerUser($event->getCustomer());
|
||||
$this->securityContext->setCustomerUser($event->getCustomer());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,17 +137,7 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function logout(ActionEvent $event)
|
||||
{
|
||||
$this->getSecurityContext()->clearCustomerUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the security context
|
||||
*
|
||||
* @return Thelia\Core\Security\SecurityContext
|
||||
*/
|
||||
protected function getSecurityContext()
|
||||
{
|
||||
return $this->container->get('thelia.securityContext');
|
||||
$this->securityContext->clearCustomerUser();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
@@ -144,7 +130,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
|
||||
*/
|
||||
public function saveDocument(DocumentCreateOrUpdateEvent $event)
|
||||
{
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$model = $event->getModelDocument();
|
||||
|
||||
$nbModifiedLines = $model->save();
|
||||
@@ -180,7 +166,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
|
||||
$event->getModelDocument()->setTitle($event->getUploadedFile()->getClientOriginalName());
|
||||
}
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
// Copy and save file
|
||||
if ($event->getUploadedFile()) {
|
||||
// Remove old picture file from file storage
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,7 +197,7 @@ class Document extends BaseCachedFile implements EventSubscriberInterface
|
||||
*/
|
||||
public function deleteDocument(DocumentDeleteEvent $event)
|
||||
{
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$fileManager->deleteFile($event->getDocumentToDelete(), $event->getDocumentType(), FileManager::FILE_TYPE_DOCUMENTS);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
*/
|
||||
public function saveImage(ImageCreateOrUpdateEvent $event)
|
||||
{
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$model = $event->getModelImage();
|
||||
|
||||
$nbModifiedLines = $model->save();
|
||||
@@ -286,7 +286,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
*/
|
||||
public function updateImage(ImageCreateOrUpdateEvent $event)
|
||||
{
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
// Copy and save file
|
||||
if ($event->getUploadedFile()) {
|
||||
// Remove old picture file from file storage
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,7 +317,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface
|
||||
*/
|
||||
public function deleteImage(ImageDeleteEvent $event)
|
||||
{
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
|
||||
$fileManager->deleteFile($event->getImageToDelete(), $event->getImageType(), FileManager::FILE_TYPE_IMAGES);
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
;
|
||||
|
||||
|
||||
@@ -23,19 +23,23 @@
|
||||
|
||||
namespace Thelia\Action;
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
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\Order\OrderPaymentEvent;
|
||||
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Map\ModuleTableMap;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class Module
|
||||
@@ -44,6 +48,15 @@ use Thelia\Core\Translation\Translator;
|
||||
*/
|
||||
class Module extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function toggleActivation(ModuleToggleActivationEvent $event)
|
||||
{
|
||||
@@ -63,7 +76,7 @@ class Module extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$event->setModule($module);
|
||||
|
||||
$this->cacheClear();
|
||||
$this->cacheClear($event->getDispatcher());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +121,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 +138,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 +152,50 @@ 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(
|
||||
$this->container->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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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\Order\OrderAddressEvent;
|
||||
use Thelia\Core\Event\Order\OrderEvent;
|
||||
use Thelia\Core\Event\Order\OrderManualEvent;
|
||||
use Thelia\Core\Event\Order\OrderPaymentEvent;
|
||||
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;
|
||||
@@ -47,6 +52,8 @@ use Thelia\Model\OrderProductAttributeCombination;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
use Thelia\Tools\I18n;
|
||||
use Thelia\Model\Country;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -58,6 +65,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 +150,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
|
||||
@@ -126,9 +158,9 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
/* 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 +270,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 +311,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 +330,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 */
|
||||
@@ -318,14 +352,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,10 +384,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());
|
||||
@@ -362,7 +396,8 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
;
|
||||
|
||||
// Build subject and body
|
||||
$message->buildMessage($parser, $instance);
|
||||
|
||||
$message->buildMessage($this->parser, $instance);
|
||||
|
||||
$this->getMailer()->send($instance);
|
||||
}
|
||||
@@ -376,9 +411,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function getMailer()
|
||||
{
|
||||
$mailer = $this->container->get('mailer');
|
||||
|
||||
return $mailer->getSwiftMailer();
|
||||
return $this->mailer->getSwiftMailer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,24 +502,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
|
||||
*
|
||||
@@ -494,8 +509,6 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
protected function getSession()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
return $request->getSession();
|
||||
return $this->request->getSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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()
|
||||
;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Thelia\Command;
|
||||
|
||||
use Thelia\Command\ContainerAwareCommand;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace %%NAMESPACE%%;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class %%CLASSNAME%% extends BaseModule
|
||||
{
|
||||
@@ -24,8 +24,7 @@
|
||||
namespace Thelia\Condition;
|
||||
|
||||
use Thelia\Condition\Implementation\ConditionInterface;
|
||||
use Thelia\Condition\Operators;
|
||||
use Thelia\Condition\ConditionCollection;
|
||||
|
||||
|
||||
/**
|
||||
* Validate Conditions
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace Thelia\Condition\Implementation;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Thelia\Condition\Implementation\ConditionAbstract;
|
||||
|
||||
|
||||
/**
|
||||
* Allow every one, perform no check
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -6,172 +6,153 @@
|
||||
|
||||
<services>
|
||||
|
||||
<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">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.address" class="Thelia\Action\Address">
|
||||
<argument type="service" id="service_container"/>
|
||||
<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"/>
|
||||
<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.profile" class="Thelia\Action\Profile">
|
||||
<argument type="service" id="service_container"/>
|
||||
<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.customer" class="Thelia\Action\Customer" scope="request">
|
||||
<argument type="service" id="thelia.securityContext"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
|
||||
<service id="thelia.action.address" class="Thelia\Action\Address">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.administrator" class="Thelia\Action\Administrator">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.cart" class="Thelia\Action\Cart">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.image" class="Thelia\Action\Image">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
<service id="thelia.action.document" class="Thelia\Action\Document">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.category" class="Thelia\Action\Category">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.product" class="Thelia\Action\Product">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.product_sale_element" class="Thelia\Action\ProductSaleElement">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.config" class="Thelia\Action\Config">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.message" class="Thelia\Action\Message">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.currency" class="Thelia\Action\Currency">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.template" class="Thelia\Action\Template">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.attribute" class="Thelia\Action\Attribute">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.feature" class="Thelia\Action\Feature">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.attributeav" class="Thelia\Action\AttributeAv">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.featureav" class="Thelia\Action\FeatureAv">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.folder" class="Thelia\Action\Folder">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.taxrule" class="Thelia\Action\TaxRule">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.tax" class="Thelia\Action\Tax">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.content" class="Thelia\Action\Content">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.pdf" class="Thelia\Action\Pdf">
|
||||
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.country" class="Thelia\Action\Country">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.area" class="Thelia\Action\Area">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.shippingZone" class="Thelia\Action\ShippingZone">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.cache" class="Thelia\Action\Cache">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.profile" class="Thelia\Action\Profile">
|
||||
<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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class FileController extends BaseAdminController
|
||||
/** @var UploadedFile $fileBeingUploaded */
|
||||
$fileBeingUploaded = $this->getRequest()->files->get('file');
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
|
||||
// Validate if file is too big
|
||||
if ($fileBeingUploaded->getError() == 1) {
|
||||
@@ -171,7 +171,7 @@ class FileController extends BaseAdminController
|
||||
/** @var UploadedFile $fileBeingUploaded */
|
||||
$fileBeingUploaded = $this->getRequest()->files->get('file');
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
|
||||
// Validate if file is too big
|
||||
if ($fileBeingUploaded->getError() == 1) {
|
||||
@@ -312,7 +312,7 @@ class FileController extends BaseAdminController
|
||||
return $response;
|
||||
}
|
||||
try {
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$image = $fileManager->getImageModelQuery($parentType)->findPk($imageId);
|
||||
$redirectUrl = $fileManager->getRedirectionUrl($parentType, $image->getParentId(), FileManager::FILE_TYPE_IMAGES);
|
||||
|
||||
@@ -341,7 +341,7 @@ class FileController extends BaseAdminController
|
||||
return $response;
|
||||
}
|
||||
try {
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$document = $fileManager->getDocumentModelQuery($parentType)->findPk($documentId);
|
||||
$redirectUrl = $fileManager->getRedirectionUrl($parentType, $document->getParentId(), FileManager::FILE_TYPE_DOCUMENTS);
|
||||
|
||||
@@ -372,7 +372,7 @@ class FileController extends BaseAdminController
|
||||
|
||||
$message = false;
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$imageModification = $fileManager->getImageForm($parentType, $this->getRequest());
|
||||
|
||||
try {
|
||||
@@ -449,7 +449,7 @@ class FileController extends BaseAdminController
|
||||
|
||||
$message = false;
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$documentModification = $fileManager->getDocumentForm($parentType, $this->getRequest());
|
||||
|
||||
try {
|
||||
@@ -525,7 +525,7 @@ class FileController extends BaseAdminController
|
||||
$this->checkAuth(AdminResources::retrieve($parentType), array(), AccessManager::UPDATE);
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$imageModelQuery = $fileManager->getImageModelQuery($parentType);
|
||||
$model = $imageModelQuery->findPk($imageId);
|
||||
|
||||
@@ -606,7 +606,7 @@ class FileController extends BaseAdminController
|
||||
$this->checkAuth(AdminResources::retrieve($parentType), array(), AccessManager::UPDATE);
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$imageModelQuery = $fileManager->getImageModelQuery($parentType);
|
||||
$model = $imageModelQuery->findPk($imageId);
|
||||
|
||||
@@ -660,7 +660,7 @@ class FileController extends BaseAdminController
|
||||
$this->checkAuth(AdminResources::retrieve($parentType), array(), AccessManager::UPDATE);
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$documentModelQuery = $fileManager->getDocumentModelQuery($parentType);
|
||||
$model = $documentModelQuery->findPk($documentId);
|
||||
|
||||
@@ -717,7 +717,7 @@ class FileController extends BaseAdminController
|
||||
$this->checkAuth(AdminResources::retrieve($parentType), array(), AccessManager::UPDATE);
|
||||
$this->checkXmlHttpRequest();
|
||||
|
||||
$fileManager = new FileManager($this->container);
|
||||
$fileManager = new FileManager();
|
||||
$documentModelQuery = $fileManager->getDocumentModelQuery($parentType);
|
||||
$model = $documentModelQuery->findPk($documentId);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Form\ModuleModificationForm;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\ModuleManagement;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
@@ -56,20 +57,6 @@ class ModuleController extends AbstractCrudController
|
||||
null,
|
||||
null,
|
||||
TheliaEvents::MODULE_UPDATE_POSITION
|
||||
/*
|
||||
$objectName,
|
||||
|
||||
$defaultListOrder = null,
|
||||
$orderRequestParameterName = null,
|
||||
|
||||
$resourceCode,
|
||||
|
||||
$createEventIdentifier,
|
||||
$updateEventIdentifier,
|
||||
$deleteEventIdentifier,
|
||||
$visibilityToggleEventIdentifier = null,
|
||||
$changePositionEventIdentifier = null
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
@@ -249,6 +236,8 @@ class ModuleController extends AbstractCrudController
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
|
||||
Tlog::getInstance()->addError("Failed to activate/deactivate module:", $e);
|
||||
}
|
||||
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
@@ -288,8 +277,9 @@ class ModuleController extends AbstractCrudController
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during module removal : %s", $message));
|
||||
$message = $e->getMessage();
|
||||
|
||||
Tlog::getInstance()->addError("Error during module removal", $e);
|
||||
}
|
||||
|
||||
if ($message) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,6 +62,8 @@ class AdministratorEvent extends ActionEvent
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
@@ -72,6 +74,8 @@ class AdministratorEvent extends ActionEvent
|
||||
public function setFirstname($firstname)
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFirstname()
|
||||
@@ -82,6 +86,8 @@ class AdministratorEvent extends ActionEvent
|
||||
public function setLastname($lastname)
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastname()
|
||||
@@ -92,6 +98,8 @@ class AdministratorEvent extends ActionEvent
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLogin()
|
||||
@@ -102,6 +110,8 @@ class AdministratorEvent extends ActionEvent
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
@@ -112,6 +122,8 @@ class AdministratorEvent extends ActionEvent
|
||||
public function setProfile($profile)
|
||||
{
|
||||
$this->profile = $profile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
|
||||
@@ -54,6 +54,8 @@ class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +72,8 @@ class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
public function setAdmin(Admin $admin)
|
||||
{
|
||||
$this->admin = $admin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,8 @@ class AreaCreateEvent extends AreaEvent
|
||||
public function setAreaName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,9 @@ use Thelia\Core\Event\ActionEvent;
|
||||
*/
|
||||
class AreaEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Area
|
||||
*/
|
||||
protected $area;
|
||||
|
||||
public function __construct($area = null)
|
||||
@@ -51,7 +54,7 @@ class AreaEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return null|\Thelia\Model\Area
|
||||
*/
|
||||
public function getArea()
|
||||
{
|
||||
|
||||
52
core/lib/Thelia/Core/Event/Order/OrderPaymentEvent.php
Normal file
52
core/lib/Thelia/Core/Event/Order/OrderPaymentEvent.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Order;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Security\UserProvider;
|
||||
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
use Thelia\Model\AdminQuery;
|
||||
|
||||
class AdminUserProvider implements UserProviderInterface
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Security\UserProvider;
|
||||
|
||||
use Thelia\Action\Customer;
|
||||
|
||||
use Thelia\Model\CustomerQuery;
|
||||
class CustomerUserProvider implements UserProviderInterface
|
||||
{
|
||||
|
||||
@@ -316,8 +316,6 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
// Get the URL part from the relative path
|
||||
$outputRelativePath = $webAssetsTemplate . DS . $webAssetsKey;
|
||||
|
||||
$outputRelativeWebPath = rtrim(str_replace('\\', '/', $outputRelativePath), '/') . '/';
|
||||
|
||||
$assetTargetFilename = $asset->getTargetPath();
|
||||
|
||||
/*
|
||||
@@ -333,11 +331,18 @@ class AsseticAssetManager implements AssetManagerInterface
|
||||
|
||||
$writer = new AssetWriter($outputDirectory . DS . $assetFileDirectoryInAssetDirectory);
|
||||
|
||||
Tlog::getInstance()->addDebug("Writing asset to $outputDirectory . DS . $assetFileDirectoryInAssetDirectory");
|
||||
Tlog::getInstance()->addDebug("Writing asset to $outputDirectory" . DS . "$assetFileDirectoryInAssetDirectory");
|
||||
|
||||
$writer->writeAsset($asset);
|
||||
}
|
||||
|
||||
// Normalize path to generate a valid URL
|
||||
if (DS != '/') {
|
||||
$outputRelativeWebPath = str_replace(DS, '/', $outputRelativePath);
|
||||
$assetFileDirectoryInAssetDirectory = str_replace(DS, '/', $assetFileDirectoryInAssetDirectory);
|
||||
$assetTargetFilename = str_replace(DS, '/', $assetTargetFilename);
|
||||
}
|
||||
|
||||
return rtrim($outputUrl, '/') . '/' . trim($outputRelativeWebPath, '/') . '/' . trim($assetFileDirectoryInAssetDirectory, '/') . '/' . ltrim($assetTargetFilename, '/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -24,14 +24,11 @@
|
||||
namespace Thelia\Core\Template\Element;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Template\Element\Exception\LoopException;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Type\AlphaNumStringListType;
|
||||
use Thelia\Type\EnumListType;
|
||||
use Thelia\Type\EnumType;
|
||||
use Thelia\Type\TypeCollection;
|
||||
@@ -339,7 +336,7 @@ abstract class BaseLoop
|
||||
public function count()
|
||||
{
|
||||
$hash = $this->args->getHash();
|
||||
if(false === array_key_exists($hash, self::$cacheCount))
|
||||
if(false === isset(self::$cacheCount[$hash]))
|
||||
{
|
||||
$count = 0;
|
||||
if ($this instanceof PropelSearchLoopInterface) {
|
||||
@@ -370,7 +367,7 @@ abstract class BaseLoop
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$hash = $this->args->getHash();
|
||||
if(false === array_key_exists($hash, self::$cacheLoopResult))
|
||||
if(false === isset(self::$cacheLoopResult[$hash]))
|
||||
{
|
||||
if ($this instanceof PropelSearchLoopInterface) {
|
||||
$searchModelCriteria = $this->buildModelCriteria();
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -56,6 +56,11 @@ class Argument
|
||||
return $this->type->getFormattedValue($this->value);
|
||||
}
|
||||
|
||||
public function getRawValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
if ($value === null) {
|
||||
@@ -147,4 +152,5 @@ class Argument
|
||||
$empty
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -153,6 +153,11 @@ class ArgumentCollection implements \Iterator
|
||||
unset($arguments['name']);
|
||||
}
|
||||
|
||||
return sha1(serialize($arguments));
|
||||
$string = '';
|
||||
foreach ($arguments as $key => $argument) {
|
||||
$string .= $key.'='.$argument->getRawValue();
|
||||
}
|
||||
|
||||
return md5($string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
namespace Thelia\Core\Template\Smarty\Assets;
|
||||
|
||||
use Thelia\Core\Template\TemplateDefinition;
|
||||
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\Template\Assets\AssetManagerInterface;
|
||||
|
||||
@@ -109,6 +110,11 @@ class SmartyAssetsManager
|
||||
|
||||
$assetSource = $templateDirectories[$templateDefinition->getName()][$assetOrigin];
|
||||
|
||||
if (DS != '/') {
|
||||
// Just to be sure to generate a clean pathname
|
||||
$file = str_replace('/', DS, $file);
|
||||
}
|
||||
|
||||
$url = $this->assetsManager->processAsset(
|
||||
$assetSource . DS . $file,
|
||||
$assetSource . DS . self::$assetsDirectory,
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -48,7 +48,13 @@ class Module extends AbstractSmartyPlugin
|
||||
/**
|
||||
* Process theliaModule template inclusion function
|
||||
*
|
||||
* @param unknown $params
|
||||
* This function accepts two parameters:
|
||||
*
|
||||
* - location : this is the location in the admin template. Example: folder-edit'. The function will search for
|
||||
* AdminIncludes/<location>.html file, and fetch it as a Smarty template.
|
||||
* - countvar : this is the name of a template variable where the number of found modules includes will be assigned.
|
||||
*
|
||||
* @param array $params
|
||||
* @param \Smarty_Internal_Template $template
|
||||
* @internal param \Thelia\Core\Template\Smarty\Plugins\unknown $smarty
|
||||
*
|
||||
@@ -68,6 +74,8 @@ class Module extends AbstractSmartyPlugin
|
||||
|
||||
$modules = ModuleQuery::getActivated();
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($modules as $module) {
|
||||
|
||||
if (null !== $moduleLimit && $moduleLimit != $module->getCode()) {
|
||||
@@ -78,6 +86,8 @@ class Module extends AbstractSmartyPlugin
|
||||
|
||||
if (file_exists($file)) {
|
||||
$content .= file_get_contents($file);
|
||||
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +96,10 @@ class Module extends AbstractSmartyPlugin
|
||||
return $template->fetch(sprintf("string:%s", $content));
|
||||
}
|
||||
|
||||
if (false !== $countvarname = $this->getParam($params, 'countvar', false)) {
|
||||
$template->assign($countvarname, $count);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -30,10 +30,10 @@ class TemplateDefinition
|
||||
const PDF = 3;
|
||||
const EMAIL = 4;
|
||||
|
||||
const FRONT_OFFICE_SUBDIR = 'frontOffice/';
|
||||
const BACK_OFFICE_SUBDIR = 'backOffice/';
|
||||
const PDF_SUBDIR = 'pdf/';
|
||||
const EMAIL_SUBDIR = 'email/';
|
||||
const FRONT_OFFICE_SUBDIR = 'frontOffice';
|
||||
const BACK_OFFICE_SUBDIR = 'backOffice';
|
||||
const PDF_SUBDIR = 'pdf';
|
||||
const EMAIL_SUBDIR = 'email';
|
||||
|
||||
protected static $standardTemplatesSubdirs = array(
|
||||
self::FRONT_OFFICE => self::FRONT_OFFICE_SUBDIR,
|
||||
@@ -64,16 +64,16 @@ class TemplateDefinition
|
||||
|
||||
switch ($type) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
$this->path = self::FRONT_OFFICE_SUBDIR . $name;
|
||||
$this->path = self::FRONT_OFFICE_SUBDIR . DS . $name;
|
||||
break;
|
||||
case TemplateDefinition::BACK_OFFICE:
|
||||
$this->path = self::BACK_OFFICE_SUBDIR . $name;
|
||||
$this->path = self::BACK_OFFICE_SUBDIR . DS . $name;
|
||||
break;
|
||||
case TemplateDefinition::PDF:
|
||||
$this->path = self::PDF_SUBDIR . $name;
|
||||
$this->path = self::PDF_SUBDIR . DS . $name;
|
||||
break;
|
||||
case TemplateDefinition::EMAIL:
|
||||
$this->path = self::EMAIL_SUBDIR . $name;
|
||||
$this->path = self::EMAIL_SUBDIR . DS . $name;
|
||||
break;
|
||||
default:
|
||||
$this->path = $name;
|
||||
|
||||
@@ -129,7 +129,7 @@ class TemplateHelper
|
||||
if ($file->isDot() || ! $file->isDir()) continue;
|
||||
|
||||
// Ignore reserved directory names
|
||||
if (in_array($file->getFilename()."/", $exclude)) continue;
|
||||
if (in_array($file->getFilename(), $exclude)) continue;
|
||||
|
||||
$list[] = new TemplateDefinition($file->getFilename(), $templateType);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class BaseFacade implements FacadeInterface
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
return $this->getCartFromTrait($this->getRequest());
|
||||
return $this->getCartFromTrait($this->getDispatcher(), $this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
use Thelia\Coupon\Type\CouponAbstract;
|
||||
|
||||
|
||||
/**
|
||||
* Allow to remove an amount from the checkout total
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
namespace Thelia\Coupon\Type;
|
||||
|
||||
use Thelia\Coupon\FacadeInterface;
|
||||
use Thelia\Coupon\Type\CouponAbstract;
|
||||
use Thelia\Exception\MissingFacadeException;
|
||||
|
||||
|
||||
/**
|
||||
* @package Coupon
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user