function TestExtension::testFunction

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

Outputs either an uppercase or lowercase test phrase.

The function generates either an uppercase or lowercase version of the phrase "The quick brown fox jumps over the lazy dog 123.", depending on whether or not the $upperCase parameter evaluates to TRUE. If $upperCase evaluates to TRUE, the result will be uppercase, and if it evaluates to FALSE, the result will be lowercase.

Parameters

bool $upperCase: (optional) Whether the result is uppercase (true) or lowercase (false).

Return value

string The generated string.

See also

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

File

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

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 testFunction($upperCase = FALSE) {
    $string = "The quick brown box jumps over the lazy dog 123.";
    if ($upperCase == TRUE) {
        return strtoupper($string);
    }
    else {
        return strtolower($string);
    }
}

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