You are here

public function TwigExtension::getFunctions in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()
  2. 9 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()

File

core/lib/Drupal/Core/Template/TwigExtension.php, line 97

Class

TwigExtension
A class providing Drupal Twig extensions.

Namespace

Drupal\Core\Template

Code

public function getFunctions() {
  return [
    // This function will receive a renderable array, if an array is detected.
    new TwigFunction('render_var', [
      $this,
      'renderVar',
    ]),
    // The url and path function are defined in close parallel to those found
    // in \Symfony\Bridge\Twig\Extension\RoutingExtension
    new TwigFunction('url', [
      $this,
      'getUrl',
    ], [
      'is_safe_callback' => [
        $this,
        'isUrlGenerationSafe',
      ],
    ]),
    new TwigFunction('path', [
      $this,
      'getPath',
    ], [
      'is_safe_callback' => [
        $this,
        'isUrlGenerationSafe',
      ],
    ]),
    new TwigFunction('link', [
      $this,
      'getLink',
    ]),
    new TwigFunction('file_url', [
      $this,
      'getFileUrl',
    ]),
    new TwigFunction('attach_library', [
      $this,
      'attachLibrary',
    ]),
    new TwigFunction('active_theme_path', [
      $this,
      'getActiveThemePath',
    ]),
    new TwigFunction('active_theme', [
      $this,
      'getActiveTheme',
    ]),
    new TwigFunction('create_attribute', [
      $this,
      'createAttribute',
    ]),
  ];
}