Version 1
[yaffs-website] / web / core / modules / toolbar / tests / modules / toolbar_test / toolbar_test.module
diff --git a/web/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module b/web/core/modules/toolbar/tests/modules/toolbar_test/toolbar_test.module
new file mode 100644 (file)
index 0000000..323af16
--- /dev/null
@@ -0,0 +1,49 @@
+<?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'] = [
+    '#type' => 'toolbar_item',
+    'tab' => [
+      '#type' => 'link',
+      '#title' => t('Test tab'),
+      '#url' => Url::fromRoute('<front>'),
+      '#options' => [
+        'attributes' => [
+          'id' => 'toolbar-tab-testing',
+          'title' => t('Test tab'),
+        ],
+      ],
+    ],
+    'tray' => [
+      '#heading' => t('Test tray'),
+      '#wrapper_attributes' => [
+        'id' => 'toolbar-tray-testing',
+      ],
+      'content' => [
+        '#theme' => 'item_list',
+        '#items' => [
+          \Drupal::l(t('link 1'), new Url('<front>', [], ['attributes' => ['title' => 'Test link 1 title']])),
+          \Drupal::l(t('link 2'), new Url('<front>', [], ['attributes' => ['title' => 'Test link 2 title']])),
+          \Drupal::l(t('link 3'), new Url('<front>', [], ['attributes' => ['title' => 'Test link 3 title']])),
+        ],
+        '#attributes' => [
+          'class' => ['toolbar-menu'],
+        ],
+      ],
+    ],
+    '#weight' => 50,
+  ];
+
+  return $items;
+}