Example #1
0
 protected function isNotCalcelled(AuctionPayment $payment)
 {
     return !$payment->getIsCancel();
 }
 /**
  * @Route("/{id}", name="auction_payment_drop", options={"expose"=true})
  * @ParamConverter("payment", class="WoojinStoreBundle:AuctionPayment")
  * @Method("DELETE")
  */
 public function dropAction(AuctionPayment $payment)
 {
     /**
      * DoctrineManager
      *
      * @var \Doctrine\ORM\EntityManager;
      */
     $em = $this->getDoctrine()->getManager();
     /**
      * 目前登入的使用者實體
      *
      * @var \Woojin\UserBundle\Entity\User
      */
     $user = $this->get('security.token_storage')->getToken()->getUser();
     /**
      * Session
      *
      * @var \Symfony\Component\HttpFoundation\Session\Session
      */
     $session = $this->get('session');
     /**
      * @var \Woojin\Service\Store\AuctionPaymentService
      */
     $service = $this->get('auction.payment.service');
     if (!$payment->getAuction()->isAllowedEditPayment($user) || true === $payment->getIsCancel()) {
         throw $this->createAccessDeniedException('Not allowed to edit this auction!');
     }
     try {
         $payment = $service->drop($payment, array('canceller' => $user));
         $em->persist($payment);
         $em->flush();
         $session->getFlashBag()->add('success', '競拍付款取消完成!');
     } catch (\Exception $e) {
         $session->getFlashBag()->add('error', $e->getMessage());
     }
     return $this->redirect($this->generateUrl('goods_edit_v2', array('id' => $payment->getAuction()->getProduct()->getId())) . '/#_soldop');
 }