function MenuTestHooks::menuLocalTasksAlter
Implements hook_menu_local_tasks_alter().
File
-
core/
modules/ system/ tests/ modules/ menu_test/ src/ Hook/ MenuTestHooks.php, line 38
Class
- MenuTestHooks
- Hook implementations for menu_test.
Namespace
Drupal\menu_test\HookCode
public function menuLocalTasksAlter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) : void {
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.