From 1daaae639a91b7cb7e6f67b13457c601ca339744 Mon Sep 17 00:00:00 2001 From: Qamar HAYAT Date: Mon, 20 Nov 2023 14:39:02 +0100 Subject: [PATCH] [findEntityFqcnByCrud] - Allows you to find the Fqcn of an entity from the crud, either based on the 'findEntityFqcnByCrud' or on the 'findEntityFqcnByCrud' method. --- src/Factory/AdminContextFactory.php | 2 +- src/Registry/CrudControllerRegistry.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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