function toolbar_menu_navigation_links in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/toolbar/toolbar.module \toolbar_menu_navigation_links()
Adds toolbar-specific attributes to the menu link tree.
Parameters
\Drupal\Core\Menu\MenuLinkTreeElement[] $tree: The menu link tree to manipulate.
Return value
\Drupal\Core\Menu\MenuLinkTreeElement[] The manipulated menu link tree.
3 string references to 'toolbar_menu_navigation_links'
- admin_toolbar_prerender_toolbar_administration_tray in modules/
admin_toolbar/ admin_toolbar.module - Renders the toolbar's administration tray. This is a clone of core's toolbar_prerender_toolbar_administration_tray() function, which uses setMaxDepth(4) instead of setTopLevelOnly()
- toolbar_prerender_toolbar_administration_tray in core/
modules/ toolbar/ toolbar.module - Renders the toolbar's administration tray.
- _toolbar_do_get_rendered_subtrees in core/
modules/ toolbar/ toolbar.module - #pre_render callback for toolbar_get_rendered_subtrees().
File
- core/
modules/ toolbar/ toolbar.module, line 250 - Administration toolbar for quick access to top level administration items.
Code
function toolbar_menu_navigation_links(array $tree) {
foreach ($tree as $element) {
if ($element->subtree) {
toolbar_menu_navigation_links($element->subtree);
}
// Make sure we have a path specific ID in place, so we can attach icons
// and behaviors to the menu links.
$link = $element->link;
$url = $link
->getUrlObject();
if (!$url
->isRouted()) {
// This is an unusual case, so just get a distinct, safe string.
$id = substr(Crypt::hashBase64($url
->getUri()), 0, 16);
}
else {
$id = str_replace(array(
'.',
'<',
'>',
), array(
'-',
'',
'',
), $url
->getRouteName());
}
// Get the non-localized title to make the icon class.
$definition = $link
->getPluginDefinition();
$element->options['attributes']['id'] = 'toolbar-link-' . $id;
$element->options['attributes']['class'][] = 'toolbar-icon';
$element->options['attributes']['class'][] = 'toolbar-icon-' . strtolower(str_replace(array(
'.',
' ',
'_',
), array(
'-',
'-',
'-',
), $definition['id']));
$element->options['attributes']['title'] = $link
->getDescription();
}
return $tree;
}