Jelajahi Sumber

changed Application to have nice error messages when something bad happens early on the CLI

Fabien Potencier 14 tahun lalu
induk
melakukan
d0e31b8ca6

+ 0 - 3
src/Symfony/Bundle/DoctrineBundle/Tests/Command/InfoDoctrineCommandTest.php

@@ -24,9 +24,6 @@ class InfoDoctrineCommandTest extends TestCase
 
         $testContainer = $this->createYamlBundleTestContainer();
         $kernel = $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false);
-        $kernel->expects($this->once())
-               ->method('getBundles')
-               ->will($this->returnValue(array()));
         $kernel->expects($this->once())
                ->method('getContainer')
                ->will($this->returnValue($testContainer));

+ 4 - 5
src/Symfony/Bundle/FrameworkBundle/Console/Application.php

@@ -41,10 +41,6 @@ class Application extends BaseApplication
         $this->getDefinition()->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
         $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev'));
         $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
-
-        $this->kernel->boot();
-
-        $this->registerCommands();
     }
 
     /**
@@ -67,6 +63,8 @@ class Application extends BaseApplication
      */
     public function doRun(InputInterface $input, OutputInterface $output)
     {
+        $this->registerCommands();
+
         if (true === $input->hasParameterOption(array('--shell', '-s'))) {
             $shell = new Shell($this);
             $shell->run();
@@ -79,8 +77,9 @@ class Application extends BaseApplication
 
     protected function registerCommands()
     {
+        $this->kernel->boot();
         foreach ($this->kernel->getBundles() as $bundle) {
             $bundle->registerCommands($this);
         }
     }
-}
+}