From b85059a672cffb192aa1df2f7d8c33244cc82f44 Mon Sep 17 00:00:00 2001 From: Stepan Anchugov Date: Wed, 20 Jan 2016 17:10:14 +0500 Subject: [PATCH] Remove default match from AbstractConfigCommand::findExtension Previously, findExtension would return the first extension that might not even match the $name parameter. --- .../Command/AbstractConfigCommand.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index aee0eb1f00d8..232d62ffc97a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -48,26 +48,25 @@ protected function listBundles(OutputInterface $output) protected function findExtension($name) { - $extension = null; $bundles = $this->initializeBundles(); foreach ($bundles as $bundle) { - $extension = $bundle->getContainerExtension(); + if ($name === $bundle->getName()) { + return $bundle->getContainerExtension(); + } - if ($extension && ($name === $extension->getAlias() || $name === $bundle->getName())) { - break; + $extension = $bundle->getContainerExtension(); + if ($extension && $name === $extension->getAlias()) { + return $extension; } } - if (!$extension) { + if ('Bundle' !== substr($name, -6)) { + $message = sprintf('No extensions with configuration available for "%s"', $name); + } else { $message = sprintf('No extension with alias "%s" is enabled', $name); - if (preg_match('/Bundle$/', $name)) { - $message = sprintf('No extensions with configuration available for "%s"', $name); - } - - throw new \LogicException($message); } - return $extension; + throw new \LogicException($message); } public function validateConfiguration(ExtensionInterface $extension, $configuration)