src/Controller/Admin/SecurityController.php line 69

Open in your IDE?
  1. <?php
  2. /**
  3.  * Controller gérant la sécurité et l'authentification de l'administration Colibi.
  4.  */
  5. namespace App\Controller\Admin;
  6. use App\Service\CityServices;
  7. use App\Service\TraitementData;
  8. use App\Service\TraitementFolder;
  9. use Doctrine\ORM\EntityManagerInterface;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  14. use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  15. use Exception;
  16. /**
  17.  * Class SecurityController
  18.  * @package App\Controller\Admin
  19.  */
  20. class SecurityController extends AbstractController
  21. {
  22.     /**
  23.      * @var EntityManagerInterface
  24.      */
  25.     protected $em;
  26.     /**
  27.      * @var CityServices
  28.      */
  29.     protected $cityServices;
  30.     /**
  31.      * @var TraitementData
  32.      */
  33.     protected $traitementData;
  34.     /**
  35.      * @var DenormalizerInterface
  36.      */
  37.     private $denormalizer;
  38.     /**
  39.      * SecurityController constructor.
  40.      * @param TraitementData $traitementData
  41.      * @param EntityManagerInterface $em
  42.      * @param CityServices $cityServices
  43.      * @param DenormalizerInterface $denormalizer
  44.      */
  45.     public function __construct(
  46.         TraitementData $traitementData,
  47.         EntityManagerInterface $em,
  48.         CityServices $cityServices,
  49.         DenormalizerInterface $denormalizer
  50.     ) {
  51.         $this->em $em;
  52.         $this->cityServices $cityServices;
  53.         $this->traitementData $traitementData;
  54.         $this->denormalizer $denormalizer;
  55.     }
  56.     /**
  57.      * Rendu de la page de connexion admin.
  58.      * 
  59.      * @Route("/admin/login", name="app_login")
  60.      * @param AuthenticationUtils $authenticationUtils
  61.      * @param TraitementFolder $traiteFolder
  62.      * @return Response
  63.      */
  64.     public function login(AuthenticationUtils $authenticationUtilsTraitementFolder $traiteFolder): Response
  65.     {
  66.         // $traiteFolder->add(); // Optimization: Removed to avoid heavy filesystem checks on every login page render. This should be handled by a command or deployment script.
  67.         $error $authenticationUtils->getLastAuthenticationError();
  68.         $lastUsername $authenticationUtils->getLastUsername();
  69.         return $this->render('admin/security/login.html.twig', [
  70.             'last_username' => $lastUsername,
  71.             'error' => $error
  72.         ]);
  73.     }
  74.     /**
  75.      * Point de sortie de l'application.
  76.      * Intercepté par le firewall Symfony.
  77.      * 
  78.      * @Route("/admin/logout", name="app_logout")
  79.      * @throws Exception
  80.      */
  81.     public function logout(): void
  82.     {
  83.         throw new Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
  84.     }
  85. }