You are here

toolbar_test.module in Zircon Profile 8

A dummy module to test API interaction with the Toolbar module.

File

core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module
View source
<?php

/**
 * @file
 * A dummy module to test API interaction with the Toolbar module.
 */
use Drupal\Core\Url;

/**
 * Implements hook_toolbar().
 */
function toolbar_test_toolbar() {
  $items['testing'] = array(
    '#type' => 'toolbar_item',
    'tab' => array(
      '#type' => 'link',
      '#title' => t('Test tab'),
      '#url' => Url::fromRoute('<front>'),
      '#options' => array(
        'attributes' => array(
          'id' => 'toolbar-tab-testing',
          'title' => t('Test tab'),
        ),
      ),
    ),
    'tray' => array(
      '#heading' => t('Test tray'),
      '#wrapper_attributes' => array(
        'id' => 'toolbar-tray-testing',
      ),
      'content' => array(
        '#theme' => 'item_list',
        '#items' => array(
          \Drupal::l(t('link 1'), new Url('<front>', [], array(
            'attributes' => array(
              'title' => 'Test link 1 title',
            ),
          ))),
          \Drupal::l(t('link 2'), new Url('<front>', [], array(
            'attributes' => array(
              'title' => 'Test link 2 title',
            ),
          ))),
          \Drupal::l(t('link 3'), new Url('<front>', [], array(
            'attributes' => array(
              'title' => 'Test link 3 title',
            ),
          ))),
        ),
        '#attributes' => array(
          'class' => array(
            'toolbar-menu',
          ),
        ),
      ),
    ),
    '#weight' => 50,
  );
  return $items;
}

Functions

Namesort descending Description
toolbar_test_toolbar Implements hook_toolbar().