Skip to content
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

replace Bundle with the new AbstractBundle class #1514

Merged
merged 9 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading