Skip to content

Commit 452ddec

Browse files
committedDec 3, 2024·
bug #6617 Some fixes related to pretty URLs (javiereguiluz)
This PR was merged into the 4.x branch. Discussion ---------- Some fixes related to pretty URLs Commits ------- b98e5a6 Some fixes related to pretty URLs
2 parents 6ea974b + b98e5a6 commit 452ddec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎src/EventListener/AdminRouterSubscriber.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ public function onKernelController(ControllerEvent $event): void
138138

139139
// if the request is related to a CRUD controller, change the controller to be executed
140140
if (null !== $crudControllerInstance = $this->getCrudControllerInstance($request)) {
141-
$symfonyControllerFqcnCallable = [$crudControllerInstance, $request->query->get(EA::CRUD_ACTION)];
142-
$symfonyControllerStringCallable = [$crudControllerInstance::class, $request->query->get(EA::CRUD_ACTION)];
141+
$symfonyControllerFqcnCallable = [$crudControllerInstance, $request->attributes->get(EA::CRUD_ACTION) ?? $request->query->get(EA::CRUD_ACTION)];
142+
$symfonyControllerStringCallable = [$crudControllerInstance::class, $request->attributes->get(EA::CRUD_ACTION) ?? $request->query->get(EA::CRUD_ACTION)];
143143

144144
// this makes Symfony believe that another controller is being executed
145145
// (e.g. this is needed for the autowiring of controller action arguments)
@@ -207,9 +207,9 @@ private function getDashboardControllerInstance(string $dashboardControllerFqcn,
207207

208208
private function getCrudControllerInstance(Request $request): ?CrudControllerInterface
209209
{
210-
$crudControllerFqcn = $request->query->get(EA::CRUD_CONTROLLER_FQCN);
211-
212-
$crudAction = $request->query->get(EA::CRUD_ACTION);
210+
// when using pretty URLs, the data is in the request attributes instead of the query string
211+
$crudControllerFqcn = $request->attributes->get(EA::CRUD_CONTROLLER_FQCN) ?? $request->query->get(EA::CRUD_CONTROLLER_FQCN);
212+
$crudAction = $request->attributes->get(EA::CRUD_ACTION) ?? $request->query->get(EA::CRUD_ACTION);
213213

214214
return $this->controllerFactory->getCrudControllerInstance($crudControllerFqcn, $crudAction, $request);
215215
}

0 commit comments

Comments
 (0)
Please sign in to comment.