<?php
namespace Elements\Bundle\DemiFrontendBundle\EventListener;
use Elements\Bundle\DemiFrontendBundle\Controller\AbstractDemiController;
use JetBrains\PhpStorm\ArrayShape;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class ControllerEventListener implements EventSubscriberInterface {
use ContainerAwareTrait;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
#[ArrayShape([KernelEvents::CONTROLLER => "array"])]
public static function getSubscribedEvents(): array
{
return [KernelEvents::CONTROLLER => ['onKernelController', 100]];
}
public function onKernelController(ControllerEvent $event): void
{
$controller = $event->getController();
if($controller instanceof AbstractDemiController) {
$event->getRequest()->attributes->set('_demi_frontend_request', true);
//was used for engine setting in controller - not required anymore
}
}
}