]> Raphaƫl G. Git Repositories - airbundle/blobdiff - EventSubscriber/LocaleSubscriber.php
Version 0.5.0
[airbundle] / EventSubscriber / LocaleSubscriber.php
index 7941a80442e8adcb95699ebbe5d4cda697a1f937..5975bd3ed58f1a1f775424b0f78c09b8e3edcdab 100644 (file)
@@ -33,17 +33,23 @@ class LocaleSubscriber implements EventSubscriberInterface {
                                //Save preferred locale in session
                                $request->getSession()->set('_locale', $preferred);
 
-                               //Generate current route with preferred language
-                               //XXX: may trigger a Symfony\Component\Routing\Exception\RouteNotFoundException if route is not found for preferred locale
-                               $uri = $this->router->generate(
-                                       //Current route
-                                       $request->get('_route'),
-                                       //Force preferred locale
-                                       ['_locale' => $preferred]+$request->get('_route_params')
-                               );
-
-                               //Regenerate route with preferred locale
-                               $event->setResponse(new RedirectResponse($uri, 302));
+                               //Send vary header as current page locale depend on it
+                               #header('Vary: accept-language');
+
+                               //Set locale
+                               #$request->setLocale($preferred);
+
+                               //Set default locale
+                               #$request->setDefaultLocale($preferred);
+
+                               //Get router context
+                               #$context = $this->router->getContext();
+
+                               //Set context locale
+                               #$context->setParameter('_locale', $preferred);
+
+                               //Set back router context
+                               #$this->router->setContext($context);
 
                                //End process
                                return;