From 9c575c637c3176253f1d2b9f9d4970bb11df3050 Mon Sep 17 00:00:00 2001 From: Toni Uebernickel Date: Sat, 23 Jan 2016 17:50:54 +0100 Subject: [PATCH] enforce error message if bundle argument is set This fixes #180. The kernel will throw an exception if the bundle could not be found, which also contains the name of the bundle. --- Command/AbstractCommand.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Command/AbstractCommand.php b/Command/AbstractCommand.php index b9687db..6888df2 100644 --- a/Command/AbstractCommand.php +++ b/Command/AbstractCommand.php @@ -128,11 +128,13 @@ abstract class AbstractCommand extends ContainerAwareCommand $this->checkConfiguration(); - if ($input->hasArgument('bundle') && '@' === substr($input->getArgument('bundle'), 0, 1)) { - $this->bundle = $this - ->getContainer() - ->get('kernel') - ->getBundle(substr($input->getArgument('bundle'), 1)); + if ($input->hasArgument('bundle')) { + $bundleName = $input->getArgument('bundle'); + if (0 === strpos($bundleName, '@')) { + $bundleName = substr($bundleName, 1); + } + + $this->bundle = $this->getContainer()->get('kernel')->getBundle($bundleName); } }