Skip to content

Commit

Permalink
[Routing][PrefixTrait] Add the _locale requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyweb committed Apr 20, 2020
1 parent e464954 commit dde442f
Showing 1 changed file with 1 addition and 0 deletions.
Expand Up @@ -33,6 +33,7 @@ final protected function addPrefix(RouteCollection $routes, $prefix, bool $trail
foreach ($prefix as $locale => $localePrefix) {
$localizedRoute = clone $route;
$localizedRoute->setDefault('_locale', $locale);
$localizedRoute->setRequirement('_locale', preg_quote($locale));
$localizedRoute->setDefault('_canonical_route', $name);
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
$routes->add($name.'.'.$locale, $localizedRoute);
Expand Down

0 comments on commit dde442f

Please sign in to comment.