Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: localized dashboard routes #6235

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Factory/AdminContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ private function getDashboardDto(Request $request, DashboardControllerInterface

foreach ($dashboardControllerRoutes as $routeName => $controller) {
if ($controller === $dashboardController) {
// if present, remove the suffix of i18n route names (it's a two-letter locale at the end
// of the route name; e.g. 'dashboard.en' -> remove '.en', 'admin.index.es' -> remove '.es')
$dashboardRouteName = preg_replace('~\.\w{2}$~', '', $routeName);
// if present, remove the suffix of i18n route names (it's an ISO639 or ISO3166 locale at the end
// of the route name for ; e.g. 'dashboard.en' -> remove '.en', 'admin.index.es' -> remove '.es'
// or 'dashboard.en_GB' -> remove '.en_GB', 'admin.index.es_ES' -> remove '.es_ES')
$dashboardRouteName = preg_replace('~\.\w{2}(_\w{2})?$~', '', $routeName);

break;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Router/AdminUrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,10 @@ public function generateUrl(): string
$this->dashboardRoute = $this->dashboardControllerRegistry->getFirstDashboardRoute();
}

// if present, remove the suffix of i18n route names (it's a two-letter locale at the end
// of the route name; e.g. 'dashboard.en' -> remove '.en', 'admin.index.es' -> remove '.es')
$this->dashboardRoute = preg_replace('~\.\w{2}$~', '', $this->dashboardRoute);
// if present, remove the suffix of i18n route names (it's an ISO639 or ISO3166 locale at the end
// of the route name for ; e.g. 'dashboard.en' -> remove '.en', 'admin.index.es' -> remove '.es'
// or 'dashboard.en_GB' -> remove '.en_GB', 'admin.index.es_ES' -> remove '.es_ES')
$this->dashboardRoute = preg_replace('~\.\w{2}(_\w{2})?$~', '', $this->dashboardRoute);

// this removes any parameter with a NULL value
$routeParameters = array_filter(
Expand Down
Loading