* updated Twig to the latest version in 1.x series (v1.35.0)

This commit is contained in:
slawkens1
2017-12-25 13:02:46 +01:00
parent 6528a4a60c
commit 8b4eccc064
198 changed files with 4132 additions and 1977 deletions

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -12,6 +12,8 @@
/**
* Twig_NodeVisitor_Escaper implements output escaping.
*
* @final
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
@@ -28,16 +30,14 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
$this->safeAnalysis = new Twig_NodeVisitor_SafeAnalysis();
}
/**
* {@inheritdoc}
*/
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
{
if ($node instanceof Twig_Node_Module) {
if ($env->hasExtension('escaper') && $defaultStrategy = $env->getExtension('escaper')->getDefaultStrategy($node->getAttribute('filename'))) {
if ($env->hasExtension('Twig_Extension_Escaper') && $defaultStrategy = $env->getExtension('Twig_Extension_Escaper')->getDefaultStrategy($node->getTemplateName())) {
$this->defaultStrategy = $defaultStrategy;
}
$this->safeVars = array();
$this->blocks = array();
} elseif ($node instanceof Twig_Node_AutoEscape) {
$this->statusStack[] = $node->getAttribute('value');
} elseif ($node instanceof Twig_Node_Block) {
@@ -49,14 +49,12 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
return $node;
}
/**
* {@inheritdoc}
*/
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
{
if ($node instanceof Twig_Node_Module) {
$this->defaultStrategy = false;
$this->safeVars = array();
$this->blocks = array();
} elseif ($node instanceof Twig_Node_Expression_Filter) {
return $this->preEscapeFilterNode($node, $env);
} elseif ($node instanceof Twig_Node_Print) {
@@ -88,7 +86,7 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
return new $class(
$this->getEscaperFilter($type, $expression),
$node->getLine()
$node->getTemplateLine()
);
}
@@ -140,18 +138,17 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
protected function getEscaperFilter($type, Twig_NodeInterface $node)
{
$line = $node->getLine();
$line = $node->getTemplateLine();
$name = new Twig_Node_Expression_Constant('escape', $line);
$args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line)));
return new Twig_Node_Expression_Filter($node, $name, $args, $line);
}
/**
* {@inheritdoc}
*/
public function getPriority()
{
return 0;
}
}
class_alias('Twig_NodeVisitor_Escaper', 'Twig\NodeVisitor\EscaperNodeVisitor', false);