public function addexperienceAction() { 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(); $c = new Candidat(); $c = $em->getRepository("UtilisateurBundle:Candidat")->findOneByUtilisateur($this->getUser()); if (!$c) { $this->get('session')->getFlashBag()->add('msgformation', 'formation'); $router = $this->container->get('router'); return $this->redirect($router->generate('candidat_afficherexperience'), 307); } $experience = new Experience(); $nivexperience = new CandidatExperienceNiveau(); $nivexperience->setIdExperience($experience); $nivexperience->setIdCandidat($c); $experience->getCandidatNE()->add($nivexperience); $form = $this->createForm(new ExperienceType(), $experience); $form->bind($this->getRequest()); if ($form->isValid()) { try { $add = $form->getData(); $em->persist($add); $em->flush(); $this->get('session')->getFlashBag()->add('notice', 'enregistré'); } catch (\Exception $e) { $this->get('session')->getFlashBag()->add('erreur', $e); } } return $this->render('CandidatBundle:Pages:addexperience.html.twig', array('form' => $form->createView())); }
/** * {@inheritDoc} */ public function getIdNiveauExperience() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIdNiveauExperience', array()); return parent::getIdNiveauExperience(); }
public function addCandidatNE(\Utilisateur\UtilisateurBundle\Entity\CandidatExperienceNiveau $candidatNE) { $candidatNE->setIdExperience($this); $this->candidatNE[] = $candidatNE; return $this; }