From 485fb15c912ef08b2c35ac7037ed82816acca3df Mon Sep 17 00:00:00 2001 From: tgabi333 Date: Fri, 6 Sep 2013 17:04:46 +0200 Subject: [PATCH] [DependencyInjection] remove code duplication from ContainerBuilder --- .../DependencyInjection/ContainerBuilder.php | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) 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();