function TwigExtension::getFunctions
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()
- 10 core/modules/sdc/src/Twig/TwigExtension.php \Drupal\sdc\Twig\TwigExtension::getFunctions()
- 10 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()
- 11.x core/modules/sdc/src/Twig/TwigExtension.php \Drupal\sdc\Twig\TwigExtension::getFunctions()
- 11.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()
File
-
core/
lib/ Drupal/ Core/ Template/ TwigExtension.php, line 101
Class
- TwigExtension
- A class providing Drupal Twig extensions.
Namespace
Drupal\Core\TemplateCode
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',
]),
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.