<?php
namespace App\EventSubscriber;
use App\Helper\Company;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
class ProfilSubscriber implements EventSubscriberInterface
{
/**
* @var Company
*/
private $company;
public function __construct(Company $company)
{
$this->company = $company;
}
public function onRequestEvent(RequestEvent $event)
{
$request = $event->getRequest();
$request->getSession()->set('profil', $this->company->getCompany()->getName());
}
public static function getSubscribedEvents(): array
{
return [
RequestEvent::class => 'onRequestEvent',
];
}
}