function LinkGenerationTestHooks::linkAlter
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/link_generation_test/src/Hook/LinkGenerationTestHooks.php \Drupal\link_generation_test\Hook\LinkGenerationTestHooks::linkAlter()
Implements hook_link_alter().
Attributes
#[Hook('link_alter')]
File
-
core/
modules/ system/ tests/ modules/ link_generation_test/ src/ Hook/ LinkGenerationTestHooks.php, line 20
Class
- LinkGenerationTestHooks
- Hook implementations for link_generation_test.
Namespace
Drupal\link_generation_test\HookCode
public function linkAlter(&$variables) : void {
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'] = $this->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.