8000 [Bridge\Twig] Lazy-load deps by nicolas-grekas · Pull Request #24863 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Bridge\Twig] Lazy-load deps #24863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Symfony/Bridge/Twig/Extension/DumpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DumpExtension extends AbstractExtension
public function __construct(ClonerInterface $cloner, HtmlDumper $dumper = null)
{
$this->cloner = $cloner;
$this->dumper = $dumper ?: new HtmlDumper();
$this->dumper = $dumper;
}

public function getFunctions()
Expand Down Expand Up @@ -73,6 +73,7 @@ public function dump(Environment $env, $context)
}

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

foreach ($vars as $value) {
Expand Down
8 changes: 2 additions & 6 deletions src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class TranslationExtension extends AbstractExtension

public function __construct(TranslatorInterface $translator = null, NodeVisitorInterface $translationNodeVisitor = null)
{
if (!$translationNodeVisitor) {
$translationNodeVisitor = new TranslationNodeVisitor();
}

$this->translator = $translator;
$this->translationNodeVisitor = $translationNodeVisitor;
}
Expand Down Expand Up @@ -84,12 +80,12 @@ public function getTokenParsers()
*/
public function getNodeVisitors()
{
return array($this->translationNodeVisitor, new TranslationDefaultDomainNodeVisitor());
return array($this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor());
}

public function getTranslationNodeVisitor()
{
return $this->translationNodeVisitor;
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor();
}

public function trans($message, array $arguments = array(), $domain = null, $locale = null)
Expand Down
0