public function TwigExtension::getFunctions in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()
- 10 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::getFunctions()
File
- core/
lib/ Drupal/ Core/ Template/ TwigExtension.php, line 137
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 \Twig_SimpleFunction('render_var', [
$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', [
$this,
'getUrl',
], [
'is_safe_callback' => [
$this,
'isUrlGenerationSafe',
],
]),
new \Twig_SimpleFunction('path', [
$this,
'getPath',
], [
'is_safe_callback' => [
$this,
'isUrlGenerationSafe',
],
]),
new \Twig_SimpleFunction('link', [
$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',
]),
new \Twig_SimpleFunction('create_attribute', [
$this,
'createAttribute',
]),
];
}