You are here

public static function TestExtension::testFilter 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::testFilter()
  2. 10 core/modules/system/tests/modules/twig_extension_test/src/TwigExtension/TestExtension.php \Drupal\twig_extension_test\TwigExtension\TestExtension::testFilter()

Replaces all instances of "animal" in a string with "plant".

Parameters

string $string: The string to be filtered.

Return value

string The filtered string.

See also

\Drupal\system\Tests\Theme\TwigExtensionTest::testTwigExtensionFilter()

File

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

Class

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

Namespace

Drupal\twig_extension_test\TwigExtension

Code

public static function testFilter($string) {
  return str_replace([
    'animal',
  ], [
    'plant',
  ], $string);
}