You are here

function dxpr_theme_helper_toolbar in DXPR Theme Helper 1.0.x

Implements hook_toolbar().

File

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

Code

function dxpr_theme_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 DXPR Theme Helper toolbar render array.
    $items['DxprThemeSettings'] = [
      '#type' => 'toolbar_item',
      'tab' => [
        '#type' => 'link',
        '#title' => t('Theme Settings'),
        '#url' => Url::fromRoute('system.theme_settings_theme', [
          'theme' => $default_theme,
        ]),
        '#attributes' => [
          'title' => t('DXPR Theme Settings'),
          'class' => [
            'toolbar-icon',
            'toolbar-icon-dxpr-theme-helper',
          ],
        ],
      ],
      '#weight' => 99,
      '#attached' => [
        'library' => [
          'dxpr_theme_helper/dxpr_theme_helper.icons',
        ],
      ],
    ];
    return $items;
  }
}