You are here

function coffee_toolbar in Coffee 8

Implements hook_toolbar().

File

./coffee.module, line 70
Coffee primary module file.

Code

function coffee_toolbar() {
  $items['coffee'] = [
    '#cache' => [
      'contexts' => [
        'user.permissions',
      ],
    ],
  ];
  if (\Drupal::currentUser()
    ->hasPermission('access coffee')) {
    $items['coffee'] += [
      '#weight' => 999,
      '#type' => 'toolbar_item',
      'tab' => [
        '#type' => 'link',
        '#title' => t('Go to'),
        '#url' => Url::fromRoute('<none>'),
        '#attributes' => [
          'title' => t('Use alt+d to start Coffee and search for a page to go to'),
          'class' => [
            'toolbar-icon',
            'toolbar-icon-coffee',
          ],
        ],
      ],
      '#attached' => [
        'library' => [
          'coffee/drupal.coffee',
        ],
      ],
    ];
  }
  return $items;
}