From 8d9067ec8731af705ad6d59084b395801a44cba2 Mon Sep 17 00:00:00 2001 From: Robin van der Vleuten Date: Mon, 31 Mar 2014 13:03:58 +0200 Subject: [PATCH] Correct prefix when PSR-4 bundle --- Command/AbstractCommand.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Command/AbstractCommand.php b/Command/AbstractCommand.php index bb21aec..e63474a 100644 --- a/Command/AbstractCommand.php +++ b/Command/AbstractCommand.php @@ -77,7 +77,13 @@ abstract class AbstractCommand extends ContainerAwareCommand protected function getPackagePrefix(Bundle $bundle, $baseDirectory = '') { $parts = explode(DIRECTORY_SEPARATOR, realpath($bundle->getPath())); - $length = count(explode('\\', $bundle->getNamespace())) * (-1); + $segments = explode('\\', $bundle->getNamespace()); + $length = count($parts); + + $partsDiff = array_diff($segments, $parts); + if (empty($partsDiff)) { + $length = count(explode('\\', $bundle->getNamespace())) * (-1); + } $prefix = implode(DIRECTORY_SEPARATOR, array_slice($parts, 0, $length)); $prefix = ltrim(str_replace($baseDirectory, '', $prefix), DIRECTORY_SEPARATOR); @@ -95,7 +101,7 @@ abstract class AbstractCommand extends ContainerAwareCommand protected function initialize(InputInterface $input, OutputInterface $output) { parent::initialize($input, $output); - + if ($input->getOption('verbose')) { $this->additionalPhingArgs[] = 'verbose'; }