Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function apply(CartInterface $cart, $transition, $andFlush = false)
 {
     $finiteStateMachine = $this->finiteContext->getStateMachine($cart);
     if ($finiteStateMachine->can($transition)) {
         $finiteStateMachine->apply($transition);
         if ($andFlush) {
             $this->cartManager->updateCart($cart);
         }
         return true;
     }
     throw new TransitionException($transition, $cart->getState());
 }
Ejemplo n.º 2
0
 /**
  * Remove the given cart item from the given cart.
  *
  * @param CartInterface $cart
  * @param ItemInterface $item
  *
  * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
  */
 private function doDeleteItem(CartInterface $cart, ItemInterface $item)
 {
     if (!$this->cartManager->removeItem($cart, $item)) {
         throw new BadRequestHttpException();
     }
     $this->dispatcher->dispatch(LeaphlyCartEvents::ITEM_DELETE_COMPLETED, $this->eventFactory->getEvent($cart, $item));
 }