src/EventListener/TwigRequestListener.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Symfony\Component\HttpKernel\Event\RequestEvent;
  4. use Twig\Environment;
  5. class TwigRequestListener
  6. {
  7.     /** @var Environment */
  8.     protected $twig;
  9.     public function __construct(Environment $twig)
  10.     {
  11.         $this->twig $twig;
  12.     }
  13.     public function onKernelRequest(RequestEvent $event): void
  14.     {
  15.         $this->twig->addGlobal('master_request'$event->isMainRequest());
  16.     }
  17. }