Example #1
0
 /**
  * @Route("/contrat/{id}/suppression", name="contrat_suppression")
  * @ParamConverter("contrat", class="AppBundle:Contrat")
  */
 public function suppressionAction(Request $request, Contrat $contrat)
 {
     $dm = $this->get('doctrine_mongodb')->getManager();
     if (!$contrat->isModifiable()) {
         throw $this->createNotFoundException();
     }
     $societeId = $contrat->getSociete()->getId();
     foreach ($contrat->getContratPassages() as $contratPassages) {
         foreach ($contratPassages->getPassages() as $passage) {
             $dm->remove($passage);
         }
     }
     $dm->remove($contrat);
     $dm->flush();
     return $this->redirectToRoute('contrats_societe', array('id' => $societeId));
 }