示例#1
0
 private function validateOwner(\Club\ShopBundle\Entity\Order $order)
 {
     $user = $this->get('security.context')->getToken()->getUser();
     // FIXME, does security not allowed exception exists
     if ($order->getUser()->getId() != $user->getId()) {
         throw new \Exception('You are not allowed to change this order.');
     }
 }
示例#2
0
 public function isFirstAccepted(\Club\ShopBundle\Entity\Order $order)
 {
     if (!$order->getOrderStatus()->getAccepted()) {
         return false;
     }
     foreach ($order->getOrderStatusHistory() as $status) {
         // check if order already has been accepted
         if ($status->getOrderStatus()->getAccepted()) {
             return false;
         }
     }
     return true;
 }
 /**
  * @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());
 }