ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Profiler_NodeVisitor_Profiler Class Reference
+ Inheritance diagram for Twig_Profiler_NodeVisitor_Profiler:
+ Collaboration diagram for Twig_Profiler_NodeVisitor_Profiler:

Public Member Functions

 __construct ($extensionName)
 
 getPriority ()
 Returns the priority for this visitor. More...
 
- Public Member Functions inherited from Twig_BaseNodeVisitor
 enterNode (Twig_NodeInterface $node, Twig_Environment $env)
 Called before child nodes are visited. More...
 
 leaveNode (Twig_NodeInterface $node, Twig_Environment $env)
 Called after child nodes are visited. More...
 

Protected Member Functions

 doEnterNode (Twig_Node $node, Twig_Environment $env)
 
 doLeaveNode (Twig_Node $node, Twig_Environment $env)
 
- Protected Member Functions inherited from Twig_BaseNodeVisitor
 doEnterNode (Twig_Node $node, Twig_Environment $env)
 Called before child nodes are visited. More...
 
 doLeaveNode (Twig_Node $node, Twig_Environment $env)
 Called after child nodes are visited. More...
 

Private Member Functions

 getVarName ()
 

Private Attributes

 $extensionName
 

Detailed Description

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

Definition at line 17 of file Profiler.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Profiler_NodeVisitor_Profiler::__construct (   $extensionName)

Definition at line 21 of file Profiler.php.

References $extensionName.

22  {
23  $this->extensionName = $extensionName;
24  }

Member Function Documentation

◆ doEnterNode()

Twig_Profiler_NodeVisitor_Profiler::doEnterNode ( Twig_Node  $node,
Twig_Environment  $env 
)
protected

Definition at line 26 of file Profiler.php.

27  {
28  return $node;
29  }

◆ doLeaveNode()

Twig_Profiler_NodeVisitor_Profiler::doLeaveNode ( Twig_Node  $node,
Twig_Environment  $env 
)
protected

Definition at line 31 of file Profiler.php.

References array, Twig_Profiler_Profile\BLOCK, Twig_Node\getAttribute(), Twig_Node\getNode(), Twig_Node\getTemplateName(), getVarName(), Twig_Profiler_Profile\MACRO, Twig_Node\setNode(), and Twig_Profiler_Profile\TEMPLATE.

32  {
33  if ($node instanceof Twig_Node_Module) {
34  $varName = $this->getVarName();
35  $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start'))));
36  $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
37  } elseif ($node instanceof Twig_Node_Block) {
38  $varName = $this->getVarName();
39  $node->setNode('body', new Twig_Node_Body(array(
40  new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
41  $node->getNode('body'),
42  new Twig_Profiler_Node_LeaveProfile($varName),
43  )));
44  } elseif ($node instanceof Twig_Node_Macro) {
45  $varName = $this->getVarName();
46  $node->setNode('body', new Twig_Node_Body(array(
47  new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
48  $node->getNode('body'),
49  new Twig_Profiler_Node_LeaveProfile($varName),
50  )));
51  }
52 
53  return $node;
54  }
getTemplateName()
Definition: Node.php:229
Represents a node in the AST.
Definition: Node.php:18
Represents a macro node.
Definition: Macro.php:17
Represents a block node.
Definition: Block.php:18
setNode($name, $node=null)
Definition: Node.php:195
Represents a profile leave node.
Represents a body node.
Definition: Body.php:17
getAttribute($name)
Definition: Node.php:152
Represents a module node.
Definition: Module.php:22
Create styles array
The data for the language used.
Represents a profile enter node.
getNode($name)
Definition: Node.php:186
+ Here is the call graph for this function:

◆ getPriority()

Twig_Profiler_NodeVisitor_Profiler::getPriority ( )

Returns the priority for this visitor.

Priority should be between -10 and 10 (0 is the default).

Returns
int The priority level

Implements Twig_NodeVisitorInterface.

Definition at line 61 of file Profiler.php.

62  {
63  return 0;
64  }

◆ getVarName()

Twig_Profiler_NodeVisitor_Profiler::getVarName ( )
private

Definition at line 56 of file Profiler.php.

References GuzzleHttp\Psr7\hash().

Referenced by doLeaveNode().

57  {
58  return sprintf('__internal_%s', hash('sha256', $this->extensionName));
59  }
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
Definition: functions.php:406
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $extensionName

Twig_Profiler_NodeVisitor_Profiler::$extensionName
private

Definition at line 19 of file Profiler.php.

Referenced by __construct().


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