mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
improve loading for existing crud cotnroller
This commit is contained in:
parent
95edbc673c
commit
c04ccef4cd
@ -50,12 +50,21 @@ class CRUDControllerCompilerPass implements CompilerPassInterface
|
|||||||
private function configureCrudController(ContainerBuilder $container, array $crudEntry, string $apiOrCrud): void
|
private function configureCrudController(ContainerBuilder $container, array $crudEntry, string $apiOrCrud): void
|
||||||
{
|
{
|
||||||
$controllerClass = $crudEntry['controller'];
|
$controllerClass = $crudEntry['controller'];
|
||||||
|
|
||||||
$controllerServiceName = 'cs'.$apiOrCrud.'_'.$crudEntry['name'].'_controller';
|
$controllerServiceName = 'cs'.$apiOrCrud.'_'.$crudEntry['name'].'_controller';
|
||||||
|
|
||||||
|
// create config parameter in container
|
||||||
|
$param = 'chill_main_'.$apiOrCrud.'_config_'.$crudEntry['name'];
|
||||||
|
$container->setParameter($param, $crudEntry);
|
||||||
|
|
||||||
if ($container->hasDefinition($controllerClass)) {
|
if ($container->hasDefinition($controllerClass)) {
|
||||||
|
// create an alias to not to re-create the service
|
||||||
$alias = new Alias($controllerClass, true);
|
$alias = new Alias($controllerClass, true);
|
||||||
$container->setAlias($controllerServiceName, $alias);
|
$container->setAlias($controllerServiceName, $alias);
|
||||||
|
|
||||||
|
// add the "addMethodCall"
|
||||||
|
$container->getDefinition($controllerClass)
|
||||||
|
->addMethodCall('setCrudConfig', ['%'.$param.'%']);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$controller = new Definition($controllerClass);
|
$controller = new Definition($controllerClass);
|
||||||
|
|
||||||
@ -63,8 +72,6 @@ class CRUDControllerCompilerPass implements CompilerPassInterface
|
|||||||
$controller->setAutoconfigured(true);
|
$controller->setAutoconfigured(true);
|
||||||
$controller->setPublic(true);
|
$controller->setPublic(true);
|
||||||
|
|
||||||
$param = 'chill_main_'.$apiOrCrud.'_config_'.$crudEntry['name'];
|
|
||||||
$container->setParameter($param, $crudEntry);
|
|
||||||
$controller->addMethodCall('setCrudConfig', ['%'.$param.'%']);
|
$controller->addMethodCall('setCrudConfig', ['%'.$param.'%']);
|
||||||
|
|
||||||
$container->setDefinition($controllerServiceName, $controller);
|
$container->setDefinition($controllerServiceName, $controller);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user