/** * @Route("/behalf/{id}", requirements={"id"="\d+"}, name="front_behalf_delete") * @ParamConverter("behalf", class="WoojinGoodsBundle:Behalf") * @Method("DELETE") */ public function deleteAction(Request $request, Behalf $behalf) { $custom = $this->get('session.custom')->current(); if (!$this->get('security.csrf.token_manager')->isCsrfTokenValid('behalf_cancel', $request->request->get('avenue_token'))) { throw new AccessDeniedHttpException('Invalid CSRF token.'); } if ($behalf->getCustom()->getId() !== $custom->getId()) { throw new AccessDeniedHttpException('不可刪除他人的代購請求'); } $options = array('behalf' => $behalf); $this->get('factory.behalf')->cancel($options); $session = $this->get('session'); $session->getFlashBag()->add('success', $behalf->getWant()->getName() . '的代購請求已經取消'); return $this->redirect($this->generateUrl('front_profile_behalf')); }
public function behalfForAvenue(Behalf $behalf) { $message = $this->genMessage(array($behalf->getCustom()->getEmail()), '官網代購通知', $this->templating->render(':Email:behalfEm.html.twig', array('behalf' => $behalf))); $this->mailer->send($message); return $this; }