Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Language switcher, redirect to current page with symfony2.0

I set up a language switcher on my website but right now I only know how to redirect to the homepage:

public function englishAction(Request $request)
{
    $this->get('session')->setLocale('en_US');
    return $this->redirect($this->generateUrl('homepage'));
}

How can I do to redirect to the current page?

like image 847
fkoessler Avatar asked Oct 12 '12 05:10

fkoessler


1 Answers

Try:

return $this->redirect($request->headers->get('referer'));

Or another solution: you may put back url link as a get parameter and use it in redirect in your "englishAction" action.

like image 109
Cyprian Avatar answered Nov 14 '22 23:11

Cyprian