Namespace

Drupal\sdc_other_node_visitor\Twig\Profiler

File

core/modules/system/tests/modules/sdc_other_node_visitor/src/Twig/Profiler/EnterProfileNode.php
View source
<?php

namespace Drupal\sdc_other_node_visitor\Twig\Profiler;

use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Node\Node;

/**
 * Represents a profile enter node.
 */

#[YieldReady]
class EnterProfileNode extends Node {
  public function __construct(string $extensionName, string $varName) {
    parent::__construct([], [
      'extension_name' => $extensionName,
      'var_name' => $varName,
    ]);
  }
  public function compile(Compiler $compiler) : void {
    $compiler
      ->write(sprintf('$%s = $this->extensions[', $this
      ->getAttribute('var_name')))
      ->repr($this
      ->getAttribute('extension_name'))
      ->raw("];\n")
      ->write(sprintf('$%s->enter();', $this
      ->getAttribute('var_name')))
      ->raw("\n\n");
  }

}

Classes

Namesort descending Description
EnterProfileNode