create a new event fire when cart item is duplicated

This commit is contained in:
Manuel Raynaud
2014-04-09 17:05:18 +02:00
parent ad58b27b00
commit 48b7eb9353
4 changed files with 78 additions and 2 deletions

View File

@@ -4,6 +4,9 @@ namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\Cart\CartItemDuplicationItem;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\Cart as BaseCart;
class Cart extends BaseCart
@@ -15,7 +18,7 @@ class Cart extends BaseCart
* @param Customer $customer
* @return Cart
*/
public function duplicate($token, Customer $customer = null)
public function duplicate($token, Customer $customer = null, EventDispatcherInterface $dispatcher)
{
$cartItems = $this->getCartItems();
@@ -62,6 +65,7 @@ class Cart extends BaseCart
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
}
$item->save();
$dispatcher->dispatch(TheliaEvents::CART_ITEM_DUPLICATE, new CartItemDuplicationItem($item, $cartItem));
}
}