8000 replace Bundle with the new AbstractBundle class by jrushlow · Pull Request #1514 · symfony/maker-bundle · GitHub
[go: up one dir, main page]

Skip to content

replace Bundle with the new AbstractBundle class #1514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor in new generate_final_* params
  • Loading branch information
jrushlow committed Sep 27, 2024
commit 6f02865ceaf1fc4b5ce752ba35cd6bb7dd7fee82
3 changes: 3 additions & 0 deletions src/Resources/config/makers.xml → config/makers.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" ?>




<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
Expand Down
File renamed without changes.
34 changes: 0 additions & 34 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,34 +0,0 @@
<?php

/*
* This file is part of the Symfony MakerBundle package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\MakerBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('maker');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
->scalarNode('root_namespace')->defaultValue('App')->end()
->booleanNode('generate_final_classes')->defaultTrue()->end()
->booleanNode('generate_final_entities')->defaultFalse()->end()
->end()
;

return $treeBuilder;
}
}
58 changes: 0 additions & 58 deletions src/DependencyInjection/MakerExtension.php
Original file line number Diff line number Diff line change
@@ -1,58 +0,0 @@
<?php

/*
* This file is part of the Symfony MakerBundle package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\MakerBundle\DependencyInjection;

use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\MakeCommandRegistrationPass;
use Symfony\Bundle\MakerBundle\MakerInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* This is the class that loads and manages your bundle configuration.
*
* @see http://symfony.com/doc/current/cookbook/bundles/extension.html
*/
class MakerExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
$loader->load('makers.xml');

$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);

$rootNamespace = trim($config['root_namespace'], '\\');

$autoloaderFinderDefinition = $container->getDefinition('maker.autoloader_finder');
$autoloaderFinderDefinition->replaceArgument(0, $rootNamespace);

$makeCommandDefinition = $container->getDefinition('maker.generator');
$makeCommandDefinition->replaceArgument(1, $rootNamespace);

$doctrineHelperDefinition = $container->getDefinition('maker.doctrine_helper');
$doctrineHelperDefinition->replaceArgument(0, $rootNamespace.'\\Entity');

$componentGeneratorDefinition = $container->getDefinition('maker.template_component_generator');
$componentGeneratorDefinition
->replaceArgument(0, $config['generate_final_classes'])
->replaceArgument(1, $config['generate_final_entities'])
->replaceArgument(2, $rootNamespace)
;

$container->registerForAutoconfiguration(MakerInterface::class)
->addTag(MakeCommandRegistrationPass::MAKER_TAG);
}
}
42 changes: 41 additions & 1 deletion src/MakerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,56 @@
use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\MakeCommandRegistrationPass;
use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\RemoveMissingParametersPass;
use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\SetDoctrineAnnotatedPrefixesPass;
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
* @author Ryan Weaver <weaverryan@gmail.com>
*/
class MakerBundle extends Bundle
class MakerBundle extends AbstractBundle
{
public function configure(DefinitionConfigurator $definition): void
{
$definition->rootNode()
->children()
->scalarNode('root_namespace')->defaultValue('App')->end()
->booleanNode('generate_final_classes')->defaultTrue()->end()
->booleanNode('generate_final_entities')->defaultFalse()->end()
->end()
;
}

public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
{
$container->import('../config/services.xml');
$container->import('../config/makers.xml');

$rootNamespace = trim($config['root_namespace'], '\\');

$container->services()
->get('maker.autoloader_finder')
->arg(0, $rootNamespace)
->get('maker.generator')
->arg(1, $rootNamespace)
->get('maker.doctrine_helper')
->arg(0, $rootNamespace)
->get('maker.template_component_generator')
->arg(0, $config['generate_final_classes'])
->arg(1, $config['generate_final_entities'])
->arg(2, $rootNamespace)
;

$builder
->registerForAutoconfiguration(MakerInterface::class)
->addTag(MakeCommandRegistrationPass::MAKER_TAG)
;
}

public function build(ContainerBuilder $container): void
{
// add a priority so we run before the core command pass
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/maker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the old maker.xml... why is github complaining abaout a merge conflict....
0