Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,382 @@
Admin Toolbar 8.x-1.25, 2018-11-22
----------------------------------
Changes since 8.x-1.24:
- #3012102 by tikaszvince, Jody Lynn, adriancid, grahl, jigarius: Provider
property missing on link definition.
- #3010451 by epowelljr, adriancid: Improve the admin_toolbar module
description.
- #2958415 by adriancid, romainj, Prashant.c, harshita29: Replace usages of the
deprecated drupal_set_message() function.
- #2996485 by idebr, adriancid: Remove unused function
admin_toolbar_tools_get_links().
- #2989281 by JKerschner, adriancid: Consistently use $entityTypeManager.
- #2985106 by Eli-T, adriancid, eme: Add ability to hide Drupal.org links
exposed by admin_toolbar_tools from certain users.
- #2938884 by Spurlos, bdanin, romainj, purdy_nc, adriancid: A non-existent
route breaks the site.
Admin Toolbar 8.x-1.24, 2018-05-28
----------------------------------
Changes since 8.x-1.23:
- #2973131 by adriancid: Don't refer to Drupal in the help page.
- #2975170 by adriancid: Add composer.json file to submodules.
- #2975165 by Gamewalker, adriancid: datetime.time services is not found in
ToolbarController.
- #2971466 by recrit, adriancid, acbramley: Add media links incorrectly set to
"node.add.".
- #2972553 by dww, adriancid: Add static cache to speed up
admin_toolbar_links_access_filter_user_has_admin_role().
- #2971435 by adriancid: Module help page for Admin Toolbar Extra Tools module
doesn't show the links.
- #2971398 by adriancid: Add the docblock to the ToolbarController constructor.
- #2969686 by adriancid, Vidushi Mehta: Add a menu link to clean the twig cache.
- #2969325 by adriancid: Fix the module version in the CHANGELOG.txt.
- #2961450 by adriancid: Convert the AdminToolbarAlterTest test class to
PHPUnit.
- #2961445 by adriancid: Convert the AdminToolbarToolsAlterTest test class to
PHPUnit.
- #2959684 by adriancid: Remove recommended modules section from README.txt.
- #2959647 by adriancid: Use interfaces instead of classes to inject
dependencies.
- #2952643 by romainj, if-jds, adriancid: Add Item for Files under Content Menu.
- #2944463 by adriancid: Update the composer.json file.
Admin Toolbar 8.x-1.23, 2018-02-06
----------------------------------
Changes since 8.x-1.22:
- #2924266 by sunlix, romainj, adriancid, samerali: Add a menu link for the
media module.
- #2941184 by daniel.nitsche, adriancid: Remove unwanted comment from
admin.toolbar.css.
- #2912503 by Amsteri, m.abdulqader: Right to left language direction support.
- #2937982 by romainj, adriancid: Auto-generation of menu links conflicts with
other modules.
- #2932873 by vaplas, saravanaprasanth, adriancid: Horizontal mode only works if
the page is loaded in horizontal mode.
- #2935311 by romainj, adriancid: Use the $entityTypeManager variable instead of
the \Drupal::entityTypeManager service.
- #2935449 by adriancid: Add the release information for the 1.22 version in the
CHANGELOG.txt.
- #2932476 by romainj: toolbar.tree library should have a dependency to the
core/drupal library.
- #2931503 by K3vin_nl: Admin toolbar generates invalid class names.
Admin Toolbar 8.x-1.22, 2018-01-02
----------------------------------
Changes since 8.x-1.21:
- #2929053 by kkuhnen, eme, adriancid: admin_toolbar.js should use Drupal
behaviors.
- #2929061 by romainj, dsnopek, adriancid: admin_toolbar_links_access_filter
doesn't do anything unless admin_toolbar is enabled.
- #2928836 by eme: One extra pixel line under the admin toolbar.
- #2925501 by eme, adriancid, RumyanaRuseva: Menu does not take changes into
account (caching issue).
- #2927914 by adriancid: Parameter comment indentation must be 3 spaces.
- #2927911 by adriancid: Remove unused variables.
- #2927905 by adriancid: All dependencies must be prefixed with the project
name.
- #2925327 by Berdir, adriancid: Better check for is-link-in-admin-menu for
local task links.
- #2922046 by mikejw, adriancid, Berdir, BrianLewisDesign: Notice: Undefined
index: entity.eform_type.collection in
admin_toolbar_tools_menu_links_discovered_alter.
- #2925128 by adriancid: Create the module help page for the Admin Toolbar Links
Access Filter submodule.
Admin Toolbar 8.x-1.21, 2017-11-20
----------------------------------
Changes since 8.x-1.20:
- #2923580 by sylus, adriancid: Unsupported operand types in
ToolbarHandler::lazyBuilder().
- #2731369 by stefan.r, DuneBL, Berdir, kbasarab, joachim, adriancid: Local
tasks don't show in the toolbar.
- #2920793 by adriancid: Change the user TAKTAK by matio89 in the CHANGELOG.txt
file.
- #2873228 by smustgrave, adriancid, flocondetoile: Toolbar menu accessible and
navigable with keyboard.
- #2919775 by adriancid: Create the CHANGELOG.txt file.
- #2919772 by adriancid: Use the README.txt template.
- #2919769 by adriancid: Use the README.txt template for the admin_toolbar_tools
submodule.
- #2897309 by finne, adriancid, eme, rgpublic: admin_toolbar_tools module
makes all pages uncacheable.
- #2913299 by esod, Chi, adriancid, hudri, eme: CSS Z-Index of toolbar is
inappropriate.
- #2919390 by adriancid: Create the README.txt file for the admin toolbar links
access filter submodule.
- #2919367 by adriancid: Fix coding standard format.
- #2919346 by adriancid: Don't show menu links that you don't have access
permission for.
- #2917710: Create the .info.yml file for the admin_toolbar_links_access_filter
submodule.
- #2916064 by adriancid, eme, finne: Use in drupal.org links url parameter and
not route_name.
- #2916040 by adriancid, finne, eme: Remove unused route admin_development.
- #2915778 by finne, adriancid: Remove the _csrf_token from routes that don't
need it.
- #2909359 by adriancid, Musa.thomas: Add a menu link to clean the Views cache.
- #2910931 by adriancid: .info.yml files don't have the drupal version.
- #2759135 by Johnny vd Laar, miiimooo, romainj, chegor, adriancid, ckaotik,
bdominguez, SpadXIII, mrtndlmt: Content type, Vocabularies and Menus names are
not translated.
- #2909710 by adriancid, Musa.thomas: Fix coding standard format.
- #2910934 by adriancid, romainj: Error trying to clean the cache.
- #2910892 by adriancid: Delete the LICENSE.txt.
- #2909637 by bapi_22, Musa.thomas, adriancid: Avoid static call inside class
method.
- #2909003 by eme: fix z-index for CKEditor.
- #2504449 by robin.ingelbrecht, rwam, eme: Un-hover delay.
Admin Toolbar 8.x-1.20, 2017-09-07
----------------------------------
Changes since 8.x-1.19:
- #2887439 by romainj: Fix test.
- #2759135 by Johnny vd Laar, miiimooo, chegor, romainj: Content type,
Vocabularies and Menus names are not translated.
- #2894520 by romainj, bapi_22: Remove deprecated constant REQUEST_TIME from
code base.
- #2883098 by romainj, Alka Kumari: Admin Toolbar Extra Tools module display
theme machine names instead of labels.
- #2504449 by robin.ingelbrecht: Un-hover delay.
- #2838636 by ddrozdik, Fons Vandamme, kerby70, romainj: Issue with z-index of
dropdown in horizontal tray.
- #2838636 by Fons Vandamme, ddrozdik, romainj: Issue with z-index of dropdown
in horizontal tray.
- #2870404 by romainj: Add a link to the Webprofiler settings page.
- #2706643 by esod, romainj, Keenegan, DamienMcKenna: Use short array syntax.
Admin Toolbar 8.x-1.19, 2017-04-06
----------------------------------
Changes since 8.x-1.18:
- #2706643 by esod, romainj, Keenegan, DamienMcKenna: Use short array syntax.
- #2781745 by minakshiPh, eelkeblok, romainj, akhilavnair_zyxware: Drupal coding
standard issues found in most of the files.
- #2855720 by stefan.r, romainj: No logout link in admin toolbar anymore.
- #2841512 by Chi, romainj: User error: Redirects to external URLs are not
allowed by default.
Admin Toolbar 8.x-1.18, 2016-12-01
----------------------------------
Changes since 8.x-1.17:
- #2830677 by vaplas, romainj: z-index for sub menu.
- by romainj: Get rid of the Hello popup.
- #2805431 by marcusx: Accidentaly committed alert.
- #2630724 by squarecandy, romainj, reblutus, Hemangi Gokhale, jacoferg,
Balu Ertl, Jeff Burnz, Don Greco: Consider changes to link title parameter to
avoid tooltip visual conflict.
- #2518202 by james.williams, chegor, eme, romainj, DuneBL: Change default link
to taxonomy.
Admin Toolbar 8.x-1.17, 2016-08-19
----------------------------------
Changes since 8.x-1.16:
- #2779251 by romainj, DuneBL: Wrong integration of field_collection delete
form.
- #2776229 by Chi, romainj, mattlt: Chevron icons missing if Drupal is not in
document root.
- by romainj: CSS coding standard cleaning.
- #2781059 by mstrelan, romainj: Why is CRON in all caps?
- #2778935 by akhilavnair_zyxware, rjarraud: As per Drupal Standards each line
in documentation should not exceeds 80 characters.
- by romainj: Adds ending new line where required.
- #2776229 by Chi, rjarraud: Chevron icons missing if Drupal is not in document
root.
- by eme: Commiting again #2707611.
- #2757687 by neerajsingh: Remove usages of \Drupal::url().
- #2707747 by Balu Ertl, nevergone, eme, esod: D8 logo not rendered with smooth
antialiasing.
Admin Toolbar 8.x-1.16, 2016-07-28
----------------------------------
Changes since 8.x-1.15:
- #2723209 by andrewmacpherson, colan, mattshoaf: Enabling admin_toolbar_tools
causes Devel Settings to disappear from the main configuration page.
- #2759335 bycwells, jalpesh: fixes a mistaken link in hook_help().
- #2664564 by kolier, matio89, romainj and Michèle: auto-detect content entities
with Field UI route.
- #2735257 by colan, romainj, Balu Ertl: respect of coding standards in the
module README.txt file.
- #2735257 by colan, romainj, Balu Ertl: shortens the module README.txt
description text.
- by romainj: Fixes a problem with the link to the Admin menu overview page.
- #2735257 by Balu Ertl, colan, romainj: improves Admin Toolbar Extra Tools
description in the README.txt file.
- #2723381 by joachim, romainj: fieldable content entities are no more
hardcoded.
- #2735257 by Balu Ertl, colan, romainj: added some description details in the
README.txt files.
- by romainj: Menu link definitions updated.
- by romainj: Change routing permissions to follow Drupal default permissions
for administration pages.
- by romainj: Fixes issue #2737027.
- by romainj: fixes issue #2701825.
- by romainj: Adds the menu name for each menu item in
admin_toolbar_tools/admin_toolbar_tools.links.menu.yml file.
- #2735153 by Kionn: InvalidArgumentException: Cannot redirect to an empty URL.
в Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl().
- by matio89: correction InvalidArgumentException: Cannot redirect to an empty
URL. в Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl().
- by romainj: Add a new Render Cache shortcut on the admin menu.
- by romainj: Fixes issue #2731663 by canceling the move of the Logout menu
link.
Admin Toolbar 8.x-1.15, 2016-05-23
----------------------------------
Changes since 8.x-1.14:
- by matio89: add RTL in admin.toolbar.css.
- by romainj: Changes Devel menu item titles.
- by romainj: Fixes issue #2713899.
- by romainj: Minor code/typo cleaning.
- #2707611 by Balu Ertl: Add fine shadow under dropdown menus.
- #2707789 by esod: Fix Automated Tests.
- by romainj: Code cleaning.
- by romainj: Replace the deprecated entityManager() by entityTypeManager()
service.
- by romainj: Emptying menu cache with all link types.
- #2614962 by dbt102, seppelM, neha.gangwar, chegor: Correct text in
info.yml(s).
- by eme: Minor typo changes.
- by eme: Fix dependencies to core modules.
- by eme: Fix issue #2666964.
- by eme: Fix css background color level3.
- by eme: fix issue #2658896 and refactor and fix chevron-right.svg.
- by eme: fix Issue #2493037.
Admin Toolbar 8.x-1.14, 2016-02-08
----------------------------------
Changes since 8.x-1.13:
- by matio89: Correction differents bugs(problem white page when installing a
new module).
- #2643648 by Lord_of_Codes: Proposed README.txt file for Admin Toolbar.
- by matio89: resolving the dependecies problem(dependencies of others modules).
- by matio89: Correction route of entities.
Admin Toolbar 8.x-1.13, 2016-02-02
----------------------------------
Changes since 8.x-1.12:
- by matio89: Admin toolbar is compatible with 8.0.2.
- by matio89: Commmit dev version compatible with drupal 8.0.2.
- by matio89: New version of admin toolbar compatible with 8.0.2.
Admin Toolbar 8.x-1.12, 2016-01-15
----------------------------------
Changes since 8.x-1.11:
- by matio89: Correction AdminToolbaToolsAlterTest.
- #2493037 by mimran: Empty elements in #toolbar-bar.
- #2598136 by mimran, felribeiro: Menu items duplicated.
- #2635154 by Lukas von Blarer: Too general CSS selectors.
- by eme: Fix chevron right in local state.
Admin Toolbar 8.x-1.11, 2015-12-11
----------------------------------
Changes since 8.x-1.10:
- #2620430 by Vagelis, NarendraR: Typo.
- #2632888 by JamesK: Add dependency on node module.
- by eme: Fix admin toolbar test.
- #2552081 by jonhattan, bruvers: chevron-right.svg not found.
- by Vagelis: Minor typos.
- by eme: Refactor basic tests.
- #2613378 by chegor: Add basic test.
- #2612694 by chegor: Add new view.
- #2627918 by joe_carvajal: Version in info.yml files does Update Manager try to
update.
- by matio89: correction collapsible behaviour in vertical menu layout.
- #2582825 by Ben Coleman: Installing Admin Toolbar Tools loses anonymous user
login link.
- by matio89: Correction the login link on the site when in a logged-out state.
Admin Toolbar 8.x-1.10, 2015-08-07
----------------------------------
Changes since 8.x-1.9:
- #2546939 by jonhattan: Add dependency on toolbar module.
Admin Toolbar 8.x-1.9, 2015-07-22
---------------------------------
Changes since 8.x-1.8:
- #2537016 by matio89: Removing dependance for user & system.
- #2533420 by Dave Reid, twistor: Chase HEAD changes in toolbar.
- #2537016 by twistor: Rewrite admin_toolbar_tools.module
- by matio89: Correction all bugs and add new security features.
Admin Toolbar 8.x-1.8, 2015-06-22
---------------------------------
Changes since 8.x-1.7:
- correction not found route.
- #2493037 by bobrov1989: Empty elements in #toolbar-bar.
- by fethi: icones.
Admin Toolbar 8.x-1.7, 2015-06-22
---------------------------------
Changes since 8.x-1.6:
- correction not found route.
- #2493037 by bobrov1989: Empty elements in #toolbar-bar.
- by fethi: icones.
Admin Toolbar 8.x-1.6, 2015-06-03
---------------------------------
Changes since 8.x-1.5:
- by matio89: correction admin_toolbar.
Admin Toolbar 8.x-1.5, 2015-06-03
---------------------------------
Changes since 8.x-1.4:
- by matio89: test if module update exist or no to display install and update
module.
- by fethi: Change the colors used to match the Seven styleguide.
- by matio89: compatibility with Drupal 8 béta 11.
- by fethi: Change the colors used to match the Seven styleguide.
Admin Toolbar 8.x-1.4, 2015-05-20
---------------------------------
Changes since 8.x-1.3:
- by matio89: correction add/node.
Admin Toolbar 8.x-1.3, 2015-05-19
---------------------------------
Changes since 8.x-1.2:
- by matio89: add new functionalities.
- by matio89: add administration devel link.
- by matio89: correction reload page.
- by matio89: correction redirect to the same page.
Admin Toolbar 8.x-1.2, 2015-05-19
---------------------------------
Changes since 8.x-1.1:
- by matio89: add new functionalities.
- by matio89: add administration devel link.
- by matio89: correction reload page.
- by matio89: correction redirect to the same page.
Admin Toolbar 8.x-1.1, 2015-05-19
---------------------------------
Changes since 8.x-1.0:
- by matio89: add new functionalities.
Admin Toolbar 8.x-1.0, 2015-05-07
---------------------------------
- Initial release.

