public function TwigTweakExtension::getFunctions in Twig Tweak 3.x
Same name and namespace in other branches
- 3.1.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::getFunctions()
File
- src/
TwigTweakExtension.php, line 60
Class
- TwigTweakExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public function getFunctions() : array {
$context_options = [
'needs_context' => TRUE,
];
$all_options = [
'needs_environment' => TRUE,
'needs_context' => TRUE,
];
$functions = [
new TwigFunction('drupal_view', 'views_embed_view'),
new TwigFunction('drupal_view_result', 'views_get_view_result'),
new TwigFunction('drupal_block', [
self::class,
'drupalBlock',
]),
new TwigFunction('drupal_region', [
self::class,
'drupalRegion',
]),
new TwigFunction('drupal_entity', [
self::class,
'drupalEntity',
]),
new TwigFunction('drupal_entity_form', [
self::class,
'drupalEntityForm',
]),
new TwigFunction('drupal_field', [
self::class,
'drupalField',
]),
new TwigFunction('drupal_menu', [
self::class,
'drupalMenu',
]),
new TwigFunction('drupal_form', [
self::class,
'drupalForm',
]),
new TwigFunction('drupal_image', [
self::class,
'drupalImage',
]),
new TwigFunction('drupal_token', [
self::class,
'drupalToken',
]),
new TwigFunction('drupal_config', [
self::class,
'drupalConfig',
]),
new TwigFunction('drupal_dump', [
self::class,
'drupalDump',
], $context_options),
new TwigFunction('dd', [
self::class,
'drupalDump',
], $context_options),
new TwigFunction('drupal_title', [
self::class,
'drupalTitle',
]),
new TwigFunction('drupal_url', [
self::class,
'drupalUrl',
]),
new TwigFunction('drupal_link', [
self::class,
'drupalLink',
]),
new TwigFunction('drupal_messages', function () : array {
return [
'#type' => 'status_messages',
];
}),
new TwigFunction('drupal_breadcrumb', [
self::class,
'drupalBreadcrumb',
]),
new TwigFunction('drupal_breakpoint', [
self::class,
'drupalBreakpoint',
], $all_options),
// @phpcs:ignore Drupal.Arrays.Array.LongLineDeclaration
new TwigFunction('drupal_contextual_links', [
self::class,
'drupalContextualLinks',
]),
];
$this->moduleHandler
->alter('twig_tweak_functions', $functions);
$this->themeManager
->alter('twig_tweak_functions', $functions);
return $functions;
}