public function addformationAction(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()->getEntityManager();
     $candidat = new Candidat();
     $candidat = $em->getRepository("UtilisateurBundle:Candidat")->findOneByUtilisateur($this->getUser());
     if (!$candidat) {
         $this->get('session')->getFlashBag()->add('msgformation', 'formation');
         $router = $this->container->get('router');
         return $this->redirect($router->generate('candidat_showformation'), 307);
     }
     $candidat->getUtilisateur();
     $formation = new Formation();
     $formation->setIdCandidat($candidat);
     $em->persist($candidat);
     $form = $this->createForm(new FormationType(), $formation);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $add = $form->getData();
         try {
             $em->persist($add);
             $em->flush();
             $this->get('session')->getFlashBag()->add('notice', 'enregistré');
         } catch (\Exception $e) {
             $this->get('session')->getFlashBag()->add('notice', 'enregistré');
             $this->get('session')->getFlashBag()->add('erreur', $e);
         }
     }
     return $this->render('CandidatBundle:Pages:addformation.html.twig', array('form' => $form->createView()));
 }
 /**
  * {@inheritDoc}
  */
 public function getIdCandidat()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getIdCandidat', array());
     return parent::getIdCandidat();
 }