Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 018f91a

Browse files
implemented reviewer's suggestions
1 parent 807aaeb commit 018f91a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/EventListener/SuggestMissingPackageSubscriber.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
*/
2525
final class SuggestMissingPackageSubscriber implements EventSubscriberInterface
2626
{
27-
const SUGGESTED_PACKAGES = [
27+
/**
28+
* Mappings between namespaces of Symfony commands and packages required to run these commands.
29+
*
30+
* @var array $suggestedPackages
31+
*/
32+
private static $suggestedPackages = [
2833
'doctrine' => [
2934
'Doctrine ORM',
3035
'symfony/orm-pack',
@@ -49,10 +54,10 @@ public function onConsoleError(ConsoleErrorEvent $event)
4954
if (null !== $event->getInput()->getFirstArgument()) {
5055
$namespace = explode(':', $event->getInput()->getFirstArgument())[0];
5156

52-
if (isset(self::SUGGESTED_PACKAGES[$namespace])) {
53-
$suggestion = self::SUGGESTED_PACKAGES[$namespace];
57+
if (isset(self::$suggestedPackages[$namespace])) {
58+
$suggestion = self::$suggestedPackages[$namespace];
5459
$message = sprintf("It seems that you are trying to run a command from '%s' bundle/package, but you do not have it installed. You may try installing the missing bundle/package by running:\n\n composer require %s", $suggestion[0], $suggestion[1]);
55-
throw new NamespaceNotFoundException($message);
60+
$event->setError(new NamespaceNotFoundException($message));
5661
}
5762
}
5863
}

0 commit comments

Comments
 (0)