ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Node_SandboxedPrint Class Reference

Twig_Node_SandboxedPrint adds a check for the __toString() method when the variable is an object and the sandbox is activated. More...

+ Inheritance diagram for Twig_Node_SandboxedPrint:
+ Collaboration diagram for Twig_Node_SandboxedPrint:

Public Member Functions

 compile (Twig_Compiler $compiler)
 Compiles the node to PHP. More...
 
- Public Member Functions inherited from Twig_Node_Print
 __construct (Twig_Node_Expression $expr, $lineno, $tag=null)
 
 compile (Twig_Compiler $compiler)
 Compiles the node to PHP. More...
 
- Public Member Functions inherited from Twig_Node
 __construct (array $nodes=array(), array $attributes=array(), $lineno=0, $tag=null)
 Constructor. More...
 
 __toString ()
 
 toXml ($asDom=false)
 
 compile (Twig_Compiler $compiler)
 Compiles the node to PHP. More...
 
 getTemplateLine ()
 
 getLine ()
 
 getNodeTag ()
 
 hasAttribute ($name)
 
 getAttribute ($name)
 
 setAttribute ($name, $value)
 
 removeAttribute ($name)
 
 hasNode ($name)
 
 getNode ($name)
 
 setNode ($name, $node=null)
 
 removeNode ($name)
 
 count ()
 
 getIterator ()
 
 setTemplateName ($name)
 
 getTemplateName ()
 
 setFilename ($name)
 
 getFilename ()
 

Protected Member Functions

 removeNodeFilter (Twig_Node $node)
 Removes node filters. More...
 

Additional Inherited Members

- Protected Attributes inherited from Twig_Node
 $nodes
 
 $attributes
 
 $lineno
 
 $tag
 

Detailed Description

Twig_Node_SandboxedPrint adds a check for the __toString() method when the variable is an object and the sandbox is activated.

When there is a simple Print statement, like {{ article }}, and if the sandbox is enabled, we need to check that the __toString() method is allowed if 'article' is an object.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 22 of file SandboxedPrint.php.

Member Function Documentation

◆ compile()

Twig_Node_SandboxedPrint::compile ( Twig_Compiler  $compiler)

Compiles the node to PHP.

Implements Twig_NodeInterface.

Definition at line 24 of file SandboxedPrint.php.

References Twig_Compiler\addDebugInfo(), and Twig_Node\getNode().

25  {
26  $compiler
27  ->addDebugInfo($this)
28  ->write('echo $this->env->getExtension(\'Twig_Extension_Sandbox\')->ensureToStringAllowed(')
29  ->subcompile($this->getNode('expr'))
30  ->raw(");\n")
31  ;
32  }
getNode($name)
Definition: Node.php:186
addDebugInfo(Twig_NodeInterface $node)
Adds debugging information.
Definition: Compiler.php:212
+ Here is the call graph for this function:

◆ removeNodeFilter()

Twig_Node_SandboxedPrint::removeNodeFilter ( Twig_Node  $node)
protected

Removes node filters.

This is mostly needed when another visitor adds filters (like the escaper one).

Returns
Twig_Node

Definition at line 41 of file SandboxedPrint.php.

References Twig_Node\getNode().

42  {
43  if ($node instanceof Twig_Node_Expression_Filter) {
44  return $this->removeNodeFilter($node->getNode('node'));
45  }
46 
47  return $node;
48  }
removeNodeFilter(Twig_Node $node)
Removes node filters.
getNode($name)
Definition: Node.php:186
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: