<?php
namespace App\Listener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
class KernelListener
{
private $twig;
public function __construct(\Twig\Environment $twig)
{
$this->twig = $twig;
}
public function onKernelRequest(RequestEvent $event)
{
//Wartungsmodus
if(strlen($_ENV["MAINTENANCE_IPS"])) {
$remoteIP = $_SERVER['REMOTE_ADDR'];
$alloweedIPs = explode(',', $_ENV["MAINTENANCE_IPS"]);
if (!in_array($remoteIP, $alloweedIPs)) {
echo $this->twig->render('baustelle.html.twig', [
'start' => $_ENV["MAINTENANCE_STARTZEIT"],
'ende' => $_ENV["MAINTENANCE_ENDZEIT"]
]);
exit;
}
}
}
}