src/EventSubscriber/TwigEventSubscriber.php line 25
<?phpnamespace App\EventSubscriber;use App\Repository\BranchOfficeRepository;use App\Repository\HeaderRepository;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\HttpKernel\Event\ControllerEvent;use Symfony\Component\HttpKernel\KernelEvents;use Twig\Environment;class TwigEventSubscriber implements EventSubscriberInterface{private $twig;private $branchOfficeRepository;private $headerRepository;public function __construct(Environment $twig, BranchOfficeRepository $branchOfficeRepository, HeaderRepository $headerRepository){$this->twig = $twig;$this->branchOfficeRepository = $branchOfficeRepository;$this->headerRepository = $headerRepository;}public function onKernelController(ControllerEvent $event): void{$this->twig->addGlobal('branch_offices', $this->branchOfficeRepository->findAll());$this->twig->addGlobal('header', $this->headerRepository->findOneBy([]));}public static function getSubscribedEvents(): array{return [KernelEvents::CONTROLLER => 'onKernelController',];}}