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) {
    $page_top['toolbar'] = [
        '#type' => 'toolbar',
        '#access' => \Drupal::currentUser()->hasPermission('access toolbar'),
        '#cache' => [
            'keys' => [
                'toolbar',
            ],
            'contexts' => [
                'user.permissions',
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.