function link_generation_test_link_alter
Same name in other branches
- 8.9.x core/modules/system/tests/modules/link_generation_test/link_generation_test.module \link_generation_test_link_alter()
- 10 core/modules/system/tests/modules/link_generation_test/link_generation_test.module \link_generation_test_link_alter()
- 11.x core/modules/system/tests/modules/link_generation_test/link_generation_test.module \link_generation_test_link_alter()
Implements hook_link_alter().
1 string reference to 'link_generation_test_link_alter'
- LinkGenerationTest::testHookLinkAlter in core/
tests/ Drupal/ KernelTests/ Core/ Url/ LinkGenerationTest.php - Tests how hook_link_alter() can affect escaping of the link text.
File
-
core/
modules/ system/ tests/ modules/ link_generation_test/ link_generation_test.module, line 11
Code
function link_generation_test_link_alter(&$variables) {
if (\Drupal::state()->get('link_generation_test_link_alter', FALSE)) {
// Add a text to the end of links.
if (\Drupal::state()->get('link_generation_test_link_alter_safe', FALSE)) {
$variables['text'] = t('@text <strong>Test!</strong>', [
'@text' => $variables['text'],
]);
}
else {
$variables['text'] .= ' <strong>Test!</strong>';
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.