]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/EventListener/LocaleListener.php
Move related event things in Event folder
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / EventListener / LocaleListener.php
diff --git a/src/Wallabag/CoreBundle/EventListener/LocaleListener.php b/src/Wallabag/CoreBundle/EventListener/LocaleListener.php
deleted file mode 100644 (file)
index a1c7e5a..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-namespace Wallabag\CoreBundle\EventListener;
-
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
-use Symfony\Component\HttpKernel\KernelEvents;
-
-/**
- * @see http://symfony.com/doc/current/cookbook/session/locale_sticky_session.html
- */
-class LocaleListener implements EventSubscriberInterface
-{
-    private $defaultLocale;
-
-    public function __construct($defaultLocale = 'en')
-    {
-        $this->defaultLocale = $defaultLocale;
-    }
-
-    public function onKernelRequest(GetResponseEvent $event)
-    {
-        $request = $event->getRequest();
-        if (!$request->hasPreviousSession()) {
-            return;
-        }
-
-        // try to see if the locale has been set as a _locale routing parameter
-        if ($locale = $request->attributes->get('_locale')) {
-            $request->getSession()->set('_locale', $locale);
-        } else {
-            // if no explicit locale has been set on this request, use one from the session
-            $request->setLocale($request->getSession()->get('_locale', $this->defaultLocale));
-        }
-    }
-
-    public static function getSubscribedEvents()
-    {
-        return [
-            // must be registered before the default Locale listener
-            KernelEvents::REQUEST => [['onKernelRequest', 17]],
-        ];
-    }
-}