/**
  * @Security("has_role('ROLE_SUIVEUR')")
  */
 public function addAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     // On vérifie que l'article d'id $id existe bien, sinon, erreur 404.
     if (!($etude = $em->getRepository('Mgate\\SuiviBundle\\Entity\\Etude')->find($id))) {
         throw $this->createNotFoundException('Article[id=' . $id . '] inexistant');
     }
     if ($this->get('Mgate.etude_manager')->confidentielRefus($etude, $this->getUser(), $this->get('security.authorization_checker'))) {
         throw new AccessDeniedException('Cette étude est confidentielle');
     }
     $avmission = new AvMission();
     $avmission->setEtude($etude);
     $form = $this->createForm(new AvMissionType(), $avmission);
     $formHandler = new AvMissionHandler($form, $this->get('request'), $em);
     if ($formHandler->process()) {
         return $this->redirect($this->generateUrl('MgateSuivi_avmission_voir', array('id' => $avmission->getId())));
     }
     return $this->render('MgateSuiviBundle:AvMission:ajouter.html.twig', array('form' => $form->createView()));
 }
Esempio n. 2
0
 /**
  * Remove avenantsMissions.
  *
  * @param AvMission $avenantsMissions
  */
 public function removeAvenantsMission(AvMission $avenantsMissions)
 {
     $this->avenantsMissions->removeElement($avenantsMissions);
 }