2 * Implements hook_menu_local_tasks_alter().
4 function {{ machine_name }}_menu_local_tasks_alter(&$data, $route_name, \Drupal\Core\Cache\RefinableCacheableDependencyInterface &$cacheability) {
6 // Add a tab linking to node/add to all pages.
7 $data['tabs'][0]['node.add_page'] = [
8 '#theme' => 'menu_local_task',
10 'title' => t('Example tab'),
11 'url' => Url::fromRoute('node.add_page'),
12 'localized_options' => [
14 'title' => t('Add content'),
19 // The tab we're adding is dependent on a user's access to add content.
20 $cacheability->addCacheTags(['user.permissions']);