From cf06fff7f97ac41ed278933c695928f0c38f0706 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 19 Nov 2024 21:40:49 +0100 Subject: [PATCH] Tweaks --- src/Factory/AdminContextFactory.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Factory/AdminContextFactory.php b/src/Factory/AdminContextFactory.php index ec8d313cde..7778d2cc3b 100644 --- a/src/Factory/AdminContextFactory.php +++ b/src/Factory/AdminContextFactory.php @@ -183,14 +183,9 @@ private function getI18nDto(Request $request, DashboardDto $dashboardDto, ?CrudD if (null !== $crudDto) { $translationParameters['%entity_name%'] = $entityName = basename(str_replace('\\', '/', $crudDto->getEntityFqcn())); $translationParameters['%entity_as_string%'] = null === $entityDto ? '' : $entityDto->toString(); - - // If pretty URLs are used, extract the entity ID from the route attributes, otherwise from the query parameters - if ($this->adminRouteGenerator->usesPrettyUrls()) { - $translationParameters['%entity_id%'] = $entityId = $request->attributes->get(EA::ENTITY_ID); - } else { - $translationParameters['%entity_id%'] = $entityId = $request->query->get(EA::ENTITY_ID); - } - + // when using pretty URLs, the entity ID is passed as a request attribute (it's part of the route path); + // in legacy URLs, the entity ID is passed as a regular query parameter + $translationParameters['%entity_id%'] = $entityId = $request->attributes->get(EA::ENTITY_ID) ?? $request->query->get(EA::ENTITY_ID); $translationParameters['%entity_short_id%'] = null === $entityId ? null : u($entityId)->truncate(7)->toString(); $entityInstance = null === $entityDto ? null : $entityDto->getInstance();