Exemplo n.º 1
0
 /**
  * Add taches
  *
  * @param \KG\BeekeepingManagementBundle\Entity\Tache $tache
  * @return Ruche
  */
 public function addTache(\KG\BeekeepingManagementBundle\Entity\Tache $tache)
 {
     $this->taches[] = $tache;
     $tache->setVisite($this);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @Security("has_role('ROLE_USER')")
  * @ParamConverter("tache", options={"mapping": {"tache_id" : "id"}})  
  * @ParamConverter("rucher", options={"mapping": {"rucher_id" : "id"}})  
  */
 public function duplicateAction(Request $request, Tache $tache, Rucher $rucher)
 {
     if (!$this->getUser()->canDisplayExploitation($tache->getColonie()->getRuche()->getRucher()->getExploitation()) || !$this->getUser()->canDisplayExploitation($rucher->getExploitation()) || !$rucher->hasRuche()) {
         throw new NotFoundHttpException('Page inexistante.');
     }
     $form = $this->createForm(new DupliquerTacheType($this->getDoctrine()->getManager()), $rucher);
     if ($form->handleRequest($request)->isValid()) {
         $em = $this->getDoctrine()->getManager();
         foreach ($form['ruches']->getData() as $ruche) {
             $tacheCopy = new Tache($ruche->getColonie());
             $tacheCopy->setDate($tache->getDate());
             $tacheCopy->setDescription($tache->getDescription());
             $tacheCopy->setResume($tache->getResume());
             $tacheCopy->setPriorite($tache->getPriorite());
             $em->persist($tacheCopy);
         }
         $em->flush();
         $flash = $this->get('braincrafted_bootstrap.flash');
         $flash->success('Tâche dupliquée avec succès');
         return $this->redirect($this->generateUrl('kg_beekeeping_management_view_rucher', array('rucher_id' => $rucher->getId())));
     }
     return $this->render('KGBeekeepingManagementBundle:Tache:duplicate.html.twig', array('form' => $form->createView(), 'rucher' => $rucher, 'tache' => $tache));
 }