Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale switch and forwards #84

Open
thanosp opened this issue Aug 12, 2013 · 6 comments
Open

Locale switch and forwards #84

thanosp opened this issue Aug 12, 2013 · 6 comments

Comments

@thanosp
Copy link

thanosp commented Aug 12, 2013

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?

@kingcrunch
Copy link
Contributor

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')})) }}

@lunetics
Copy link
Collaborator

lunetics commented Sep 6, 2013

Any idea how to best fix this?

@kingcrunch
Copy link
Contributor

@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.

@lunetics
Copy link
Collaborator

lunetics commented Sep 6, 2013

@kingcrunch there was a point where i intentionally removed the locale from the request attributes, let me look in the older issues :)

@fschaeffer
Copy link

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') }}

@nurikabe
Copy link

Still a problem in 2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants