diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index 23a446017909f..f2e763f4eebfe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -46,21 +46,44 @@ protected function listBundles($output) protected function findExtension($name) { $bundles = $this->initializeBundles(); + $minScore = INF; + foreach ($bundles as $bundle) { if ($name === $bundle->getName()) { return $bundle->getContainerExtension(); } + $distance = levenshtein($name, $bundle->getName()); + + if ($distance < $minScore) { + $guess = $bundle->getName(); + $minScore = $distance; + } + $extension = $bundle->getContainerExtension(); - if ($extension && $name === $extension->getAlias()) { - return $extension; + + if ($extension) { + if ($name === $extension->getAlias()) { + return $extension; + } + + $distance = levenshtein($name, $extension->getAlias()); + + if ($distance < $minScore) { + $guess = $extension->getAlias(); + $minScore = $distance; + } } } if ('Bundle' !== substr($name, -6)) { - $message = sprintf('No extensions with configuration available for "%s"', $name); + $message = sprintf('No extensions with configuration available for "%s".', $name); } else { - $message = sprintf('No extension with alias "%s" is enabled', $name); + $message = sprintf('No extension with alias "%s" is enabled.', $name); + } + + if (isset($guess) && $minScore < 3) { + $message .= sprintf("\n\nDid you mean \"%s\"?", $guess); } throw new \LogicException($message);
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: