diff --git a/src/Factory/AdminContextFactory.php b/src/Factory/AdminContextFactory.php index d4dcad2fec..410bc80f68 100644 --- a/src/Factory/AdminContextFactory.php +++ b/src/Factory/AdminContextFactory.php @@ -115,7 +115,7 @@ private function getCrudDto(CrudControllerRegistry $crudControllers, DashboardCo $defaultCrud = $dashboardController->configureCrud(); $crudDto = $crudController->configureCrud($defaultCrud)->getAsDto(); - $entityFqcn = $crudControllers->findEntityFqcnByCrudFqcn($crudController::class); + $entityFqcn = $crudControllers->findEntityFqcnByCrud($crudController); $crudDto->setControllerFqcn($crudController::class); $crudDto->setActionsConfig($actionConfigDto); diff --git a/src/Registry/CrudControllerRegistry.php b/src/Registry/CrudControllerRegistry.php index 21d9a985c7..c88daa509d 100644 --- a/src/Registry/CrudControllerRegistry.php +++ b/src/Registry/CrudControllerRegistry.php @@ -2,6 +2,8 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Registry; +use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface; + /** * @author Javier Eguiluz */ @@ -31,9 +33,9 @@ public function findCrudFqcnByEntityFqcn(string $entityFqcn): ?string return $this->entityFqcnToCrudFqcnMap[$entityFqcn] ?? null; } - public function findEntityFqcnByCrudFqcn(string $controllerFqcn): ?string + public function findEntityFqcnByCrud(CrudControllerInterface $controllerFqcn): ?string { - return $this->crudFqcnToEntityFqcnMap[$controllerFqcn] ?? null; + return $this->crudFqcnToEntityFqcnMap[$controllerFqcn::class] ?? $controllerFqcn::getEntityFqcn() ?? null; } public function findCrudFqcnByCrudId(string $crudId): ?string