You are here

function tour_toolbar in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/tour/tour.module \tour_toolbar()

Implements hook_toolbar().

File

core/modules/tour/tour.module, line 34
Main functions of the module.

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;
}