You are here

function admin_toolbar_search_toolbar_alter in Admin Toolbar Search 8

Implements hook_toolbar_alter().

File

./admin_toolbar_search.module, line 15
This is the module to create a drop-down menu for the core toolbar.

Code

function admin_toolbar_search_toolbar_alter(&$items) {
  $items['administration_search'] = [
    "#type" => "toolbar_item",
    'tab' => [
      '#type' => 'link',
      '#title' => new TranslatableMarkup('Search'),
      '#url' => URL::fromRoute('system.admin'),
      '#attributes' => [
        'class' => [
          'toolbar-icon',
        ],
      ],
    ],
    'tray' => [
      'search' => [
        '#title' => 'Search',
        '#type' => 'textfield',
        '#size' => 60,
        '#attributes' => [
          'id' => 'admin-toolbar-search-input',
        ],
      ],
    ],
    '#attached' => [
      'library' => [
        'admin_toolbar_search/search',
      ],
    ],
    '#wrapper_attributes' => [
      "id" => "admin-toolbar-search-tab",
    ],
  ];
}