diff --git a/admin_menu.inc b/admin_menu.inc index faebfb3..b1235ae 100644 --- a/admin_menu.inc +++ b/admin_menu.inc @@ -15,7 +15,7 @@ function admin_menu_tree($menu_name) { // Get placeholder expansion arguments from hook_admin_menu_map() // implementations. module_load_include('inc', 'admin_menu', 'admin_menu.map'); - $expand_map = module_invoke_all('admin_menu_map'); + $expand_map = Drupal::moduleHandler()->invokeAll('admin_menu_map'); // Allow modules to alter the expansion map. drupal_alter('admin_menu_map', $expand_map); @@ -489,7 +489,7 @@ function admin_menu_links_icon() { 'query' => $destination + array('token' => drupal_get_token('admin_menu/flush-cache')), ), ); - $caches = module_invoke_all('admin_menu_cache_info'); + $caches = Drupal::moduleHandler()->invokeAll('admin_menu_cache_info'); foreach ($caches as $name => $cache) { $links['icon']['flush-cache'][$name] = array( '#title' => $cache['title'], @@ -769,7 +769,7 @@ function admin_menu_flush_cache($name = NULL) { } if (isset($name)) { - $caches = module_invoke_all('admin_menu_cache_info'); + $caches = Drupal::moduleHandler()->invokeAll('admin_menu_cache_info'); if (!isset($caches[$name])) { throw new Symfony\Component\HttpKernel\Exception\NotFoundHttpException(); } @@ -859,7 +859,7 @@ function _admin_menu_flush_cache($name = NULL) { case 'cache': // @see drupal_flush_all_caches() - foreach (module_invoke_all('cache_flush') as $bin) { + foreach (Drupal::moduleHandler()->invokeAll('cache_flush') as $bin) { cache($bin)->deleteAll(); } break; diff --git a/admin_menu.info.yml b/admin_menu.info.yml index cc4ee4b..eb31107 100644 --- a/admin_menu.info.yml +++ b/admin_menu.info.yml @@ -3,4 +3,4 @@ type: module description: 'Provides a dropdown menu to most administrative tasks and other common destinations (to users with the proper permissions).' package: Administration core: 8.x -configure: admin/config/admin/admin_menu +configure: admin_menu.form diff --git a/admin_menu.links.menu.yml b/admin_menu.links.menu.yml new file mode 100644 index 0000000..16f726a --- /dev/null +++ b/admin_menu.links.menu.yml @@ -0,0 +1,12 @@ +admin_menu.admin: + route_name: system.admin_config_development + parent: system.admin_config + title: Administration + description: 'Administration tools.' + weight: -9 +admin_menu.admin_menu: + title: 'Administration menu' + description: 'Adjust administration menu settings.' + parent: admin_menu.admin + route_name: admin_menu.form + weight: 100 diff --git a/admin_menu.map.inc b/admin_menu.map.inc index 68b9bb4..b3f90fb 100644 --- a/admin_menu.map.inc +++ b/admin_menu.map.inc @@ -34,10 +34,11 @@ function node_admin_menu_map() { */ function admin_menu_admin_menu_map() { $map = array(); - $entity_info = entity_get_info(); + $entity_info = \Drupal::entityManager()->getDefinitions(); + foreach ($entity_info as $entity_type => $info) { // @todo Core: Allow to identify... config entity types, but exclude 'block'... - if (!isset($info['config_prefix']) || $entity_type == 'block') { + if (is_a($info, 'ConfigEntityType') || $entity_type == 'block') { continue; } $entities = entity_load_multiple($entity_type); @@ -47,16 +48,18 @@ function admin_menu_admin_menu_map() { // For now, we assume that all config entities share the same URI pattern. // @todo Core: Add 'router path' to entity info. $entity = reset($entities); - $uri = $entity->uri(); - if (!isset($uri['path'])) { + $uri = $entity->url(); + if ($uri) { continue; } // We cannot use menu_get_item() here, since that returns FALSE when access // is denied for an entity, which can be bogus; e.g., in case of disabled // filter formats. // @see menu_get_item() - $original_map = explode('/', $uri['path']); - $parts = array_slice($original_map, 0, MENU_MAX_PARTS); + $original_map = explode('/', $uri); + // TODO: I'm not sure what's happened to MENU_MAX_PARTS, so I've hardcoded + // it to get this working for now + $parts = array_slice($original_map, 0, 9); $ancestors = menu_get_ancestors($parts); $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc(); $router_item['load_functions'] = unserialize($router_item['load_functions']); diff --git a/admin_menu.module b/admin_menu.module index 7c56412..135cfca 100644 --- a/admin_menu.module +++ b/admin_menu.module @@ -8,17 +8,16 @@ use Drupal\Core\Template\Attribute; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Component\Utility\UrlHelper; +use \Drupal\Core\Language\LanguageInterface; +use Drupal\Core\Routing\RouteMatchInterface; /** * Implements hook_help(). */ -function admin_menu_help($path, $arg) { - switch ($path) { - case 'admin/config/admin/admin_menu': - return '

' . t('The administration menu module provides a dropdown menu arranged for one- or two-click access to most administrative tasks and other common destinations (to users with the proper permissions). Use the settings below to customize the appearance of the menu.') . '

'; - - case 'admin/help#admin_menu': - $output = ''; +function admin_menu_help($route_name, RouteMatchInterface $route_match) { + switch ($route_name) { + case 'help.page.admin_menu': + $output = '

' . t('About') . '

'; $output .= '

' . t('The administration menu module provides a dropdown menu arranged for one- or two-click access to most administrative tasks and other common destinations (to users with the proper permissions). Administration menu also displays the number of anonymous and authenticated users, and allows modules to add their own custom menu items. Integration with the menu varies from module to module; the contributed module Devel, for instance, makes strong use of the administration menu module to provide quick access to development tools.', array('@drupal' => 'http://drupal.org/project/devel')) . '

'; $output .= '

' . t('The administration menu settings page allows you to modify some elements of the menu\'s behavior and appearance. Since the appearance of the menu is dependent on your site theme, substantial customizations require modifications to your site\'s theme and CSS files. See the advanced module README.txt file for more information on theme and CSS customizations.', array('@settings' => url('admin/config/admin/admin_menu'))) . '

