TwigExtension::getFunctions

public TwigExtension::getFunctions()

File

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

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']),
  ];
}
doc_Drupal
2016-10-29 09:49:40
Comments
Leave a Comment

Please login to continue.