Locale switch and forwards
If a forward happens in symfony (2.3 but i think 2.1 as well) the _route request attribute becomes empty.
That means in some cases (when useController is off which is the default and on does not seem to work right now anyway) after a forward, TargetInformationBuilder will catch a RouteNotFoundException and the locales array for the locale switcher will be empty.
I think the bundle should be able to at least generate a fallback url in this case. Maybe use the redirect_to_route config option which in this case seems to be unused?
Or do you suggest anything else to try out?
I can confirm this. I use the FrameworkBundle:TemplateController
{{ render(controller('FrameworkBundle:Template:template', {template: '::partials/top-bar.html.twig', maxAge: 3600, sharedAge: 3600}) }}
I just want to point out, that this will probably be an bigger issue, when ESI comes into play. The only solution, that comes into my mind, is to provide an own controller-action, that accepts all required parameters (optionally) and renders the template.
{{ render(controller('LuneticsLocaleBundle:Locale:renderer', {route: app.request.attributes.get('_route')})) }}
Any idea how to best fix this?
@lunetics Uh, too fast. I updated my comment. Doesn't mean, that this is the best, or only solution, but feels like the simplest for now. Up for discussion.
@KingCrunch there was a point where i intentionally removed the locale from the request attributes, let me look in the older issues :)
Any news an this issue? I can also confirm this using SF 2.3. A regular show action works as expected, only if I forward an action to another method the locales-array remains empty. It is set, I can even ladybug-dump the locales-array, it shows an empty array.
Config:
lunetics_locale:
switcher:
show_current_locale: true
allowed_locales:
- de
- en
- it
- fr
guessing_order:
- query
- router
- session
- cookie
cookie:
set_on_change: true
So while
return $this->redirect($this->generateUrl('certificate.show', ['id' => $certificate->getId()]));
works as it sould (it displays all four languages), the following action leaves the selector empty:
return $this->forward('WebBundle:EntryCertificate:finalized', ['id' => $certificate->getId()]);
Both of them share the same base.html which calls the locale_switcher:
{{ locale_switcher(null, null, 'WebBundle::localeSwitcherDropdown.html.twig') }}
Still a problem in 2.5