<?php
namespace App\Event;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
class MaintenanceModeEvent
{
/**
* @var \Twig\Environment
*/
private $environment;
public function __construct(\Twig\Environment $environment)
{
$this->environment = $environment;
}
public function onKernelRequest(RequestEvent $event){
if($_ENV['MAINTENANCE_MODE'] === 'false'){
return;
}
$event->setResponse(new Response($this->environment->render('maintenance.html.twig')));
$event->stopPropagation();
}
}