mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
add support for re-use of same controller in CRUD
This commit is contained in:
@@ -228,6 +228,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
|
||||
foreach ($config as $crudEntry) {
|
||||
$controller = $crudEntry['controller'];
|
||||
$controllerServiceName = 'cscrud_'.$crudEntry['name'].'_controller';
|
||||
$name = $crudEntry['name'];
|
||||
|
||||
// check for existing crud names
|
||||
@@ -235,15 +236,16 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
throw new LogicException(sprintf("the name %s is defined twice in CRUD", $name));
|
||||
}
|
||||
|
||||
if (!$container->has($controller)) {
|
||||
if (!$container->has($controllerServiceName)) {
|
||||
$controllerDefinition = new Definition($controller);
|
||||
$controllerDefinition->addTag('controller.service_arguments');
|
||||
$controllerDefinition->setAutoconfigured(true);
|
||||
$container->setDefinition($controller, $controllerDefinition);
|
||||
$controllerDefinition->setClass($crudEntry['controller']);
|
||||
$container->setDefinition($controllerServiceName, $controllerDefinition);
|
||||
}
|
||||
|
||||
$container->setParameter('chill_main_crud_config_'.$name, $crudEntry);
|
||||
$container->getDefinition($controller)
|
||||
$container->getDefinition($controllerServiceName)
|
||||
->addMethodCall('setCrudConfig', ['%chill_main_crud_config_'.$name.'%']);
|
||||
}
|
||||
}
|
||||
|
@@ -134,10 +134,10 @@ class Configuration implements ConfigurationInterface
|
||||
->useAttributeAsKey('name')
|
||||
->arrayPrototype()
|
||||
->children()
|
||||
->scalarNode('controller')
|
||||
->scalarNode('controller_action')
|
||||
->defaultNull()
|
||||
->info('the method name to call in the route. Will be set to the action name if left empty.')
|
||||
->example("'MyBundle\Controller\MyCrudController::action'")
|
||||
->example("'action'")
|
||||
->end()
|
||||
->scalarNode('path')
|
||||
->defaultNull()
|
||||
|
Reference in New Issue
Block a user