diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index b89b7344ba2ec..6ce1542aa60b3 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -38,18 +38,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface protected $injectors = array(); protected $compiler; - /** - * Constructor. - * - * @param ParameterBagInterface $parameterBag - */ - public function __construct(ParameterBagInterface $parameterBag = null) - { - parent::__construct($parameterBag); - - $this->compiler = new Compiler(); - } - /** * Registers an extension. * @@ -175,6 +163,10 @@ public function loadFromExtension($extension, array $values = array()) */ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) { + if (null === $this->compiler) { + $this->compiler = new Compiler(); + } + $this->compiler->addPass($pass, $type); $this->addObjectResource($pass); @@ -187,6 +179,10 @@ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig: */ public function getCompilerPassConfig() { + if (null === $this->compiler) { + $this->compiler = new Compiler(); + } + return $this->compiler->getPassConfig(); } @@ -197,6 +193,10 @@ public function getCompilerPassConfig() */ public function getCompiler() { + if (null === $this->compiler) { + $this->compiler = new Compiler(); + } + return $this->compiler; } @@ -391,6 +391,10 @@ public function getExtensionConfig($name) */ public function compile() { + if (null === $this->compiler) { + $this->compiler = new Compiler(); + } + foreach ($this->compiler->getPassConfig()->getPasses() as $pass) { $this->addObjectResource($pass); }