Refresh same page in other controller

Viewed 106

I have a <select> to switch between languages in all footer pages, when user select a new language, I want to refresh the same page, not homepage.

To change language, <select> call to a LanguageController and this set _locale and redirect to correct controller to refresh the same page.

Which is the best way to refresh same page when user change language?

This is an example of my config.yml

homepage_es:
 path: /es
 defaults: { _controller: AppBundle:Language:indexEs }

And this my LanguageController

 /**
 * @Route("/es", name="homepage_es")
 * @Method("GET")
 */
public function indexEsAction(Request $request)
{
    $session = $this->get('session');
    $session->set("_locale", 'es');
    return new RedirectResponse('/es/home');
}

Now Redirect to homepage, but I want to redirect to the same page where user was.

This is an <option> of my <select> in my twig

<option value="{{ path('homepage_es') }}">Español</option>
0 Answers
Related