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

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

Return value

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


  {{ foo|test_filter }}
  

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

File

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

Class

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

Namespace

Drupal\twig_extension_test\TwigExtension

Code

public function getFilters() {
  return [
    'test_filter' => new TwigFilter('test_filter', [
      'Drupal\\twig_extension_test\\TwigExtension\\TestExtension',
      'testFilter',
    ]),
  ];
}