示例#1
0
 /**
  * Set support
  *
  * @param \Koopa\PostBundle\Entity\Support $support
  * @return Formule
  */
 public function setSupport(\Koopa\PostBundle\Entity\Support $support)
 {
     $this->support = $support;
     $support->addFormule($this);
     return $this;
 }
 /**
  * @Route("/formule/add/{support}", name="formule_add")
  * @Template()
  */
 public function formuleAddAction(Support $support, Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $formule = new Formule();
     $form = $this->createForm(new FormuleType($support->getId()), $formule);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em->persist($formule);
         $em->flush();
         $this->get('session')->getFlashBag()->add('success', "Formule bien ajouté");
         return $this->redirect($this->generateUrl('support_view', ['id' => $support->getId()]));
     }
     return ['form' => $form->createView(), 'supportId' => $support->getId()];
 }