[DependencyInjection] remove code duplication from ContainerBuilder

This commit is contained in:
tgabi333 2013-09-06 17:04:46 +02:00
parent d1ef0f3fdd
commit 485fb15c91
1 changed files with 5 additions and 15 deletions

View File

@ -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();