-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #3546 Added a compiler pass to create the controller registries (…
…javiereguiluz) This PR was merged into the 3.0.x-dev branch. Discussion ---------- Added a compiler pass to create the controller registries Fixes #3541. Commits ------- e650e53 Added a compiler pass to create the controller registries
- Loading branch information
Showing
5 changed files
with
64 additions
and
16 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/DependencyInjection/CreateControllerRegistriesPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\DependencyInjection; | ||
|
||
use EasyCorp\Bundle\EasyAdminBundle\Registry\CrudControllerRegistry; | ||
use EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* Creates the services of the Dashboard and CRUD controller registries. They can't | ||
* be defined as normal services because they cause circular dependencies. | ||
* See https://github.com/EasyCorp/EasyAdminBundle/issues/3541 | ||
* | ||
* @author Javier Eguiluz <javier.eguiluz@gmail.com> | ||
*/ | ||
class CreateControllerRegistriesPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$this->createDashboardControllerRegistryService($container); | ||
$this->createCrudControllerRegistryService($container); | ||
} | ||
|
||
private function createDashboardControllerRegistryService(ContainerBuilder $container): void | ||
{ | ||
$dashboardControllersFqcn = array_keys($container->findTaggedServiceIds(EasyAdminExtension::TAG_DASHBOARD_CONTROLLER, true)); | ||
|
||
$container | ||
->register(DashboardControllerRegistry::class, DashboardControllerRegistry::class) | ||
->setPublic(false) | ||
->setArguments([ | ||
$container->getParameter('kernel.secret'), | ||
$container->getParameter('kernel.cache_dir'), | ||
$dashboardControllersFqcn, | ||
]); | ||
} | ||
|
||
private function createCrudControllerRegistryService(ContainerBuilder $container): void | ||
{ | ||
$crudControllersFqcn = array_keys($container->findTaggedServiceIds(EasyAdminExtension::TAG_CRUD_CONTROLLER, true)); | ||
|
||
$container | ||
->register(CrudControllerRegistry::class, CrudControllerRegistry::class) | ||
->setPublic(false) | ||
->setArguments([ | ||
$container->getParameter('kernel.secret'), | ||
$crudControllersFqcn, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters