Skip to content

Commit

Permalink
Correctly generate root and fallback routes with languagePrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Apr 8, 2020
1 parent 39d987b commit 5b03a6c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions core-bundle/src/Routing/RouteProvider.php
Expand Up @@ -242,27 +242,24 @@ private function addRoutesForRootPage(PageModel $page, array &$routes): void

$page->loadDetails();

$path = '/';
$requirements = [];
$defaults = $this->getRouteDefaults($page);

if ($this->prependLocale) {
$path = '/{_locale}'.$path;
$requirements['_locale'] = $page->rootLanguage;
}

$routes['tl_page.'.$page->id.'.root'] = new Route(
$path,
$page->languagePrefix ? '/'.$page->languagePrefix.'/' : '/',
$defaults,
$requirements,
[],
[],
$page->domain,
$page->rootUseSSL ? 'https' : null,
[]
);

if (!$page->languagePrefix) {
return;
}

$defaults['_controller'] = 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction';
$defaults['path'] = '/'.$page->language.'/';
$defaults['path'] = '/'.$page->languagePrefix.'/';
$defaults['permanent'] = true;

$routes['tl_page.'.$page->id.'.fallback'] = new Route(
Expand Down

0 comments on commit 5b03a6c

Please sign in to comment.