Determine if there is a route with matching locale associated with the given route via associated content.
SymfonyRoute $route:
array $parameters:
SymfonyRoute either the passed route or an alternative with better locale
protected function getBestLocaleRoute(SymfonyRoute $route, $parameters) {
if (!$route instanceof RouteObjectInterface) {
// this route has no content, we can't get the alternatives
return $route;
}
$locale = $this
->getLocale($parameters);
if (!$this
->checkLocaleRequirement($route, $locale)) {
$content = $route
->getRouteContent();
if ($content instanceof RouteAwareInterface) {
$routes = $content
->getRoutes();
$contentRoute = $this
->getRouteByLocale($routes, $locale);
if ($contentRoute) {
return $contentRoute;
}
}
}
return $route;
}