function MenuTestHooks::menuLinksDiscoveredAlter

Implements hook_menu_links_discovered_alter().

Attributes

#[Hook('menu_links_discovered_alter')]

File

core/modules/system/tests/modules/menu_test/src/Hook/MenuTestHooks.php, line 20

Class

MenuTestHooks
Hook implementations for menu_test.

Namespace

Drupal\menu_test\Hook

Code

public function menuLinksDiscoveredAlter(&$links) : void {
  // Many of the machine names here are slightly different from the route
  // name. Since the machine name is arbitrary, this helps ensure that core
  // does not add mistaken assumptions about the correlation.
  $links['menu_test.menu_name_test']['menu_name'] = MenuTestHelper::menuName();
  $links['menu_test.context']['title'] = \Drupal::config('menu_test.menu_item')->get('title');
  // Adds a custom menu link.
  $links['menu_test.custom'] = [
    'title' => 'Custom link',
    'route_name' => 'menu_test.custom',
    'description' => 'Custom link used to check the integrity of manually added menu links.',
    'parent' => 'menu_test',
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.