<?php declare(strict_types=1);
namespace CioCustomerPermissionGroups\Subscriber;
use CioCustomerPermissionGroups\Utils\ContainerUtility;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class ContainerSubscriber implements EventSubscriberInterface
{
/**
* CIO-AI-Driven
*/
private ContainerInterface $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function onKernelRequest(RequestEvent $requestEvent): void
{
ContainerUtility::setContainer($this->container);
}
public function onConsoleCommand(ConsoleCommandEvent $event): void
{
ContainerUtility::setContainer($this->container);
}
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => 'onKernelRequest',
ConsoleEvents::COMMAND => 'onConsoleCommand',
];
}
}