You are here

function toolbar_page_top in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/toolbar/toolbar.module \toolbar_page_top()
  2. 10 core/modules/toolbar/toolbar.module \toolbar_page_top()

Implements hook_page_top().

Add admin toolbar to the top of the page automatically.

File

core/modules/toolbar/toolbar.module, line 55
Administration toolbar for quick access to top level administration items.

Code

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