Reputation: 37308
I have a route for just the locale without any other information (the startpage that is):
homepage:
pattern: /{_locale}/
defaults: { _controller: OurStartBundle:Default:index }
If I call the route directly it works (i.e.: localhost/de_DE/) but if I forward it throws the Error:
Unable to parse the controller name "/app_dev.php/de_DE/".
I forward using the Controller Method like this:
$locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
return $this->forward($this->generateUrl('homepage', array('_locale' => $locale)));
Anyone jave any idea why this doesn't work?
Upvotes: 2
Views: 2626
Reputation: 37308
The Problem was that i used $this->forward() where i wanted a redirect and should have used $this->redirect().
Solution is:
$locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
return $this->redirect($this->generateUrl('OurStartBundle_homepage', array('_locale' => $locale)));
Upvotes: 0
Reputation: 13475
You are trying to forward the request to a URI, rather than a bundle string.
For example, your forward call should be...
$response = $this->forward('OurStartBundle:Default:index', array(
'_locale' => 'de_DE'
));
Upvotes: 5