From 7546ef43316b78caaa553d61b3b634b53c3ba157 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 7 Jan 2025 19:22:41 +0100 Subject: [PATCH] Tweak implementation --- src/Router/AdminRouteGenerator.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Router/AdminRouteGenerator.php b/src/Router/AdminRouteGenerator.php index c62b72a502..de26d558e8 100644 --- a/src/Router/AdminRouteGenerator.php +++ b/src/Router/AdminRouteGenerator.php @@ -220,12 +220,11 @@ private function getDashboardsRouteConfig(): array $reflectionClass = new \ReflectionClass($dashboardController); $indexMethod = $reflectionClass->getMethod('index'); - if (class_exists(\Symfony\Component\Routing\Attribute\Route::class)) { - $attributes = $indexMethod->getAttributes(\Symfony\Component\Routing\Attribute\Route::class); - } - - if (!isset($attributes) || [] === $attributes) { - $attributes = $indexMethod->getAttributes(\Symfony\Component\Routing\Annotation\Route::class); + // for BC reasons, the Symfony Route attribute is available under two different namespaces; + // true first the recommended namespace and then fall back to the legacy namespace + $attributes = $indexMethod->getAttributes('Symfony\Component\Routing\Attribute\Route'); + if ([] === $attributes) { + $attributes = $indexMethod->getAttributes('Symfony\Component\Routing\Annotation\Route'); } if ([] === $attributes) {