Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/src/Controller/AdminController.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\system\Controller; | |
4 | |
5 use Drupal\Core\Controller\ControllerBase; | |
6 | |
7 /** | |
8 * Controller for admin section. | |
9 */ | |
10 class AdminController extends ControllerBase { | |
11 | |
12 /** | |
13 * Prints a listing of admin tasks, organized by module. | |
14 * | |
15 * @return array | |
16 * A render array containing the listing. | |
17 */ | |
18 public function index() { | |
19 $module_info = system_get_info('module'); | |
20 foreach ($module_info as $module => $info) { | |
21 $module_info[$module] = new \stdClass(); | |
22 $module_info[$module]->info = $info; | |
23 } | |
24 | |
25 uasort($module_info, 'system_sort_modules_by_info_name'); | |
26 $menu_items = []; | |
27 | |
28 foreach ($module_info as $module => $info) { | |
29 // Only display a section if there are any available tasks. | |
30 if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) { | |
31 // Sort links by title. | |
32 uasort($admin_tasks, ['\Drupal\Component\Utility\SortArray', 'sortByTitleElement']); | |
33 // Move 'Configure permissions' links to the bottom of each section. | |
34 $permission_key = "user.admin_permissions.$module"; | |
35 if (isset($admin_tasks[$permission_key])) { | |
36 $permission_task = $admin_tasks[$permission_key]; | |
37 unset($admin_tasks[$permission_key]); | |
38 $admin_tasks[$permission_key] = $permission_task; | |
39 } | |
40 | |
41 $menu_items[$info->info['name']] = [$info->info['description'], $admin_tasks]; | |
42 } | |
43 } | |
44 | |
45 $output = [ | |
46 '#theme' => 'system_admin_index', | |
47 '#menu_items' => $menu_items, | |
48 ]; | |
49 | |
50 return $output; | |
51 } | |
52 | |
53 } |