function menu_test_menu_local_tasks_alter
Same name in other branches
- 8.9.x core/modules/system/tests/modules/menu_test/menu_test.module \menu_test_menu_local_tasks_alter()
- 10 core/modules/system/tests/modules/menu_test/menu_test.module \menu_test_menu_local_tasks_alter()
Implements hook_menu_local_tasks_alter().
File
-
core/
modules/ system/ tests/ modules/ menu_test/ menu_test.module, line 33
Code
function menu_test_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) {
if (in_array($route_name, [
'menu_test.tasks_default',
])) {
$data['tabs'][0]['foo'] = [
'#theme' => 'menu_local_task',
'#link' => [
'title' => "Task 1 <script>alert('Welcome to the jungle!')</script>",
'url' => Url::fromRoute('menu_test.router_test1', [
'bar' => '1',
]),
],
'#weight' => 10,
];
$data['tabs'][0]['bar'] = [
'#theme' => 'menu_local_task',
'#link' => [
'title' => 'Task 2',
'url' => Url::fromRoute('menu_test.router_test2', [
'bar' => '2',
]),
],
'#weight' => 20,
];
}
$cacheability->addCacheTags([
'kittens:dwarf-cat',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.