function hook_navigation_menu_link_tree_alter
Alter the content of a given Navigation menu link tree.
Parameters
array &$tree: The Navigation link tree.
See also
\Drupal\navigation\Menu\NavigationMenuLinkTree::transform()
Related topics
1 invocation of hook_navigation_menu_link_tree_alter()
- NavigationMenuLinkTree::transform in core/
modules/ navigation/ src/ Menu/ NavigationMenuLinkTree.php - Applies menu link tree manipulators to transform the given tree.
File
-
core/
modules/ navigation/ navigation.api.php, line 99
Code
function hook_navigation_menu_link_tree_alter(array &$tree) : void {
foreach ($tree as $key => $item) {
// Skip elements where menu is not the 'admin' one.
$menu_name = $item->link
->getMenuName();
if ($menu_name != 'admin') {
continue;
}
// Remove unwanted Help menu link.
$plugin_id = $item->link
->getPluginId();
if ($plugin_id == 'help.main') {
unset($tree[$key]);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.