diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 733d016d66..46d908c551 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -305,11 +305,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - $this->compiler->addPass($pass, $type); + $this->getCompiler()->addPass($pass, $type); $this->addObjectResource($pass); @@ -325,11 +321,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function getCompilerPassConfig() { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } - - return $this->compiler->getPassConfig(); + return $this->getCompiler()->getPassConfig(); } /** @@ -610,12 +602,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function compile() { - if (null === $this->compiler) { - $this->compiler = new Compiler(); - } + $compiler = $this->getCompiler(); if ($this->trackResources) { - foreach ($this->compiler->getPassConfig()->getPasses() as $pass) { + foreach ($compiler->getPassConfig()->getPasses() as $pass) { $this->addObjectResource($pass); } @@ -626,7 +616,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface } } - $this->compiler->compile($this); + $compiler->compile($this); $this->extensionConfigs = array();