/** * @Security("has_role('ROLE_USER')") * @ParamConverter("colonie", options={"mapping": {"colonie_id" : "id"}}) */ public function addAction(Colonie $colonie, Request $request) { if (!$this->getUser()->canDisplayExploitation($colonie->getRuche()->getRucher()->getExploitation()) || !$colonie->canBeRemeree()) { throw new NotFoundHttpException('Page inexistante.'); } $lastRemerage = $colonie->getRemerages()->last(); $colonie->remerer(); $form = $this->createForm(new RemerageType($lastRemerage), $colonie->getRemerages()->last()); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($colonie); $em->flush(); $flash = $this->get('braincrafted_bootstrap.flash'); $flash->success('Remérage créé avec succès'); return $this->redirect($this->generateUrl('kg_beekeeping_management_view_ruche', array('ruche_id' => $colonie->getRuche()->getId()))); } return $this->render('KGBeekeepingManagementBundle:Remerage:add.html.twig', array('form' => $form->createView(), 'colonie' => $colonie)); }