diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/InitBundleCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/InitBundleCommand.php index c3c2b5ef5e..deb6a1639b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/InitBundleCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/InitBundleCommand.php @@ -39,12 +39,13 @@ class InitBundleCommand extends Command ->setHelp(<<init:bundle command generates a new bundle with a basic skeleton. -./app/console init:bundle "Application\HelloBundle" src [bundleName] +./app/console init:bundle "Vendor\HelloBundle" src [bundleName] -The bundle namespace must end with "Bundle" (e.g. Application\HelloBundle) +The bundle namespace must end with "Bundle" (e.g. Vendor\HelloBundle) and can be placed in any directory (e.g. src). -If you don't specify a bundle name (e.g. HelloBundle the bundle name will -be a concatenation of namespace (e.g. ApplicationHelloBundle). + +If you don't specify a bundle name (e.g. HelloBundle), the bundle name will +be the concatenation of the namespace segments (e.g. VendorHelloBundle). EOT ) ->setName('init:bundle') @@ -62,28 +63,27 @@ EOT if (!preg_match('/Bundle$/', $namespace = $input->getArgument('namespace'))) { throw new \InvalidArgumentException('The namespace must end with Bundle.'); } - - //validate namespace - if (preg_match('/[^A-Za-z0-9_\-\\\]/', $namespace)) { + + // validate namespace + if (preg_match('/[^A-Za-z0-9_\\\-]/', $namespace)) { throw new \InvalidArgumentException('The namespace contains invalid characters.'); } - - //user specified bundle name? - if ('' == ($bundle = $input->getArgument('bundleName'))) { + + // user specified bundle name? + $bundle = $input->getArgument('bundleName'); + if ('' === $bundle) { $bundle = strtr($namespace, array('\\' => '')); - } else { - if (!preg_match('/Bundle$/', $bundle)) { - throw new \InvalidArgumentException('The bundleName must end with Bundle.'); - } + } elseif (!preg_match('/Bundle$/', $bundle)) { + throw new \InvalidArgumentException('The bundle name must end with Bundle.'); } $dir = $input->getArgument('dir'); - //add trailing / if necessary - $dir = ('/' == substr($dir, -1, 1)) ? $dir : $dir . '/'; - - $targetDir = $dir . strtr($namespace, '\\', '/'); - + // add trailing / if necessary + $dir = '/' === substr($dir, -1, 1) ? $dir : $dir . '/'; + + $targetDir = $dir.strtr($namespace, '\\', '/'); + $output->writeln(sprintf('Initializing bundle "%s" in "%s"', $bundle, $dir)); if (file_exists($targetDir)) {