You are here

public function TestExtension::getFunctions in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php \Drupal\twig_extension_test\TwigExtension\TestExtension::getFunctions()
  2. 10 core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php \Drupal\twig_extension_test\TwigExtension\TestExtension::getFunctions()

Generates a list of all Twig functions that this extension defines.

Return value

array A key/value array that defines custom Twig functions. The key denotes the function name used in the tag, e.g.:


  {{ testfunc() }}
  

The value is a standard PHP callback that defines what the function does.

File

core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php, line 25

Class

TestExtension
A test Twig extension that adds a custom function and a custom filter.

Namespace

Drupal\twig_extension_test\TwigExtension

Code

public function getFunctions() {
  return [
    'testfunc' => new TwigFunction('testfunc', [
      'Drupal\\twig_extension_test\\TwigExtension\\TestExtension',
      'testFunction',
    ]),
  ];
}