diff --git a/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php b/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php index d8a46837c..f84628ccd 100644 --- a/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php +++ b/src/Bundle/ChillMainBundle/CRUD/CompilerPass/CRUDControllerCompilerPass.php @@ -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,25 +54,21 @@ 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->addTag('controller.service_arguments'); $controller->setAutoconfigured(true); $controller->setPublic(true); + + $param = 'chill_main_'.$apiOrCrud.'_config_'.$crudEntry['name']; + $container->setParameter($param, $crudEntry); + $controller->addMethodCall('setCrudConfig', ['%'.$param.'%']); + + $container->setDefinition($controllerServiceName, $controller); } - - $param = 'chill_main_'.$apiOrCrud.'_config_'.$crudEntry['name']; - $container->setParameter($param, $crudEntry); - $controller->addMethodCall('setCrudConfig', ['%'.$param.'%']); - - $container->setDefinition($controllerServiceName, $controller); } }