Skip to content

Commit 2fb303b

Browse files
Merge branch '3.4'
* 3.4: [Bridge\Twig] Lazy-load deps
2 parents 9f1c017 + 850bb2d commit 2fb303b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/Symfony/Bridge/Twig/Extension/DumpExtension.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DumpExtension extends AbstractExtension
3232
public function __construct(ClonerInterface $cloner, HtmlDumper $dumper = null)
3333
{
3434
$this->cloner = $cloner;
35-
$this->dumper = $dumper ?: new HtmlDumper();
35+
$this->dumper = $dumper;
3636
}
3737

3838
public function getFunctions()
@@ -73,6 +73,7 @@ public function dump(Environment $env, $context)
7373
}
7474

7575
$dump = fopen('php://memory', 'r+b');
76+
$this->dumper = $this->dumper ?: new HtmlDumper();
7677
$this->dumper->setCharset($env->getCharset());
7778

7879
foreach ($vars as $value) {

src/Symfony/Bridge/Twig/Extension/TranslationExtension.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ class TranslationExtension extends AbstractExtension
3434

3535
public function __construct(TranslatorInterface $translator = null, NodeVisitorInterface $translationNodeVisitor = null)
3636
{
37-
if (!$translationNodeVisitor) {
38-
$translationNodeVisitor = new TranslationNodeVisitor();
39-
}
40-
4137
$this->translator = $translator;
4238
$this->translationNodeVisitor = $translationNodeVisitor;
4339
}
@@ -84,12 +80,12 @@ public function getTokenParsers()
8480
*/
8581
public function getNodeVisitors()
8682
{
87-
return array($this->translationNodeVisitor, new TranslationDefaultDomainNodeVisitor());
83+
return array($this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor());
8884
}
8985

9086
public function getTranslationNodeVisitor()
9187
{
92-
return $this->translationNodeVisitor;
88+
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor();
9389
}
9490

9591
public function trans($message, array $arguments = array(), $domain = null, $locale = null)

0 commit comments

Comments
 (0)