Commit f98362c4 authored by romainj's avatar romainj

Minor code/typo cleaning

parent 3993f41a
toolbar.icon: toolbar.icon:
version: VERSION
css: css:
theme: theme:
css/tools.css: {} css/tools.css: {}
\ No newline at end of file
admin_toolbar_tools.flush: admin_toolbar_tools.flush:
title: Flush all caches title: 'Flush all caches'
route_name: admin_toolbar_tools.flush route_name: admin_toolbar_tools.flush
weight: -9 weight: -9
parent: admin_toolbar_tools.help parent: admin_toolbar_tools.help
admin_toolbar_tools.cssjs: admin_toolbar_tools.cssjs:
title: CSS and Javascript title: 'CSS and Javascript'
route_name: admin_toolbar_tools.cssjs route_name: admin_toolbar_tools.cssjs
parent: admin_toolbar_tools.flush parent: admin_toolbar_tools.flush
admin_toolbar_tools.plugin: admin_toolbar_tools.plugin:
title: Plugins title: 'Plugins'
route_name: admin_toolbar_tools.plugin route_name: admin_toolbar_tools.plugin
parent: admin_toolbar_tools.flush parent: admin_toolbar_tools.flush
admin_toolbar_tools.flush_static: admin_toolbar_tools.flush_static:
title: Static caches title: 'Static caches'
route_name: admin_toolbar_tools.flush_static route_name: admin_toolbar_tools.flush_static
parent: admin_toolbar_tools.flush parent: admin_toolbar_tools.flush
admin_toolbar_tools.flush_menu: admin_toolbar_tools.flush_menu:
...@@ -20,17 +20,17 @@ admin_toolbar_tools.flush_menu: ...@@ -20,17 +20,17 @@ admin_toolbar_tools.flush_menu:
route_name: admin_toolbar_tools.flush_menu route_name: admin_toolbar_tools.flush_menu
parent: admin_toolbar_tools.flush parent: admin_toolbar_tools.flush
admin_toolbar_tools.drupalorg: admin_toolbar_tools.drupalorg:
title: Drupal.org title: 'Drupal.org'
weight: -5 weight: -5
route_name: admin_toolbar_tools.drupalorg route_name: admin_toolbar_tools.drupalorg
parent: admin_toolbar_tools.help parent: admin_toolbar_tools.help
admin_toolbar_tools.listchanges: admin_toolbar_tools.listchanges:
title: List changes D8 title: 'Change records for Drupal core'
weight: -6 weight: -6
route_name: admin_toolbar_tools.listchanges route_name: admin_toolbar_tools.listchanges
parent: admin_toolbar_tools.drupalorg parent: admin_toolbar_tools.drupalorg
admin_toolbar_tools.doc: admin_toolbar_tools.doc:
title: Documentation D8 title: 'D8 API documentation'
weight: -5 weight: -5
route_name: admin_toolbar_tools.doc route_name: admin_toolbar_tools.doc
parent: admin_toolbar_tools.drupalorg parent: admin_toolbar_tools.drupalorg
...@@ -36,7 +36,7 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) ...@@ -36,7 +36,7 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match)
case 'help.page.admin_toolbar_tools': case 'help.page.admin_toolbar_tools':
$output = ''; $output = '';
$output .= '<h3>' . t('About') . '</h3>'; $output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar Extra Tools module allows you to to add more fonctionalities to the default toolbar like flush caches, runnig cron.') . '</p>'; $output .= '<p>' . t('The Admin Toolbar Extra Tools module allows you to to add more functionalities to the default toolbar like flushing caches, running cron.') . '</p>';
return $output; return $output;
} }
...@@ -47,6 +47,7 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) ...@@ -47,6 +47,7 @@ function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match)
*/ */
function admin_toolbar_tools_menu_links_discovered_alter(&$links) { function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
$moduleHandler = \Drupal::moduleHandler(); $moduleHandler = \Drupal::moduleHandler();
$links['admin_toolbar_tools.help'] = array( $links['admin_toolbar_tools.help'] = array(
'title' => t('Tools'), 'title' => t('Tools'),
'route_name' => '<front>', 'route_name' => '<front>',
...@@ -73,7 +74,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) { ...@@ -73,7 +74,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'weight' => -6 'weight' => -6
); );
$links['system.modules_uninstall'] = array( $links['system.modules_uninstall'] = array(
'title' => t('Uninstall'), 'title' => t('Uninstall module'),
'route_name' => 'system.modules_uninstall', 'route_name' => 'system.modules_uninstall',
'parent' => 'system.modules_list', 'parent' => 'system.modules_list',
); );
...@@ -102,10 +103,10 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) { ...@@ -102,10 +103,10 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
); );
/** /**
* Add common links to entities if parent module exists. * Add common links to entities if parent module exists.
* The common links for entities are : * The common links for entities are:
* - Editing entity, Deleting entity,manage fields for entity * - Editing entity, Deleting entity, manage fields for entity
* manage form display for an entity, entity view display * manage form display for an entity, entity view display
* and others links relating to entity * and others links related to entity.
*/ */
foreach ($content_entities as $module_name => $entities) { foreach ($content_entities as $module_name => $entities) {
if ($moduleHandler->moduleExists($module_name)) { if ($moduleHandler->moduleExists($module_name)) {
...@@ -173,7 +174,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) { ...@@ -173,7 +174,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'route_name' => 'entity.user_role.collection', 'route_name' => 'entity.user_role.collection',
'parent' => 'entity.user.collection', 'parent' => 'entity.user.collection',
); );
$links['user.logoutt'] = array( $links['user.logout'] = array(
'title' => t('Logout'), 'title' => t('Logout'),
'route_name' => 'user.logout', 'route_name' => 'user.logout',
'parent' => 'admin_toolbar_tools.help', 'parent' => 'admin_toolbar_tools.help',
...@@ -332,7 +333,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) { ...@@ -332,7 +333,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
'parent' => 'block.admin_display', 'parent' => 'block.admin_display',
); );
} }
// If module contact is enabled. // If module Contact is enabled.
if ($moduleHandler->moduleExists('contact')) { if ($moduleHandler->moduleExists('contact')) {
$links['contact.form_add'] = array( $links['contact.form_add'] = array(
'title' => t('Add contact form'), 'title' => t('Add contact form'),
......
<?php <?php
/** /**
* @file * @file
* Contains \Drupal\admin_toolbar_tools\Controller\ToolbarController. * Contains \Drupal\admin_toolbar_tools\Controller\ToolbarController.
...@@ -7,7 +8,6 @@ ...@@ -7,7 +8,6 @@
namespace Drupal\admin_toolbar_tools\Controller; namespace Drupal\admin_toolbar_tools\Controller;
//Use the necessary classes
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\CronInterface; use Drupal\Core\CronInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -22,10 +22,11 @@ use Drupal\Core\Menu\MenuLinkManager; ...@@ -22,10 +22,11 @@ use Drupal\Core\Menu\MenuLinkManager;
* @package Drupal\admin_toolbar_tools\Controller * @package Drupal\admin_toolbar_tools\Controller
*/ */
class ToolbarController extends ControllerBase { class ToolbarController extends ControllerBase {
/** /**
* The cron service. * The cron service.
* *
* @var \Drupal\Core\CronInterface * @var $cron \Drupal\Core\CronInterface
*/ */
protected $cron; protected $cron;
...@@ -64,20 +65,21 @@ class ToolbarController extends ControllerBase { ...@@ -64,20 +65,21 @@ class ToolbarController extends ControllerBase {
$container->get('plugin.manager.menu.local_action') $container->get('plugin.manager.menu.local_action')
); );
} }
//Reload the previous page.
// Reload the previous page.
public function reload_page() { public function reload_page() {
$request = \Drupal::request(); $request = \Drupal::request();
return $request->server->get('HTTP_REFERER'); return $request->server->get('HTTP_REFERER');
} }
//Flush all caches. // Flushes all caches.
public function flushAll() { public function flushAll() {
drupal_flush_all_caches(); drupal_flush_all_caches();
drupal_set_message($this->t('All cache cleared.')); drupal_set_message($this->t('All cache cleared.'));
return new RedirectResponse($this->reload_page()); return new RedirectResponse($this->reload_page());
} }
//This function flush css and javascript caches. // Flushes css and javascript caches.
public function flush_js_css() { public function flush_js_css() {
\Drupal::state() \Drupal::state()
->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); ->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36));
...@@ -85,22 +87,21 @@ class ToolbarController extends ControllerBase { ...@@ -85,22 +87,21 @@ class ToolbarController extends ControllerBase {
return new RedirectResponse($this->reload_page()); return new RedirectResponse($this->reload_page());
} }
//This function flush plugins caches. // Flushes plugins caches.
public function flush_plugins() { public function flush_plugins() {
// Clear all plugin caches.
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
drupal_set_message($this->t('Plugin cache cleared.')); drupal_set_message($this->t('Plugin cache cleared.'));
return new RedirectResponse($this->reload_page()); return new RedirectResponse($this->reload_page());
} }
// Reset all static caches. // Resets all static caches.
public function flush_static() { public function flush_static() {
drupal_static_reset(); drupal_static_reset();
drupal_set_message($this->t('All static caches cleared.')); drupal_set_message($this->t('All static caches cleared.'));
return new RedirectResponse($this->reload_page()); return new RedirectResponse($this->reload_page());
} }
// Clears all cached menu data. // Clears all cached menu data.
public function flush_menu() { public function flush_menu() {
menu_cache_clear_all(); menu_cache_clear_all();
$this->menuLinkManager->rebuild(); $this->menuLinkManager->rebuild();
...@@ -111,26 +112,26 @@ class ToolbarController extends ControllerBase { ...@@ -111,26 +112,26 @@ class ToolbarController extends ControllerBase {
return new RedirectResponse($this->reload_page()); return new RedirectResponse($this->reload_page());
} }
// this function allow to access in documentation via admin_toolbar module // Links to drupal.org home page.
public function drupal_org() { public function drupal_org() {
$response = new RedirectResponse("https://www.drupal.org"); $response = new RedirectResponse("https://www.drupal.org");
$response->send(); $response->send();
return $response; return $response;
} }
//This function display the administration link Development // Displays the administration link Development.
public function development() { public function development() {
return new RedirectResponse('/admin/structure/menu/'); return new RedirectResponse('/admin/structure/menu/');
} }
// this function allow to access in documentation(list changes of the different versions of drupal core) via admin_toolbar module. // Access to Drupal 8 changes (list changes of the different versions of drupal core).
public function list_changes() { public function list_changes() {
$response = new RedirectResponse("https://www.drupal.org/list-changes"); $response = new RedirectResponse("https://www.drupal.org/list-changes");
$response->send(); $response->send();
return $response; return $response;
} }
//this function allow to add // Adds a link to the Drupal 8 documentation.
public function documentation() { public function documentation() {
$response = new RedirectResponse("https://api.drupal.org/api/drupal/8"); $response = new RedirectResponse("https://api.drupal.org/api/drupal/8");
$response->send(); $response->send();
...@@ -143,5 +144,4 @@ class ToolbarController extends ControllerBase { ...@@ -143,5 +144,4 @@ class ToolbarController extends ControllerBase {
return new RedirectResponse($this->reload_page()); return new RedirectResponse($this->reload_page());
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment