ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Node_Expression_GetAttr Class Reference
+ Inheritance diagram for Twig_Node_Expression_GetAttr:
+ Collaboration diagram for Twig_Node_Expression_GetAttr:

Public Member Functions

 __construct (Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments=null, $type, $lineno)
 
 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 ()
 

Additional Inherited Members

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

Detailed Description

Definition at line 12 of file GetAttr.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Node_Expression_GetAttr::__construct ( Twig_Node_Expression  $node,
Twig_Node_Expression  $attribute,
Twig_Node_Expression  $arguments = null,
  $type,
  $lineno 
)

Definition at line 14 of file GetAttr.php.

References Twig_Node\$lineno, Twig_Node\$nodes, and $type.

15  {
16  $nodes = array('node' => $node, 'attribute' => $attribute);
17  if (null !== $arguments) {
18  $nodes['arguments'] = $arguments;
19  }
20 
21  parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
22  }
$lineno
Definition: Node.php:22
$type
$nodes
Definition: Node.php:20

Member Function Documentation

◆ compile()

Twig_Node_Expression_GetAttr::compile ( Twig_Compiler  $compiler)

Compiles the node to PHP.

Implements Twig_NodeInterface.

Definition at line 24 of file GetAttr.php.

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

25  {
26  if ($this->getAttribute('disable_c_ext')) {
27  @trigger_error(sprintf('Using the "disable_c_ext" attribute on %s is deprecated since version 1.30 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
28  }
29 
30  if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
31  $compiler->raw('twig_template_get_attributes($this, ');
32  } else {
33  $compiler->raw('$this->getAttribute(');
34  }
35 
36  if ($this->getAttribute('ignore_strict_check')) {
37  $this->getNode('node')->setAttribute('ignore_strict_check', true);
38  }
39 
40  $compiler->subcompile($this->getNode('node'));
41 
42  $compiler->raw(', ')->subcompile($this->getNode('attribute'));
43 
44  // only generate optional arguments when needed (to make generated code more readable)
45  $needFourth = $this->getAttribute('ignore_strict_check');
46  $needThird = $needFourth || $this->getAttribute('is_defined_test');
47  $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type');
48  $needFirst = $needSecond || $this->hasNode('arguments');
49 
50  if ($needFirst) {
51  if ($this->hasNode('arguments')) {
52  $compiler->raw(', ')->subcompile($this->getNode('arguments'));
53  } else {
54  $compiler->raw(', array()');
55  }
56  }
57 
58  if ($needSecond) {
59  $compiler->raw(', ')->repr($this->getAttribute('type'));
60  }
61 
62  if ($needThird) {
63  $compiler->raw(', ')->repr($this->getAttribute('is_defined_test'));
64  }
65 
66  if ($needFourth) {
67  $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check'));
68  }
69 
70  $compiler->raw(')');
71  }
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:

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