You are here

function seeds_toolbar_toolbar in Seeds Toolbar 8

Implements hook_toolbar().

File

./seeds_toolbar.module, line 130
Contains seeds_toolbar.module.

Code

function seeds_toolbar_toolbar() {
  $config = \Drupal::config('seeds_toolbar.settings');
  $items = [];

  // Support Tab.
  $support_url = $config
    ->get('support') ? $config
    ->get('support') : NULL;
  if (isset($support_url) && $support_url) {
    $items['seeds_support'] = [
      '#weight' => 1000,
      '#type' => 'toolbar_item',
      'tab' => [
        '#type' => 'html_tag',
        '#tag' => 'a',
        '#title' => t('Support'),
        '#attributes' => [
          'title' => t('Link to the support page'),
          'class' => [
            'toolbar-icon',
            'toolbar-icon-support',
          ],
          'href' => $support_url,
          'target' => '_blank',
        ],
      ],
    ];
  }
  $items['seeds_add'] = [
    '#type' => 'toolbar_item',
    'tab' => [
      '#type' => 'html_tag',
      '#tag' => 'button',
      '#value' => t('Seeds Add'),
      '#attributes' => [
        'class' => [
          'toolbar-icon',
          'toolbar-icon-seeds-add',
        ],
      ],
    ],
    'tray' => [
      '#theme' => 'seeds_add',
    ],
  ];
  $items['seeds_logo'] = [
    '#type' => 'toolbar_item',
    '#attributes' => [
      'class' => 'toolbar-icon-seeds',
    ],
    'tab' => [
      '#type' => 'link',
      '#title' => t('Home'),
      '#url' => Url::fromRoute('<front>'),
      '#attributes' => [
        'title' => t('Link to Seeds drupal.org project.'),
        'class' => [
          'toolbar-icon',
          'toolbar-icon-seeds',
        ],
      ],
    ],
  ];
  return $items;
}