From 90d1e027580723608530f002bd9289af4cd69d13 Mon Sep 17 00:00:00 2001 From: Parmifer Date: Sun, 25 Jun 2017 16:45:34 +0200 Subject: [PATCH] =?UTF-8?q?L'utilisateur=20connect=C3=A9=20est=20enregistr?= =?UTF-8?q?=C3=A9=20comme=20cr=C3=A9ateur=20lors=20qu'il=20cr=C3=A9=C3=A9e?= =?UTF-8?q?=20une=20entit=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppBundle/Controller/AnnonceController.php | 10 ++++++---- src/AppBundle/Controller/ApplicationController.php | 10 ++++++---- src/AppBundle/Controller/EvenementController.php | 6 +++--- src/AppBundle/Controller/MainController.php | 2 ++ src/AppBundle/Controller/NotificationController.php | 10 ++++++---- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/AppBundle/Controller/AnnonceController.php b/src/AppBundle/Controller/AnnonceController.php index 600ef9d..aeb5586 100644 --- a/src/AppBundle/Controller/AnnonceController.php +++ b/src/AppBundle/Controller/AnnonceController.php @@ -5,7 +5,9 @@ use AppBundle\Entity\Annonce; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Session; /** * Annonce controller. @@ -54,9 +56,9 @@ public function nouveauAction(Request $request) $form->handleRequest($request); $annonce->setDateCreation(new \DateTime()); - // TODO: - // Remplacer l'id 2 par l'id de l'utilisateur connecté - $createur = $em->getRepository('AppBundle:Utilisateur')->find(2); + + $session = new Session(); + $createur = $session->get('utilisateur'); $annonce->setCreateur($createur); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/AppBundle/Controller/ApplicationController.php b/src/AppBundle/Controller/ApplicationController.php index c713ebe..1bcb1ba 100644 --- a/src/AppBundle/Controller/ApplicationController.php +++ b/src/AppBundle/Controller/ApplicationController.php @@ -5,7 +5,9 @@ use AppBundle\Entity\Application; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Session; /** * Application controller. @@ -65,9 +67,9 @@ public function nouveauAction(Request $request) $form->handleRequest($request); $application->setDateCreation(new \DateTime()); - // TODO: - // Remplacer l'id 2 par l'id de l'utilisateur connecté - $createur = $em->getRepository('AppBundle:Utilisateur')->find(2); + + $session = new Session(); + $createur = $session->get('utilisateur'); $application->setCreateur($createur); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/AppBundle/Controller/EvenementController.php b/src/AppBundle/Controller/EvenementController.php index 2e27b0c..afdc521 100644 --- a/src/AppBundle/Controller/EvenementController.php +++ b/src/AppBundle/Controller/EvenementController.php @@ -54,9 +54,9 @@ public function nouveauAction(Request $request) $form->handleRequest($request); $evenement->setDateCreation(new \DateTime()); - // TODO: - // Remplacer l'id 2 par l'id de l'utilisateur connecté - $createur = $em->getRepository('AppBundle:Utilisateur')->find(2); + + $session = new Session(); + $createur = $session->get('utilisateur'); $evenement->setCreateur($createur); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/AppBundle/Controller/MainController.php b/src/AppBundle/Controller/MainController.php index 6e7aa75..668dbb0 100644 --- a/src/AppBundle/Controller/MainController.php +++ b/src/AppBundle/Controller/MainController.php @@ -18,7 +18,9 @@ public function indexAction(Request $request) $session = new Session(); $em = $this->getDoctrine()->getManager(); + // TODO : Faire la même chose pour les annonces que pour les évents $annonces = $em->getRepository('AppBundle:Annonce')->findPublicatedOnes(); + if ($session->get('estConnecte')) { $evenements = $em->getRepository('AppBundle:Evenement')->findComingOnes(); diff --git a/src/AppBundle/Controller/NotificationController.php b/src/AppBundle/Controller/NotificationController.php index 402f6d6..a6ea9b7 100644 --- a/src/AppBundle/Controller/NotificationController.php +++ b/src/AppBundle/Controller/NotificationController.php @@ -5,7 +5,9 @@ use AppBundle\Entity\Notification; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Session; /** * Notification controller. @@ -57,9 +59,9 @@ public function nouveauAction(Request $request) $form->handleRequest($request); $notification->setDateCreation(new \DateTime()); - // TODO: - // Remplacer l'id 2 par l'id de l'utilisateur connecté - $createur = $em->getRepository('AppBundle:Utilisateur')->find(2); + + $session = new Session(); + $createur = $session->get('utilisateur'); $notification->setCreateur($createur); if ($form->isSubmitted() && $form->isValid()) {