protected function ContentAwareGenerator::getBestLocaleRoute in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony-cmf/routing/ContentAwareGenerator.php \Symfony\Cmf\Component\Routing\ContentAwareGenerator::getBestLocaleRoute()
Determine if there is a route with matching locale associated with the given route via associated content.
Parameters
SymfonyRoute $route:
array $parameters:
Return value
SymfonyRoute either the passed route or an alternative with better locale
2 calls to ContentAwareGenerator::getBestLocaleRoute()
- ContentAwareGenerator::generate in vendor/
symfony-cmf/ routing/ ContentAwareGenerator.php - ContentAwareGenerator::getRouteByName in vendor/
symfony-cmf/ routing/ ContentAwareGenerator.php - Get the route by a string name
File
- vendor/
symfony-cmf/ routing/ ContentAwareGenerator.php, line 117
Class
- ContentAwareGenerator
- A generator that tries to generate routes from object, route names or content objects or names.
Namespace
Symfony\Cmf\Component\RoutingCode
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
->getContent();
if ($content instanceof RouteReferrersReadInterface) {
$routes = $content
->getRoutes();
$contentRoute = $this
->getRouteByLocale($routes, $locale);
if ($contentRoute) {
return $contentRoute;
}
}
}
return $route;
}