public function addlangueAction(Request $request) { if (false === $this->get('security.context')->isGranted('ROLE_USER') || $this->get('security.context')->isGranted('ROLE_ADMIN') || $this->get('security.context')->isGranted('ROLE_MANAGER')) { throw new AccessDeniedException(); } $em = $this->getDoctrine()->getManager(); $router = $this->container->get('router'); $c = new Candidat(); $c = $em->getRepository("UtilisateurBundle:Candidat")->findOneByUtilisateur($this->getUser()); $niv = new NivLanguCandidat(); $niv->setIdCandidat($c); $langue = $em->getRepository("UtilisateurBundle:NivLanguCandidat")->findByIdCandidat($c); $form = $this->createForm(new NivLanguCandidatType(), $niv); $form->handleRequest($request); if ($form->isValid()) { $add = $form->getData(); try { $em->persist($add); $em->flush(); $this->get('session')->getFlashBag()->add('notice', 'enregistré'); return new RedirectResponse($router->generate('candidat_addlangue'), 302); } catch (\Exception $e) { $this->get('session')->getFlashBag()->add('erreur', $e); } } return $this->render('CandidatBundle:Pages:addlangue.html.twig', array('candidat' => $langue, 'form' => $form->createView())); }
/** * {@inheritDoc} */ public function getIdNiveauLangue() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIdNiveauLangue', array()); return parent::getIdNiveauLangue(); }