src/Controller/DefaultController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Repository\BailRepository;
  7. use App\Repository\CommuneRepository;
  8. class DefaultController extends AbstractController
  9. {
  10.     #[Route('/'name'app_default')]
  11.     public function index(BailRepository $bailRepositoryCommuneRepository $communeRepository): Response
  12.     {
  13.         $user $this->getUser();
  14.         if ($this->isGranted('ROLE_ADMIN')) {
  15.             return $this->render('default/index.html.twig', [
  16.                 'controller_name' => 'DefaultController',
  17.                 'baux' => $bailRepository->findAll(),
  18.                 'communes' => $communeRepository->findAll()
  19.             ]);
  20.         }
  21.         elseif ($this->isGranted('ROLE_AGENT')) {
  22.             // Redirection pour le rĂ´le agent
  23.             return $this->redirectToRoute('app_agent_index');
  24.         }
  25.         else{
  26.             return $this->redirectToRoute('app_login');
  27.         }
  28.         
  29.     }
  30. }