src/EventListener/MaintenanceListener.php line 27

Open in your IDE?
  1. <?php 
  2. namespace App\EventListener;
  3. use Twig\Environment;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\RouterInterface;
  6. use Symfony\Component\HttpKernel\Event\RequestEvent;
  7. use Symfony\Component\HttpFoundation\RedirectResponse;
  8. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  9. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  10. class MaintenanceListener
  11. {
  12.     private $twig;
  13.     private $maintenanceMode;
  14.     private $authorizationChecker;
  15.     private $tokenStorage;
  16.     public function __construct(Environment $twig,AuthorizationCheckerInterface $authorizationCheckerTokenStorageInterface $tokenStorage,bool $maintenanceMode false,)
  17.     {
  18.         $this->twig $twig;
  19.         $this->tokenStorage $tokenStorage;
  20.         $this->maintenanceMode $maintenanceMode;  
  21.         $this->authorizationChecker $authorizationChecker;
  22.     }
  23.     public function onKernelRequest(RequestEvent $event)
  24.     {
  25.         // if ($this->authorizationChecker->isGranted('ROLE_CLIENT')) {
  26.         //     $this->tokenStorage->setToken(null);
  27.         //     $template = $this->renderMaintenanceTemplate();
  28.         //     $event->setResponse(new Response($template));
  29.         // }
  30.         
  31.     }
  32.     private function renderMaintenanceTemplate(): string
  33.     {
  34.         return $this->twig->render('maintenance/maintenance.html.twig');
  35.     }
  36. }