|
14 | 14 | use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\MakeCommandRegistrationPass; |
15 | 15 | use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\RemoveMissingParametersPass; |
16 | 16 | use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\SetDoctrineAnnotatedPrefixesPass; |
| 17 | +use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator; |
17 | 18 | use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
18 | 19 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 20 | +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; |
| 21 | +use Symfony\Component\HttpKernel\Bundle\AbstractBundle; |
19 | 22 | use Symfony\Component\HttpKernel\Bundle\Bundle; |
20 | 23 |
|
21 | 24 | /** |
22 | 25 | * @author Javier Eguiluz <[email protected]> |
23 | 26 | * @author Ryan Weaver <[email protected]> |
24 | 27 | */ |
25 | | -class MakerBundle extends Bundle |
| 28 | +class MakerBundle extends AbstractBundle |
26 | 29 | { |
| 30 | + public function configure(DefinitionConfigurator $definition): void |
| 31 | + { |
| 32 | + $definition->rootNode() |
| 33 | + ->children() |
| 34 | + ->scalarNode('root_namespace') |
| 35 | + ->defaultValue('App') |
| 36 | + ->end() |
| 37 | + ->end() |
| 38 | + ; |
| 39 | + } |
| 40 | + |
| 41 | + public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void |
| 42 | + { |
| 43 | + $container->import('../config/services.xml'); |
| 44 | + $container->import('../config/makers.xml'); |
| 45 | + |
| 46 | + $rootNamespace = trim($config['root_namespace'], '\\'); |
| 47 | + |
| 48 | + $container->services() |
| 49 | + ->get('maker.autoloader_finder') |
| 50 | + ->arg(0, $rootNamespace) |
| 51 | + ->get('maker.generator') |
| 52 | + ->arg(1, $rootNamespace) |
| 53 | + ->get('maker.doctrine_helper') |
| 54 | + ->arg(0, $rootNamespace) |
| 55 | + ; |
| 56 | + |
| 57 | + $builder |
| 58 | + ->registerForAutoconfiguration(MakerInterface::class) |
| 59 | + ->addTag(MakeCommandRegistrationPass::MAKER_TAG) |
| 60 | + ; |
| 61 | + } |
| 62 | + |
27 | 63 | public function build(ContainerBuilder $container): void |
28 | 64 | { |
29 | 65 | // add a priority so we run before the core command pass |
|
0 commit comments