Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TwigExtension.php

function TwigExtension::getFunctions

Overrides AbstractExtension::getFunctions

File

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

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',
        ]),
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal