Skip to content

Commit f5c6c43

Browse files
committed
bug #6639 Fix pretty URLs when using multiple dashboards (javiereguiluz)
This PR was merged into the 4.x branch. Discussion ---------- Fix pretty URLs when using multiple dashboards Fixes #6603. Commits ------- 76524bf Fix pretty URLs when using multiple dashboards
2 parents ecf581d + 76524bf commit f5c6c43

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Router/AdminRouteGenerator.php

+14
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,20 @@ private function saveAdminRoutesInCache(array $adminRoutes): void
376376
// 2) $cache[dashboard][CRUD controller][action] => route_name
377377
$routeNameToFqcn = [];
378378
$fqcnToRouteName = [];
379+
380+
// first, add the routes of all the application dashboards; this is needed because in
381+
// applications with multiple dashboards, EasyAdmin must be able to find the route data associated
382+
// to each dashboard; otherwise, the URLs of the menu items when visiting the dashboard route will be wrong
383+
foreach ($this->getDashboardsRouteConfig() as $dashboardFqcn => $dashboardRouteConfig) {
384+
$routeNameToFqcn[$dashboardRouteConfig['routeName']] = [
385+
EA::DASHBOARD_CONTROLLER_FQCN => $dashboardFqcn,
386+
EA::CRUD_CONTROLLER_FQCN => null,
387+
EA::CRUD_ACTION => null,
388+
];
389+
$fqcnToRouteName[$dashboardFqcn][''][''] = $dashboardRouteConfig['routeName'];
390+
}
391+
392+
// then, add all the generated admin routes
379393
foreach ($adminRoutes as $routeName => $route) {
380394
$routeNameToFqcn[$routeName] = [
381395
EA::DASHBOARD_CONTROLLER_FQCN => $route->getOption(EA::DASHBOARD_CONTROLLER_FQCN),

0 commit comments

Comments
 (0)