Ver código fonte

Fixed init:bundle

Christophe Coevoet 14 anos atrás
pai
commit
1e793a2500

+ 3 - 3
src/Symfony/Bundle/FrameworkBundle/Command/InitBundleCommand.php

@@ -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));
         }
 

+ 16 - 3
src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Bundle.php

@@ -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__, '\\', '/');
+    }
 }

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Controller/DefaultController.php

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