src/EventSubscriber/AdminMenuEventSubscriber.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  5. use Twig\Environment;
  6. use \Symfony\Component\Yaml\Yaml;
  7. class AdminMenuEventSubscriber implements EventSubscriberInterface
  8. {
  9.     private $twig;
  10.     public function __construct(Environment $twig)
  11.     {
  12.         $this->twig $twig;
  13.     }
  14.     public function onKernelController(ControllerEvent $event): void
  15.     {
  16.         $adminMenu Yaml::parseFile(__DIR__.'/../../src/Config/adminMenu.yaml');
  17.         $this->twig->addGlobal('adminMenu'$adminMenu);
  18.     }
  19.     public static function getSubscribedEvents(): array
  20.     {
  21.         return [
  22.             'kernel.controller' => 'onKernelController',
  23.         ];
  24.     }
  25. }