Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Fix dumping extension config without bundle#46412

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:4.4fromyceruto:dump_extension_config
May 21, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\StyleInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;

/**
Expand DownExpand Up@@ -59,7 +60,7 @@ protected function listBundles($output)
/**
* @return ExtensionInterface
*/
protected function findExtension($name)
protected function findExtension($name, ContainerBuilder $container)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

that's a BC break

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

My bad!

I don't remember, is it ok to add a new deprecation in a patch version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We cannot do that in a patch release.

yceruto reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed in#46434

{
$bundles = $this->initializeBundles();
$minScore = \INF;
Expand All@@ -79,20 +80,18 @@ protected function findExtension($name)
$guess = $bundle->getName();
$minScore = $distance;
}
}

$extension = $bundle->getContainerExtension();

if ($extension) {
if ($name === $extension->getAlias()) {
return $extension;
}
if ($container->hasExtension($name)) {
return $container->getExtension($name);
}

$distance = levenshtein($name, $extension->getAlias());
foreach ($container->getExtensions() as $extension) {
$distance = levenshtein($name, $extension->getAlias());

if ($distance < $minScore) {
$guess = $extension->getAlias();
$minScore = $distance;
}
if ($distance < $minScore) {
$guess = $extension->getAlias();
$minScore = $distance;
}
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -79,9 +79,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

$extension = $this->findExtension($name);
$extensionAlias = $extension->getAlias();
$container = $this->compileContainer();
$extension = $this->findExtension($name, $container);
$extensionAlias = $extension->getAlias();

$config = $container->resolveEnvPlaceholders(
$container->getParameterBag()->resolveValue(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,9 +89,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

$extension = $this->findExtension($name);
$container = $this->getContainerBuilder();
$extension = $this->findExtension($name, $container);

$configuration = $extension->getConfiguration([], $this->getContainerBuilder());
$configuration = $extension->getConfiguration([], $container);

$this->validateConfiguration($extension, $configuration);

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,6 +68,15 @@ public function testDefaultParameterValueIsResolvedIfConfigIsExisting()
$this->assertStringContainsString(sprintf("dsn: 'file:%s/profiler'", $kernelCacheDir), $tester->getDisplay());
}

public function testDumpExtensionConfigWithoutBundle()
{
$tester = $this->createCommandTester();
$ret = $tester->execute(['name' => 'test_dump']);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertStringContainsString('enabled: true', $tester->getDisplay());
}

public function testDumpUndefinedBundleOption()
{
$tester = $this->createCommandTester();
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,15 @@ public function testDumpBundleName()
$this->assertStringContainsString(' custom:', $tester->getDisplay());
}

public function testDumpExtensionConfigWithoutBundle()
{
$tester = $this->createCommandTester();
$ret = $tester->execute(['name' => 'test_dump']);

$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertStringContainsString('enabled: true', $tester->getDisplay());
}

public function testDumpAtPath()
{
$tester = $this->createCommandTester();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Symfony 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\FrameworkBundle\Tests\Functional\Extension;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;

class TestDumpExtension extends Extension implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('test_dump');
$treeBuilder->getRootNode()
->children()
->booleanNode('enabled')->defaultTrue()->end()
->end()
;

return $treeBuilder;
}

public function load(array $configs, ContainerBuilder $container)
{
}

public function getConfiguration(array $config, ContainerBuilder $container)
{
return $this;
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\app;

use Psr\Log\NullLogger;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Extension\TestDumpExtension;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand DownExpand Up@@ -78,6 +79,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
protected function build(ContainerBuilder $container)
{
$container->register('logger', NullLogger::class);
$container->registerExtension(new TestDumpExtension());
}

public function __sleep(): array
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp