<?phpnamespace App\EventListener;use Symfony\Component\HttpKernel\Event\RequestEvent;use Twig\Environment;class TwigRequestListener{ /** @var Environment */ protected $twig; public function __construct(Environment $twig) { $this->twig = $twig; } public function onKernelRequest(RequestEvent $event): void { $this->twig->addGlobal('master_request', $event->isMainRequest()); }}