You are here

public function ToolbarHandler::toolbar in Rebuild Cache Access 8

Hook bridge.

Return value

array The devel toolbar items render array.

See also

hook_toolbar()

File

src/ToolbarHandler.php, line 52

Class

ToolbarHandler
Toolbar integration handler.

Namespace

Drupal\rebuild_cache_access

Code

public function toolbar() {
  $items['rebuild_cache_access'] = [
    '#cache' => [
      'contexts' => [
        'user.permissions',
      ],
    ],
  ];
  if ($this->account
    ->hasPermission('rebuild cache access')) {
    $items['rebuild_cache_access'] += [
      '#type' => 'toolbar_item',
      '#weight' => 999,
      'tab' => [
        '#type' => 'link',
        '#title' => $this
          ->t('Rebuild Cache'),
        '#url' => Url::fromRoute('rebuild_cache_access.rebuild_cache'),
        '#attributes' => [
          'title' => $this
            ->t('Rebuild Cache Access'),
          'class' => [
            'toolbar-icon',
            'toolbar-icon-rebuild-cache-access',
          ],
        ],
      ],
      '#attached' => [
        'library' => 'rebuild_cache_access/rebuild-cache-access-toolbar',
      ],
    ];
  }
  return $items;
}