From 3998d78770481a4870efbbfea7047970e3c96913 Mon Sep 17 00:00:00 2001 From: "Nikola Svitlica a.k.a. TheCelavi" Date: Tue, 31 May 2016 17:19:01 +0200 Subject: [PATCH] Fixed #288, auto generated form types now have unique service name, no possibility for overwritting. --- .../AdmingeneratorGeneratorExtension.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/AdmingeneratorGeneratorExtension.php b/DependencyInjection/AdmingeneratorGeneratorExtension.php index 85cf75bc..02833136 100644 --- a/DependencyInjection/AdmingeneratorGeneratorExtension.php +++ b/DependencyInjection/AdmingeneratorGeneratorExtension.php @@ -269,13 +269,15 @@ private function registerGeneratedFormsAsServices(ContainerBuilder $container) private function registerFormsServicesFromGenerator(array $generatorParameters, array $builders, ContainerBuilder $container) { $modelParts = explode('\\', $generatorParameters['model']); - $model = array_pop($modelParts); + $model = strtolower(array_pop($modelParts)); // @TODO: BC Support, remove it starting from v.3.0.0 + $fullQualifiedNormalizedModelName = strtolower(str_replace('\\', '_', ltrim($generatorParameters['model']))); $formsBundleNamespace = sprintf( '%s%s\\Form\\Type\\%s', $generatorParameters['namespace_prefix'] ? $generatorParameters['namespace_prefix'] . '\\' : '', $generatorParameters['bundle_name'], $generatorParameters['prefix'] ); + $authorizationCheckerServiceReference = new Reference('security.authorization_checker'); if (in_array('new', $builders)) { @@ -284,7 +286,8 @@ private function registerFormsServicesFromGenerator(array $generatorParameters, ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference)) ->addTag('form.type'); - $container->setDefinition('admingen_generator_' . strtolower($model) . '_new', $newDefinition); + $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedModelName . '_new'), $newDefinition); + $container->setAlias('admingen_generator_' . $model . '_new', $id); } if (in_array('edit', $builders)) { @@ -293,7 +296,8 @@ private function registerFormsServicesFromGenerator(array $generatorParameters, ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference)) ->addTag('form.type'); - $container->setDefinition('admingen_generator_' . strtolower($model) . '_edit', $editDefinition); + $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedModelName . '_edit'), $editDefinition); + $container->setAlias('admingen_generator_' . $model . '_edit', $id); } if (in_array('list', $builders) || in_array('nested_list', $builders)) { @@ -302,7 +306,8 @@ private function registerFormsServicesFromGenerator(array $generatorParameters, ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference)) ->addTag('form.type'); - $container->setDefinition('admingen_generator_' . strtolower($model) . '_filter', $filterDefinition); + $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedModelName . '_filter'), $filterDefinition); + $container->setAlias('admingen_generator_' . $model . '_filter', $id); } }