mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-16 02:34:54 +02:00
Update Twig to v2.15.4
This commit is contained in:
@@ -24,16 +24,16 @@ use Twig\Profiler\Profile;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ProfilerNodeVisitor extends AbstractNodeVisitor
|
||||
final class ProfilerNodeVisitor extends AbstractNodeVisitor
|
||||
{
|
||||
private $extensionName;
|
||||
private $varName;
|
||||
|
||||
public function __construct($extensionName)
|
||||
public function __construct(string $extensionName)
|
||||
{
|
||||
$this->extensionName = $extensionName;
|
||||
$this->varName = sprintf('__internal_%s', hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', $extensionName));
|
||||
}
|
||||
|
||||
protected function doEnterNode(Node $node, Environment $env)
|
||||
@@ -44,33 +44,25 @@ class ProfilerNodeVisitor extends AbstractNodeVisitor
|
||||
protected function doLeaveNode(Node $node, Environment $env)
|
||||
{
|
||||
if ($node instanceof ModuleNode) {
|
||||
$varName = $this->getVarName();
|
||||
$node->setNode('display_start', new Node([new EnterProfileNode($this->extensionName, Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start')]));
|
||||
$node->setNode('display_end', new Node([new LeaveProfileNode($varName), $node->getNode('display_end')]));
|
||||
$node->setNode('display_start', new Node([new EnterProfileNode($this->extensionName, Profile::TEMPLATE, $node->getTemplateName(), $this->varName), $node->getNode('display_start')]));
|
||||
$node->setNode('display_end', new Node([new LeaveProfileNode($this->varName), $node->getNode('display_end')]));
|
||||
} elseif ($node instanceof BlockNode) {
|
||||
$varName = $this->getVarName();
|
||||
$node->setNode('body', new BodyNode([
|
||||
new EnterProfileNode($this->extensionName, Profile::BLOCK, $node->getAttribute('name'), $varName),
|
||||
new EnterProfileNode($this->extensionName, Profile::BLOCK, $node->getAttribute('name'), $this->varName),
|
||||
$node->getNode('body'),
|
||||
new LeaveProfileNode($varName),
|
||||
new LeaveProfileNode($this->varName),
|
||||
]));
|
||||
} elseif ($node instanceof MacroNode) {
|
||||
$varName = $this->getVarName();
|
||||
$node->setNode('body', new BodyNode([
|
||||
new EnterProfileNode($this->extensionName, Profile::MACRO, $node->getAttribute('name'), $varName),
|
||||
new EnterProfileNode($this->extensionName, Profile::MACRO, $node->getAttribute('name'), $this->varName),
|
||||
$node->getNode('body'),
|
||||
new LeaveProfileNode($varName),
|
||||
new LeaveProfileNode($this->varName),
|
||||
]));
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getVarName()
|
||||
{
|
||||
return sprintf('__internal_%s', hash('sha256', $this->extensionName));
|
||||
}
|
||||
|
||||
public function getPriority()
|
||||
{
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user