<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Twig\Environment;
use \Symfony\Component\Yaml\Yaml;
class AdminMenuEventSubscriber implements EventSubscriberInterface
{
private $twig;
public function __construct(Environment $twig)
{
$this->twig = $twig;
}
public function onKernelController(ControllerEvent $event): void
{
$adminMenu = Yaml::parseFile(__DIR__.'/../../src/Config/adminMenu.yaml');
$this->twig->addGlobal('adminMenu', $adminMenu);
}
public static function getSubscribedEvents(): array
{
return [
'kernel.controller' => 'onKernelController',
];
}
}