/** * This action is used to submit the cart summary form. * If the form and updated cart are valid, it refreshes * the cart data and saves it using the operator. * * If there are any errors, it displays the cart summary page. * * @param Request $request * * @return Response */ public function saveAction(Request $request) { $cart = $this->getCurrentCart(); $form = $this->createForm('sylius_cart', $cart); if ($form->handleRequest($request)->isValid()) { $event = new CartEvent($cart); $event->isFresh(true); $eventDispatcher = $this->getEventDispatcher(); $eventDispatcher->dispatch(SyliusCartEvents::CART_CHANGE, new GenericEvent($cart)); // Update models $eventDispatcher->dispatch(SyliusCartEvents::CART_SAVE_INITIALIZE, $event); // Write flash message $eventDispatcher->dispatch(SyliusCartEvents::CART_SAVE_COMPLETED, new FlashEvent()); return $this->redirectToCartSummary(); } $view = $this->view()->setTemplate($this->config->getTemplate('summary.html'))->setData(array('cart' => $cart, 'form' => $form->createView())); return $this->handleView($view); }