Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Nov 19, 2024
1 parent 3fd4515 commit cf06fff
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/Factory/AdminContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit cf06fff

Please sign in to comment.