refactor modify Article action

This commit is contained in:
Manuel Raynaud
2013-08-13 10:09:12 +02:00
parent 541fe7f75d
commit cf5ccdc7ae
5 changed files with 118 additions and 108 deletions

View File

@@ -24,18 +24,31 @@ namespace Thelia\Controller\Front;
use Thelia\Core\Event\CartEvent;
use Thelia\Core\Event\TheliaEvents;
class CartController extends BaseFrontController
{
use \Thelia\Cart\CartTrait;
public function addArticle()
{
$cartEvent = $this->getCartEvent();
$this->dispatch(TheliaEvents::CART_ADD, $cartEvent);
}
public function modifyArticle()
{
$cartEvent = $this->getCartEvent();
$this->dispatch(TheliaEvents::CART_MODIFYARTICLE, $cartEvent);
}
protected function getCartEvent()
{
$request = $this->getRequest();
$cart = $this->getCart($request);
$cartEvent = new CartEvent($request, "action.addArticle", $cart);
$this->dispatch("action.addArticle", $cartEvent);
return new CartEvent($request, $cart);
}
}