class Twig_Profiler_NodeVisitor_Profiler in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php \Twig_Profiler_NodeVisitor_Profiler
@author Fabien Potencier <fabien@symfony.com>
Hierarchy
- class \Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
Expanded class hierarchy of Twig_Profiler_NodeVisitor_Profiler
File
- vendor/
twig/ twig/ lib/ Twig/ Profiler/ NodeVisitor/ Profiler.php, line 15
View source
class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor {
private $extensionName;
public function __construct($extensionName) {
$this->extensionName = $extensionName;
}
/**
* {@inheritdoc}
*/
protected function doEnterNode(Twig_Node $node, Twig_Environment $env) {
return $node;
}
/**
* {@inheritdoc}
*/
protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) {
if ($node instanceof Twig_Node_Module) {
$varName = $this
->getVarName();
$node
->setNode('display_start', new Twig_Node(array(
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node
->getAttribute('filename'), $varName),
$node
->getNode('display_start'),
)));
$node
->setNode('display_end', new Twig_Node(array(
new Twig_Profiler_Node_LeaveProfile($varName),
$node
->getNode('display_end'),
)));
}
elseif ($node instanceof Twig_Node_Block) {
$varName = $this
->getVarName();
$node
->setNode('body', new Twig_Node_Body(array(
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node
->getAttribute('name'), $varName),
$node
->getNode('body'),
new Twig_Profiler_Node_LeaveProfile($varName),
)));
}
elseif ($node instanceof Twig_Node_Macro) {
$varName = $this
->getVarName();
$node
->setNode('body', new Twig_Node_Body(array(
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node
->getAttribute('name'), $varName),
$node
->getNode('body'),
new Twig_Profiler_Node_LeaveProfile($varName),
)));
}
return $node;
}
private function getVarName() {
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
}
/**
* {@inheritdoc}
*/
public function getPriority() {
return 0;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Twig_BaseNodeVisitor:: |
final public | function |
Called before child nodes are visited. Overrides Twig_NodeVisitorInterface:: |
|
Twig_BaseNodeVisitor:: |
final public | function |
Called after child nodes are visited. Overrides Twig_NodeVisitorInterface:: |
|
Twig_Profiler_NodeVisitor_Profiler:: |
private | property | ||
Twig_Profiler_NodeVisitor_Profiler:: |
protected | function |
Called before child nodes are visited. Overrides Twig_BaseNodeVisitor:: |
|
Twig_Profiler_NodeVisitor_Profiler:: |
protected | function |
Called after child nodes are visited. Overrides Twig_BaseNodeVisitor:: |
|
Twig_Profiler_NodeVisitor_Profiler:: |
public | function |
Returns the priority for this visitor. Overrides Twig_NodeVisitorInterface:: |
|
Twig_Profiler_NodeVisitor_Profiler:: |
private | function | ||
Twig_Profiler_NodeVisitor_Profiler:: |
public | function |