diff --git a/src/Admin/Pool.php b/src/Admin/Pool.php index e7c59d0f68..3f9b65d389 100644 --- a/src/Admin/Pool.php +++ b/src/Admin/Pool.php @@ -86,19 +86,20 @@ public function getDashboardGroups(): array $groups = []; foreach ($this->adminGroups as $name => $adminGroup) { - $items = array_values(array_filter(array_map(function (array $item): ?AdminInterface { + $items = []; + foreach ($adminGroup['items'] as $item) { // NEXT_MAJOR: Remove the '' check if (!isset($item['admin']) || '' === $item['admin']) { - return null; + continue; } $admin = $this->getInstance($item['admin']); - // NEXT_MAJOR: Keep the if part. + // NEXT_MAJOR: Keep the "if" part. // @phpstan-ignore-next-line if (method_exists($admin, 'showInDashboard')) { if (!$admin->showInDashboard()) { - return null; + continue; } } else { @trigger_error(sprintf( @@ -111,12 +112,12 @@ public function getDashboardGroups(): array * @psalm-suppress DeprecatedMethod, DeprecatedConstant */ if (!$admin->showIn(AbstractAdmin::CONTEXT_DASHBOARD)) { - return null; + continue; } } - return $admin; - }, $adminGroup['items']))); + $items[] = $admin; + } if ([] !== $items) { $groups[$name] = ['items' => $items] + $adminGroup; diff --git a/src/Controller/CRUDController.php b/src/Controller/CRUDController.php index bafdc3b3d8..7809b32b2b 100644 --- a/src/Controller/CRUDController.php +++ b/src/Controller/CRUDController.php @@ -1481,7 +1481,12 @@ final protected function assertObjectExists(Request $request, bool $strict = fal */ final protected function getSelectedTab(Request $request): array { - return array_filter(['_tab' => (string) $request->request->get('_tab')]); + $tab = (string) $request->request->get('_tab'); + if ('' === $tab) { + return []; + } + + return ['_tab' => $tab]; } /**