소스 검색

[Symfony] Adding isBooted() method so that I can pass an existing kernel to a Console application. Right now it throws an exception otherwise about it already being booted.

Jonathan H. Wage 15 년 전
부모
커밋
b3d8aa414e
3개의 변경된 파일20개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 0
      src/Symfony/Foundation/Kernel.php
  2. 6 0
      src/Symfony/Foundation/bootstrap.php
  3. 4 1
      src/Symfony/Framework/WebBundle/Console/Application.php

+ 10 - 0
src/Symfony/Foundation/Kernel.php

@@ -83,6 +83,16 @@ abstract class Kernel
 
   abstract public function registerRoutes();
 
+  /**
+   * Checks whether the current kernel has been booted or not.
+   *
+   * @return boolean $booted
+   */
+  public function isBooted()
+  {
+    return $this->booted;
+  }
+
   /**
    * Boots the current kernel.
    *

+ 6 - 0
src/Symfony/Foundation/bootstrap.php

@@ -373,6 +373,12 @@ abstract class Kernel
   abstract public function registerRoutes();
 
   
+  public function isBooted()
+  {
+    return $this->booted;
+  }
+
+  
   public function boot()
   {
     if (true === $this->booted)

+ 4 - 1
src/Symfony/Framework/WebBundle/Console/Application.php

@@ -38,7 +38,10 @@ class Application extends BaseApplication
 
     $this->definition->addOption(new InputOption('--shell', '-s', InputOption::PARAMETER_NONE, 'Launch the shell.'));
 
-    $this->kernel->boot();
+    if (!$this->kernel->isBooted())
+    {
+      $this->kernel->boot();
+    }
 
     $this->registerCommands();
   }