Move all files to 2017/
This commit is contained in:
parent
ac7370f67f
commit
2875863330
15717 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,62 @@
|
|||
CONTENTS OF THIS FILE
|
||||
---------------------
|
||||
|
||||
* Introduction
|
||||
* Requirements
|
||||
* Recommended modules
|
||||
* Installation
|
||||
* Configuration
|
||||
* Maintainers
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
------------
|
||||
|
||||
Admin Toolbar Extra Tools provides menu links to administration pages or actions
|
||||
(eg. Flushing caches) that are not generated by Drupal core. It adds menu items
|
||||
that are not generated by Drupal core. For example there are no menu items for
|
||||
each content type by default or menu links to Manage fields on each entity
|
||||
types. That's the purpose of Admin Toolbar Extra Tools to add them.
|
||||
|
||||
* For a full description of the module, visit the project page:
|
||||
https://www.drupal.org/project/admin_toolbar
|
||||
|
||||
* To submit bug reports and feature suggestions, or to track changes:
|
||||
https://www.drupal.org/project/issues/search/admin_toolbar
|
||||
|
||||
|
||||
REQUIREMENTS
|
||||
------------
|
||||
|
||||
This module requires the following modules:
|
||||
|
||||
* Admin Toolbar (https://www.drupal.org/project/admin_toolbar)
|
||||
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
* Install as you would normally install a contributed Drupal module.
|
||||
See: https://www.drupal.org/node/895232 for further information.
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
-------------
|
||||
|
||||
No configuration is needed.
|
||||
|
||||
|
||||
MAINTAINERS
|
||||
-----------
|
||||
|
||||
Current maintainers:
|
||||
* Wilfrid Roze (eme) - https://www.drupal.org/u/eme
|
||||
* Romain Jarraud (romainj) - https://www.drupal.org/u/romainj
|
||||
* Adrian Cid Almaguer (adriancid) - https://www.drupal.org/u/adriancid
|
||||
* Mohamed Anis Taktak (matio89) - https://www.drupal.org/u/matio89
|
||||
|
||||
This project has been sponsored by:
|
||||
* emerya
|
||||
Founded in 2009, emerya is a human-sized company, dedicated to the design and
|
||||
implementation of web interfaces. Visit: http://http://emerya.fr/ for more
|
||||
information.
|
|
@ -0,0 +1,16 @@
|
|||
name: Admin Toolbar Extra Tools
|
||||
description: Adds menu links to the Admin Toolbar.
|
||||
package: Administration
|
||||
|
||||
type: module
|
||||
# core: 8.x
|
||||
|
||||
dependencies:
|
||||
- admin_toolbar:admin_toolbar
|
||||
- drupal:system (>=8.5)
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-11-22
|
||||
version: '8.x-1.25'
|
||||
core: '8.x'
|
||||
project: 'admin_toolbar'
|
||||
datestamp: 1542915184
|
|
@ -0,0 +1,4 @@
|
|||
toolbar.icon:
|
||||
css:
|
||||
theme:
|
||||
css/tools.css: {}
|
|
@ -0,0 +1,76 @@
|
|||
admin_toolbar_tools.help:
|
||||
title: 'Tools'
|
||||
route_name: <front>
|
||||
menu_name: admin
|
||||
parent: system.admin
|
||||
weight: -100
|
||||
|
||||
system.admin_index:
|
||||
title: 'Index'
|
||||
route_name: system.admin_index
|
||||
menu_name: admin
|
||||
parent: admin_toolbar_tools.help
|
||||
weight: -100
|
||||
|
||||
system.run_cron:
|
||||
title: 'Run cron'
|
||||
route_name: admin_toolbar.run.cron
|
||||
menu_name: admin
|
||||
parent: admin_toolbar_tools.help
|
||||
weight: -8
|
||||
|
||||
system.db_update:
|
||||
title: 'Run updates'
|
||||
route_name: system.db_update
|
||||
menu_name: admin
|
||||
parent: admin_toolbar_tools.help
|
||||
weight: -6
|
||||
|
||||
system.modules_uninstall:
|
||||
title: 'Uninstall module'
|
||||
route_name: system.modules_uninstall
|
||||
menu_name: admin
|
||||
parent: system.modules_list
|
||||
|
||||
admin_toolbar_tools.flush:
|
||||
title: 'Flush all caches'
|
||||
route_name: admin_toolbar_tools.flush
|
||||
weight: -9
|
||||
parent: admin_toolbar_tools.help
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.cssjs:
|
||||
title: 'Flush CSS and Javascript'
|
||||
route_name: admin_toolbar_tools.cssjs
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.plugin:
|
||||
title: 'Flush plugins cache'
|
||||
route_name: admin_toolbar_tools.plugin
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.flush_static:
|
||||
title: 'Flush static cache'
|
||||
route_name: admin_toolbar_tools.flush_static
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.flush_menu:
|
||||
title: 'Flush routing and links cache'
|
||||
route_name: admin_toolbar_tools.flush_menu
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.flush_twig:
|
||||
title: 'Flush twig cache'
|
||||
route_name: admin_toolbar_tools.flush_twig
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.flush_rendercache:
|
||||
title: 'Flush render cache'
|
||||
route_name: admin_toolbar_tools.flush_rendercache
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
|
@ -0,0 +1,677 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides extra menu links for the core drupal toolbar.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Implements hook_toolbar().
|
||||
*/
|
||||
function admin_toolbar_tools_toolbar() {
|
||||
$items = [];
|
||||
$items['admin_toolbar_tools'] = [
|
||||
'#type' => 'toolbar_item',
|
||||
'tab' => [
|
||||
'#type' => 'link',
|
||||
'#attributes' => [
|
||||
'class' => ['toolbar-icon', 'toolbar-icon-admin-toolbar-tools-help'],
|
||||
],
|
||||
],
|
||||
'#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']],
|
||||
];
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) {
|
||||
switch ($route_name) {
|
||||
case 'help.page.admin_toolbar_tools':
|
||||
$output = '';
|
||||
$output .= '<p>';
|
||||
$output .= t('The Admin Toolbar Extra Tools module comes packaged with the <a href=":admin-toolbar">Admin Toolbar</a> module and adds functionality to it. The additional functionality is accessed thru extra links on the main administration Toolbar. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page.</a>', [':admin-toolbar' => Url::fromRoute('help.page', ['name' => 'admin_toolbar'])->toString()]);
|
||||
$output .= '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<p>' . t('To use Admin Toolbar Extra Tools just install it like any other module. There is no other configuration required.') . '</p>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_links_discovered_alter().
|
||||
*/
|
||||
function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
|
||||
$moduleHandler = \Drupal::moduleHandler();
|
||||
$entityTypeManager = \Drupal::entityTypeManager();
|
||||
$routeProvider = \Drupal::service('router.route_provider');
|
||||
$routes = [];
|
||||
foreach ($routeProvider->getAllRoutes() as $route_name => $route) {
|
||||
$routes[] = $route_name;
|
||||
}
|
||||
|
||||
$entityTypes = $entityTypeManager->getDefinitions();
|
||||
$content_entities = [];
|
||||
foreach ($entityTypes as $key => $entityType) {
|
||||
if ($entityType->getBundleEntityType() && ($entityType->get('field_ui_base_route') != '')) {
|
||||
$content_entities[$key] = [
|
||||
'content_entity' => $key,
|
||||
'content_entity_bundle' => $entityType->getBundleEntityType(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Adding a menu link to clean the Views cache.
|
||||
if ($moduleHandler->moduleExists('views')) {
|
||||
$links['admin_toolbar_tools.flush_views'] = [
|
||||
'title' => t('Flush views cache'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'admin_toolbar_tools.flush_views',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_toolbar_tools.flush',
|
||||
];
|
||||
// Adding a menu link to Files.
|
||||
if ($moduleHandler->moduleExists('file') && in_array('view.files.page_1', $routes)) {
|
||||
$links['admin_toolbar_tools.view.files'] = [
|
||||
'title' => t('Files'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'view.files.page_1',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.admin_content',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Adds common links to entities.
|
||||
foreach ($content_entities as $entities) {
|
||||
$content_entity_bundle = $entities['content_entity_bundle'];
|
||||
$content_entity = $entities['content_entity'];
|
||||
foreach ($entityTypeManager->getStorage($content_entity_bundle)->loadMultiple() as $machine_name => $bundle) {
|
||||
// Normally, the edit form for the bundle would be its root link.
|
||||
$content_entity_bundle_root = NULL;
|
||||
if (in_array('entity.' . $content_entity_bundle . '.overview_form', $routes)) {
|
||||
// Some bundles have an overview/list form that make a better root link.
|
||||
$content_entity_bundle_root = 'entity.' . $content_entity_bundle . '.overview_form.' . $machine_name;
|
||||
$links[$content_entity_bundle_root] = [
|
||||
'title' => t($bundle->label()),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.' . $content_entity_bundle . '.overview_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.' . $content_entity_bundle . '.collection',
|
||||
'route_parameters' => [$content_entity_bundle => $machine_name],
|
||||
];
|
||||
}
|
||||
if (in_array('entity.' . $content_entity_bundle . '.edit_form', $routes)) {
|
||||
$key = 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name;
|
||||
$links[$key] = [
|
||||
'title' => t($bundle->label()),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.' . $content_entity_bundle . '.edit_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.' . $content_entity_bundle . '.collection',
|
||||
'route_parameters' => [$content_entity_bundle => $machine_name],
|
||||
];
|
||||
if (empty($content_entity_bundle_root)) {
|
||||
$content_entity_bundle_root = $key;
|
||||
}
|
||||
else {
|
||||
$links[$key]['parent'] = $content_entity_bundle_root;
|
||||
$links[$key]['title'] = t('Edit');
|
||||
}
|
||||
}
|
||||
if ($moduleHandler->moduleExists('field_ui')) {
|
||||
if (in_array('entity.' . $content_entity . '.field_ui_fields', $routes)) {
|
||||
$links['entity.' . $content_entity . '.field_ui_fields' . $machine_name] = [
|
||||
'title' => t('Manage fields'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.' . $content_entity . '.field_ui_fields',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => $content_entity_bundle_root,
|
||||
'route_parameters' => [$content_entity_bundle => $machine_name],
|
||||
'weight' => 1,
|
||||
];
|
||||
}
|
||||
if (in_array('entity.entity_form_display.' . $content_entity . '.default', $routes)) {
|
||||
$links['entity.entity_form_display.' . $content_entity . '.default' . $machine_name] = [
|
||||
'title' => t('Manage form display'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.entity_form_display.' . $content_entity . '.default',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => $content_entity_bundle_root,
|
||||
'route_parameters' => [$content_entity_bundle => $machine_name],
|
||||
'weight' => 2,
|
||||
];
|
||||
}
|
||||
if (in_array('entity.entity_view_display.' . $content_entity . '.default', $routes)) {
|
||||
$links['entity.entity_view_display.' . $content_entity . '.default.' . $machine_name] = [
|
||||
'title' => t('Manage display'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.entity_view_display.' . $content_entity . '.default',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => $content_entity_bundle_root,
|
||||
'route_parameters' => [$content_entity_bundle => $machine_name],
|
||||
'weight' => 3,
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($moduleHandler->moduleExists('devel') && in_array('entity.' . $content_entity_bundle . '.devel_load', $routes)) {
|
||||
$links['entity.' . $content_entity_bundle . '.devel_load.' . $machine_name] = [
|
||||
'title' => t('Devel'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.' . $content_entity_bundle . '.devel_load',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => $content_entity_bundle_root,
|
||||
'route_parameters' => [$content_entity_bundle => $machine_name],
|
||||
'weight' => 4,
|
||||
];
|
||||
}
|
||||
if (in_array('entity.' . $content_entity_bundle . '.delete_form', $routes)) {
|
||||
$links['entity.' . $content_entity_bundle . '.delete_form.' . $machine_name] = [
|
||||
'title' => t('Delete'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.' . $content_entity_bundle . '.delete_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => $content_entity_bundle_root,
|
||||
'route_parameters' => [$content_entity_bundle => $machine_name],
|
||||
'weight' => 5,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add user links.
|
||||
$links['user.admin_create'] = [
|
||||
'title' => t('Add a new user'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'user.admin_create',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user.collection',
|
||||
];
|
||||
$links['user.admin_permissions'] = [
|
||||
'title' => t('Permissions'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'user.admin_permissions',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user.collection',
|
||||
];
|
||||
$links['entity.user_role.collection'] = [
|
||||
'title' => t('Roles'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.user_role.collection',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user.collection',
|
||||
];
|
||||
$links['admin_toolbar_tools.user.logout'] = [
|
||||
'title' => t('Logout'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'user.logout',
|
||||
'parent' => 'admin_toolbar_tools.help',
|
||||
'weight' => 10,
|
||||
];
|
||||
$links['user.role_add'] = [
|
||||
'title' => t('Add a new role'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'user.role_add',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user_role.collection',
|
||||
'weight' => -5,
|
||||
];
|
||||
if ($moduleHandler->moduleExists('field_ui')) {
|
||||
$links['entity.user.field_ui_fields_'] = [
|
||||
'title' => t('Manage fields'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.user.field_ui_fields',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user.admin_form',
|
||||
];
|
||||
$links['entity.entity_form_display.user.default_'] = [
|
||||
'title' => t('Manage form display'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.entity_form_display.user.default',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user.admin_form',
|
||||
];
|
||||
$links['entity.entity_view_display.user.default_'] = [
|
||||
'title' => t('Manage display'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.entity_view_display.user.default',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user.admin_form',
|
||||
];
|
||||
}
|
||||
foreach (user_roles() as $role) {
|
||||
$links['entity.user_role.edit_form.' . $role->id()] = [
|
||||
'title' => t($role->label()),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.user_role.edit_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user_role.collection',
|
||||
'route_parameters' => ['user_role' => $role->id()],
|
||||
];
|
||||
$links['entity.user_role.edit_permissions_form.' . $role->id()] = [
|
||||
'title' => t('Edit permissions'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.user_role.edit_permissions_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user_role.edit_form.' . $role->id(),
|
||||
'route_parameters' => ['user_role' => $role->id()],
|
||||
];
|
||||
$links['entity.user_role.delete_form.' . $role->id()] = [
|
||||
'title' => t('Delete'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.user_role.delete_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user_role.edit_form.' . $role->id(),
|
||||
'route_parameters' => ['user_role' => $role->id()],
|
||||
];
|
||||
if ($moduleHandler->moduleExists('devel')) {
|
||||
$links['entity.user_role.devel_load.' . $role->id()] = [
|
||||
'title' => t('Devel'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.user_role.devel_load',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.user_role.edit_form.' . $role->id(),
|
||||
'route_parameters' => ['user_role' => $role->id()],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ($moduleHandler->moduleExists('node')) {
|
||||
$links['admin_toolbar_tools.add_content'] = $links['node.add_page'];
|
||||
$links['admin_toolbar_tools.add_content']['parent'] = 'system.admin_content';
|
||||
$links['node.type_add'] = [
|
||||
'title' => t('Add content type'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'node.type_add',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.node_type.collection',
|
||||
'weight' => -5,
|
||||
];
|
||||
// Add node links for each content type.
|
||||
foreach ($entityTypeManager->getStorage('node_type')->loadMultiple() as $type) {
|
||||
$links['node.add.' . $type->id()] = [
|
||||
'title' => t($type->label()),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'node.add',
|
||||
'parent' => 'admin_toolbar_tools.add_content',
|
||||
'route_parameters' => ['node_type' => $type->id()],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ($moduleHandler->moduleExists('field_ui')) {
|
||||
$links['field_ui.entity_form_mode_add'] = [
|
||||
'title' => t('Add new form mode'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'field_ui.entity_form_mode_add',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.entity_form_mode.collection',
|
||||
];
|
||||
$links['field_ui.entity_view_mode_add'] = [
|
||||
'title' => t('Add new view mode'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'field_ui.entity_view_mode_add',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.entity_view_mode.collection',
|
||||
];
|
||||
}
|
||||
|
||||
if ($moduleHandler->moduleExists('taxonomy')) {
|
||||
$links['entity.taxonomy_vocabulary.add_form'] = [
|
||||
'title' => t('Add vocabulary'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.taxonomy_vocabulary.add_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.taxonomy_vocabulary.collection',
|
||||
'weight' => -5,
|
||||
];
|
||||
}
|
||||
|
||||
if ($moduleHandler->moduleExists('menu_ui')) {
|
||||
$links['entity.menu.add_form'] = [
|
||||
'title' => t('Add menu'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.menu.add_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.menu.collection',
|
||||
'weight' => -50,
|
||||
];
|
||||
// Adds links to /admin/structure/menu.
|
||||
foreach (menu_ui_get_menus() as $machine_name => $label) {
|
||||
$links['entity.menu.edit_form.' . $machine_name] = [
|
||||
'title' => t($label),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.menu.edit_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.menu.collection',
|
||||
'route_parameters' => ['menu' => $machine_name],
|
||||
];
|
||||
$links['entity.menu.delete_form.' . $machine_name] = [
|
||||
'title' => t('Delete'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.menu.delete_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.menu.edit_form.' . $machine_name,
|
||||
'route_parameters' => ['menu' => $machine_name],
|
||||
];
|
||||
if ($moduleHandler->moduleExists('devel')) {
|
||||
$links['entity.menu.devel_load.' . $machine_name] = [
|
||||
'title' => t('Devel'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.menu.devel_load',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.menu.edit_form.' . $machine_name,
|
||||
'route_parameters' => ['menu' => $machine_name],
|
||||
];
|
||||
}
|
||||
$links['entity.menu.add_link_form.' . $machine_name] = [
|
||||
'title' => t('Add link'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.menu.add_link_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.menu.edit_form.' . $machine_name,
|
||||
'route_parameters' => ['menu' => $machine_name],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// If module block_content is enabled.
|
||||
if ($moduleHandler->moduleExists('block_content')) {
|
||||
$links['block_content.add_page'] = [
|
||||
'title' => t('Add custom block'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'block_content.add_page',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'block.admin_display',
|
||||
'weight' => -100,
|
||||
];
|
||||
$links['entity.block_content.collection'] = [
|
||||
'title' => t('Custom block library'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.block_content.collection',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'block.admin_display',
|
||||
];
|
||||
$links['entity.block_content_type.collection'] = [
|
||||
'title' => t('Types'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.block_content_type.collection',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'block.admin_display',
|
||||
];
|
||||
}
|
||||
|
||||
// If module Contact is enabled.
|
||||
if ($moduleHandler->moduleExists('contact')) {
|
||||
$links['contact.form_add'] = [
|
||||
'title' => t('Add contact form'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'contact.form_add',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.contact_form.collection',
|
||||
'weight' => -5,
|
||||
];
|
||||
}
|
||||
|
||||
// If module Update Manager is enabled.
|
||||
if ($moduleHandler->moduleExists('update')) {
|
||||
$links['update.module_update'] = [
|
||||
'title' => t('Update'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'update.module_update',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.modules_list',
|
||||
];
|
||||
$links['update.module_install'] = [
|
||||
'title' => t('Install new module'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'update.module_install',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.modules_list',
|
||||
];
|
||||
}
|
||||
|
||||
// If module Devel is enabled.
|
||||
if ($moduleHandler->moduleExists('devel')) {
|
||||
$links['admin_development'] = [
|
||||
'title' => t('Development'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'system.admin_config_development',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_toolbar_tools.help',
|
||||
'weight' => '-8',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.admin_settings'] = [
|
||||
'title' => t('Devel settings'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.admin_settings',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
'weight' => '-1',
|
||||
];
|
||||
if ($moduleHandler->moduleExists('webprofiler')) {
|
||||
$links['admin_toolbar_tools.devel.webprofiler'] = [
|
||||
'title' => t('Web Profiler settings'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'webprofiler.settings',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
}
|
||||
$links['admin_toolbar_tools.devel.configs_list'] = [
|
||||
'title' => t('Config editor'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.configs_list',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.reinstall'] = [
|
||||
'title' => t('Reinstall modules'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.reinstall',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.menu_rebuild'] = [
|
||||
'title' => t('Rebuild menu'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.menu_rebuild',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.state_system_page'] = [
|
||||
'title' => t('State editor'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.state_system_page',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.theme_registry'] = [
|
||||
'title' => t('Theme registry'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.theme_registry',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.entity_info_page'] = [
|
||||
'title' => t('Entity Info'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.entity_info_page',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.execute_php'] = [
|
||||
'title' => t('Execute PHP Code'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.execute_php',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.session'] = [
|
||||
'title' => t('Session viewer'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.session',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
$links['admin_toolbar_tools.devel.elements_page'] = [
|
||||
'title' => t('Form API field types'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.elements_page',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
// Menu link for the Toolbar module.
|
||||
$links['admin_toolbar_tools.toolbar.settings'] = [
|
||||
'title' => t('Toolbar settings'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'devel.toolbar.settings_form',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'devel.admin_settings',
|
||||
];
|
||||
}
|
||||
|
||||
// If module Views Ui enabled.
|
||||
if ($moduleHandler->moduleExists('views_ui')) {
|
||||
$links['admin_toolbar_tools.views_ui.add'] = [
|
||||
'title' => t('Add new view'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'views_ui.add',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.view.collection',
|
||||
'weight' => -5,
|
||||
];
|
||||
$links['admin_toolbar_tools.views_ui.field_list'] = [
|
||||
'title' => t('Used in views'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'views_ui.reports_fields',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.field_storage_config.collection',
|
||||
];
|
||||
}
|
||||
|
||||
$links['admin_toolbar_tools.system.theme_settings'] = [
|
||||
'title' => t('Settings'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'system.theme_settings',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.themes_page',
|
||||
];
|
||||
|
||||
if ($moduleHandler->moduleExists('webprofiler')) {
|
||||
$links['admin_toolbar_tools.devel.webprofiler'] = [
|
||||
'title' => t('Webprofiler settings'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'webprofiler.settings',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_development',
|
||||
];
|
||||
}
|
||||
|
||||
if ($moduleHandler->moduleExists('update')) {
|
||||
$links['update.theme_install_'] = [
|
||||
'title' => t('Install new theme'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'update.theme_install',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.themes_page',
|
||||
];
|
||||
$links['update.theme_update_'] = [
|
||||
'title' => t('Update'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'update.theme_update',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.themes_page',
|
||||
];
|
||||
// Lists installed themes.
|
||||
$installed_themes = admin_toolbar_tools_installed_themes();
|
||||
foreach ($installed_themes as $key_theme => $label_theme) {
|
||||
$links['system.theme_settings_theme.' . $key_theme] = [
|
||||
'title' => t($label_theme),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'system.theme_settings_theme',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.theme_settings_',
|
||||
'route_parameters' => [
|
||||
'theme' => $key_theme,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// If module Language enabled.
|
||||
if ($moduleHandler->moduleExists('language')) {
|
||||
$links['admin_toolbar_tools.language.negotiation'] = [
|
||||
'title' => t('Detection and selection'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'language.negotiation',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'entity.configurable_language.collection',
|
||||
];
|
||||
}
|
||||
|
||||
// If module Media enabled.
|
||||
if ($moduleHandler->moduleExists('media')) {
|
||||
$links['admin_toolbar_tools.add_media'] = [
|
||||
'title' => t('Add media'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.media.add_page',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'system.admin_content',
|
||||
];
|
||||
// Add node links for each media type.
|
||||
foreach ($entityTypeManager->getStorage('media_type')->loadMultiple() as $type) {
|
||||
$links['media.add.' . $type->id()] = [
|
||||
'title' => t($type->label()),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'entity.media.add_form',
|
||||
'parent' => 'admin_toolbar_tools.add_media',
|
||||
'route_parameters' => ['media_type' => $type->id()],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// If module Config enabled.
|
||||
if ($moduleHandler->moduleExists('config')) {
|
||||
$links['admin_toolbar_tools.config.import'] = [
|
||||
'title' => t('Import'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'config.import_full',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'config.sync',
|
||||
'weight' => 1,
|
||||
];
|
||||
$links['admin_toolbar_tools.config.export'] = [
|
||||
'title' => t('Export'),
|
||||
'provider' => 'admin_toolbar_tools',
|
||||
'route_name' => 'config.export_full',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'config.sync',
|
||||
'weight' => 2,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return installed themes.
|
||||
*
|
||||
* @return array
|
||||
* An array of friendly theme names, keyed by the machine name.
|
||||
*/
|
||||
function admin_toolbar_tools_installed_themes() {
|
||||
$themeHandler = \Drupal::service('theme_handler');
|
||||
$all_themes = $themeHandler->listInfo();
|
||||
$themes_installed = [];
|
||||
foreach ($all_themes as $key_theme => $theme) {
|
||||
if ($themeHandler->hasUi($key_theme)) {
|
||||
$themes_installed[$key_theme] = $themeHandler->getName($key_theme);
|
||||
}
|
||||
}
|
||||
|
||||
return $themes_installed;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
admin_toolbar_tools.flush:
|
||||
path: '/admin/flush'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushAll'
|
||||
_title: 'Flush all caches'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar_tools.cssjs:
|
||||
path: '/admin/flush/cssjs'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushJsCss'
|
||||
_title: 'Flush Css and Javascript'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar_tools.plugin:
|
||||
path: '/admin/flush/plugin'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushPlugins'
|
||||
_title: 'Plugin'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar_tools.flush_static:
|
||||
path: '/admin/flush/static-caches'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushStatic'
|
||||
_title: 'Static caches'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar_tools.flush_menu:
|
||||
path: '/admin/flush/menu'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushMenu'
|
||||
_title: 'Menu'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar_tools.flush_rendercache:
|
||||
path: '/admin/flush/rendercache'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::cacheRender'
|
||||
_title: 'Render cache'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar_tools.flush_views:
|
||||
path: '/admin/flush/views'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushViews'
|
||||
_title: 'Views'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar_tools.flush_twig:
|
||||
path: '/admin/flush/twig'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushTwig'
|
||||
_title: 'Twig'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
||||
|
||||
admin_toolbar.run.cron:
|
||||
path: '/run-cron'
|
||||
defaults:
|
||||
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::runCron'
|
||||
_title: 'Run cron'
|
||||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
_csrf_token: 'TRUE'
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "drupal/admin_toolbar_tools",
|
||||
"description": "Adds menu links to the Admin Toolbar.",
|
||||
"type": "drupal-module",
|
||||
"keywords": ["Drupal", "Toolbar"],
|
||||
"homepage": "http://drupal.org/project/admin_toolbar",
|
||||
"license": "GPL-2.0+",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Wilfrid Roze (eme)",
|
||||
"homepage": "https://www.drupal.org/u/eme",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Romain Jarraud (romainj)",
|
||||
"homepage": "https://www.drupal.org/u/romainj",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Adrian Cid Almaguer (adriancid)",
|
||||
"email": "adriancid@gmail.com",
|
||||
"homepage": "https://www.drupal.org/u/adriancid",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Mohamed Anis Taktak (matio89)",
|
||||
"homepage": "https://www.drupal.org/u/matio89",
|
||||
"role": "Maintainer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://www.drupal.org/project/issues/admin_toolbar",
|
||||
"source": "http://cgit.drupalcode.org/admin_toolbar"
|
||||
},
|
||||
"require": {
|
||||
"drupal/admin_toolbar": "^1",
|
||||
"drupal/core": "~8.5"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
.toolbar-icon-admin-toolbar-tools-help {
|
||||
text-indent: -9999px;
|
||||
}
|
||||
|
||||
.toolbar-icon-admin-toolbar-tools-help:before {
|
||||
background-image: url(../misc/icons/ffffff/d8-item.svg);
|
||||
padding-bottom: 0;
|
||||
padding-left: 4px;
|
||||
padding-right: 8px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.toolbar-icon-admin-toolbar-tools-help:active:before,
|
||||
.toolbar-icon-admin-toolbar-tools-help.active:before {
|
||||
background-image: url(../misc/icons/ffffff/d8-item.svg);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" preserveAspectRatio="xMinYMin" viewBox="0 0 611 646"><path fill="#2ba9e0" d="M 161.14248,607.07981 C 135.931,577.51327 120.7662,539.33875 120.7662,497.60876 c 0,-87.01545 66.15644,-158.68624 151.648,-168.60413 -14.59612,-20.95856 -23.31588,-46.40824 -23.31588,-73.72922 0,-71.85792 58.95316,-129.86822 131.7442,-129.86822 6.06592,0 11.94228,0.37426 17.62908,1.12278 C 355.44148,89.85249 312.41136,52.61362 278.48012,12.00641 295.73008,190.15417 114.1316,125.40719 46.8378,289.70733 1.91208,399.73977 42.47792,535.78328 161.14248,607.07981 Z m 143.1178,-351.8044 c 0,41.72999 34.31036,75.41339 76.39268,75.41339 42.08232,0 76.58224,-33.87053 76.58224,-75.41339 0,-41.72999 -34.31036,-75.41339 -76.39268,-75.41339 -42.08232,0 -76.58224,33.6834 -76.58224,75.41339 z m 112.97776,124.81571 c 29.57136,30.50219 47.76912,71.85792 47.76912,117.51764 0,57.82317 -29.19224,108.72253 -73.73884,139.41185 82.4586,-25.07542 150.7002,-86.26693 181.21936,-160.37041 42.27188,-102.54724 2.8434,-179.6448 -63.12348,-249.63142 2.08516,8.98224 3.22252,18.52587 3.22252,28.0695 -0.18956,59.50734 -40.37628,109.47105 -95.34868,125.00284 z m -124.35136,18.90013 c -55.16196,0 -99.89812,44.16268 -99.89812,98.61751 0,54.45483 44.73616,98.61751 99.89812,98.61751 55.16196,0 99.89812,-44.16268 99.89812,-98.61751 0,-54.45483 -44.73616,-98.61751 -99.89812,-98.61751 z" /></svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\admin_toolbar_tools\Controller;
|
||||
|
||||
use Drupal\Component\Datetime\TimeInterface;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\CronInterface;
|
||||
use Drupal\Core\Menu\ContextualLinkManagerInterface;
|
||||
use Drupal\Core\Menu\LocalActionManagerInterface;
|
||||
use Drupal\Core\Menu\LocalTaskManagerInterface;
|
||||
use Drupal\Core\Menu\MenuLinkManagerInterface;
|
||||
use Drupal\Core\Plugin\CachedDiscoveryClearerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Drupal\Core\PhpStorage\PhpStorageFactory;
|
||||
|
||||
/**
|
||||
* Class ToolbarController.
|
||||
*
|
||||
* @package Drupal\admin_toolbar_tools\Controller
|
||||
*/
|
||||
class ToolbarController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* A cron instance.
|
||||
*
|
||||
* @var \Drupal\Core\CronInterface
|
||||
*/
|
||||
protected $cron;
|
||||
|
||||
/**
|
||||
* A menu link manager instance.
|
||||
*
|
||||
* @var \Drupal\Core\Menu\MenuLinkManagerInterface
|
||||
*/
|
||||
protected $menuLinkManager;
|
||||
|
||||
/**
|
||||
* A context link manager instance.
|
||||
*
|
||||
* @var \Drupal\Core\Menu\ContextualLinkManagerInterface
|
||||
*/
|
||||
protected $contextualLinkManager;
|
||||
|
||||
/**
|
||||
* A local task manager instance.
|
||||
*
|
||||
* @var \Drupal\Core\Menu\LocalTaskManagerInterface
|
||||
*/
|
||||
protected $localTaskLinkManager;
|
||||
|
||||
/**
|
||||
* A local action manager instance.
|
||||
*
|
||||
* @var \Drupal\Core\Menu\LocalActionManagerInterface
|
||||
*/
|
||||
protected $localActionLinkManager;
|
||||
|
||||
/**
|
||||
* A cache backend interface instance.
|
||||
*
|
||||
* @var \Drupal\Core\Cache\CacheBackendInterface
|
||||
*/
|
||||
protected $cacheRender;
|
||||
|
||||
/**
|
||||
* A date time instance.
|
||||
*
|
||||
* @var \Drupal\Component\Datetime\TimeInterface
|
||||
*/
|
||||
protected $time;
|
||||
|
||||
/**
|
||||
* A request stack symfony instance.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\RequestStack
|
||||
*/
|
||||
protected $requestStack;
|
||||
|
||||
/**
|
||||
* A plugin cache clear instance.
|
||||
*
|
||||
* @var \Drupal\Core\Plugin\CachedDiscoveryClearerInterface
|
||||
*/
|
||||
protected $pluginCacheClearer;
|
||||
|
||||
/**
|
||||
* Constructs a ToolbarController object.
|
||||
*
|
||||
* @param \Drupal\Core\CronInterface $cron
|
||||
* A cron instance.
|
||||
* @param \Drupal\Core\Menu\MenuLinkManagerInterface $menuLinkManager
|
||||
* A menu link manager instance.
|
||||
* @param \Drupal\Core\Menu\ContextualLinkManagerInterface $contextualLinkManager
|
||||
* A context link manager instance.
|
||||
* @param \Drupal\Core\Menu\LocalTaskManagerInterface $localTaskLinkManager
|
||||
* A local task manager instance.
|
||||
* @param \Drupal\Core\Menu\LocalActionManagerInterface $localActionLinkManager
|
||||
* A local action manager instance.
|
||||
* @param \Drupal\Core\Cache\CacheBackendInterface $cacheRender
|
||||
* A cache backend interface instance.
|
||||
* @param \Drupal\Component\Datetime\TimeInterface $time
|
||||
* A date time instance.
|
||||
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
|
||||
* A request stack symfony instance.
|
||||
* @param \Drupal\Core\Plugin\CachedDiscoveryClearerInterface $plugin_cache_clearer
|
||||
* A plugin cache clear instance.
|
||||
*/
|
||||
public function __construct(CronInterface $cron,
|
||||
MenuLinkManagerInterface $menuLinkManager,
|
||||
ContextualLinkManagerInterface $contextualLinkManager,
|
||||
LocalTaskManagerInterface $localTaskLinkManager,
|
||||
LocalActionManagerInterface $localActionLinkManager,
|
||||
CacheBackendInterface $cacheRender,
|
||||
TimeInterface $time,
|
||||
RequestStack $request_stack,
|
||||
CachedDiscoveryClearerInterface $plugin_cache_clearer) {
|
||||
$this->cron = $cron;
|
||||
$this->menuLinkManager = $menuLinkManager;
|
||||
$this->contextualLinkManager = $contextualLinkManager;
|
||||
$this->localTaskLinkManager = $localTaskLinkManager;
|
||||
$this->localActionLinkManager = $localActionLinkManager;
|
||||
$this->cacheRender = $cacheRender;
|
||||
$this->time = $time;
|
||||
$this->requestStack = $request_stack;
|
||||
$this->pluginCacheClearer = $plugin_cache_clearer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('cron'),
|
||||
$container->get('plugin.manager.menu.link'),
|
||||
$container->get('plugin.manager.menu.contextual_link'),
|
||||
$container->get('plugin.manager.menu.local_task'),
|
||||
$container->get('plugin.manager.menu.local_action'),
|
||||
$container->get('cache.render'),
|
||||
$container->get('datetime.time'),
|
||||
$container->get('request_stack'),
|
||||
$container->get('plugin.cache_clearer')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the previous page.
|
||||
*/
|
||||
public function reloadPage() {
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
if ($request->server->get('HTTP_REFERER')) {
|
||||
return $request->server->get('HTTP_REFERER');
|
||||
}
|
||||
else {
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes all caches.
|
||||
*/
|
||||
public function flushAll() {
|
||||
$this->messenger()->addMessage($this->t('All caches cleared.'));
|
||||
drupal_flush_all_caches();
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes css and javascript caches.
|
||||
*/
|
||||
public function flushJsCss() {
|
||||
$this->state()
|
||||
->set('system.css_js_query_string', base_convert($this->time->getCurrentTime(), 10, 36));
|
||||
$this->messenger()->addMessage($this->t('CSS and JavaScript cache cleared.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes plugins caches.
|
||||
*/
|
||||
public function flushPlugins() {
|
||||
$this->pluginCacheClearer->clearCachedDefinitions();
|
||||
$this->messenger()->addMessage($this->t('Plugins cache cleared.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all static caches.
|
||||
*/
|
||||
public function flushStatic() {
|
||||
drupal_static_reset();
|
||||
$this->messenger()->addMessage($this->t('Static cache cleared.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all cached menu data.
|
||||
*/
|
||||
public function flushMenu() {
|
||||
menu_cache_clear_all();
|
||||
$this->menuLinkManager->rebuild();
|
||||
$this->contextualLinkManager->clearCachedDefinitions();
|
||||
$this->localTaskLinkManager->clearCachedDefinitions();
|
||||
$this->localActionLinkManager->clearCachedDefinitions();
|
||||
$this->messenger()->addMessage($this->t('Routing and links cache cleared.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all cached views data.
|
||||
*/
|
||||
public function flushViews() {
|
||||
views_invalidate_cache();
|
||||
$this->messenger()->addMessage($this->t('Views cache cleared.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the twig cache.
|
||||
*/
|
||||
public function flushTwig() {
|
||||
// @todo Update once Drupal 8.6 will be released.
|
||||
// @see https://www.drupal.org/node/2908461
|
||||
PhpStorageFactory::get('twig')->deleteAll();
|
||||
$this->messenger()->addMessage($this->t('Twig cache cleared.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the cron.
|
||||
*/
|
||||
public function runCron() {
|
||||
$this->cron->run();
|
||||
$this->messenger()->addMessage($this->t('Cron ran successfully.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the rendered cache.
|
||||
*/
|
||||
public function cacheRender() {
|
||||
$this->cacheRender->invalidateAll();
|
||||
$this->messenger()->addMessage($this->t('Render cache cleared.'));
|
||||
return new RedirectResponse($this->reloadPage());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\admin_toolbar_tools\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests for the existence of Admin Toolbar tools new links.
|
||||
*
|
||||
* @group admin_toolbar
|
||||
*/
|
||||
class AdminToolbarToolsAlterTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $modules = [
|
||||
'toolbar',
|
||||
'admin_toolbar',
|
||||
'admin_toolbar_tools',
|
||||
];
|
||||
|
||||
/**
|
||||
* A test user with permission to access the administrative toolbar.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Create and log in an administrative user.
|
||||
$this->adminUser = $this->drupalCreateUser([
|
||||
'access toolbar',
|
||||
'access administration pages',
|
||||
'administer site configuration',
|
||||
]);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for the hover of sub menus.
|
||||
*/
|
||||
public function testAdminToolbarTools() {
|
||||
// Assert that special menu items are present in the HTML.
|
||||
$this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-flush"');
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue