admin_toolbar_search.module in Admin Toolbar Search 8
This is the module to create a drop-down menu for the core toolbar.
File
admin_toolbar_search.moduleView source
<?php
/**
* @file
* This is the module to create a drop-down menu for the core toolbar.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Implements hook_toolbar_alter().
*/
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",
],
];
}
/**
* Implements hook_help().
*/
function admin_toolbar_search_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.admin_toolbar_search':
$output = '<p>' . t('Admin Toolbar Search provides a search field for searching links within the Admin Toolbar.') . '</p>';
return $output;
}
}
Functions
Name | Description |
---|---|
admin_toolbar_search_help | Implements hook_help(). |
admin_toolbar_search_toolbar_alter | Implements hook_toolbar_alter(). |