src/EventSubscriber/DoctrineExtensionSubscriber.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Gedmo\Blameable\BlameableListener;
  4. use Gedmo\Loggable\LoggableListener;
  5. use Gedmo\Translatable\TranslatableListener;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
  8. use Symfony\Component\HttpKernel\KernelEvents;
  9. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  10. class DoctrineExtensionSubscriber implements EventSubscriberInterface
  11. {
  12.     /**
  13.      * @var TranslatableListener
  14.      */
  15.     private $translatableListener;
  16.     public function __construct(
  17.         TranslatableListener $translatableListener
  18.     ) {
  19.         $this->translatableListener $translatableListener;
  20.     }    
  21.     public static function getSubscribedEvents()
  22.     {
  23.         return [
  24.             KernelEvents::FINISH_REQUEST => 'onLateKernelRequest'
  25.         ];
  26.     }
  27.     
  28.     public function onLateKernelRequest(FinishRequestEvent $event): void
  29.     {
  30.         $this->translatableListener->setTranslatableLocale($event->getRequest()->getLocale());
  31.     }
  32. }