vendor/rawafed/commons-bundle/Service/LocaleListener.php line 17

Open in your IDE?
  1. <?php
  2. namespace Rawafed\CommonsBundle\Service;
  3. use Doctrine\ORM\EntityManager;
  4. use Symfony\Component\HttpKernel\Event\RequestEvent;
  5. class LocaleListener
  6. {
  7.     private $entity_manager;
  8.     private $locale;
  9.     public function __construct(EntityManager $entity_manager)
  10.     {
  11.         $this->entity_manager $entity_manager;
  12.     }
  13.     public function onKernelRequest(RequestEvent $event)
  14.     {
  15.         $this->locale $event->getRequest()->getLocale();
  16.         
  17.         $filter $this->entity_manager->getFilters()->enable('locale_filter');
  18.         $filter->setParameter('locale'$this->locale);
  19.     }
  20.     public function getLocale()
  21.     {
  22.         return $this->locale;
  23.     }
  24. }