W3cubDocs

/Drupal 8

public function TwigExtension::getFunctions

public TwigExtension::getFunctions()

File

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

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', function($uri) {
      return file_url_transform_relative(file_create_url($uri));
    }),
    new \Twig_SimpleFunction('attach_library', [$this, 'attachLibrary']),
    new \Twig_SimpleFunction('active_theme_path', [$this, 'getActiveThemePath']),
    new \Twig_SimpleFunction('active_theme', [$this, 'getActiveTheme']),
  ];
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Template!TwigExtension.php/function/TwigExtension::getFunctions/8.1.x