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

Represents a block call node. More...

+ Inheritance diagram for Twig_Node_Expression_BlockReference:
+ Collaboration diagram for Twig_Node_Expression_BlockReference:

Public Member Functions

 __construct (Twig_NodeInterface $name, $template=null, $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 ()
 

Private Member Functions

 compileTemplateCall (Twig_Compiler $compiler, $method)
 
 compileBlockArguments (Twig_Compiler $compiler)
 

Additional Inherited Members

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

Detailed Description

Represents a block call node.

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

Definition at line 18 of file BlockReference.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Node_Expression_BlockReference::__construct ( Twig_NodeInterface  $name,
  $template = null,
  $lineno,
  $tag = null 
)
Parameters
Twig_Node | null$template

Definition at line 23 of file BlockReference.php.

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

24  {
25  if (is_bool($template)) {
26  @trigger_error(sprintf('The %s method "$asString" argument is deprecated since version 1.28 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
27 
28  $template = null;
29  }
30 
31  $nodes = array('name' => $name);
32  if (null !== $template) {
33  $nodes['template'] = $template;
34  }
35 
36  parent::__construct($nodes, array('is_defined_test' => false, 'output' => false), $lineno, $tag);
37  }
$lineno
Definition: Node.php:22
$template
$nodes
Definition: Node.php:20
Create styles array
The data for the language used.

Member Function Documentation

◆ compile()

Twig_Node_Expression_BlockReference::compile ( Twig_Compiler  $compiler)

Compiles the node to PHP.

Implements Twig_NodeInterface.

Definition at line 39 of file BlockReference.php.

References Twig_Compiler\addDebugInfo(), compileTemplateCall(), and Twig_Node\getAttribute().

40  {
41  if ($this->getAttribute('is_defined_test')) {
42  $this->compileTemplateCall($compiler, 'hasBlock');
43  } else {
44  if ($this->getAttribute('output')) {
45  $compiler->addDebugInfo($this);
46 
47  $this
48  ->compileTemplateCall($compiler, 'displayBlock')
49  ->raw(";\n");
50  } else {
51  $this->compileTemplateCall($compiler, 'renderBlock');
52  }
53  }
54  }
getAttribute($name)
Definition: Node.php:152
compileTemplateCall(Twig_Compiler $compiler, $method)
addDebugInfo(Twig_NodeInterface $node)
Adds debugging information.
Definition: Compiler.php:212
+ Here is the call graph for this function:

◆ compileBlockArguments()

Twig_Node_Expression_BlockReference::compileBlockArguments ( Twig_Compiler  $compiler)
private

Definition at line 78 of file BlockReference.php.

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

Referenced by compileTemplateCall().

79  {
80  $compiler
81  ->raw('(')
82  ->subcompile($this->getNode('name'))
83  ->raw(', $context');
84 
85  if (!$this->hasNode('template')) {
86  $compiler->raw(', $blocks');
87  }
88 
89  return $compiler->raw(')');
90  }
raw($string)
Adds a raw string to the compiled code.
Definition: Compiler.php:112
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:

◆ compileTemplateCall()

Twig_Node_Expression_BlockReference::compileTemplateCall ( Twig_Compiler  $compiler,
  $method 
)
private

Definition at line 56 of file BlockReference.php.

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

Referenced by compile().

57  {
58  if (!$this->hasNode('template')) {
59  $compiler->write('$this');
60  } else {
61  $compiler
62  ->write('$this->loadTemplate(')
63  ->subcompile($this->getNode('template'))
64  ->raw(', ')
65  ->repr($this->getTemplateName())
66  ->raw(', ')
67  ->repr($this->getTemplateLine())
68  ->raw(')')
69  ;
70  }
71 
72  $compiler->raw(sprintf('->%s', $method));
73  $this->compileBlockArguments($compiler);
74 
75  return $compiler;
76  }
compileBlockArguments(Twig_Compiler $compiler)
raw($string)
Adds a raw string to the compiled code.
Definition: Compiler.php:112
getTemplateName()
Definition: Node.php:229
getTemplateLine()
Definition: Node.php:121
hasNode($name)
Definition: Node.php:178
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:

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