function 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|testfilter }}
  

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 43

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 [
    'testfilter' => new TwigFilter('testfilter', [
      'Drupal\\twig_extension_test\\TwigExtension\\TestExtension',
      'testFilter',
    ]),
  ];
}

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