function NavigationHooks::pageTop
Implements hook_page_top().
File
-
core/
modules/ navigation/ src/ Hook/ NavigationHooks.php, line 83
Class
- NavigationHooks
- Hook implementations for navigation.
Namespace
Drupal\navigation\HookCode
public function pageTop(array &$page_top) : void {
if (!$this->currentUser
->hasPermission('access navigation')) {
return;
}
$this->navigationRenderer
->removeToolbar($page_top);
if ($this->routeMatch
->getRouteName() !== 'layout_builder.navigation.view') {
// Don't render the admin toolbar if in layout edit mode.
$this->navigationRenderer
->buildNavigation($page_top);
$this->navigationRenderer
->buildTopBar($page_top);
return;
}
// But if in layout mode, add an empty element to leave space. We need to
// use an empty .admin-toolbar element because the css uses the adjacent
// sibling selector. The actual rendering of the navigation blocks/layout
// occurs in the layout form.
$page_top['navigation'] = [
'#type' => 'html_tag',
'#tag' => 'aside',
'#attributes' => [
'class' => 'admin-toolbar',
],
];
$this->navigationRenderer
->buildTopBar($page_top);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.