[Foundation] moved some Kernel initializations in the boot() method to speed up creation of Kernel instances

This commit is contained in:
Fabien Potencier 2010-05-03 09:54:17 +02:00
parent 0858289397
commit a9d8f39382
2 changed files with 20 additions and 24 deletions

View File

@ -50,28 +50,23 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
*/
public function __construct($environment, $debug)
{
$this->environment = $environment;
$this->debug = (Boolean) $debug;
$this->booted = false;
$this->rootDir = realpath($this->registerRootDir());
$this->name = basename($this->rootDir);
if ($this->debug)
{
ini_set('display_errors', 1);
error_reporting(-1);
$this->startTime = microtime(true);
}
else
{
ini_set('display_errors', 0);
}
if ($this->debug)
{
$this->startTime = microtime(true);
}
$this->booted = false;
$this->environment = $environment;
$this->bundles = $this->registerBundles();
$this->bundleDirs = $this->registerBundleDirs();
$this->rootDir = realpath($this->registerRootDir());
$this->name = basename($this->rootDir);
}
abstract public function registerRootDir();
@ -111,6 +106,9 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
throw new \LogicException('The kernel is already booted.');
}
$this->bundles = $this->registerBundles();
$this->bundleDirs = $this->registerBundleDirs();
// initialize the container
$this->container = $this->initializeContainer();
$this->container->setService('kernel', $this);

View File

@ -390,28 +390,23 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
public function __construct($environment, $debug)
{
$this->environment = $environment;
$this->debug = (Boolean) $debug;
$this->booted = false;
$this->rootDir = realpath($this->registerRootDir());
$this->name = basename($this->rootDir);
if ($this->debug)
{
ini_set('display_errors', 1);
error_reporting(-1);
$this->startTime = microtime(true);
}
else
{
ini_set('display_errors', 0);
}
if ($this->debug)
{
$this->startTime = microtime(true);
}
$this->booted = false;
$this->environment = $environment;
$this->bundles = $this->registerBundles();
$this->bundleDirs = $this->registerBundleDirs();
$this->rootDir = realpath($this->registerRootDir());
$this->name = basename($this->rootDir);
}
abstract public function registerRootDir();
@ -438,6 +433,9 @@ abstract class Kernel implements RequestHandlerInterface, \Serializable
throw new \LogicException('The kernel is already booted.');
}
$this->bundles = $this->registerBundles();
$this->bundleDirs = $this->registerBundleDirs();
$this->container = $this->initializeContainer();
$this->container->setService('kernel', $this);