src/Event/MaintenanceModeEvent.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Event;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\HttpKernel\Event\RequestEvent;
  5. class MaintenanceModeEvent
  6. {
  7.     /**
  8.      * @var \Twig\Environment
  9.      */
  10.     private $environment;
  11.     public function __construct(\Twig\Environment $environment)
  12.     {
  13.         $this->environment $environment;
  14.     }
  15.     public function onKernelRequest(RequestEvent $event){
  16.         if($_ENV['MAINTENANCE_MODE'] === 'false'){
  17.             return;
  18.         }
  19.         $event->setResponse(new Response($this->environment->render('maintenance.html.twig')));
  20.         $event->stopPropagation();
  21.     }
  22. }