/** * @Route("/product/edit/{id}") * @Template() */ public function productEditAction(\Club\ShopBundle\Entity\Order $order) { $em = $this->getDoctrine()->getManager(); if ($order->getPaid() || $order->getCancelled() || $order->getDelivered()) { $this->get('session')->getFlashBag()->add('error', $this->get('translator')->trans('You cannot chance a order which has been processed')); return $this->redirect($this->generateUrl('admin_shop_order_edit', array('id' => $order->getId()))); } $form = $this->createForm(new \Club\ShopBundle\Form\OrderType(), $order); if ($this->getRequest()->getMethod() == 'POST') { $form->bind($this->getRequest()); if ($form->isValid()) { $this->get('order')->setOrder($order); $this->get('order')->recalcPrice(); $em->persist($order); $em->flush(); $this->get('session')->getFlashBag()->add('notice', $this->get('translator')->trans('Your changes are saved.')); return $this->redirect($this->generateUrl('admin_shop_order_edit', array('id' => $order->getId()))); } } return array('order' => $order, 'form' => $form->createView()); }