Fixed init:bundle

This commit is contained in:
Christophe Coevoet 2011-01-21 14:04:29 +01:00 committed by Fabien Potencier
parent 4e0ecfdf81
commit 1e793a2500
3 changed files with 20 additions and 7 deletions

View File

@ -51,13 +51,13 @@ class InitBundleCommand extends Command
throw new \InvalidArgumentException('The namespace must end with Bundle.');
}
$pos = strrpos($namespace, '\\');
$bundle = substr($namespace, $pos ? $pos + 1 : 0);
$bundle = strtr($namespace, array('\\' => ''));
$dir = $input->getArgument('dir');
$targetDir = $dir . strtr($namespace, '\\', '/');
$output->writeln(sprintf('Initializing bundle "<info>%s</info>" in "<info>%s</info>"', $bundle, $dir));
if (file_exists($targetDir = $dir.'/'.$bundle)) {
if (file_exists($targetDir)) {
throw new \RuntimeException(sprintf('Bundle "%s" already exists.', $bundle));
}

View File

@ -1,11 +1,24 @@
<?php
namespace {{ namespace }}\{{ bundle }};
namespace {{ namespace }};
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class {{ bundle }} extends Bundle
{
/**
* {@inheritdoc}
*/
public function getNamespace()
{
return __NAMESPACE__;
}
/**
* {@inheritdoc}
*/
public function getPath()
{
return strtr(__DIR__, '\\', '/');
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace {{ namespace }}\{{ bundle }}\Controller;
namespace {{ namespace }}\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;