improve loading for crud controller

This commit is contained in:
Julien Fastré 2021-06-22 10:08:19 +02:00
parent 50be29308d
commit 95edbc673c

View File

@ -22,6 +22,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;
use Chill\MainBundle\Routing\MenuComposer;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Alias;
/**
*
@ -53,19 +54,14 @@ class CRUDControllerCompilerPass implements CompilerPassInterface
$controllerServiceName = 'cs'.$apiOrCrud.'_'.$crudEntry['name'].'_controller';
if ($container->hasDefinition($controllerClass)) {
$controller = $container->getDefinition($controllerClass);
$container->removeDefinition($controllerClass);
$alreadyDefined = true;
$alias = new Alias($controllerClass, true);
$container->setAlias($controllerServiceName, $alias);
} else {
$controller = new Definition($controllerClass);
$alreadyDefined = false;
}
$controller->addTag('controller.service_arguments');
if (FALSE === $alreadyDefined) {
$controller->setAutoconfigured(true);
$controller->setPublic(true);
}
$param = 'chill_main_'.$apiOrCrud.'_config_'.$crudEntry['name'];
$container->setParameter($param, $crudEntry);
@ -73,5 +69,6 @@ class CRUDControllerCompilerPass implements CompilerPassInterface
$container->setDefinition($controllerServiceName, $controller);
}
}
}