You are here

public function TwigExtension::getFunctions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()
1 method overrides TwigExtension::getFunctions()
TestExtension::getFunctions in core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php
Generates a list of all Twig functions that this extension defines.

File

core/lib/Drupal/Core/Template/TwigExtension.php, line 129
Contains \Drupal\Core\Template\TwigExtension.

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 \Twig_SimpleFunction('render_var', array(
      $this,
      'renderVar',
    )),
    // The url and path function are defined in close parallel to those found
    // in \Symfony\Bridge\Twig\Extension\RoutingExtension
    new \Twig_SimpleFunction('url', array(
      $this,
      'getUrl',
    ), array(
      'is_safe_callback' => array(
        $this,
        'isUrlGenerationSafe',
      ),
    )),
    new \Twig_SimpleFunction('path', array(
      $this,
      'getPath',
    ), array(
      'is_safe_callback' => array(
        $this,
        'isUrlGenerationSafe',
      ),
    )),
    new \Twig_SimpleFunction('link', array(
      $this,
      'getLink',
    )),
    new \Twig_SimpleFunction('file_url', 'file_create_url'),
    new \Twig_SimpleFunction('attach_library', [
      $this,
      'attachLibrary',
    ]),
    new \Twig_SimpleFunction('active_theme_path', [
      $this,
      'getActiveThemePath',
    ]),
    new \Twig_SimpleFunction('active_theme', [
      $this,
      'getActiveTheme',
    ]),
  ];
}