Skip to content

Commit

Permalink
[findEntityFqcnByCrud] - Allows you to find the Fqcn of an entity fro…
Browse files Browse the repository at this point in the history
…m the crud, either based on the 'findEntityFqcnByCrud' or on the 'findEntityFqcnByCrud' method.
  • Loading branch information
Qamar HAYAT committed Nov 20, 2023
1 parent 7003ee7 commit 1daaae6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Factory/AdminContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/Registry/CrudControllerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace EasyCorp\Bundle\EasyAdminBundle\Registry;

use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface;

/**
* @author Javier Eguiluz <[email protected]>
*/
Expand Down Expand Up @@ -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;

Check failure on line 38 in src/Registry/CrudControllerRegistry.php

View workflow job for this annotation

GitHub Actions / phpstan

Expression on left side of ?? is not nullable.
}

public function findCrudFqcnByCrudId(string $crudId): ?string
Expand Down

0 comments on commit 1daaae6

Please sign in to comment.