Skip to content

Commit 8432950

Browse files
committed
merged branch tgabi333/di_minor_code_duplication (PR #8949)
This PR was merged into the master branch. Discussion ---------- [DependencyInjection] remove code duplication from ContainerBuilder | Q | A | ------------- | --- | Bug fix? | no | New feature? |no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 485fb15 [DependencyInjection] remove code duplication from ContainerBuilder
2 parents d1ef0f3 + 485fb15 commit 8432950

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,7 @@ public function loadFromExtension($extension, array $values = array())
305305
*/
306306
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION)
307307
{
308-
if (null === $this->compiler) {
309-
$this->compiler = new Compiler();
310-
}
311-
312-
$this->compiler->addPass($pass, $type);
308+
$this->getCompiler()->addPass($pass, $type);
313309

314310
$this->addObjectResource($pass);
315311

@@ -325,11 +321,7 @@ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig:
325321
*/
326322
public function getCompilerPassConfig()
327323
{
328-
if (null === $this->compiler) {
329-
$this->compiler = new Compiler();
330-
}
331-
332-
return $this->compiler->getPassConfig();
324+
return $this->getCompiler()->getPassConfig();
333325
}
334326

335327
/**
@@ -610,12 +602,10 @@ public function prependExtensionConfig($name, array $config)
610602
*/
611603
public function compile()
612604
{
613-
if (null === $this->compiler) {
614-
$this->compiler = new Compiler();
615-
}
605+
$compiler = $this->getCompiler();
616606

617607
if ($this->trackResources) {
618-
foreach ($this->compiler->getPassConfig()->getPasses() as $pass) {
608+
foreach ($compiler->getPassConfig()->getPasses() as $pass) {
619609
$this->addObjectResource($pass);
620610
}
621611

@@ -626,7 +616,7 @@ public function compile()
626616
}
627617
}
628618

629-
$this->compiler->compile($this);
619+
$compiler->compile($this);
630620

631621
$this->extensionConfigs = array();
632622

0 commit comments

Comments
 (0)