Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ToolbarHooks.php

function ToolbarHooks::pageTop

Implements hook_page_top().

Add admin toolbar to the top of the page automatically.

File

core/modules/toolbar/src/Hook/ToolbarHooks.php, line 57

Class

ToolbarHooks
Hook implementations for toolbar.

Namespace

Drupal\toolbar\Hook

Code

public function pageTop(array &$page_top) : void {
    $page_top['toolbar'] = [
        '#type' => 'toolbar',
        '#access' => \Drupal::currentUser()->hasPermission('access toolbar'),
        '#cache' => [
            'keys' => [
                'toolbar',
            ],
            'contexts' => [
                'user.permissions',
            ],
        ],
    ];
}
RSS feed
Powered by Drupal