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

unset _locale parameter if matching route has been found #56

Merged
merged 1 commit into from
Apr 5, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ContentAwareGenerator.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function generate($name, $parameters = array(), $absolute = false)
* *
* @throws RouteNotFoundException if there is no route found for the provided name * @throws RouteNotFoundException if there is no route found for the provided name
*/ */
protected function getRouteByName($name, array $parameters) protected function getRouteByName($name, array &$parameters)
{ {
$route = $this->provider->getRouteByName($name, $parameters); $route = $this->provider->getRouteByName($name, $parameters);
if (empty($route)) { if (empty($route)) {
Expand All @@ -98,7 +98,7 @@ protected function getRouteByName($name, array $parameters)
* *
* @return SymfonyRoute either the passed route or an alternative with better locale * @return SymfonyRoute either the passed route or an alternative with better locale
*/ */
protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) protected function getBestLocaleRoute(SymfonyRoute $route, &$parameters)
{ {
if (! $route instanceof RouteObjectInterface) { if (! $route instanceof RouteObjectInterface) {
// this route has no content, we can't get the alternatives // this route has no content, we can't get the alternatives
Expand All @@ -111,6 +111,7 @@ protected function getBestLocaleRoute(SymfonyRoute $route, $parameters)
$routes = $content->getRoutes(); $routes = $content->getRoutes();
$contentRoute = $this->getRouteByLocale($routes, $locale); $contentRoute = $this->getRouteByLocale($routes, $locale);
if ($contentRoute) { if ($contentRoute) {
unset($parameters['_locale']);
return $contentRoute; return $contentRoute;
} }
} }
Expand Down Expand Up @@ -167,6 +168,7 @@ protected function getRouteByContent($name, &$parameters)


$route = $this->getRouteByLocale($routes, $this->getLocale($parameters)); $route = $this->getRouteByLocale($routes, $this->getLocale($parameters));
if ($route) { if ($route) {
unset($parameters['_locale']);
return $route; return $route;
} }


Expand Down