function TestExtension::getFunctions

Same name 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. 8.9.x core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php \Drupal\twig_extension_test\TwigExtension\TestExtension::getFunctions()
  3. 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.:


  {{ custom_function() }}
  

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 28

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 [
        'custom_function' => new TwigFunction('custom_function', [
            'Drupal\\twig_extension_test\\TwigExtension\\TestExtension',
            'testFunction',
        ]),
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.