protected function ContentAwareGenerator::unsetLocaleIfNotNeeded

Unset the _locale parameter if it is there and not needed

Parameters

SymfonyRoute $route:

array $parameters:

1 call to ContentAwareGenerator::unsetLocaleIfNotNeeded()
ContentAwareGenerator::generate in drupal/core/vendor/symfony-cmf/routing/Symfony/Cmf/Component/Routing/ContentAwareGenerator.php

File

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

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 unsetLocaleIfNotNeeded(SymfonyRoute $route, array &$parameters) {
  $locale = $this
    ->getLocale($parameters);
  if (null !== $locale) {
    if (preg_match('/' . $route
      ->getRequirement('_locale') . '/', $locale) && $locale == $route
      ->getDefault('_locale')) {
      $compiledRoute = $route
        ->compile();
      if (!in_array('_locale', $compiledRoute
        ->getVariables())) {
        unset($parameters['_locale']);
      }
    }
  }
}