admin_toolbar_search.module in Admin Toolbar 8.2
Same filename and directory in other branches
Functionality for search of Admin Toolbar.
File
admin_toolbar_search/admin_toolbar_search.moduleView source
<?php
/**
* @file
* Functionality for search of Admin Toolbar.
*/
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function admin_toolbar_search_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help.
case 'help.page.admin_toolbar_search':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar Search module add a search option to the toolbar for site administrative tasks.') . '</p>';
return $output;
}
}
/**
* Implements hook_toolbar_alter().
*/
function admin_toolbar_search_toolbar_alter(&$items) {
if (!\Drupal::currentUser()
->hasPermission('use admin toolbar search')) {
return;
}
$admin_toolbar_tools_enabled = \Drupal::service('module_handler')
->moduleExists('admin_toolbar_tools');
$items['administration_search'] = [
"#type" => "toolbar_item",
'#weight' => 100,
'tab' => [
'search' => [
'#type' => 'textfield',
'#size' => 30,
'#attributes' => [
'id' => 'admin-toolbar-search-input',
'aria-labelledby' => 'toolbar-item-administration-search',
'placeholder' => new TranslatableMarkup('Admin Toolbar quick search'),
],
],
],
'#attached' => [
'library' => [
'admin_toolbar_search/search',
],
'drupalSettings' => [
'adminToolbarSearch' => [
'loadExtraLinks' => $admin_toolbar_tools_enabled,
],
],
],
'#wrapper_attributes' => [
'id' => 'admin-toolbar-search-tab',
],
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
}
Functions
Name | Description |
---|---|
admin_toolbar_search_help | Implements hook_help(). |
admin_toolbar_search_toolbar_alter | Implements hook_toolbar_alter(). |