View file

@ -1,45 +1,69 @@
---SUMMARY---
CONTENTS OF THIS FILE
---------------------
Admin Toolbar intends to improve the default Drupal Toolbar to transformit into
* Introduction
* Requirements
* Recommended modules
* Installation
* Configuration
* Maintainers
INTRODUCTION
------------
Admin Toolbar intends to improve the default Drupal Toolbar to transform it into
a drop-down menu, providing a fast and full access to all administration links.
For a full description visit project page:
https://www.drupal.org/project/admin_toolbar
* For a full description of the module, visit the project page:
https://www.drupal.org/project/admin_toolbar
Bug reports, feature suggestions and latest developments:
http://drupal.org/project/issues/admin_toolbar
* To submit bug reports and feature suggestions, or to track changes:
https://www.drupal.org/project/issues/search/admin_toolbar
---REQUIREMENTS---
REQUIREMENTS
------------
No special requirements.
*None. (Other than a clean Drupal 8 installation)
RECOMMENDED MODULES
-------------------
* Admin Toolbar Extra Tools (https://www.drupal.org/project/admin_toolbar):
Provides menu links to administration pages or actions (eg. Flushing caches)
that are not generated by Drupal core.
* Admin Toolbar Links Access Filter (https://www.drupal.org/node/2474539):
Provides a workaround for the common problem that users with
'Use the administration pages and help' permission see menu links they don't
have access permission for.
INSTALLATION
------------
* Install as you would normally install a contributed Drupal module.
See: https://www.drupal.org/node/895232 for further information.
---INSTALLATION---
CONFIGURATION
-------------
No configuration is needed.
Install as usual.
Place the entirety of this directory in the /modules folder of your Drupal
installation. Navigate to Administer > Extend. Check the 'Enabled' box next
to the 'Admin toolbar' and/or 'Admin toolbar Extra Tools' and then click
the 'Save Configuration' button at the bottom.
For help regarding installation, visit:
https://www.drupal.org/documentation/install/modules-themes/modules-8
---CONTACT---
Current Maintainers:
*Wilfrid Roze (eme) - https://www.drupal.org/u/eme
*Mohamed Anis Taktak (matio89) - https://www.drupal.org/u/matio89
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.
* 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.

View file

@ -1,13 +1,15 @@
name: Admin Toolbar
# core: 8.x
description: Provides a drop-down menu interface to the core Drupal Toolbar.
description: Provides an improved drop-down menu interface to the site Toolbar.
package: Administration
type: module
dependencies:
- toolbar
# Information added by Drupal.org packaging script on 2016-12-01
version: '8.x-1.18'
type: module
# core: 8.x
dependencies:
- drupal:toolbar
# Information added by Drupal.org packaging script on 2018-11-22
version: '8.x-1.25'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1480614186
datestamp: 1542915184

View file

@ -0,0 +1,16 @@
<?php
/**
* @file
* Install, update and uninstall functions for the Admin Toolbar module.
*/
/**
* Rebuild routes to mitigate issue 2938884.
*
* @see https://www.drupal.org/project/admin_toolbar/issues/2938884
*/
function admin_toolbar_update_8001() {
// Rebuilding the route cache.
\Drupal::service("router.builder")->rebuild();
}

View file

@ -3,6 +3,8 @@ toolbar.tree:
theme:
css/admin.toolbar.css: {}
js:
js/jquery.hoverIntent.js: {}
js/admin_toolbar.js: {}
dependencies:
- core/jquery
- core/drupal

View file

@ -8,26 +8,32 @@
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\Component\Utility\Html;
/**
* Implements hook_toolbar_alter().
* Implements hook_toolbar_alter().
*/
function admin_toolbar_toolbar_alter(&$items) {
$items['administration']['tray']['toolbar_administration']['#pre_render'] = array('admin_toolbar_prerender_toolbar_administration_tray');
$items['administration']['tray']['toolbar_administration']['#pre_render'] = ['admin_toolbar_prerender_toolbar_administration_tray'];
$items['administration']['#attached']['library'][] = 'admin_toolbar/toolbar.tree';
}
/**
* Implements hook_help().
* Implements hook_help().
*/
function admin_toolbar_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.admin_toolbar':
$variables = [
':toolbar' => Url::fromRoute('help.page', ['name' => 'toolbar'])->toString(),
':automated_cron' => (\Drupal::moduleHandler()->moduleExists('automated_cron')) ? Url::fromRoute('help.page', ['name' => 'automated_cron'])->toString() : '#',
];
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar module enhances the <a href=":toolbar">Toolbar</a> module by providing fast access to all the administrative links at the top of your site. Admin Toolbar remains a very "lightweight" module by closely integrating with all Toolbar functionality. It can be used in conjunction with all the sub or complimentary modules, listed on <a href="https://www.drupal.org/project/admin_toolbar">Admin Toolbar</a>, for quick access to system commands such as Flush all caches, <a href=":automated_cron">Run cron</a>, Run Updates, etc... For more information, see <a href=":admin_toolbar_documentation">the online documentation for the Admin Toolbar module</a>.', array(':toolbar' => Url::fromRoute('help.page', array('name' => 'toolbar'))->toString(), ':automated_cron' => (\Drupal::moduleHandler()->moduleExists('automated_cron')) ? Url::fromRoute('help.page', array('name' => 'automated_cron'))->toString() : '#', ':admin_toolbar_documentation' => 'https://www.drupal.org/node/2713693')) . '</p>';
$output .= '<p>' . t('The Admin Toolbar module enhances the <a href=":toolbar">Toolbar</a> module by providing fast access to all the administrative links at the top of your site. Admin Toolbar remains a very "lightweight" module by closely integrating with all Toolbar functionality. It can be used in conjunction with all the sub modules included on Admin Toolbar, for quick access to system commands such as Flush all caches, <a href=":automated_cron">Run cron</a>, Run Updates, etc.', $variables) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar greatly improves the user experience for those who regularly interact with the Drupal Toolbar by providing fast, full access to all links in the Drupal Toolbar without having to click to get there.') . '</p>';
$output .= '<p>' . t('The Admin Toolbar greatly improves the user experience for those who regularly interact with the site Toolbar by providing fast, full access to all links in the site Toolbar without having to click to get there.') . '</p>';
return $output;
}
@ -35,8 +41,10 @@ function admin_toolbar_help($route_name, RouteMatchInterface $route_match) {
/**
* Renders the toolbar's administration tray.
*
* This is a clone of core's toolbar_prerender_toolbar_administration_tray()
* function, which uses setMaxDepth(4) instead of setTopLevelOnly()
* function, which uses setMaxDepth(4) instead of setTopLevelOnly().
*
* @param array $element
* A renderable array.
*
@ -50,18 +58,17 @@ function admin_toolbar_prerender_toolbar_administration_tray(array $element) {
$parameters = new MenuTreeParameters();
$parameters->setRoot('system.admin')->excludeRoot()->setMaxDepth(4)->onlyEnabledLinks();
$tree = $menu_tree->load(NULL, $parameters);
$manipulators = array(
array('callable' => 'menu.default_tree_manipulators:checkAccess'),
array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
array('callable' => 'toolbar_tools_menu_navigation_links'),
);
$manipulators = [
['callable' => 'menu.default_tree_manipulators:checkAccess'],
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
['callable' => 'toolbar_tools_menu_navigation_links'],
];
$tree = $menu_tree->transform($tree, $manipulators);
$element['administration_menu'] = $menu_tree->build($tree);
return $element;
}
/**
* Adds toolbar-specific attributes to the menu link tree.
*
@ -82,7 +89,8 @@ function toolbar_tools_menu_navigation_links(array $tree) {
$definition = $link->getPluginDefinition();
$element->options['attributes']['class'][] = 'toolbar-icon';
$element->options['attributes']['class'][] = 'toolbar-icon-' . strtolower(str_replace(array('.', ' ', '_'), array('-', '-', '-'), $definition['id']));
$string = strtolower(str_replace(['.', ' ', '_'], ['-', '-', '-'], $definition['id']));
$element->options['attributes']['class'][] = Html::cleanCssIdentifier('toolbar-icon-' . $string);
$element->options['attributes']['title'] = $link->getDescription();
}
return $tree;

View file

@ -0,0 +1,53 @@
CONTENTS OF THIS FILE
---------------------
* Introduction
* Requirements
* Installation
* Configuration
* Maintainers
INTRODUCTION
------------
The Admin Toolbar Links Access Filter module Provides a workaround for the
common problem that users with 'Use the administration pages and help'
permission see menu links they don't have access permission for. Once the issue
https://www.drupal.org/node/296693 be solved, this module will be deprecated.
* To know why we create this module check this issue:
https://www.drupal.org/node/2917704
* 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

View file

@ -0,0 +1,15 @@
name: Admin Toolbar Links Access Filter
description: Provides a workaround for the common problem that users with 'Use the administration pages and help' permission see menu links they don't have access permission for. Once the issue <a href='https://www.drupal.org/node/296693'>https://www.drupal.org/node/296693</a> be solved, this module will be deprecated.
package: Administration
type: module
# core: 8.x
dependencies:
- admin_toolbar:admin_toolbar
# Information added by Drupal.org packaging script on 2018-11-22
version: '8.x-1.25'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1542915184

View file

@ -0,0 +1,200 @@
<?php
/**
* @file
* This module don't show menu links that you don't have access permission for.
*/
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\user\Entity\Role;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function admin_toolbar_links_access_filter_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help.
case 'help.page.admin_toolbar_links_access_filter':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar Links Access Filter module provides a workaround for the common problem that users with <em>Use the administration pages and help</em> permission see menu links they done not have access permission for.') . '</p>';
return $output;
}
}
/**
* Implements hook_preprocess_menu().
*
* Hides links from admin menu, if user doesn't have access rights.
*/
function admin_toolbar_links_access_filter_preprocess_menu(&$variables) {
if (empty($variables['items'])) {
// Additional empty check to prevent exotic situations, where the preprocess
// function is entered even without items.
// @see https://www.drupal.org/node/2833885
return;
}
// Ensure that menu_name exists.
if (!isset($variables['menu_name'])) {
// In rare cases (for unknown reasons) menu_name may not be set.
// As fallback, we can fetch it from the first menu item.
$first_link = reset($variables['items']);
/** @var Drupal\Core\Menu\MenuLinkDefault $original_link */
// Fetch the menu_name from the original link.
$original_link = $first_link['original_link'];
$variables['menu_name'] = $original_link->getMenuName();
}
if ($variables['menu_name'] == 'admin') {
if (!admin_toolbar_links_access_filter_user_has_admin_role($variables['user'])) {
admin_toolbar_links_access_filter_filter_non_accessible_links($variables['items']);
}
}
}
/**
* Hides links from admin menu, if user doesn't have access rights.
*/
function admin_toolbar_links_access_filter_filter_non_accessible_links(array &$items) {
foreach ($items as $route => &$item) {
$route_name = $route;
$route_params = [];
if (!empty($item['original_link'])) {
/** @var \Drupal\Core\Menu\MenuLinkBase $original_link */
$original_link = $item['original_link'];
if ($original_link->getUrlObject()->isExternal()) {
// Do not filter external URL at all.
continue;
}
$route_name = $original_link->getRouteName();
$route_params = $original_link->getRouteParameters();
}
// Check, if user has access rights to the route.
if (!\Drupal::accessManager()->checkNamedRoute($route_name, $route_params)) {
unset($items[$route]);
}
else {
if (!empty($items[$route]['below'])) {
// Recursively call this function for the child items.
admin_toolbar_links_access_filter_filter_non_accessible_links($items[$route]['below']);
}
if (empty($items[$route]['below']) && \Drupal::moduleHandler()->moduleExists('admin_toolbar')) {
// Every child item has been cleared out.
// Now check, if the given route represents an overview page only,
// without having functionality on its own. In this case, we can safely
// unset this item, as there aren't any children left.
// This assumption is only valid, when the admin_toolbar module is
// installed because otherwise we won't have child items at all.
if (admin_toolbar_links_access_filter_is_overview_page($route)) {
unset($items[$route]);
}
else {
// Let's remove the expanded flag.
$items[$route]['is_expanded'] = FALSE;
}
}
}
}
}
/**
* Implements template_preprocess_admin_block_content().
*/
function admin_toolbar_links_access_filter_admin_block_content(&$variables) {
if (!admin_toolbar_links_access_filter_user_has_admin_role($variables['user'])) {
foreach ($variables['content'] as $key => &$item) {
if (isset($item['url']) && $item['url'] instanceof Url) {
/* @var \Drupal\Core\Url $url */
$url = $item['url'];
if ($url->access()) {
continue;
}
unset($variables['content'][$key]);
}
// The key is structured in the form: "ID title route",
// concatenated with spaces.
$key_parts = explode(' ', $key);
$route = end($key_parts);
// Special handling for Views pages, as they are not defined
// system routes.
// @TODO check the permission for Views + find a generic way for similar
// cases. Best way would be to get the link entity somehow to properly
// check permissions.
if (strpos($route, 'views_view:') === 0) {
continue;
}
// Check, if user has access rights to the route.
if (!\Drupal::accessManager()->checkNamedRoute($route)) {
unset($variables['content'][$key]);
}
}
}
}
/**
* Checks if the given route name is an overview page.
*
* Checks if the given route name matches a pure (admin) overview page that can
* be skipped, if there are no child items set. The typical example are routes
* having the SystemController::systemAdminMenuBlockPage() function as their
* controller callback set.
*
* @param string $route_name
* The route name to check.
*
* @return bool
* TRUE, if the given route name matches a pure admin overview page route,
* FALSE otherwise.
*/
function admin_toolbar_links_access_filter_is_overview_page($route_name) {
// @var \Drupal\Core\Routing\RouteProviderInterface $route_provider.
$route_provider = \Drupal::service('router.route_provider');
$overview_page_controllers = [
'\Drupal\system\Controller\AdminController::index',
'\Drupal\system\Controller\SystemController::overview',
'\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage',
];
try {
$route = $route_provider->getRouteByName($route_name);
$controller = $route->getDefault('_controller');
return !empty($controller) && in_array($controller, $overview_page_controllers);
}
catch (RouteNotFoundException $ex) {
}
return FALSE;
}
/**
* Checks, if the given user has admin rights.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The account to check.
*
* @return bool
* TRUE, if the given user account has at least one role with admin rights
* assigned, FALSE otherwise.
*/
function admin_toolbar_links_access_filter_user_has_admin_role(AccountInterface $account) {
static $user_has_admin_role = [];
$uid = $account->id();
if (!isset($user_has_admin_role[$uid])) {
$roles = Role::loadMultiple($account->getRoles());
foreach ($roles as $role) {
if ($role->isAdmin()) {
$user_has_admin_role[$uid] = TRUE;
break;
}
$user_has_admin_role[$uid] = FALSE;
}
}
return $user_has_admin_role[$uid];
}

