updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
@@ -6,8 +6,8 @@ type: module
dependencies:
- toolbar
# Information added by Drupal.org packaging script on 2016-08-30
version: '8.x-1.17'
# Information added by Drupal.org packaging script on 2017-04-06
version: '8.x-1.19'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1472585040
datestamp: 1491487686
@@ -1,5 +1,8 @@
toolbar.tree:
version: VERSION
css:
theme:
css/admin.toolbar.css: {}
js:
js/admin_toolbar.js: {}
dependencies:
- core/jquery
@@ -10,7 +10,7 @@ use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* 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');
@@ -18,7 +18,7 @@ function admin_toolbar_toolbar_alter(&$items) {
}
/**
* Implements hook_help().
* Implements hook_help().
*/
function admin_toolbar_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
@@ -35,8 +35,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.
*
@@ -61,7 +63,6 @@ function admin_toolbar_prerender_toolbar_administration_tray(array $element) {
return $element;
}
/**
* Adds toolbar-specific attributes to the menu link tree.
*
@@ -6,8 +6,8 @@ type: module
dependencies:
- admin_toolbar
# Information added by Drupal.org packaging script on 2016-08-30
version: '8.x-1.17'
# Information added by Drupal.org packaging script on 2017-04-06
version: '8.x-1.19'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1472585040
datestamp: 1491487686
@@ -28,7 +28,7 @@ function admin_toolbar_tools_toolbar() {
}
/**
* Implements hook_help().
* Implements hook_help().
*/
function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
@@ -43,7 +43,7 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match)
}
/**
* Implements hook_menu_links_discovered_alter().
* Implements hook_menu_links_discovered_alter().
*/
function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
$moduleHandler = \Drupal::moduleHandler();
@@ -70,14 +70,35 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
$content_entity_bundle = $entities['content_entity_bundle'];
$content_entity = $entities['content_entity'];
foreach ($entityTypeManager->getStorage($content_entity_bundle)->loadMultiple() as $machine_name => $bundle) {
// Normally, the edit form for the bundle would be its root link.
$content_entity_bundle_root = NULL;
if (in_array('entity.' . $content_entity_bundle . '.overview_form', $routes)) {
// Some bundles have an overview/list form that make a better root link.
$content_entity_bundle_root = 'entity.' . $content_entity_bundle . '.overview_form.' . $machine_name;
$links[$content_entity_bundle_root] = array(
'title' => $bundle->label(),
'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),
);
}
if (in_array('entity.' . $content_entity_bundle . '.edit_form', $routes)) {
$links['entity.' . $content_entity_bundle . '.edit_form.' . $machine_name] = array(
$key = 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name;
$links[$key] = array(
'title' => $bundle->label(),
'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),
);
if (empty($content_entity_bundle_root)) {
$content_entity_bundle_root = $key;
}
else {
$links[$key]['parent'] = $content_entity_bundle_root;
$links[$key]['title'] = t('Edit');
}
}
if ($moduleHandler->moduleExists('field_ui')) {
if (in_array('entity.' . $content_entity . '.field_ui_fields', $routes)) {
@@ -85,7 +106,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => t('Manage fields'),
'route_name' => 'entity.' . $content_entity . '.field_ui_fields',
'menu_name' => 'admin',
'parent' => 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name,
'parent' => $content_entity_bundle_root,
'route_parameters' => array($content_entity_bundle => $machine_name),
'weight' => 1,
);
@@ -95,7 +116,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => t('Manage form display'),
'route_name' => 'entity.entity_form_display.' . $content_entity . '.default',
'menu_name' => 'admin',
'parent' => 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name,
'parent' => $content_entity_bundle_root,
'route_parameters' => array($content_entity_bundle => $machine_name),
'weight' => 2,
);
@@ -105,7 +126,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => t('Manage display'),
'route_name' => 'entity.entity_view_display.' . $content_entity . '.default',
'menu_name' => 'admin',
'parent' => 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name,
'parent' => $content_entity_bundle_root,
'route_parameters' => array($content_entity_bundle => $machine_name),
'weight' => 3,
);
@@ -116,7 +137,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => t('Devel'),
'route_name' => 'entity.' . $content_entity_bundle . '.devel_load',
'menu_name' => 'admin',
'parent' => 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name,
'parent' => $content_entity_bundle_root,
'route_parameters' => array($content_entity_bundle => $machine_name),
'weight' => 4,
);
@@ -126,7 +147,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'title' => t('Delete'),
'route_name' => 'entity.' . $content_entity_bundle . '.delete_form',
'menu_name' => 'admin',
'parent' => 'entity.' . $content_entity_bundle . '.edit_form.' . $machine_name,
'parent' => $content_entity_bundle_root,
'route_parameters' => array($content_entity_bundle => $machine_name),
'weight' => 5,
);
@@ -153,6 +174,12 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'menu_name' => 'admin',
'parent' => 'entity.user.collection',
);
$links['admin_toolbar_tools.user.logout'] = array(
'title' => t('Logout'),
'route_name' => 'user.logout',
'parent' => 'admin_toolbar_tools.help',
'weight' => 10,
);
$links['user.role_add'] = array(
'title' => t('Add a new role'),
'route_name' => 'user.role_add',
@@ -220,16 +247,15 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'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 (\Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple() as $type) {
$links['node.add.' . $type->id()] = array(
'title' => t($type->label()),
'route_name' => 'node.add',
'menu_name' => 'admin',
'parent' => 'node.add_page',
'route_parameters' => array('node_type' => $machine_name),
'route_parameters' => array('node_type' => $type->id()),
);
}
}
@@ -265,7 +291,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'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) {
@@ -309,7 +335,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'route_name' => 'block_content.add_page',
'menu_name' => 'admin',
'parent' => 'block.admin_display',
'weight' => -100
'weight' => -100,
);
$links['entity.block_content.collection'] = array(
'title' => t('Custom block library'),
@@ -332,7 +358,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'route_name' => 'contact.form_add',
'menu_name' => 'admin',
'parent' => 'entity.contact_form.collection',
'weight' => -5
'weight' => -5,
);
}
@@ -455,9 +481,9 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'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] = array(
'title' => t($label_theme),
'route_name' => 'system.theme_settings_theme',
'menu_name' => 'admin',
@@ -472,9 +498,11 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
/**
* Return installed themes.
*
* @return array
* An array of friendly theme names, keyed by the machine name.
*/
function installedThemes() {
function admin_toolbar_tools_installed_themes() {
$all_themes = \Drupal::service('theme_handler')->listInfo();
$themes_installed = array();
foreach ($all_themes as $key_theme => $theme) {
@@ -487,11 +515,15 @@ function installedThemes() {
}
/**
* Get all links related to entity
* @param $entity_type_id
* Get all links related to entity.
*
* @param string $entity_type_id
* The machine name for the entity type.
*
* @return array
* The links for the entity type.
*/
function getLinks($entity_type_id) {
function admin_toolbar_tools_get_links($entity_type_id) {
$entity = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
// Get all links related to entity.
$links = $entity->getLinkTemplates();
@@ -5,6 +5,7 @@ namespace Drupal\admin_toolbar_tools\Controller;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\CronInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Menu\ContextualLinkManager;
@@ -14,6 +15,7 @@ use Drupal\Core\Menu\MenuLinkManager;
/**
* Class ToolbarController
*
* @package Drupal\admin_toolbar_tools\Controller
*/
class ToolbarController extends ControllerBase {
@@ -64,25 +66,31 @@ class ToolbarController extends ControllerBase {
);
}
// Reload the previous page.
/**
* Reload the previous page.
*/
public function reload_page() {
$request = \Drupal::request();
if($request->server->get('HTTP_REFERER')) {
if ($request->server->get('HTTP_REFERER')) {
return $request->server->get('HTTP_REFERER');
}
else{
else {
return '/';
}
}
// Flushes all caches.
/**
* Flushes all caches.
*/
public function flushAll() {
drupal_flush_all_caches();
drupal_set_message($this->t('All caches cleared.'));
return new RedirectResponse($this->reload_page());
}
// Flushes css and javascript caches.
/**
* Flushes css and javascript caches.
*/
public function flush_js_css() {
\Drupal::state()
->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36));
@@ -90,21 +98,27 @@ class ToolbarController extends ControllerBase {
return new RedirectResponse($this->reload_page());
}
// Flushes plugins caches.
/**
* 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());
}
// Resets all static caches.
/**
* Resets all static caches.
*/
public function flush_static() {
drupal_static_reset();
drupal_set_message($this->t('Static cache cleared.'));
return new RedirectResponse($this->reload_page());
}
// Clears all cached menu data.
/**
* Clears all cached menu data.
*/
public function flush_menu() {
menu_cache_clear_all();
$this->menuLinkManager->rebuild();
@@ -115,38 +129,53 @@ class ToolbarController extends ControllerBase {
return new RedirectResponse($this->reload_page());
}
// Links to drupal.org home page.
/**
* Links to drupal.org home page.
*/
public function drupal_org() {
$response = new RedirectResponse("https://www.drupal.org");
$response = new TrustedRedirectResponse("https://www.drupal.org");
$response->send();
return $response;
}
// Displays the administration link Development.
/**
* 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).
/**
* 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 = new TrustedRedirectResponse("https://www.drupal.org/list-changes");
$response->send();
return $response;
}
// Adds a link to the Drupal 8 documentation.
/**
* Adds a link to the Drupal 8 documentation.
*/
public function documentation() {
$response = new RedirectResponse("https://api.drupal.org/api/drupal/8");
$response = new TrustedRedirectResponse("https://api.drupal.org/api/drupal/8");
$response->send();
return $response;
}
/**
* Run the cron.
*/
public function runCron() {
$this->cron->run();
drupal_set_message($this->t('Cron ran successfully.'));
return new RedirectResponse($this->reload_page());
}
/**
* Clear the rendered cache.
*/
public function cacheRender() {
$this->cacheRender->invalidateAll();
drupal_set_message($this->t('Render cache cleared.'));
@@ -4,7 +4,6 @@ namespace Drupal\admin_toolbar_tools\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the existence of Admin Toolbar tools new links.
*
@@ -31,7 +30,6 @@ class AdminToolbarToolsAlterTest extends WebTestBase {
*/
protected function setUp() {
parent::setUp();
// Create and log in an administrative user.
$this->adminUser = $this->drupalCreateUser([
'access toolbar',
@@ -41,10 +39,11 @@ class AdminToolbarToolsAlterTest extends WebTestBase {
}
/**
* 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"');
}
}
@@ -61,6 +61,7 @@
position: absolute;
width: 200px;
box-shadow: 2px 2px 3px hsla(0, 0%, 0%, 0.4);
z-index: 1;
}
.toolbar-tray-horizontal ul li.menu-item--expanded .menu-item > ul {
@@ -0,0 +1,5 @@
(function($) {
$(document).ready(function() {
$('a.toolbar-icon').removeAttr('title');
});
})(jQuery);