Skip to content

Commit

Permalink
bug #6639 Fix pretty URLs when using multiple dashboards (javiereguiluz)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
javiereguiluz committed Dec 12, 2024
2 parents ecf581d + 76524bf commit f5c6c43
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Router/AdminRouteGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,20 @@ private function saveAdminRoutesInCache(array $adminRoutes): void
// 2) $cache[dashboard][CRUD controller][action] => route_name
$routeNameToFqcn = [];
$fqcnToRouteName = [];

// first, add the routes of all the application dashboards; this is needed because in
// applications with multiple dashboards, EasyAdmin must be able to find the route data associated
// to each dashboard; otherwise, the URLs of the menu items when visiting the dashboard route will be wrong
foreach ($this->getDashboardsRouteConfig() as $dashboardFqcn => $dashboardRouteConfig) {
$routeNameToFqcn[$dashboardRouteConfig['routeName']] = [
EA::DASHBOARD_CONTROLLER_FQCN => $dashboardFqcn,
EA::CRUD_CONTROLLER_FQCN => null,
EA::CRUD_ACTION => null,
];
$fqcnToRouteName[$dashboardFqcn][''][''] = $dashboardRouteConfig['routeName'];
}

// then, add all the generated admin routes
foreach ($adminRoutes as $routeName => $route) {
$routeNameToFqcn[$routeName] = [
EA::DASHBOARD_CONTROLLER_FQCN => $route->getOption(EA::DASHBOARD_CONTROLLER_FQCN),
Expand Down

0 comments on commit f5c6c43

Please sign in to comment.