src/EventSubscriber/MaintenanceSubscriber.php line 29
<?phpnamespace App\EventSubscriber;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\HttpKernel\Event\RequestEvent;use Symfony\Component\HttpKernel\KernelEvents;use Twig\Environment;class MaintenanceSubscriber implements EventSubscriberInterface{private Environment $twig;public function __construct(Environment $twig){$this->twig = $twig;}public static function getSubscribedEvents(): array{return [KernelEvents::REQUEST => [['onMaintenance', \PHP_INT_MAX - 1000],],];}public function onMaintenance(RequestEvent $event): void{/** @var bool $isMaintenance */$isMaintenance = \filter_var($_ENV['MAINTENANCE_MODE'] ?? '0', \FILTER_VALIDATE_BOOLEAN);if ($isMaintenance) {$event->setResponse(new Response($this->twig->render('maintenance.html.twig'),Response::HTTP_SERVICE_UNAVAILABLE,));$event->stopPropagation();}}}