Skip to content

Commit 673c3a5

Browse files
authored
minor #1514 replace Bundle with the new AbstractBundle class
* refactor in new generate_final_* params * is github still complaining about a merge conflict * php-cs-fixer it up * minor disclaimer for php-cs-fixer config * move docs to project level dir instead of in src/Resources * remove unused files * add missing extension alias * fix doctrine ns config * fix bundled php-cs-fixer config path
1 parent e8d226a commit 673c3a5

File tree

10 files changed

+54
-97
lines changed

10 files changed

+54
-97
lines changed

.symfony.bundle.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ branches: ["main"]
22

33
maintained_branches: ["main"]
44

5-
doc_dir: "src/Resources/doc"
5+
doc_dir: "docs"
66

_docs_build/build.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
$outputDir = __DIR__.'/output';
3131
$buildConfig = (new BuildConfig())
3232
->setSymfonyVersion('7.1')
33-
->setContentDir(__DIR__.'/../src/Resources/doc')
33+
->setContentDir(__DIR__.'/../docs')
3434
->setOutputDir($outputDir)
3535
->setImagesDir(__DIR__.'/output/_images')
3636
->setImagesPublicPrefix('_images')
File renamed without changes.

src/Resources/config/php-cs-fixer.config.php renamed to config/php-cs-fixer.config.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
/*
13+
* This PHP-CS-Fixer config file is used by the TemplateLinter for userland
14+
* code when say make:controller is run. If a user does not have a php-cs-fixer
15+
* config file, this one is used on the generated PHP files.
16+
*
17+
* It should not be confused by the root level .php-cs-fixer.dist.php config
18+
* which is used to maintain the MakerBundle codebase itself.
19+
*/
1220
return (new PhpCsFixer\Config())
1321
->setRules([
1422
'@Symfony' => true,
File renamed without changes.
File renamed without changes.

src/DependencyInjection/Configuration.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/DependencyInjection/MakerExtension.php

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/MakerBundle.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,57 @@
1414
use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\MakeCommandRegistrationPass;
1515
use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\RemoveMissingParametersPass;
1616
use Symfony\Bundle\MakerBundle\DependencyInjection\CompilerPass\SetDoctrineAnnotatedPrefixesPass;
17+
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
1718
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
19-
use Symfony\Component\HttpKernel\Bundle\Bundle;
20+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
21+
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
2022

2123
/**
2224
* @author Javier Eguiluz <[email protected]>
2325
* @author Ryan Weaver <[email protected]>
2426
*/
25-
class MakerBundle extends Bundle
27+
class MakerBundle extends AbstractBundle
2628
{
29+
protected string $extensionAlias = 'maker';
30+
31+
public function configure(DefinitionConfigurator $definition): void
32+
{
33+
$definition->rootNode()
34+
->children()
35+
->scalarNode('root_namespace')->defaultValue('App')->end()
36+
->booleanNode('generate_final_classes')->defaultTrue()->end()
37+
->booleanNode('generate_final_entities')->defaultFalse()->end()
38+
->end()
39+
;
40+
}
41+
42+
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
43+
{
44+
$container->import('../config/services.xml');
45+
$container->import('../config/makers.xml');
46+
47+
$rootNamespace = trim($config['root_namespace'], '\\');
48+
49+
$container->services()
50+
->get('maker.autoloader_finder')
51+
->arg(0, $rootNamespace)
52+
->get('maker.generator')
53+
->arg(1, $rootNamespace)
54+
->get('maker.doctrine_helper')
55+
->arg(0, \sprintf('%s\\Entity', $rootNamespace))
56+
->get('maker.template_component_generator')
57+
->arg(0, $config['generate_final_classes'])
58+
->arg(1, $config['generate_final_entities'])
59+
->arg(2, $rootNamespace)
60+
;
61+
62+
$builder
63+
->registerForAutoconfiguration(MakerInterface::class)
64+
->addTag(MakeCommandRegistrationPass::MAKER_TAG)
65+
;
66+
}
67+
2768
public function build(ContainerBuilder $container): void
2869
{
2970
// add a priority so we run before the core command pass

src/Util/TemplateLinter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private function setConfig(): void
145145

146146
// No config provided and no project dist config - use our config
147147
if (null === $this->phpCsFixerConfigPath) {
148-
$this->phpCsFixerConfigPath = \dirname(__DIR__).'/Resources/config/php-cs-fixer.config.php';
148+
$this->phpCsFixerConfigPath = \sprintf('%s/config/php-cs-fixer.config.php', \dirname(__DIR__, 2));
149149

150150
return;
151151
}

0 commit comments

Comments
 (0)