You are here

function glazed_helper_toolbar in Glazed Theme Helper 8

Implements hook_toolbar().

File

./glazed_helper.module, line 18
Module file for glazed_helper.

Code

function glazed_helper_toolbar() {
  if (\Drupal::currentUser()
    ->hasPermission('Use the administration toolbar') && \Drupal::currentUser()
    ->hasPermission('Administer themes')) {
    $config = \Drupal::config('system.theme');
    $default_theme = $config
      ->get('default');

    // Create the Glazed Helper toolbar render array.
    $items['glazedsettings'] = [
      '#type' => 'toolbar_item',
      'tab' => [
        '#type' => 'link',
        '#title' => t('Theme Settings'),
        '#url' => Url::fromRoute('system.theme_settings_theme', [
          'theme' => $default_theme,
        ]),
        '#attributes' => [
          'title' => t('Glazed Theme Settings'),
          'class' => [
            'toolbar-icon',
            'toolbar-icon-glazed-helper',
          ],
        ],
      ],
      '#weight' => 99,
      '#attached' => [
        'library' => [
          'glazed_helper/glazed_helper.icons',
        ],
      ],
    ];
    return $items;
  }
}