Skip to content

Commit

Permalink
bug #6617 Some fixes related to pretty URLs (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.x branch.

Discussion
----------

Some fixes related to pretty URLs

Commits
-------

b98e5a6 Some fixes related to pretty URLs
  • Loading branch information
javiereguiluz committed Dec 3, 2024
2 parents 6ea974b + b98e5a6 commit 452ddec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/EventListener/AdminRouterSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public function onKernelController(ControllerEvent $event): void

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

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

private function getCrudControllerInstance(Request $request): ?CrudControllerInterface
{
$crudControllerFqcn = $request->query->get(EA::CRUD_CONTROLLER_FQCN);

$crudAction = $request->query->get(EA::CRUD_ACTION);
// when using pretty URLs, the data is in the request attributes instead of the query string
$crudControllerFqcn = $request->attributes->get(EA::CRUD_CONTROLLER_FQCN) ?? $request->query->get(EA::CRUD_CONTROLLER_FQCN);
$crudAction = $request->attributes->get(EA::CRUD_ACTION) ?? $request->query->get(EA::CRUD_ACTION);

return $this->controllerFactory->getCrudControllerInstance($crudControllerFqcn, $crudAction, $request);
}
Expand Down

0 comments on commit 452ddec

Please sign in to comment.