Ver Fonte

[FrameworkBundle] added --format=xml,php,yml optional parameter to the init:bundle command

* Added the --format parameter to the InitBundleCommand.php file
* Moved all the non-format-dependent files from Resources/skeleton/bundle to Resources/skeleton/bundle/generic
* Created Resources/skeleton/bundle/[php,yml,xml] subfolders containing the files config/routing.[xml,yml,php]
Fabrice Bernhard há 14 anos atrás
pai
commit
13469a2d82

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

@@ -35,6 +35,7 @@ class InitBundleCommand extends Command
                 new InputArgument('namespace', InputArgument::REQUIRED, 'The namespace of the bundle to create'),
                 new InputArgument('dir', InputArgument::REQUIRED, 'The directory where to create the bundle'),
                 new InputArgument('bundleName', InputArgument::OPTIONAL, 'The optional bundle name'),
+                new InputOption('format', '', InputOption::VALUE_REQUIRED, 'Use the format for configuration files (php, xml, or yml)', 'xml')
             ))
             ->setHelp(<<<EOT
 The <info>init:bundle</info> command generates a new bundle with a basic skeleton.
@@ -93,7 +94,8 @@ EOT
         }
 
         $filesystem = $this->container->get('filesystem');
-        $filesystem->mirror(__DIR__.'/../Resources/skeleton/bundle', $targetDir);
+        $filesystem->mirror(__DIR__.'/../Resources/skeleton/bundle/generic', $targetDir);
+        $filesystem->mirror(__DIR__.'/../Resources/skeleton/bundle/'.$input->getOption('format'), $targetDir);
 
         Mustache::renderDir($targetDir, array(
             'namespace' => $namespace,

src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Bundle.php → src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/generic/Bundle.php


src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Controller/.symfony → src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/generic/Controller/.symfony


src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Controller/DefaultController.php → src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/generic/Controller/DefaultController.php


src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Resources/views/.symfony → src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/generic/Resources/views/.symfony


src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Resources/views/Default/index.html.twig → src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/generic/Resources/views/Default/index.html.twig


+ 12 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/php/Resources/config/routing.php

@@ -0,0 +1,12 @@
+<?php
+
+use Symfony\Component\Routing\RouteCollection;
+use Symfony\Component\Routing\Route;
+
+$collection = new RouteCollection();
+/*
+$collection->add('homepage', new Route('/', array(
+    '_controller' => 'NewBundle:Default:index',
+)));
+*/
+return $collection;

src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/Resources/config/routing.xml → src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/xml/Resources/config/routing.xml


+ 3 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/skeleton/bundle/yml/Resources/config/routing.yml

@@ -0,0 +1,3 @@
+#homepage:
+#    pattern:  /
+#    defaults: { _controller: NewBundle:Default:index }