function menu_test_menu_local_tasks_alter

Implements hook_menu_local_tasks_alter().

File

drupal/core/modules/system/tests/modules/menu_test/menu_test.module, line 479
Dummy module implementing hook menu.

Code

function menu_test_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if (!config('menu_test.settings')
    ->get('tasks.alter')) {
    return;
  }
  if (strpos($router_item['tab_root'], 'menu-test/tasks/') === 0) {

    // Rename the default local task from 'View' to 'Show'.
    // $data['tabs'] is expected to be keyed by link hrefs.
    // The default local task always links to its parent path, which means that
    // if the tab root path appears as key in $data['tabs'], then that key is
    // the default local task.
    $key = $router_item['tab_root'];
    if (isset($data['tabs'][0][$key])) {
      $data['tabs'][0][$key]['#link']['title'] = 'Show it';
    }

    // Rename the 'foo' task to "Advanced settings" and put it last.
    $data['tabs'][0]['foo']['#link']['title'] = 'Advanced settings';
    $data['tabs'][0]['foo']['#weight'] = 110;
  }
}