8000 bug #17456 [DX] Remove default match from AbstractConfigCommand::find… · gnat42/symfony@00c3192 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00c3192

Browse files
committed
bug symfony#17456 [DX] Remove default match from AbstractConfigCommand::findExtension (kix)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes symfony#17456). Discussion ---------- [DX] Remove default match from AbstractConfigCommand::findExtension | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | none Previously, `findExtension` would return the first extension that might not even match the `$name` parameter, which would quite confuse the user: ``` $ app/console config:debug TotallyNonExistentBundle # Current configuration for "TotallyNonExistentBundle" knp_paginator: default_options: sort_field_name: sort sort_direction_name: direction filter_field_name: filterField filter_value_name: filterValue page_name: page distinct: true template: pagination: 'KnpPaginatorBundle:Pagination:sliding.html.twig' filtration: 'KnpPaginatorBundle:Pagination:filtration.html.twig' sortable: 'KnpPaginatorBundle:Pagination:sortable_link.html.twig' page_range: 5 ``` Same problem goes for the `config:dump` command. When you dumped the config for a bundle you thought you've registered, but, for example, you'd use a name that's not exactly matching, you'd get confusing output for a different bundle's configuration. The problem was, an `Extension` [was always fetched in the finder method](https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php#L51), and name/alias misses were ignored. Commits ------- b85059a Remove default match from AbstractConfigCommand::findExtension
2 parents a4f7fbf + b85059a commit 00c3192

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,25 @@ protected function listBundles(OutputInterface $output)
4848

4949
protected function findExtension($name)
5050
{
51-
$extension = null;
5251
$bundles = $this->initializeBundles();
5352
foreach ($bundles as $bundle) {
54-
$extension = $bundle->getContainerExtension();
53+
if ($name === $bundle->getName()) {
54+
return $bundle->getContainerExtension();
55+
}
5556

56-
if ($extension && ($name === $extension->getAlias() || $name === $bundle->getName())) {
57-
break;
57+
$extension = $bundle->getContainerExtension();
58+
if ($extension && $name === $extension->getAlias()) {
59+
return $extension;
5860
}
5961
}
6062

61-
if (!$extension) {
63+
if ('Bundle' !== substr($name, -6)) {
64+
$message = sprintf('No extensions with configuration available for "%s"', $name);
65+
} else {
6266
$message = sprintf('No extension with alias "%s" is enabled', $name);
63-
if (preg_match('/Bundle$/', $name)) {
64-
$message = sprintf('No extensions with configuration available for "%s"', $name);
65-
}
66-
67-
throw new \LogicException($message);
6867
}
6968

70-
return $extension;
69+
throw new \LogicException($message);
7170
}
7271

7372
public function validateConfiguration(ExtensionInterface $extension, $configuration)

0 commit comments

Comments
 (0)
0