private function registerFormsServicesFromGenerator(array $generatorParameters, array $builders, ContainerBuilder $container)
    {
        $modelParts                       = explode('\\', $generatorParameters['model']);
        $model                            = strtolower(array_pop($modelParts)); // @TODO: BC Support, remove it starting from v.3.0.0
        $fullQualifiedNormalizedModelName = strtolower(str_replace('\\', '_', ltrim($generatorParameters['model'], '\\'))); // @TODO: BC Support, remove it starting from v.3.0.0
        $namespace_prefix                 = $generatorParameters['namespace_prefix'] ? $generatorParameters['namespace_prefix'] . '\\' : '';
        $fullQualifiedNormalizedFormName  = sprintf('%s%s_%s', str_replace('\\', '_', ltrim($namespace_prefix, '\\')), $generatorParameters['bundle_name'], $generatorParameters['prefix']);

        $formsBundleNamespace = sprintf(
            '%s%s\\Form\\Type\\%s',
            $namespace_prefix,
            $generatorParameters['bundle_name'],
            $generatorParameters['prefix']
        );
        $authorizationCheckerServiceReference = new Reference('security.authorization_checker');

        if (in_array('new', $builders)) {
            $newDefinition = new Definition($formsBundleNamespace . '\\' . 'NewType');
            $newDefinition
                ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference))
                ->addTag('form.type');

            $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedFormName . '_new'), $newDefinition);
            $container->setAlias('admingen_generator_' . $fullQualifiedNormalizedModelName . '_new', $id);
            $container->setAlias('admingen_generator_' . $model . '_new', $id);
        }

        if (in_array('edit', $builders)) {
            $editDefinition = new Definition($formsBundleNamespace . '\\' . 'EditType');
            $editDefinition
                ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference))
                ->addTag('form.type');

            $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedFormName . '_edit'), $editDefinition);
            $container->setAlias('admingen_generator_' . $fullQualifiedNormalizedModelName . '_edit', $id);
            $container->setAlias('admingen_generator_' . $model . '_edit', $id);
        }

        if (in_array('list', $builders) || in_array('nested_list', $builders)) {
            $filterDefinition = new Definition($formsBundleNamespace . '\\' . 'FiltersType');
            $filterDefinition
                ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference))
                ->addTag('form.type');

            $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedFormName . '_filter'), $filterDefinition);
            $container->setAlias('admingen_generator_' . $fullQualifiedNormalizedModelName . '_filter', $id);
            $container->setAlias('admingen_generator_' . $model . '_filter', $id);
        }
    }
private function registerFormsServicesFromGenerator(array $generatorParameters, array $builders, ContainerBuilder $container)
    {
        $modelParts                       = explode('\\', $generatorParameters['model']);
        $model                            = strtolower(array_pop($modelParts)); // @TODO: BC Support, remove it starting from v.3.0.0
        $fullQualifiedNormalizedModelName = strtolower(str_replace('\\', '_', ltrim($generatorParameters['model'], '\\'))); // @TODO: BC Support, remove it starting from v.3.0.0
        $namespace_prefix                 = $generatorParameters['namespace_prefix'] ? $generatorParameters['namespace_prefix'] . '\\' : '';
        $fullQualifiedNormalizedFormName  = sprintf('%s%s_%s', str_replace('\\', '_', ltrim($namespace_prefix, '\\')), $generatorParameters['bundle_name'], $generatorParameters['prefix']);

        $formsBundleNamespace = sprintf(
            '%s%s\\Form\\Type\\%s',
            $namespace_prefix,
            $generatorParameters['bundle_name'],
            $generatorParameters['prefix']
        );
        $authorizationCheckerServiceReference = new Reference('security.authorization_checker');

        if (in_array('new', $builders)) {
            $newDefinition = new Definition($formsBundleNamespace . '\\' . 'NewType');
            $newDefinition
                ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference))
                ->addTag('form.type');

            $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedFormName . '_new'), $newDefinition);
            $container->setAlias('admingen_generator_' . $fullQualifiedNormalizedModelName . '_new', $id);
            $container->setAlias('admingen_generator_' . $model . '_new', $id);
        }

        if (in_array('edit', $builders)) {
            $editDefinition = new Definition($formsBundleNamespace . '\\' . 'EditType');
            $editDefinition
                ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference))
                ->addTag('form.type');

            $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedFormName . '_edit'), $editDefinition);
            $container->setAlias('admingen_generator_' . $fullQualifiedNormalizedModelName . '_edit', $id);
            $container->setAlias('admingen_generator_' . $model . '_edit', $id);
        }

        if (in_array('list', $builders) || in_array('nested_list', $builders)) {
            $filterDefinition = new Definition($formsBundleNamespace . '\\' . 'FiltersType');
            $filterDefinition
                ->addMethodCall('setAuthorizationChecker', array($authorizationCheckerServiceReference))
                ->addTag('form.type');

            $container->setDefinition(($id = 'admingen_generator_' . $fullQualifiedNormalizedFormName . '_filter'), $filterDefinition);
            $container->setAlias('admingen_generator_' . $fullQualifiedNormalizedModelName . '_filter', $id);
            $container->setAlias('admingen_generator_' . $model . '_filter', $id);
        }
    }
private function registerFormsServicesFromGenerator ( array $ generatorParameters , array $ builders , ContainerBuilder $ container ) { $ modelParts = explode ( '\\' , $ generatorParameters [ 'model' ] ) ; $ model = strtolower ( array_pop ( $ modelParts ) ) ; // @TODO: BC Support, remove it starting from v.3.0.0 $ fullQualifiedNormalizedModelName = strtolower ( str_replace ( '\\' , '_' , ltrim ( $ generatorParameters [ 'model' ] , '\\' ) ) ) ; // @TODO: BC Support, remove it starting from v.3.0.0 $ namespace_prefix = $ generatorParameters [ 'namespace_prefix' ] ? $ generatorParameters [ 'namespace_prefix' ] . '\\' : '' ; $ fullQualifiedNormalizedFormName = sprintf ( '%s%s_%s' , str_replace ( '\\' , '_' , ltrim ( $ namespace_prefix , '\\' ) ) , $ generatorParameters [ 'bundle_name' ] , $ generatorParameters [ 'prefix' ] ) ; $ formsBundleNamespace = sprintf ( '%s%s\\Form\\Type\\%s' , $ namespace_prefix , $ generatorParameters [ 'bundle_name' ] , $ generatorParameters [ 'prefix' ] ) ; $ authorizationCheckerServiceReference = new Reference ( 'security.authorization_checker' ) ; if ( in_array ( 'new' , $ builders ) ) { $ newDefinition = new Definition ( $ formsBundleNamespace . '\\' . 'NewType' ) ; $ newDefinition -> addMethodCall ( 'setAuthorizationChecker' , array ( $ authorizationCheckerServiceReference ) ) -> addTag ( 'form.type' ) ; $ container -> setDefinition ( ( $ id = 'admingen_generator_' . $ fullQualifiedNormalizedFormName . '_new' ) , $ newDefinition ) ; $ container -> setAlias ( 'admingen_generator_' . $ fullQualifiedNormalizedModelName . '_new' , $ id ) ; $ container -> setAlias ( 'admingen_generator_' . $ model . '_new' , $ id ) ; } if ( in_array ( 'edit' , $ builders ) ) { $ editDefinition = new Definition ( $ formsBundleNamespace . '\\' . 'EditType' ) ; $ editDefinition -> addMethodCall ( 'setAuthorizationChecker' , array ( $ authorizationCheckerServiceReference ) ) -> addTag ( 'form.type' ) ; $ container -> setDefinition ( ( $ id = 'admingen_generator_' . $ fullQualifiedNormalizedFormName . '_edit' ) , $ editDefinition ) ; $ container -> setAlias ( 'admingen_generator_' . $ fullQualifiedNormalizedModelName . '_edit' , $ id ) ; $ container -> setAlias ( 'admingen_generator_' . $ model . '_edit' , $ id ) ; } if ( in_array ( 'list' , $ builders ) || in_array ( 'nested_list' , $ builders ) ) { $ filterDefinition = new Definition ( $ formsBundleNamespace . '\\' . 'FiltersType' ) ; $ filterDefinition -> addMethodCall ( 'setAuthorizationChecker' , array ( $ authorizationCheckerServiceReference ) ) -> addTag ( 'form.type' ) ; $ container -> setDefinition ( ( $ id = 'admingen_generator_' . $ fullQualifiedNormalizedFormName . '_filter' ) , $ filterDefinition ) ; $ container -> setAlias ( 'admingen_generator_' . $ fullQualifiedNormalizedModelName . '_filter' , $ id ) ; $ container -> setAlias ( 'admingen_generator_' . $ model . '_filter' , $ id ) ; } }
Register forms as services for a generator.
Register only generated forms based on defined builders.

@param array $generatorParameters
@param array $builders
@param ContainerBuilder $container
Register forms as services for a generator . Register only generated forms based on defined builders .