Ejemplo n.º 1
0
 /**
  * @Route("/deoktache/{id}", name="creneaumaker_deoktache")
  */
 public function deoktacheAction($id)
 {
     if (false === $this->get('security.context')->isGranted('ROLE_HUMAIN')) {
         throw new AccessDeniedException();
     }
     $em = $this->getDoctrine()->getEntityManager();
     $config = $this->get('config.extension');
     $admin = $this->get('security.context')->isGranted('ROLE_HUMAIN');
     $user = $this->get('security.context')->getToken()->getUser();
     $entity = $em->getRepository('AssoMakerPHPMBundle:Tache')->find($id);
     if (!$entity) {
         throw $this->createNotFoundException('Cette tâche n\'existe pas.');
     }
     if ($entity->getStatut() < 2) {
         throw new \Exception("La tâche doit être validée");
     }
     $commentaire = new Commentaire();
     $commentaire->setAuteur($user);
     $commentaire->setHeure(new \DateTime());
     $commentaire->setTache($entity);
     $commentaire->setTexte('<b>&rarr;Tache validée.</b>');
     $em->persist($commentaire);
     $entity->setStatut(2);
     $em->flush();
     return $this->redirect($this->generateUrl('tache_edit', array('id' => $entity->getId())));
 }
Ejemplo n.º 2
0
 /**
  * Moves a Tache entity to trash.
  *
  * @Route("/{id}/trash", name="tache_trash")
  *
  */
 public function trashAction($id)
 {
     if (false === $this->get('security.context')->isGranted('ROLE_USER')) {
         throw new AccessDeniedException();
     }
     $em = $this->getDoctrine()->getEntityManager();
     $entity = $em->getRepository('AssoMakerPHPMBundle:Tache')->find($id);
     $user = $this->get('security.context')->getToken()->getUser();
     if (!$entity) {
         throw $this->createNotFoundException('Unable to find Tache entity.');
     }
     $entity->removeAllCreneaux();
     $entity->setStatut(-1);
     $commentaire = new Commentaire();
     $commentaire->setAuteur($user);
     $commentaire->setHeure(new \DateTime());
     $commentaire->setTache($entity);
     $commentaire->setTexte("<b>&rarr;Fiche supprimée.</b>");
     $em->persist($commentaire);
     $em->flush();
     return $this->redirect($this->generateUrl('tache'));
 }