protected function 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 drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php
ContentAwareGenerator::getRouteByName in drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php
Get the route by a string name

File

drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php, line 98

Class

ContentAwareGenerator
A generator that tries to generate routes from object, route names or content objects or names.

Namespace

Symfony\Cmf\Component\Routing

Code

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;
}