ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Node_ForLoop Class Reference

Internal node used by the for node. More...

+ Inheritance diagram for Twig_Node_ForLoop:
+ Collaboration diagram for Twig_Node_ForLoop:

Public Member Functions

 __construct ($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 ()
 
 compile (Twig_Compiler $compiler)
 Compiles the node to PHP. More...
 
 getLine ()
 
 getNodeTag ()
 

Additional Inherited Members

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

Detailed Description

Internal node used by the for node.

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

Definition at line 17 of file ForLoop.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Node_ForLoop::__construct (   $lineno,
  $tag = null 
)

Definition at line 19 of file ForLoop.php.

20 {
21 parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
22 }
$lineno
Definition: Node.php:22

References Twig_Node\$lineno, and Twig_Node\$tag.

Member Function Documentation

◆ compile()

Twig_Node_ForLoop::compile ( Twig_Compiler  $compiler)

Compiles the node to PHP.

Reimplemented from Twig_Node.

Definition at line 24 of file ForLoop.php.

25 {
26 if ($this->getAttribute('else')) {
27 $compiler->write("\$context['_iterated'] = true;\n");
28 }
29
30 if ($this->getAttribute('with_loop')) {
31 $compiler
32 ->write("++\$context['loop']['index0'];\n")
33 ->write("++\$context['loop']['index'];\n")
34 ->write("\$context['loop']['first'] = false;\n")
35 ;
36
37 if (!$this->getAttribute('ifexpr')) {
38 $compiler
39 ->write("if (isset(\$context['loop']['length'])) {\n")
40 ->indent()
41 ->write("--\$context['loop']['revindex0'];\n")
42 ->write("--\$context['loop']['revindex'];\n")
43 ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n")
44 ->outdent()
45 ->write("}\n")
46 ;
47 }
48 }
49 }
write()
Writes a string to the compiled code by adding indentation.
Definition: Compiler.php:124
getAttribute($name)
Definition: Node.php:152

References Twig_Node\getAttribute(), and Twig_Compiler\write().

+ Here is the call graph for this function:

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