Skip to content

Commit

Permalink
minor #1514 replace Bundle with the new AbstractBundle class
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jrushlow authored Sep 28, 2024
1 parent e8d226a commit 673c3a5
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .symfony.bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ branches: ["main"]

maintained_branches: ["main"]

doc_dir: "src/Resources/doc"
doc_dir: "docs"

2 changes: 1 addition & 1 deletion _docs_build/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$outputDir = __DIR__.'/output';
$buildConfig = (new BuildConfig())
->setSymfonyVersion('7.1')
->setContentDir(__DIR__.'/../src/Resources/doc')
->setContentDir(__DIR__.'/../docs')
->setOutputDir($outputDir)
->setImagesDir(__DIR__.'/output/_images')
->setImagesPublicPrefix('_images')
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
* file that was distributed with this source code.
*/

/*
* This PHP-CS-Fixer config file is used by the TemplateLinter for userland
* code when say make:controller is run. If a user does not have a php-cs-fixer
* config file, this one is used on the generated PHP files.
*
* It should not be confused by the root level .php-cs-fixer.dist.php config
* which is used to maintain the MakerBundle codebase itself.
*/
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
Expand Down
File renamed without changes.
File renamed without changes.
34 changes: 0 additions & 34 deletions src/DependencyInjection/Configuration.php

This file was deleted.

58 changes: 0 additions & 58 deletions src/DependencyInjection/MakerExtension.php

This file was deleted.

45 changes: 43 additions & 2 deletions src/MakerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,57 @@
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\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;

/**
* @author Javier Eguiluz <[email protected]>
* @author Ryan Weaver <[email protected]>
*/
class MakerBundle extends Bundle
class MakerBundle extends AbstractBundle
{
protected string $extensionAlias = 'maker';

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, \sprintf('%s\\Entity', $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
2 changes: 1 addition & 1 deletion src/Util/TemplateLinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private function setConfig(): void

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

return;
}
Expand Down

0 comments on commit 673c3a5

Please sign in to comment.