/**
  * Creates a new Lotissement entity.
  *
  *
  */
 public function createAction(Request $request)
 {
     $this->verifyAccess();
     $em = $this->getDoctrine()->getManager();
     $entity = new Lotissement();
     $marche = new Marche();
     $avenant = new Avenant();
     $libelleZero = $em->getRepository("LaisoArmBundle:LibelleAvenant")->findOneByNumero(0);
     $avenant->setLibelle($libelleZero);
     $avenant->setMarche($marche);
     $avenant->setMotif("Marché initial");
     $avenant->setDelai($entity->getDelai());
     $entity->setValide(false);
     $entity->setPuValide(false);
     $avenant->setValide(false);
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em->persist($entity);
         $avenant->setDelai($entity->getDelai());
         $marche->setLotissement($entity);
         $marche->setEntrepriseAssujettie(false);
         $em->persist($marche);
         $em->persist($avenant);
         $em->flush();
         return $this->redirect($this->generateUrl('dao_show', array('id' => $entity->getId())));
     }
     return $this->render('LaisoArmBundle:Lotissement:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }