<?php
namespace Aqarmap\Bundle\MainBundle\Listener;
use Gedmo\Translatable\TranslatableListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class DoctrineExtensionEventSubscriber implements EventSubscriberInterface
{
private TranslatableListener $translatableListener;
public function __construct(TranslatableListener $translatableListener)
{
$this->translatableListener = $translatableListener;
}
public function onLateKernelRequest(RequestEvent $event): void
{
$this->translatableListener->setTranslatableLocale($event->getRequest()->getLocale());
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return [KernelEvents::REQUEST => ['onLateKernelRequest', -10]];
}
}