View file

@ -0,0 +1,38 @@
{
"name": "drupal/admin_toolbar_links_access_filter",
"description": "Provides a workaround for the common problem that users with 'Use the administration pages and help' permission see menu links they don't have access permission for. Once the issue https://www.drupal.org/node/296693 be solved, this module will be deprecated.",
"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"
}
}

View file

@ -1,45 +1,62 @@
---SUMMARY---
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.
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 visit project page:
https://www.drupal.org/project/admin_toolbar
* For a full description of the module, visit the project page:
https://www.drupal.org/project/admin_toolbar
Bug reports, feature suggestions and latest developments:
http://drupal.org/project/issues/admin_toolbar
* To submit bug reports and feature suggestions, or to track changes:
https://www.drupal.org/project/issues/search/admin_toolbar
---REQUIREMENTS---
REQUIREMENTS
------------
*Admin Toolbar.
This module requires the following modules:
* Admin Toolbar (https://www.drupal.org/project/admin_toolbar)
---INSTALLATION---
INSTALLATION
------------
Install as usual.
Place the entirety of this directory in the /modules folder of your Drupal
installation. Navigate to Administer > Extend. Check the 'Enabled' box next
'Admin toolbar Extra Tools' and then click the 'Save Configuration' button at
the bottom.
For help regarding installation, visit:
https://www.drupal.org/documentation/install/modules-themes/modules-8
* Install as you would normally install a contributed Drupal module.
See: https://www.drupal.org/node/895232 for further information.
---CONTACT---
CONFIGURATION
-------------
Current Maintainers:
*Wilfrid Roze (eme) - https://www.drupal.org/u/eme
*Mohamed Anis Taktak (matio89) - https://www.drupal.org/u/matio89
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.
* 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.

View file

@ -1,13 +1,16 @@
name: Admin Toolbar Extra Tools
# core: 8.x
description: Adds menu links to the Admin Toolbar.
package: Administration
type: module
dependencies:
- admin_toolbar
# Information added by Drupal.org packaging script on 2016-12-01
version: '8.x-1.18'
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: 1480614186
datestamp: 1542915184

View file

@ -63,29 +63,14 @@ 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
admin_toolbar_tools.drupalorg:
title: 'Drupal.org'
weight: -5
route_name: admin_toolbar_tools.drupalorg
parent: admin_toolbar_tools.help
menu_name: admin
admin_toolbar_tools.listchanges:
title: 'Change records for Drupal core'
weight: -6
route_name: admin_toolbar_tools.listchanges
parent: admin_toolbar_tools.drupalorg
menu_name: admin
admin_toolbar_tools.doc:
title: 'D8 API documentation'
weight: -5
route_name: admin_toolbar_tools.doc
parent: admin_toolbar_tools.drupalorg
menu_name: admin

View file

@ -6,67 +6,90 @@
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* Implements hook_toolbar().
*/
function admin_toolbar_tools_toolbar() {
$items = array();
$items['admin_toolbar_tools'] = array(
$items = [];
$items['admin_toolbar_tools'] = [
'#type' => 'toolbar_item',
'tab' => array(
'tab' => [
'#type' => 'link',
'#attributes' => array(
'class' => array('toolbar-icon', 'toolbar-icon-admin-toolbar-tools-help'),
),
),
'#attached' => array('library' => array('admin_toolbar_tools/toolbar.icon'),
),
);
'#attributes' => [
'class' => ['toolbar-icon', 'toolbar-icon-admin-toolbar-tools-help'],
],
],
'#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']],
];
return $items;
}
/**
* Implements hook_help().
* 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>' . t('The Admin Toolbar Extra Tools module comes packaged with the <a href="https://www.drupal.org/project/admin_toolbar"> Admin Toolbar</a> module and adds functionality to it. The additional functionality is accessed thru extra links on the main administration <a href="https://www.drupal.org/project/toolbar">Toolbar</a>. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page. For more information, see the <a href="https://www.drupal.org/node/2713693">online documentation for Admin Toolbar</a>') . '</p>';
$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. The Admin Toolbar functionality can be further extended by installing complimentary modules. See <a href="https://www.drupal.org/project/admin_toolbar">Admin Toolbar</a> for a complete listing of these complimentary modules.') . '</p>';
$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().
* 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 = array();
$routes = [];
foreach ($routeProvider->getAllRoutes() as $route_name => $route) {
$routes[] = $route_name;
}
$entityTypes = $entityTypeManager->getDefinitions();
$content_entities = array();
$content_entities = [];
foreach ($entityTypes as $key => $entityType) {
if ($entityType->getBundleEntityType() && ($entityType->get('field_ui_base_route') != '')) {
$content_entities[$key] = array(
$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 $module_name => $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) {
@ -75,23 +98,25 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
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] = array(
'title' => $bundle->label(),
$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' => array($content_entity_bundle => $machine_name),
);
'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] = array(
'title' => $bundle->label(),
$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' => array($content_entity_bundle => $machine_name),
);
'route_parameters' => [$content_entity_bundle => $machine_name],
];
if (empty($content_entity_bundle_root)) {
$content_entity_bundle_root = $key;
}
@ -102,420 +127,551 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
}
if ($moduleHandler->moduleExists('field_ui')) {
if (in_array('entity.' . $content_entity . '.field_ui_fields', $routes)) {
$links['entity.' . $content_entity . '.field_ui_fields' . $machine_name] = array(
$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' => array($content_entity_bundle => $machine_name),
'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] = array(
$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' => array($content_entity_bundle => $machine_name),
'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] = array(
$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' => array($content_entity_bundle => $machine_name),
'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] = array(
$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' => array($content_entity_bundle => $machine_name),
'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] = array(
$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' => array($content_entity_bundle => $machine_name),
'route_parameters' => [$content_entity_bundle => $machine_name],
'weight' => 5,
);
];
}
}
}
// Add user links.
$links['user.admin_create'] = array(
$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'] = array(
];
$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'] = array(
];
$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['user.role_add'] = array(
];
$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_'] = array(
$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_'] = array(
];
$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_'] = array(
];
$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()] = array(
'title' => $role->label(),
$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' => array('user_role' => $role->id()),
);
$links['entity.user_role.edit_permissions_form.' . $role->id()] = array(
'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' => array('user_role' => $role->id()),
);
$links['entity.user_role.delete_form.' . $role->id()] = array(
'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' => array('user_role' => $role->id()),
);
'route_parameters' => ['user_role' => $role->id()],
];
if ($moduleHandler->moduleExists('devel')) {
$links['entity.user_role.devel_load.' . $role->id()] = array(
$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' => array('user_role' => $role->id()),
);
'route_parameters' => ['user_role' => $role->id()],
];
}
}
if ($moduleHandler->moduleExists('node')) {
$links['node.add_page']['parent'] = 'system.admin_content';
$links['node.type_add'] = array(
$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
);
'weight' => -5,
];
// Add node links for each content type.
foreach (node_type_get_names() as $machine_name => $label) {
$links['node.add.' . $machine_name] = array(
'title' => $label,
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',
'menu_name' => 'admin',
'parent' => 'node.add_page',
'route_parameters' => array('node_type' => $machine_name),
);
'parent' => 'admin_toolbar_tools.add_content',
'route_parameters' => ['node_type' => $type->id()],
];
}
}
if ($moduleHandler->moduleExists('field_ui')) {
$links['field_ui.entity_form_mode_add'] = array(
$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'] = array(
];
$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'] = array(
$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'] = array(
$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
);
'weight' => -50,
];
// Adds links to /admin/structure/menu.
foreach (menu_ui_get_menus() as $machine_name => $label) {
$links['entity.menu.edit_form.' . $machine_name] = array(
'title' => $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' => array('menu' => $machine_name),
);
$links['entity.menu.delete_form.' . $machine_name] = array(
'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' => array('menu' => $machine_name),
);
'route_parameters' => ['menu' => $machine_name],
];
if ($moduleHandler->moduleExists('devel')) {
$links['entity.menu.devel_load.' . $machine_name] = array(
$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' => array('menu' => $machine_name),
);
'route_parameters' => ['menu' => $machine_name],
];
}
$links['entity.menu.add_link_form.' . $machine_name] = array(
$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' => array('menu' => $machine_name),
);
'route_parameters' => ['menu' => $machine_name],
];
}
}
// If module block_content is enabled.
if ($moduleHandler->moduleExists('block_content')) {
$links['block_content.add_page'] = array(
$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'] = array(
'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'] = array(
];
$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'] = array(
$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
);
'weight' => -5,
];
}
// If module Update Manager is enabled.
if ($moduleHandler->moduleExists('update')) {
$links['update.module_update'] = array(
$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'] = array(
];
$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'] = array(
$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'] = array(
];
$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',
);
$links['admin_toolbar_tools.devel.configs_list'] = array(
];
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'] = array(
];
$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'] = array(
];
$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'] = array(
];
$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'] = array(
];
$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'] = array(
];
$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'] = array(
];
$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'] = array(
];
$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'] = array(
];
$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['views_ui.add'] = array(
$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['system.theme_settings_'] = array(
$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_'] = array(
$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_'] = array(
];
$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 = installedThemes();
$installed_themes = admin_toolbar_tools_installed_themes();
foreach ($installed_themes as $key_theme => $label_theme) {
$links['system.theme_settings_theme' . '.' . $key_theme] = array(
$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' => array(
'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 installedThemes() {
$all_themes = \Drupal::service('theme_handler')->listInfo();
$themes_installed = array();
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 (\Drupal::service('theme_handler')->hasUi($key_theme)) {
$themes_installed[$key_theme] = $theme->getName();
if ($themeHandler->hasUi($key_theme)) {
$themes_installed[$key_theme] = $themeHandler->getName($key_theme);
}
}
return $themes_installed;
}
/**
* Get all links related to entity
* @param $entity_type_id
* @return array
*/
function getLinks($entity_type_id) {
$entity = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
// Get all links related to entity.
$links = $entity->getLinkTemplates();
return $links;
}

