function LocaleTestHooks::tokens

Implements hook_tokens().

File

core/modules/locale/tests/modules/locale_test/src/Hook/LocaleTestHooks.php, line 188

Class

LocaleTestHooks
Hook implementations for locale_test.

Namespace

Drupal\locale_test\Hook

Code

public function tokens($type, $tokens, array $data = [], array $options = []) {
    $return = [];
    if ($type == 'locale_test') {
        foreach ($tokens as $name => $original) {
            switch ($name) {
                case 'security_test1':
                    $return[$original] = "javascript:alert('Hello!');";
                    break;
                case 'security_test2':
                    $return[$original] = "<script>alert('Hello!');</script>";
                    break;
            }
        }
    }
    return $return;
}

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