From be4bd5b7f22e1f7a5956c6a9408fd01e94242ce6 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 13 May 2016 15:45:22 +0200 Subject: [PATCH] Revert "single filterinfo instance" This reverts commit b8af9febde1c1bd445cb446037fd04da0cc9ce59. --- src/Latte/Macros/BlockMacros.php | 6 +++--- src/Latte/Macros/CoreMacros.php | 4 ++-- src/Latte/PhpWriter.php | 4 ++-- src/Latte/Template.php | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Latte/Macros/BlockMacros.php b/src/Latte/Macros/BlockMacros.php index c5de548afd..ffd9c8fe67 100644 --- a/src/Latte/Macros/BlockMacros.php +++ b/src/Latte/Macros/BlockMacros.php @@ -125,7 +125,7 @@ public function macroInclude(MacroNode $node, PhpWriter $writer) } if ($node->modifiers) { - return $writer->write("ob_start(function () {}); $cmd; \$this->global->fi->contentType = %var; echo %modifyFI(ob_get_clean())", $node->context[0]); + return $writer->write("ob_start(function () {}); $cmd; \$_fi = new LR\\FilterInfo(%var); echo %modifyFI(ob_get_clean())", $node->context[0]); } else { return $writer->write($cmd); } @@ -250,7 +250,7 @@ public function macroBlock(MacroNode $node, PhpWriter $writer) $include = 'call_user_func(reset($this->blockQueue[%var]), ' . (($node->name === 'snippet' || $node->name === 'snippetArea') ? '$this->params' : 'get_defined_vars()') . ')'; if ($node->modifiers) { - $include = "ob_start(function () {}); $include; \$this->global->fi->contentType = 'html'; echo %modifyFI(ob_get_clean())"; + $include = "ob_start(function () {}); $include; \$_fi = new LR\\FilterInfo('html'); echo %modifyFI(ob_get_clean())"; } if ($node->name === 'snippet') { @@ -340,7 +340,7 @@ public function macroBlockEnd(MacroNode $node, PhpWriter $writer) return ' '; // consume next new line } elseif ($node->modifiers) { // anonymous block with modifier - return $writer->write('$this->global->fi->contentType = %var; echo %modifyFI(ob_get_clean())', $node->context[0]); + return $writer->write('$_fi = new LR\FilterInfo(%var); echo %modifyFI(ob_get_clean())', $node->context[0]); } } diff --git a/src/Latte/Macros/CoreMacros.php b/src/Latte/Macros/CoreMacros.php index cf28b1219d..0ba2c30fa1 100644 --- a/src/Latte/Macros/CoreMacros.php +++ b/src/Latte/Macros/CoreMacros.php @@ -212,7 +212,7 @@ public function macroInclude(MacroNode $node, PhpWriter $writer) $noCheck ? NULL : implode('', $node->context) ); if ($node->modifiers) { - return $writer->write('ob_start(function () {}); %raw; $this->global->fi->contentType = %var; echo %modifyFI(ob_get_clean())', $code, $node->context[0]); + return $writer->write('ob_start(function () {}); %raw; $_fi = new LR\FilterInfo(%var); echo %modifyFI(ob_get_clean())', $code, $node->context[0]); } else { return $code; } @@ -254,7 +254,7 @@ public function macroCaptureEnd(MacroNode $node, PhpWriter $writer) $body = $node->context[0] === Latte\Engine::CONTENT_HTML ? "ob_get_length() ? new LR\\Html(ob_get_clean()) : ob_get_clean()" : 'ob_get_clean()'; - return $writer->write("\$this->global->fi->contentType = %var; %raw = %modifyFI($body)", $node->context[0], $node->data->variable); + return $writer->write("\$_fi = new LR\\FilterInfo(%var); %raw = %modifyFI($body)", $node->context[0], $node->data->variable); } diff --git a/src/Latte/PhpWriter.php b/src/Latte/PhpWriter.php index f21777c076..480eb740d5 100644 --- a/src/Latte/PhpWriter.php +++ b/src/Latte/PhpWriter.php @@ -110,7 +110,7 @@ public function formatModifiers($var, $fi = FALSE) $tokens = $this->preprocess($tokens); $tokens = $this->modifierPass($tokens, $var, $fi); if ($fi) { - $tokens->prepend('LR\Filters::convertTo($this->global->fi, ' . var_export(implode('', $this->context), TRUE) . ', ') + $tokens->prepend('LR\Filters::convertTo($_fi, ' . var_export(implode('', $this->context), TRUE) . ', ') ->append(')'); } $tokens = $this->quotingPass($tokens); @@ -425,7 +425,7 @@ public function modifierPass(MacroTokens $tokens, $var, $fi = FALSE) } else { $name = strtolower($tokens->currentValue()); $res->prepend($fi - ? '$this->filters->contentFilter('. var_export($name, TRUE) . ', $this->global->fi, ' + ? '$this->filters->contentFilter('. var_export($name, TRUE) . ', $_fi, ' : 'call_user_func($this->filters->' . $name . ', ' ); $inside = TRUE; diff --git a/src/Latte/Template.php b/src/Latte/Template.php index 0abd75c945..9ddb33b62d 100644 --- a/src/Latte/Template.php +++ b/src/Latte/Template.php @@ -59,7 +59,6 @@ public function __construct(Engine $engine, array $params, Filters $filters, arr $this->filters = $filters; $this->name = $name; $this->global = (object) $providers; - $this->global->fi = new Runtime\FilterInfo; foreach ($this->blocks as $nm => $method) { $this->blockQueue[$nm][] = [$this, $method]; }