function LinkGenerationTest::linkAlter
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Url/LinkGenerationTest.php \Drupal\KernelTests\Core\Url\LinkGenerationTest::linkAlter()
Implements hook_link_alter().
Attributes
#[Hook('link_alter')]
See also
::testHookLinkAlter()
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Url/ LinkGenerationTest.php, line 30
Class
- LinkGenerationTest
- Tests link generation with hooks.
Namespace
Drupal\KernelTests\Core\UrlCode
public function linkAlter(&$variables) : void {
if (\Drupal::state()->get('link_generation_test_link_alter', FALSE)) {
// Add 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.