Skip to content

Commit

Permalink
Remove default match from AbstractConfigCommand::findExtension
Browse files Browse the repository at this point in the history
Previously, findExtension would return the first extension that might
not even match the $name parameter.
  • Loading branch information
kix authored and fabpot committed Jan 21, 2016
1 parent a4f7fbf commit b85059a
Showing 1 changed file with 10 additions and 11 deletions.
Expand Up @@ -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)
Expand Down

0 comments on commit b85059a

Please sign in to comment.