'; $output .= '

' . t('The menu items displayed in the administration menu depend upon the actual permissions of the viewer. First, the administration menu is only displayed to users in roles with the Access administration menu (admin_menu module) permission. Second, a user must be a member of a role with the Access administration pages (system module) permission to view administrative links. And, third, only currently permitted links are displayed; for example, if a user is not a member of a role with the permissions Administer permissions (user module) and Administer users (user module), the User management menu item is not displayed.') . '

'; @@ -26,9 +25,10 @@ function admin_menu_help($path, $arg) { } } -/** - * Implements hook_hook_info(). - */ + +// /** +// * Implements hook_hook_info(). +// */ function admin_menu_hook_info() { $hooks = array( 'admin_menu_cache_info', @@ -43,9 +43,9 @@ function admin_menu_hook_info() { return $hooks; } -/** - * Implements hook_theme(). - */ +// /** +// * Implements hook_theme(). +// */ function admin_menu_theme() { return array( 'admin_menu_links' => array( @@ -59,76 +59,6 @@ function admin_menu_theme() { } /** - * Implements hook_menu(). - */ -function admin_menu_menu() { - // AJAX callback. - // @see http://drupal.org/project/js - $items['js/admin_menu/cache'] = array( - 'page callback' => 'admin_menu_js_cache', - 'access arguments' => array('access administration menu'), - 'type' => MENU_CALLBACK, - ); - // Module settings. - $items['admin/config/admin'] = array( - 'title' => 'Administration', - 'description' => 'Administration tools.', - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', - 'file path' => drupal_get_path('module', 'system'), - ); - $items['admin/config/admin/admin_menu'] = array( - 'title' => 'Administration menu', - 'description' => 'Adjust administration menu settings.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('admin_menu_admin_settings_form'), - 'access arguments' => array('administer site configuration'), - 'file' => 'admin_menu.inc', - ); - // Menu link callbacks. - $items['admin_menu/flush-cache'] = array( - 'page callback' => 'admin_menu_flush_cache', - 'access arguments' => array('flush caches'), - 'type' => MENU_CALLBACK, - 'file' => 'admin_menu.inc', - ); - return $items; -} - -/** - * Implements hook_menu_alter(). - */ -function admin_menu_menu_alter(&$items) { - // Flush client-side caches whenever the menu is rebuilt. - admin_menu_cache_flush(); -} - -/** - * Implements hook_menu_link_insert(). - */ -function admin_menu_menu_link_insert($link) { - // Flush all of our caches to pick up the link. - admin_menu_cache_flush(); -} - -/** - * Implements hook_menu_link_update(). - */ -function admin_menu_menu_link_update($link) { - // Flush all of our caches to pick up the link. - admin_menu_cache_flush(); -} - -/** - * Implements hook_menu_link_delete(). - */ -function admin_menu_menu_link_delete($link) { - // Flush all of our caches to pick up the link. - admin_menu_cache_flush(); -} - -/** * Implements hook_system_info_alter(). * * Indicate that the 'page_bottom' region (in which the administration menu @@ -137,7 +67,7 @@ function admin_menu_menu_link_delete($link) { * * @see toolbar_system_info_alter() */ -function admin_menu_system_info_alter(&$info, $file, $type) { +function admin_menu_system_info_alter(array &$info, \Drupal\Core\Extension\Extension $file, $type) { if ($type == 'theme') { $info['overlay_supplemental_regions'][] = 'page_bottom'; } @@ -155,7 +85,7 @@ function admin_menu_page_bottom(array &$page_bottom) { if (strpos($current_path, 'js/') === 0) { return; } - global $user; + $user = \Drupal::currentUser(); $path = drupal_get_path('module', 'admin_menu'); $page_bottom['admin_menu'] = array( @@ -171,7 +101,7 @@ function admin_menu_page_bottom(array &$page_bottom) { // @see http://drupal.org/node/1805452 $options = array(); - if ($user->uid == 1) { + if ($user->id() == 1) { $attached['library'][] = 'admin_menu/drupal.admin_menu_uid1'; } @@ -180,13 +110,13 @@ function admin_menu_page_bottom(array &$page_bottom) { // Determine whether we need to show all components and disable all caches. $complete = FALSE; - if (current_path() == 'admin/config/admin/admin_menu' && $_SERVER['REQUEST_METHOD'] == 'GET') { + if (\Drupal::request()->getRequestUri() == 'admin/config/admin/admin_menu' && $_SERVER['REQUEST_METHOD'] == 'GET') { $complete = TRUE; } // If the client supports JavaScript and we have a cached menu for the current // user, only output the hash for the client-side HTTP cache callback URL. - $cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode; + $cid = 'admin_menu:' . $user->id() . ':' . session_id() . ':' . LanguageInterface::LANGCODE_SITE_DEFAULT; if (!$complete && ($hash = admin_menu_cache_get($cid))) { $settings['hash'] = $hash; // The base path to use for cache requests depends on whether clean URLs @@ -269,18 +199,19 @@ function admin_menu_suppress($set = TRUE) { return $suppress; } -/** - * Implements hook_js(). - */ -function admin_menu_js() { - return array( - 'cache' => array( - 'callback' => 'admin_menu_js_cache', - 'includes' => array('common', 'theme', 'unicode'), - 'dependencies' => array('devel', 'filter', 'user'), - ), - ); -} +// TODO: review this as js modules hasn't been ported +// /** +// * Implements hook_js(). +// */ +// function admin_menu_js() { +// return array( +// 'cache' => array( +// 'callback' => 'admin_menu_js_cache', +// 'includes' => array('common', 'theme', 'unicode'), +// 'dependencies' => array('devel', 'filter', 'user'), +// ), +// ); +// } /** * Retrieve a client-side cache hash from cache. @@ -297,7 +228,7 @@ function admin_menu_js() { function admin_menu_cache_get($cid) { $cache = &drupal_static(__FUNCTION__, array()); - if (!variable_get('admin_menu_cache_client', TRUE)) { + if (!\Drupal::config('admin_menu.settings')->get('admin_menu_cache_client')) { return FALSE; } if (!array_key_exists($cid, $cache)) { @@ -324,7 +255,7 @@ function admin_menu_cache_get($cid) { * The cache tags for the data to set. */ function admin_menu_cache_set($cid, $data, array $tags) { - if (variable_get('admin_menu_cache_client', TRUE)) { + if (\Drupal::config('admin_menu.settings')->get('admin_menu_cache_client')) { cache('admin_menu')->set($cid, $data, CacheBackendInterface::CACHE_PERMANENT, $tags); } } @@ -442,12 +373,13 @@ function admin_menu_session_count($timestamp = 0, $anonymous = TRUE) { * page. */ function admin_menu_output($complete = FALSE) { - global $user; + $user = \Drupal::currentUser(); - $cache_server_enabled = !$complete && variable_get('admin_menu_cache_server', TRUE); - $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; - $cid = 'admin_menu:' . $user->uid . ':' . session_id() . ':' . $langcode; - $tags = array('admin_menu' => TRUE, 'user' => $user->uid, 'language' => $langcode); + $config = \Drupal::config('admin_menu.settings'); + $cache_server_enabled = !$complete && $config->get('admin_menu_cache_server'); + $langcode = LanguageInterface::LANGCODE_SITE_DEFAULT; + $cid = 'admin_menu:' . $user->id() . ':' . session_id() . ':' . $langcode; + $tags = array('admin_menu' => TRUE, 'user' => $user->id(), 'language' => $langcode); // Try to load and output administration menu from server-side cache. // @todo Duplicates the page cache? Page cache ID contains the hash that is @@ -457,33 +389,35 @@ function admin_menu_output($complete = FALSE) { // client-side HTTP cache hash check could be based on a cid lookup in // cache_page instead? (i.e., one cache to rule them all) However, // cache_page is cleared very often. - if ($cache_server_enabled) { - $cache = cache('menu')->get($cid); - if ($cache && isset($cache->data)) { - $content = $cache->data; - } - } + // if ($cache_server_enabled) { + // $cache = cache('menu')->get($cid); + // if ($cache && isset($cache->data)) { + // $content = $cache->data; + // } + // } // Rebuild the output. if (!isset($content)) { // Retrieve enabled components to display and make them available for others. - $components = variable_get('admin_menu_components', array()); - $components += array( - 'admin_menu.menu' => TRUE, - 'admin_menu.icon' => TRUE, - 'admin_menu.account' => TRUE, - ); - $content['#components'] = $components; - $content['#complete'] = $complete; + // $components = $config->get('admin_menu_components'); + // $components += array( + // 'admin_menu.menu' => TRUE, + // 'admin_menu.icon' => TRUE, + // 'admin_menu.account' => TRUE, + // ); + // $content['#components'] = $components; + // $content['#complete'] = $complete; // Add site name as CSS class for development/staging theming purposes. We // leverage the cookie domain instead of HTTP_HOST to account for many (but // not all) multi-domain setups (e.g. language-based sub-domains). - $classes = 'admin-menu-site' . drupal_strtolower(preg_replace('/[^a-zA-Z0-9-]/', '-', $GLOBALS['cookie_domain'])); + global $cookie_domain; + $classes = 'admin-menu-site' . \Drupal\Component\Utility\Unicode::strtolower(preg_replace('/[^a-zA-Z0-9-]/', '-', $cookie_domain)); + // Displace overlay. // @see Drupal.overlay.create // @see toolbar_preprocess_toolbar() - if (module_exists('overlay')) { + if (\Drupal::moduleHandler()->moduleExists('overlay')) { $classes .= ' overlay-displace-top'; } // @todo Always output container to harden JS-less support. @@ -497,7 +431,9 @@ function admin_menu_output($complete = FALSE) { // implementations (and $module.admin_menu.inc). // Add administration menu. - if (!empty($components['admin_menu.menu']) || $complete) { + // TODO: get teh componenets working again + // if (!empty($components['admin_menu.menu']) || $complete) { + if (TRUE) { $content['menu'] = admin_menu_links_menu(admin_menu_tree('admin')); $content['menu']['#theme'] = 'admin_menu_links'; $content['menu']['#wrapper_attributes']['id'] = 'admin-menu-menu'; @@ -521,7 +457,7 @@ function admin_menu_output($complete = FALSE) { // Allow modules to enhance the menu. // Uses '_output' suffix for consistency with the alter hook (see below). - foreach (module_implements('admin_menu_output_build') as $module) { + foreach (Drupal::moduleHandler()->getImplementations('admin_menu_output_build') as $module) { $function = $module . '_admin_menu_output_build'; $function($content); } @@ -529,7 +465,8 @@ function admin_menu_output($complete = FALSE) { // Allow modules to alter the output. // The '_output' suffix is required to prevent hook implementation function // name clashes with the contributed Admin module. - drupal_alter('admin_menu_output', $content); +var_dump($content); + Drupal::moduleHandler()->alter('admin_menu_output', $content); $content = drupal_render($content); @@ -596,6 +533,7 @@ function admin_menu_admin_menu_output_build(&$content) { * Implements hook_admin_menu_output_alter(). */ function admin_menu_admin_menu_output_alter(&$content) { + var_dump($content); foreach ($content['menu'] as $key => $link) { // Move local tasks on 'admin' into icon menu. if ($key == 'admin/tasks' || $key == 'admin/index') { @@ -733,7 +671,7 @@ function admin_menu_translated_menu_link_alter(&$item, $map) { // Check whether additional development output is enabled. if (!isset($access_all)) { - $access_all = variable_get('admin_menu_show_all', 0) && module_exists('devel'); + $access_all = variable_get('admin_menu_show_all', 0) && \Drupal::moduleHandler()->moduleExists('devel'); } // Prepare links that would not be displayed normally. if ($access_all && !$item['access']) { @@ -800,7 +738,7 @@ function admin_menu_cache_flush($uid = NULL) { /** * Implements hook_form_alter(). */ -function admin_menu_form_alter(&$form, &$form_state, $form_id) { +function admin_menu_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { $global_flush_ids = array( 'admin_menu_admin_settings_form' => 1, // Incorporate changed user permissions. @@ -842,7 +780,42 @@ function admin_menu_form_alter_flush_cache_submit($form, &$form_state) { * * Extends Devel module with Administration menu developer settings. */ -function admin_menu_form_devel_admin_settings_alter(&$form, &$form_state) { +function admin_menu_form_devel_admin_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { form_load_include($form_state, 'inc', 'admin_menu'); _admin_menu_form_devel_admin_settings_alter($form, $form_state); } + +// TODO: allow for the use of the client side cache. I need to find the +// equivalent of these hooks to clear the cache when menus change +// /** +// * Implements hook_menu_alter(). +// */ +// function admin_menu_menu_alter(&$items) { +// // Flush client-side caches whenever the menu is rebuilt. +// admin_menu_cache_flush(); +// } + +// /** +// * Implements hook_menu_link_insert(). +// */ +// function admin_menu_menu_link_insert($link) { +// // Flush all of our caches to pick up the link. +// admin_menu_cache_flush(); +// } + +// /** +// * Implements hook_menu_link_update(). +// */ +// function admin_menu_menu_link_update($link) { +// // Flush all of our caches to pick up the link. +// admin_menu_cache_flush(); +// } + +// /** +// * Implements hook_menu_link_delete(). +// */ +// function admin_menu_menu_link_delete($link) { +// // Flush all of our caches to pick up the link. +// admin_menu_cache_flush(); +// } + diff --git a/admin_menu.routing.yml b/admin_menu.routing.yml new file mode 100644 index 0000000..2584e66 --- /dev/null +++ b/admin_menu.routing.yml @@ -0,0 +1,7 @@ +admin_menu.form: + path: 'admin/config/development/admin_menu' + defaults: + _form: 'Drupal\admin_menu\Form\AdminMenuForm' + _title: 'Administration Menu settings' + requirements: + _permission: 'administer site configuration' diff --git a/admin_menu.services.yml b/admin_menu.services.yml index a1593d8..8be52ff 100644 --- a/admin_menu.services.yml +++ b/admin_menu.services.yml @@ -1,8 +1,7 @@ services: cache.admin_menu: - class: Drupal\Core\Cache\CacheBackendInterface + class: \Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } - factory_method: get factory: cache_factory:get arguments: [admin_menu] diff --git a/config/install/admin_menu.settings.yml b/config/install/admin_menu.settings.yml new file mode 100644 index 0000000..243f3a6 --- /dev/null +++ b/config/install/admin_menu.settings.yml @@ -0,0 +1,14 @@ +admin_menu: + admin_menu_margin_top: 1 + admin_menu_position_fixed: 1 + system_tweaks: + admin_menu_tweak_tabs: 0 + admin_menu_tweak_modules: 0 + admin_menu_tweak_permissions: 0 + performance: + admin_menu_cache_client: 0 + plugins: + admin_menu_components: + menu: 1 + icon: 1 + account: 1 diff --git a/config/schema/admin_menu.schema.yml b/config/schema/admin_menu.schema.yml new file mode 100644 index 0000000..1c2c1d8 --- /dev/null +++ b/config/schema/admin_menu.schema.yml @@ -0,0 +1,46 @@ +admin_menu.settings: + type: mapping + label: 'Administration menu' + mapping: + admin_menu: + type: mapping + mapping: + admin_menu_margin_top: + type: text + label: 'Adjust top margin:' + admin_menu_position_fixed: + type: text + label: 'Keep menu at top of page:' + system_tweaks: + type: mapping + mapping: + admin_menu_tweak_tabs: + type: text + label: 'Move local tasks into menu:' + admin_menu_tweak_modules: + type: text + label: 'Collapse module groups on the Modules page:' + admin_menu_tweak_permissions: + type: text + label: 'Collapse module groups on the Permissions page:' + performance: + type: mapping + mapping: + admin_menu_cache_client: + type: text + label: 'Cache menu in client-side browser:' + plugins: + type: mapping + mapping: + admin_menu_components: + type: mapping + mapping: + menu: + type: text + label: 'Administration menu:' + icon: + type: text + label: 'Icon menu:' + account: + type: text + label: 'Account links:' diff --git a/src/Form/AdminMenuForm.php b/src/Form/AdminMenuForm.php new file mode 100644 index 0000000..8fde6b4 --- /dev/null +++ b/src/Form/AdminMenuForm.php @@ -0,0 +1,140 @@ +config('admin_menu.settings'); + // Adjust top margin + $form['admin_menu_margin_top'] = array( + '#type' => 'checkbox', + '#title' => $this->t('Adjust top margin:'), + '#default_value' => $config->get('admin_menu.admin_menu_margin_top'), + '#description' => $this->t('Shifts the site output down by approximately 20 pixels from the top of the viewport. If disabled, absolute- or fixed-positioned page elements may be covered by the administration menu.'), + ); + // Keep menu at top of page + $form['admin_menu_position_fixed'] = array( + '#type' => 'checkbox', + '#title' => $this->t('Keep menu at top of page:'), + '#default_value' => $config->get('admin_menu.admin_menu_position_fixed'), + '#description' => $this->t('Displays the administration menu always at the top of the browser viewport (even when scrolling the page). In some browsers, this setting may result in a malformed page, an invisible cursor, non-selectable elements in forms, or other issues.'), + ); + $form['system_tweaks'] = array( + '#type' => 'details', + '#title' => t('System tweaks'), + '#open' => TRUE, + ); + $url = Url::fromRoute('system.modules_list'); + $form['system_tweaks']['admin_menu_tweak_modules'] = array( + '#type' => 'checkbox', + '#title' => t('Collapse module groups on the') . ' ' . \Drupal::l(t('Modules'), $url) . ' ' . t('page'), + '#default_value' => $config->get('admin_menu.system_tweaks.admin_menu_tweak_modules'), + ); + $url = Url::fromRoute('user.admin_permissions'); + $form['system_tweaks']['admin_menu_tweak_permissions'] = array( + '#type' => 'checkbox', + '#title' => t('Collapse module groups on the') . ' ' . \Drupal::l(t('Permissions'), $url) . ' ' . t('page'), + '#default_value' => $config->get('admin_menu.system_tweaks.admin_menu_tweak_permissions'), + ); + $form['system_tweaks']['admin_menu_tweak_tabs'] = array( + '#type' => 'checkbox', + '#title' => t('Move local tasks into menu'), + '#default_value' => $config->get('admin_menu.system_tweaks.admin_menu_tweak_tabs'), + ); + $form['performance'] = array( + '#type' => 'details', + '#title' => t('Performance'), + '#open' => TRUE, + ); + $form['performance']['admin_menu_cache_client'] = array( + '#type' => 'checkbox', + '#title' => t('Cache menu in client-side browser'), + '#default_value' => $config->get('admin_menu.performance.admin_menu_cache_client'), + '#description' => $this->t('Moves the tabs on all pages into the administration menu. Only possible for themes using the CSS classes tabs primary and tabs secondary.'), + ); + $form['plugins'] = array( + '#type' => 'details', + '#title' => t('Plugins'), + '#open' => TRUE, + '#description' => $this->t('Enabled components'), + ); + $form['plugins']['menu'] = array( + '#type' => 'checkbox', + '#title' => t('Cache menu in client-side browser'), + '#default_value' => $config->get('admin_menu.plugins.admin_menu_components.menu'), + '#description' => $this->t('Moves the tabs on all pages into the administration menu. Only possible for themes using the CSS classes tabs primary and tabs secondary.'), + ); + $form['plugins']['icon'] = array( + '#type' => 'checkbox', + '#title' => t('Cache menu in client-side browser'), + '#default_value' => $config->get('admin_menu.plugins.admin_menu_components.icon'), + '#description' => $this->t('Moves the tabs on all pages into the administration menu. Only possible for themes using the CSS classes tabs primary and tabs secondary.'), + ); + $form['plugins']['account'] = array( + '#type' => 'checkbox', + '#title' => t('Cache menu in client-side browser'), + '#default_value' => $config->get('admin_menu.plugins.admin_menu_components.account'), + '#description' => $this->t('Moves the tabs on all pages into the administration menu. Only possible for themes using the CSS classes tabs primary and tabs secondary.'), + ); + return $form; + } + + /** + * {@inheritdoc}. + */ + public function validateForm(array &$form, FormStateInterface $form_state) { + } + + + /** + * {@inheritdoc}. + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $config = $this->config('admin_menu.settings'); + $config->set('admin_menu.admin_menu_margin_top', $form_state->getValue('admin_menu_margin_top')); + $config->set('admin_menu.admin_menu_position_fixed', $form_state->getValue('admin_menu_position_fixed')); + $config->set('admin_menu.system_tweaks.admin_menu_tweak_modules', $form_state->getValue('admin_menu_tweak_modules')); + $config->set('admin_menu.system_tweaks.admin_menu_tweak_permissions', $form_state->getValue('admin_menu_tweak_permissions')); + $config->set('admin_menu.system_tweaks.admin_menu_tweak_tabs', $form_state->getValue('admin_menu_tweak_tabs')); + $config->set('admin_menu.performance.admin_menu_cache_client', $form_state->getValue('admin_menu_cache_client')); + $config->set('admin_menu.plugins.admin_menu_components.menu', $form_state->getValue('menu')); + $config->set('admin_menu.plugins.admin_menu_components.icon', $form_state->getValue('icon')); + $config->set('admin_menu.plugins.admin_menu_components.account', $form_state->getValue('account')); + $config->save(); + return parent::submitForm($form, $form_state); + } + + + /** + * {@inheritdoc}. + */ + protected function getEditableConfigNames() { + return [ + 'admin_menu.settings', + ]; + } + + +}