View file

@ -6,38 +6,43 @@ admin_toolbar_tools.flush:
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.cssjs:
path: '/admin/flush/cssjs'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flush_js_css'
_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::flush_plugins'
_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::flush_static'
_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::flush_menu'
_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:
@ -46,38 +51,25 @@ admin_toolbar_tools.flush_rendercache:
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.drupalorg:
path: '/admin/drupal8'
admin_toolbar_tools.flush_views:
path: '/admin/flush/views'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::drupal_org'
_title: 'Drupal'
requirements:
_permission: 'access administration pages'
_csrf_token: 'TRUE'
admin_toolbar_tools.listchanges:
path: '/admin/drupal/list-changes'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::list_changes'
_title: 'List changes'
requirements:
_permission: 'access administration pages'
_csrf_token: 'TRUE'
admin_toolbar_tools.doc:
path: '/admin/drupal/documentation'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::documentation'
_title: 'Documentation D8'
requirements:
_permission: 'access administration pages'
_csrf_token: 'TRUE'
admin_development:
path: '/admin/development'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::development'
_title: 'Development'
_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:

View file

@ -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"
}
}

View file

@ -2,52 +2,130 @@
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 Drupal\Core\Menu\ContextualLinkManager;
use Drupal\Core\Menu\LocalActionManager;
use Drupal\Core\Menu\LocalTaskManager;
use Drupal\Core\Menu\MenuLinkManager;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\PhpStorage\PhpStorageFactory;
/**
* Class ToolbarController
* Class ToolbarController.
*
* @package Drupal\admin_toolbar_tools\Controller
*/
class ToolbarController extends ControllerBase {
/**
* The cron service.
* A cron instance.
*
* @var $cron \Drupal\Core\CronInterface
* @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;
/**
* Constructs a CronController object.
* 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
* The cron service.
* 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,
MenuLinkManager $menuLinkManager,
ContextualLinkManager $contextualLinkManager,
LocalTaskManager $localTaskLinkManager,
LocalActionManager $localActionLinkManager,
CacheBackendInterface $cacheRender) {
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;
}
/**
@ -60,97 +138,112 @@ class ToolbarController extends ControllerBase {
$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('cache.render'),
$container->get('datetime.time'),
$container->get('request_stack'),
$container->get('plugin.cache_clearer')
);
}
// Reload the previous page.
public function reload_page() {
$request = \Drupal::request();
if($request->server->get('HTTP_REFERER')) {
/**
* Reload the previous page.
*/
public function reloadPage() {
$request = $this->requestStack->getCurrentRequest();
if ($request->server->get('HTTP_REFERER')) {
return $request->server->get('HTTP_REFERER');
}
else{
else {
return '/';
}
}
// Flushes all caches.
/**
* Flushes all caches.
*/
public function flushAll() {
$this->messenger()->addMessage($this->t('All caches cleared.'));
drupal_flush_all_caches();
drupal_set_message($this->t('All caches cleared.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
// Flushes css and javascript caches.
public function flush_js_css() {
\Drupal::state()
->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36));
drupal_set_message($this->t('CSS and JavaScript cache cleared.'));
return new RedirectResponse($this->reload_page());
/**
* 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 flush_plugins() {
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
drupal_set_message($this->t('Plugins cache cleared.'));
return new RedirectResponse($this->reload_page());
/**
* 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 flush_static() {
/**
* Resets all static caches.
*/
public function flushStatic() {
drupal_static_reset();
drupal_set_message($this->t('Static cache cleared.'));
return new RedirectResponse($this->reload_page());
$this->messenger()->addMessage($this->t('Static cache cleared.'));
return new RedirectResponse($this->reloadPage());
}
// Clears all cached menu data.
public function flush_menu() {
/**
* Clears all cached menu data.
*/
public function flushMenu() {
menu_cache_clear_all();
$this->menuLinkManager->rebuild();
$this->contextualLinkManager->clearCachedDefinitions();
$this->localTaskLinkManager->clearCachedDefinitions();
$this->localActionLinkManager->clearCachedDefinitions();
drupal_set_message($this->t('Routing and links cache cleared.'));
return new RedirectResponse($this->reload_page());
$this->messenger()->addMessage($this->t('Routing and links cache cleared.'));
return new RedirectResponse($this->reloadPage());
}
// Links to drupal.org home page.
public function drupal_org() {
$response = new RedirectResponse("https://www.drupal.org");
$response->send();
return $response;
/**
* Clears all cached views data.
*/
public function flushViews() {
views_invalidate_cache();
$this->messenger()->addMessage($this->t('Views cache cleared.'));
return new RedirectResponse($this->reloadPage());
}
// Displays the administration link Development.
public function development() {
return new RedirectResponse('/admin/structure/menu/');
}
// Access to Drupal 8 changes (list changes of the different versions of drupal core).
public function list_changes() {
$response = new RedirectResponse("https://www.drupal.org/list-changes");
$response->send();
return $response;
}
// Adds a link to the Drupal 8 documentation.
public function documentation() {
$response = new RedirectResponse("https://api.drupal.org/api/drupal/8");
$response->send();
return $response;
/**
* 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();
drupal_set_message($this->t('Cron ran successfully.'));
return new RedirectResponse($this->reload_page());
$this->messenger()->addMessage($this->t('Cron ran successfully.'));
return new RedirectResponse($this->reloadPage());
}
/**
* Clear the rendered cache.
*/
public function cacheRender() {
$this->cacheRender->invalidateAll();
drupal_set_message($this->t('Render cache cleared.'));
return new RedirectResponse($this->reload_page());
$this->messenger()->addMessage($this->t('Render cache cleared.'));
return new RedirectResponse($this->reloadPage());
}
}

View file

@ -1,23 +1,26 @@
<?php
namespace Drupal\admin_toolbar_tools\Tests;
use Drupal\simpletest\WebTestBase;
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 WebTestBase {
class AdminToolbarToolsAlterTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['toolbar', 'admin_toolbar', 'admin_toolbar_tools'];
protected static $modules = [
'toolbar',
'admin_toolbar',
'admin_toolbar_tools',
];
/**
* A test user with permission to access the administrative toolbar.
@ -31,20 +34,21 @@ class AdminToolbarToolsAlterTest extends WebTestBase {
*/
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 a the hover of sub menus.
* Tests for the hover of sub menus.
*/
function testAdminToolbarTools() {
public function testAdminToolbarTools() {
// Assert that special menu items are present in the HTML.
$this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-flush"');
}
}

View file

@ -1,17 +1,35 @@
{
"name": "drupal/admin_toolbar",
"description": "Admin Toolbar improve the default Drupal Toolbar, it lets the hover of sub menus.",
"description": "Provides a drop-down menu interface to the core Drupal Toolbar.",
"type": "drupal-module",
"keywords": ["Drupal", "Toolbar"],
"homepage": "http://drupal.org/project/admin_toolbar",
"license": "GPL-2.0+",
"authors": [
{
"name": "Mohamed Anis Taktak",
"homepage": "https://www.drupal.org/u/matio89"
}
"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"
},
"license": "GPL-2.0+",
"require": { }
"issues": "https://www.drupal.org/project/issues/admin_toolbar",
"source": "http://cgit.drupalcode.org/admin_toolbar"
}
}

View file

@ -1,12 +1,17 @@
/*---------------------- menu horizontal hover---- Krout Fethi FrontEnd Developer-----*/
.toolbar-tray-horizontal .menu-item:hover {
background: #fff;
}
.toolbar-tray-horizontal .menu-item:focus {
.toolbar-tray-horizontal .menu-item a:focus {
background: #abeae4;
}
.toolbar-tray-horizontal .toolbar-menu:not(:first-child) li.menu-item--expanded > a:focus {
background-position: center right;
background-image: url('../misc/icons/0074bd/chevron-right.svg');
background-repeat: no-repeat;
}
.toolbar-tray-horizontal .menu-item--expanded .menu {
background: #fff;
width: auto;
@ -17,7 +22,7 @@
background-color: #f5f5f2;
}
.toolbar-tray-horizontal ul li.menu-item {
.toolbar-tray-horizontal ul li li.menu-item {
border-top: none transparent;
border-right: 1px solid #dddddd;
border-bottom: 1px solid #dddddd;
@ -33,20 +38,20 @@
border-top: 1px solid #dddddd;
}
.toolbar-tray-horizontal li.menu-item--expanded:hover ul ul,
.toolbar-tray-horizontal li.menu-item--expanded:hover ul ul ul,
.toolbar-tray-horizontal li.menu-item--expanded:hover ul ul ul ul,
.toolbar-tray-horizontal li.menu-item--expanded:hover ul ul ul ul ul {
.toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul,
.toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul ul,
.toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul ul ul,
.toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul ul ul ul {
display: none;
left: -999em; /* LTR */
}
/* Lists nested under hovered list items */
.toolbar-tray-horizontal li.menu-item--expanded:hover ul,
.toolbar-tray-horizontal li li.menu-item--expanded:hover ul,
.toolbar-tray-horizontal li li li.menu-item--expanded:hover ul,
.toolbar-tray-horizontal li li li li.menu-item--expanded:hover ul,
.toolbar-tray-horizontal li li li li li.menu-item--expanded:hover ul {
.toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul,
.toolbar-tray-horizontal li li.menu-item--expanded.hover-intent ul,
.toolbar-tray-horizontal li li li.menu-item--expanded.hover-intent ul,
.toolbar-tray-horizontal li li li li.menu-item--expanded.hover-intent ul,
.toolbar-tray-horizontal li li li li li.menu-item--expanded.hover-intent ul {
display: block;
left: auto; /* LTR */
}
@ -56,7 +61,7 @@
padding: 12px 15px 12px 12px;
}
.toolbar-tray-horizontal ul li.menu-item--expanded:hover ul {
.toolbar-tray-horizontal ul li.menu-item--expanded.hover-intent ul {
display: block;
position: absolute;
width: 200px;
@ -74,7 +79,7 @@
background-repeat: no-repeat;
}
.toolbar-tray-horizontal ul li.menu-item--expanded .menu-item:hover ul {
.toolbar-tray-horizontal ul li.menu-item--expanded .menu-item.hover-intent ul {
display: block;
margin: -40px 0 0 197px;
}
@ -83,6 +88,10 @@
float: none;
}
.toolbar-tray-horizontal li.hover-intent ul li {
float: none;
}
.toolbar-tray-horizontal .toolbar .level-2 > ul {
position: absolute;
padding-top: 0;
@ -95,24 +104,79 @@
display: block;
}
[dir="rtl"] .toolbar-tray-horizontal .toolbar .level-2 > ul {
[dir="rtl"] .toolbar-tray-horizontal .menu-item:hover {
background: #fff;
}
[dir="rtl"] .toolbar-tray-horizontal .menu-item a:focus {
background: #abeae4;
}
[dir="rtl"] .toolbar-tray-horizontal .toolbar-menu:not(:first-child) li.menu-item--expanded > a:focus {
background-position: center right;
background-image: url('../misc/icons/0074bd/chevron-right.svg');
background-repeat: no-repeat;
}
[dir="rtl"] .toolbar-tray-horizontal .menu-item--expanded .menu {
background: #fff;
width: auto;
height: auto;
}
[dir="rtl"] .toolbar-tray-horizontal .menu-item--expanded {
background-color: #f5f5f2;
}
[dir="rtl"] .toolbar-tray-horizontal ul li li.menu-item {
border-top: none transparent;
border-right: 1px solid #dddddd;
border-bottom: 1px solid #dddddd;
border-left: 1px solid #dddddd;
}
[dir="rtl"] .toolbar .toolbar-tray-horizontal .menu-item:last-child {
border-left: 1px solid #dddddd;
border-right: 1px solid #dddddd;
}
[dir="rtl"] .toolbar .toolbar-tray-horizontal ul ul li.menu-item:first-child {
border-top: 1px solid #dddddd;
}
[dir="rtl"] .toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul,
[dir="rtl"] .toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul ul,
[dir="rtl"] .toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul ul ul,
[dir="rtl"] .toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul ul ul ul ul {
display: none;
left: -999em; /* LTR */
}
/* Lists nested under hovered list items */
[dir="rtl"] .toolbar-tray-horizontal li.menu-item--expanded.hover-intent ul,
[dir="rtl"] .toolbar-tray-horizontal li li.menu-item--expanded.hover-intent ul,
[dir="rtl"] .toolbar-tray-horizontal li li li.menu-item--expanded.hover-intent ul,
[dir="rtl"] .toolbar-tray-horizontal li li li li.menu-item--expanded.hover-intent ul,
[dir="rtl"] .toolbar-tray-horizontal li li li li li.menu-item--expanded.hover-intent ul {
display: block;
left: auto; /* LTR */
}
[dir="rtl"] .toolbar-tray-horizontal .menu ul li a,
[dir="rtl"] .toolbar-tray-horizontal .menu ul .toolbar-icon {
padding: 12px 15px 12px 12px;
}
[dir="rtl"] .toolbar-tray-horizontal ul li.menu-item--expanded.hover-intent ul {
display: block;
position: absolute;
padding-top: 0;
top: 0;
right: 200px;
width: 200px;
box-shadow: 2px 2px 3px hsla(0, 0%, 0%, 0.4);
z-index: 1;
}
[dir="rtl"] .toolbar-tray-horizontal li:hover ul li {
float: none !important;
}
[dir="rtl"] .toolbar .toolbar-menu ul .toolbar-icon {
padding-left: 1.3333em;
}
[dir="rtl"] .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item:hover ul {
margin: -40px 197px 0 0;
[dir="rtl"] .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item > ul {
display: none;
}
[dir="rtl"] .toolbar-tray-horizontal ul li.menu-item--expanded ul li.menu-item--expanded {
@ -120,3 +184,28 @@
background-image: url('../misc/icons/0074bd/chevron-left.svg');
background-repeat: no-repeat;
}
[dir="rtl"] .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item.hover-intent ul {
display: block;
margin: -40px 197px 0 0;
}
[dir="rtl"] .toolbar-tray-horizontal li:hover ul li {
float: none;
}
[dir="rtl"] .toolbar-tray-horizontal li.hover-intent ul li {
float: none;
}
[dir="rtl"] .toolbar-tray-horizontal .toolbar .level-2 > ul {
position: absolute;
padding-top: 0;
top: 0;
left: 200px;
width: 200px;
}
[dir="rtl"] .toolbar .toolbar-tray-vertical li.open > ul.toolbar-menu.clearfix {
display: block;
}

View file

@ -1,5 +1,53 @@
(function($) {
$(document).ready(function() {
$('a.toolbar-icon').removeAttr('title');
});
})(jQuery);
(function ($, Drupal) {
Drupal.behaviors.adminToolbar = {
attach: function (context, settings) {
$('a.toolbar-icon', context).removeAttr('title');
$('.toolbar-tray li.menu-item--expanded, .toolbar-tray ul li.menu-item--expanded .menu-item', context).hoverIntent({
over: function () {
// At the current depth, we should delete all "hover-intent" classes.
// Other wise we get unwanted behaviour where menu items are expanded while already in hovering other ones.
$(this).parent().find('li').removeClass('hover-intent');
$(this).addClass('hover-intent');
},
out: function () {
$(this).removeClass('hover-intent');
},
timeout: 250
});
// Make the toolbar menu navigable with keyboard.
$('ul.toolbar-menu li.menu-item--expanded a', context).on('focusin', function () {
$('li.menu-item--expanded', context).removeClass('hover-intent');
$(this).parents('li.menu-item--expanded').addClass('hover-intent');
});
$('ul.toolbar-menu li.menu-item a', context).keydown(function (e) {
if ((e.shiftKey && (e.keyCode || e.which) == 9)) {
if ($(this).parent('.menu-item').prev().hasClass('menu-item--expanded')) {
$(this).parent('.menu-item').prev().addClass('hover-intent');
}
}
});
$('.toolbar-menu:first-child > .menu-item:not(.menu-item--expanded) a, .toolbar-tab > a', context).on('focusin', function () {
$('.menu-item--expanded').removeClass('hover-intent');
});
$('.toolbar-menu:first-child > .menu-item', context).on('hover', function () {
$(this, 'a').css("background: #fff;");
});
$('ul:not(.toolbar-menu)', context).on({
mousemove: function () {
$('li.menu-item--expanded').removeClass('hover-intent');
},
hover: function () {
$('li.menu-item--expanded').removeClass('hover-intent');
}
});
}
};
})(jQuery, Drupal);

View file

@ -0,0 +1,158 @@
/*!
* hoverIntent v1.8.1 // 2014.08.11 // jQuery v1.9.1+
* http://briancherne.github.io/jquery-hoverIntent/
*
* You may use hoverIntent under the terms of the MIT license. Basically that
* means you are free to use hoverIntent as long as this header is left intact.
* Copyright 2007, 2014 Brian Cherne
*/
/* hoverIntent is similar to jQuery's built-in "hover" method except that
* instead of firing the handlerIn function immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the event. The handlerOut function is only
* called after a matching handlerIn.
*
* // basic usage ... just like .hover()
* .hoverIntent( handlerIn, handlerOut )
* .hoverIntent( handlerInOut )
*
* // basic usage ... with event delegation!
* .hoverIntent( handlerIn, handlerOut, selector )
* .hoverIntent( handlerInOut, selector )
*
* // using a basic configuration object
* .hoverIntent( config )
*
* @param handlerIn function OR configuration object
* @param handlerOut function OR selector for delegation OR undefined
* @param selector selector OR undefined
* @author Brian Cherne <brian(at)cherne(dot)net>
*/
;(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (jQuery && !jQuery.fn.hoverIntent) {
factory(jQuery);
}
})(function($) {
'use strict';
// default configuration values
var _cfg = {
interval: 100,
sensitivity: 6,
timeout: 0
};
// counter used to generate an ID for each instance
var INSTANCE_COUNT = 0;
// current X and Y position of mouse, updated during mousemove tracking (shared across instances)
var cX, cY;
// saves the current pointer position coordinates based on the given mousemove event
var track = function(ev) {
cX = ev.pageX;
cY = ev.pageY;
};
// compares current and previous mouse positions
var compare = function(ev,$el,s,cfg) {
// compare mouse positions to see if pointer has slowed enough to trigger `over` function
if ( Math.sqrt( (s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY) ) < cfg.sensitivity ) {
$el.off(s.event,track);
delete s.timeoutId;
// set hoverIntent state as active for this element (permits `out` handler to trigger)
s.isActive = true;
// overwrite old mouseenter event coordinates with most recent pointer position
ev.pageX = cX; ev.pageY = cY;
// clear coordinate data from state object
delete s.pX; delete s.pY;
return cfg.over.apply($el[0],[ev]);
} else {
// set previous coordinates for next comparison
s.pX = cX; s.pY = cY;
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
s.timeoutId = setTimeout( function(){compare(ev, $el, s, cfg);} , cfg.interval );
}
};
// triggers given `out` function at configured `timeout` after a mouseleave and clears state
var delay = function(ev,$el,s,out) {
delete $el.data('hoverIntent')[s.id];
return out.apply($el[0],[ev]);
};
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
// instance ID, used as a key to store and retrieve state information on an element
var instanceId = INSTANCE_COUNT++;
// extend the default configuration and parse parameters
var cfg = $.extend({}, _cfg);
if ( $.isPlainObject(handlerIn) ) {
cfg = $.extend(cfg, handlerIn);
if ( !$.isFunction(cfg.out) ) {
cfg.out = cfg.over;
}
} else if ( $.isFunction(handlerOut) ) {
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
} else {
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
}
// A private function for handling mouse 'hovering'
var handleHover = function(e) {
// cloned event to pass to handlers (copy required for event object to be passed in IE)
var ev = $.extend({},e);
// the current target of the mouse event, wrapped in a jQuery object
var $el = $(this);
// read hoverIntent data from element (or initialize if not present)
var hoverIntentData = $el.data('hoverIntent');
if (!hoverIntentData) { $el.data('hoverIntent', (hoverIntentData = {})); }
// read per-instance state from element (or initialize if not present)
var state = hoverIntentData[instanceId];
if (!state) { hoverIntentData[instanceId] = state = { id: instanceId }; }
// state properties:
// id = instance ID, used to clean up data
// timeoutId = timeout ID, reused for tracking mouse position and delaying "out" handler
// isActive = plugin state, true after `over` is called just until `out` is called
// pX, pY = previously-measured pointer coordinates, updated at each polling interval
// event = string representing the namespaced event used for mouse tracking
// clear any existing timeout
if (state.timeoutId) { state.timeoutId = clearTimeout(state.timeoutId); }
// namespaced event used to register and unregister mousemove tracking
var mousemove = state.event = 'mousemove.hoverIntent.hoverIntent'+instanceId;
// handle the event, based on its type
if (e.type === 'mouseenter') {
// do nothing if already active
if (state.isActive) { return; }
// set "previous" X and Y position based on initial entry point
state.pX = ev.pageX; state.pY = ev.pageY;
// update "current" X and Y position based on mousemove
$el.off(mousemove,track).on(mousemove,track);
// start polling interval (self-calling timeout) to compare mouse coordinates over time
state.timeoutId = setTimeout( function(){compare(ev,$el,state,cfg);} , cfg.interval );
} else { // "mouseleave"
// do nothing if not already active
if (!state.isActive) { return; }
// unbind expensive mousemove event
$el.off(mousemove,track);
// if hoverIntent state is true, then call the mouseOut function after the specified delay
state.timeoutId = setTimeout( function(){delay(ev,$el,state,cfg.out);} , cfg.timeout );
}
};
// listen for mouseenter and mouseleave
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
};
});

View file

@ -1,23 +1,26 @@
<?php
namespace Drupal\admin_toolbar\Tests;
use Drupal\simpletest\WebTestBase;
namespace Drupal\Tests\admin_toolbar\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Test the existence of Admin Toolbar module.
*
* @group admin_toolbar
*/
class AdminToolbarAlterTest extends WebTestBase {
class AdminToolbarAlterTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['toolbar', 'breakpoint', 'admin_toolbar'];
protected static $modules = [
'toolbar',
'breakpoint',
'admin_toolbar',
];
/**
* A test user with permission to access the administrative toolbar.
@ -43,8 +46,9 @@ class AdminToolbarAlterTest extends WebTestBase {
/**
* Tests for a the hover of sub menus.
*/
function testAdminToolbar() {
public function testAdminToolbar() {
// Assert that expanded links are present in the HTML.
$this->assertRaw('class="toolbar-icon toolbar-icon-user-admin-index"');
}
}