8000 Remove default match from AbstractConfigCommand::findExtension · symfony/symfony@b85059a · GitHub
[go: up one dir, main page]

Skip to content

Commit b85059a

Browse files
kixfabpot
authored andcommitted
Remove default match from AbstractConfigCommand::findExtension
Previously, findExtension would return the first extension that might not even match the $name parameter.
1 parent a4f7fbf commit b85059a

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