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

Represents an include node. More...

+ Inheritance diagram for Twig_Node_Include:
+ Collaboration diagram for Twig_Node_Include:

Public Member Functions

 __construct (Twig_Node_Expression $expr, Twig_Node_Expression $variables=null, $only=false, $ignoreMissing=false, $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

 addGetTemplate (Twig_Compiler $compiler)
 
 addTemplateArguments (Twig_Compiler $compiler)
 

Additional Inherited Members

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

Detailed Description

Represents an include node.

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

Definition at line 18 of file Include.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Node_Include::__construct ( Twig_Node_Expression  $expr,
Twig_Node_Expression  $variables = null,
  $only = false,
  $ignoreMissing = false,
  $lineno,
  $tag = null 
)

Definition at line 20 of file Include.php.

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

21  {
22  $nodes = array('expr' => $expr);
23  if (null !== $variables) {
24  $nodes['variables'] = $variables;
25  }
26 
27  parent::__construct($nodes, array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
28  }
$lineno
Definition: Node.php:22
$nodes
Definition: Node.php:20
Create styles array
The data for the language used.

Member Function Documentation

◆ addGetTemplate()

Twig_Node_Include::addGetTemplate ( Twig_Compiler  $compiler)
protected

Definition at line 61 of file Include.php.

References Twig_Node\getNode(), Twig_Node\getTemplateLine(), Twig_Node\getTemplateName(), and Twig_Compiler\write().

Referenced by compile().

62  {
63  $compiler
64  ->write('$this->loadTemplate(')
65  ->subcompile($this->getNode('expr'))
66  ->raw(', ')
67  ->repr($this->getTemplateName())
68  ->raw(', ')
69  ->repr($this->getTemplateLine())
70  ->raw(')')
71  ;
72  }
getTemplateName()
Definition: Node.php:229
getTemplateLine()
Definition: Node.php:121
getNode($name)
Definition: Node.php:186
write()
Writes a string to the compiled code by adding indentation.
Definition: Compiler.php:124
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTemplateArguments()

Twig_Node_Include::addTemplateArguments ( Twig_Compiler  $compiler)
protected

Definition at line 74 of file Include.php.

References Twig_Node\getAttribute(), Twig_Node\getNode(), Twig_Node\hasNode(), Twig_Compiler\raw(), and Twig_Compiler\subcompile().

Referenced by compile().

75  {
76  if (!$this->hasNode('variables')) {
77  $compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
78  } elseif (false === $this->getAttribute('only')) {
79  $compiler
80  ->raw('array_merge($context, ')
81  ->subcompile($this->getNode('variables'))
82  ->raw(')')
83  ;
84  } else {
85  $compiler->subcompile($this->getNode('variables'));
86  }
87  }
raw($string)
Adds a raw string to the compiled code.
Definition: Compiler.php:112
subcompile(Twig_NodeInterface $node, $raw=true)
Definition: Compiler.php:94
getAttribute($name)
Definition: Node.php:152
hasNode($name)
Definition: Node.php:178
getNode($name)
Definition: Node.php:186
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compile()

Twig_Node_Include::compile ( Twig_Compiler  $compiler)

Compiles the node to PHP.

Implements Twig_NodeInterface.

Definition at line 30 of file Include.php.

References Twig_Compiler\addDebugInfo(), addGetTemplate(), addTemplateArguments(), Twig_Node\getAttribute(), Twig_Compiler\outdent(), Twig_Compiler\raw(), and Twig_Compiler\write().

31  {
32  $compiler->addDebugInfo($this);
33 
34  if ($this->getAttribute('ignore_missing')) {
35  $compiler
36  ->write("try {\n")
37  ->indent()
38  ;
39  }
40 
41  $this->addGetTemplate($compiler);
42 
43  $compiler->raw('->display(');
44 
45  $this->addTemplateArguments($compiler);
46 
47  $compiler->raw(");\n");
48 
49  if ($this->getAttribute('ignore_missing')) {
50  $compiler
51  ->outdent()
52  ->write("} catch (Twig_Error_Loader \$e) {\n")
53  ->indent()
54  ->write("// ignore missing template\n")
55  ->outdent()
56  ->write("}\n\n")
57  ;
58  }
59  }
raw($string)
Adds a raw string to the compiled code.
Definition: Compiler.php:112
outdent($step=1)
Outdents the generated code.
Definition: Compiler.php:267
addTemplateArguments(Twig_Compiler $compiler)
Definition: Include.php:74
getAttribute($name)
Definition: Node.php:152
addGetTemplate(Twig_Compiler $compiler)
Definition: Include.php:61
addDebugInfo(Twig_NodeInterface $node)
Adds debugging information.
Definition: Compiler.php:212
write()
Writes a string to the compiled code by adding indentation.
Definition: Compiler.php:124
+ Here is the call graph for this function:

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