src/Listener/KernelListener.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Listener;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\HttpKernel\Event\RequestEvent;
  5. class KernelListener
  6. {
  7.     private $twig;
  8.     public function __construct(\Twig\Environment $twig)
  9.     {
  10.         $this->twig $twig;
  11.     }
  12.     public function onKernelRequest(RequestEvent $event)
  13.     {
  14.         //Wartungsmodus
  15.         if(strlen($_ENV["MAINTENANCE_IPS"])) {
  16.             $remoteIP $_SERVER['REMOTE_ADDR'];
  17.             $alloweedIPs explode(','$_ENV["MAINTENANCE_IPS"]);
  18.             if (!in_array($remoteIP$alloweedIPs)) {
  19.                 echo $this->twig->render('baustelle.html.twig', [
  20.                     'start' => $_ENV["MAINTENANCE_STARTZEIT"],
  21.                     'ende' => $_ENV["MAINTENANCE_ENDZEIT"]
  22.                 ]);
  23.                 exit;
  24.             }
  25.         }
  26.     }
  27. }