function tour_toolbar

Same name in other branches
  1. 9 core/modules/tour/tour.module \tour_toolbar()
  2. 8.9.x core/modules/tour/tour.module \tour_toolbar()
  3. 11.x core/modules/tour/tour.module \tour_toolbar()

Implements hook_toolbar().

File

core/modules/tour/tour.module, line 34

Code

function tour_toolbar() {
    $items = [];
    $items['tour'] = [
        '#cache' => [
            'contexts' => [
                'user.permissions',
            ],
        ],
    ];
    if (!\Drupal::currentUser()->hasPermission('access tour')) {
        return $items;
    }
    $items['tour'] += [
        '#type' => 'toolbar_item',
        'tab' => [
            '#type' => 'html_tag',
            '#tag' => 'button',
            '#value' => t('Tour'),
            '#attributes' => [
                'class' => [
                    'toolbar-icon',
                    'toolbar-icon-help',
                ],
                'aria-pressed' => 'false',
                'type' => 'button',
            ],
        ],
        '#wrapper_attributes' => [
            'class' => [
                'tour-toolbar-tab',
                'hidden',
            ],
            'id' => 'toolbar-tab-tour',
        ],
        '#attached' => [
            'library' => [
                'tour/tour',
            ],
        ],
    ];
    return $items;
}

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