src/EventSubscriber/SeasonSubscriber.php line 26
<?phpnamespace App\EventSubscriber;use App\Service\SeasonService;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\HttpKernel\Event\ControllerEvent;use Symfony\Component\HttpKernel\KernelEvents;use Twig\Environment;class SeasonSubscriber implements EventSubscriberInterface{public function __construct(private SeasonService $seasonService,private Environment $twig) {}public static function getSubscribedEvents(): array{return [KernelEvents::CONTROLLER => 'onKernelController',];}public function onKernelController(ControllerEvent $event): void{if (!$event->isMainRequest()) {return;}// Přidáme globální proměnné do Twig pouze pro admin sekci$request = $event->getRequest();$path = $request->getPathInfo();if (str_starts_with($path, '/admin')) {$this->twig->addGlobal('allSeasons', $this->seasonService->getAllSeasons());$this->twig->addGlobal('selectedSeason', $this->seasonService->getSelectedSeason());}}}