function NavigationMenuLinkTreeManipulators::addOverviewLink
Adds "overview" menu tree element as child of a menu tree element.
Parameters
\Drupal\Core\Menu\MenuLinkTreeElement $element: The menu link tree element to add the overview child element to.
1 call to NavigationMenuLinkTreeManipulators::addOverviewLink()
- NavigationMenuLinkTreeManipulators::addSecondLevelOverviewLinks in core/
modules/ navigation/ src/ Menu/ NavigationMenuLinkTreeManipulators.php - Adds an "overview" child link to second level menu links with children.
File
-
core/
modules/ navigation/ src/ Menu/ NavigationMenuLinkTreeManipulators.php, line 140
Class
- NavigationMenuLinkTreeManipulators
- Provides a menu link tree manipulator for the navigation menu block.
Namespace
Drupal\navigation\MenuCode
protected function addOverviewLink(MenuLinkTreeElement $element) : void {
// Copy the menu link for the menu link element to a new menu link
// definition, except with overrides to make 'Overview' the title, set the
// parent to the original menu link, and set weight to a low number so that
// it likely goes to the top.
$definition = [
'title' => $this->t('Overview', [
'@title' => $element->link
->getTitle(),
]),
'parent' => $element->link
->getPluginId(),
'provider' => 'navigation',
'weight' => -1000,
] + $element->link
->getPluginDefinition();
$link = new MenuLinkDefault([], $element->link
->getPluginId() . '.navigation_overview', $definition, $this->overrides);
$overview_element = new MenuLinkTreeElement($link, FALSE, $element->depth + 1, $element->inActiveTrail, []);
$overview_element->access = $element->access ? clone $element->access : NULL;
$element->subtree[$element->link
->getPluginId() . '.navigation_overview'] = $overview_element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.