src/Controller/HomeController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\LogsService;
  4. use App\Service\ProjectService;
  5. use App\Service\YouKnowService;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class HomeController extends AbstractController
  11. {
  12.     /**
  13.      * Retourne la page d'accueil de l'application
  14.      *
  15.      * @param LogsService $logsService instance du service lié aux Logs
  16.      * @param ProjectService $projectService instance du service lié aux projets
  17.      * @return Response
  18.      */
  19.     #[Route('/'name'app_home')]
  20.     public function index(LogsService $logsServiceProjectService $projectServiceYouKnowService $youKnowService): Response
  21.     {
  22.         $user $this->getUser();
  23.         $logs $logsService->getUserLog($user);
  24.         $inProgressProjectsCount $projectService->getInProgressProject($this->getUser());
  25.         $inProgressDeliverable $projectService->getInProgressDeliverable($this->getUser());
  26.         $waitingForValidDeliverable $projectService->getWaitingForValidDeliverables($this->getUser());
  27.         if($this->isGranted('ROLE_ADMIN'$user)) {
  28.             $inProgressProjectsCount $projectService->getInProgressProject($this->getUser(), true);
  29.             $inProgressDeliverable $projectService->getInProgressDeliverable($this->getUser(), true);
  30.             $waitingForValidDeliverable $projectService->getWaitingForValidDeliverables($this->getUser(), true);
  31.             $logs $logsService->getUserLog($usertrue);
  32.         }
  33.         if(!empty($youKnowService->getRandomYouKnow())) {
  34.             $youKnow $youKnowService->getRandomYouKnow()->getContent();
  35.         } else {
  36.             $youKnow null;
  37.         }
  38.         return $this->render('home/index.html.twig', [
  39.             'user'=>$user,
  40.             'logs'=>$logs,
  41.             'youKnow'=>$youKnow,
  42.             'projectsCount'=>$inProgressProjectsCount,
  43.             'deliverablesCount' => $inProgressDeliverable,
  44.             'waitingForValidDeliverable' => $waitingForValidDeliverable
  45.         ]);
  46.     }
  47. }