diff --git a/core/modules/system/lib/Drupal/system/Controller/ConfigController.php b/core/modules/system/lib/Drupal/system/Controller/ConfigController.php new file mode 100644 index 0000000..bc8ef55 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Controller/ConfigController.php @@ -0,0 +1,141 @@ +get('system.manager'), + $container->get('entity.query'), + $container->get('plugin.manager.entity') + ); + } + + /** + * Constructs a SystemInfoController object. + * + * @param \Drupal\system\SystemManager $systemManager + * System manager service. + * + * @param \Drupal\Core\Entity\Query\QueryFactory $queryFactory + * The entity query object. + * + * @param \Drupal\Core\Entity\EntityManager $entityManager + * The entity manager. + */ + public function __construct(SystemManager $systemManager, QueryFactory $queryFactory, EntityManager $entityManager) { + $this->systemManager = $systemManager; + $this->queryFactory = $queryFactory; + $this->entityManager = $entityManager; + } + + /** + * Provide the administration overview page. + * + * @return array + * A renderable array of the administraion overview page. + */ + public function overview() { + // Check for status report errors. + if ($this->systemManager->checkRequirements() && user_access('administer site configuration')) { + drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the status report for more information.', array('@status' => url('admin/reports/status'))), 'error'); + } + $blocks = array(); + // Load all links on admin/config and menu links below it. + $query = $this->queryFactory->get('menu_link') + ->condition('link_path', 'admin/config') + ->condition('module', 'system'); + $result = $query->execute(); + if ($system_link = $this->entityManager->getStorageController('menu_link')->loadMultiple($result)) { + $system_link = reset($system_link); + $query = $this->queryFactory->get('menu_link') + ->condition('link_path', 'admin/help', '<>') + ->condition('menu_name', $system_link->menu_name) + ->condition('plid', $system_link->id()) + ->condition('hidden', 0); + $result = $query->execute(); + if (!empty($result)) { + $menu_links = $this->entityManager + ->getStorageController('menu_link') + ->loadMultiple($result); + + foreach ($menu_links as $item) { + _menu_link_translate($item); + if (!$item['access']) { + continue; + } + // The link description, either derived from 'description' in hook_menu() + // or customized via menu module is used as title attribute. + if (!empty($item['localized_options']['attributes']['title'])) { + $item['description'] = $item['localized_options']['attributes']['title']; + unset($item['localized_options']['attributes']['title']); + } + $block = $item; + $block['content'] = theme('admin_block_content', array('content' => system_admin_menu_block($item))); + + if (!empty($block['content'])) { + $block['show'] = TRUE; + } + + // Prepare for sorting as in function _menu_tree_check_access(). + // The weight is offset so it is always positive, with a uniform 5-digits. + $blocks[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $block; + } + } + } + if ($blocks) { + ksort($blocks); + return array( + '#theme' => 'admin_page', + '#blocks' => $blocks, + ); + } + else { + return array( + '#markup' => t('You do not have any administrative items.'), + ); + } + } + +} diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 957db86..8d028d1 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -16,60 +16,6 @@ use Drupal\system\Form\ModulesUninstallConfirmForm; /** - * Menu callback; Provide the administration overview page. - */ -function system_admin_config_page() { - // Check for status report errors. - // @todo Use depedancy injection in http://drupal.org/node/1987810. - if (Drupal::service('system.manager')->checkRequirements() && user_access('administer site configuration')) { - drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the status report for more information.', array('@status' => url('admin/reports/status'))), 'error'); - } - $blocks = array(); - if ($system_link = entity_load_multiple_by_properties('menu_link', array('link_path' => 'admin/config', 'module' => 'system'))) { - $system_link = reset($system_link); - $query = Drupal::entityQuery('menu_link') - ->condition('link_path', 'admin/help', '<>') - ->condition('menu_name', $system_link->menu_name) - ->condition('plid', $system_link->id()) - ->condition('hidden', 0); - $result = $query->execute(); - if (!empty($result)) { - $menu_links = menu_link_load_multiple($result); - - foreach ($menu_links as $item) { - _menu_link_translate($item); - if (!$item['access']) { - continue; - } - // The link description, either derived from 'description' in hook_menu() - // or customized via menu module is used as title attribute. - if (!empty($item['localized_options']['attributes']['title'])) { - $item['description'] = $item['localized_options']['attributes']['title']; - unset($item['localized_options']['attributes']['title']); - } - $block = $item; - $block['content'] = ''; - $block['content'] .= theme('admin_block_content', array('content' => system_admin_menu_block($item))); - if (!empty($block['content'])) { - $block['show'] = TRUE; - } - - // Prepare for sorting as in function _menu_tree_check_access(). - // The weight is offset so it is always positive, with a uniform 5-digits. - $blocks[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $block; - } - } - } - if ($blocks) { - ksort($blocks); - return theme('admin_page', array('blocks' => $blocks)); - } - else { - return t('You do not have any administrative items.'); - } -} - -/** * Provide a single block from the administration menu as a page. * * This function is often a destination for these blocks. diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a6a7786..5b4bf24 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -753,9 +753,7 @@ function system_menu() { $items['admin/config'] = array( 'title' => 'Configuration', 'description' => 'Administer settings.', - 'page callback' => 'system_admin_config_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config', ); // Media settings. diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 1e09f79..8419afc 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -1,13 +1,13 @@ system.cron: pattern: '/cron/{key}' defaults: - _controller: '\Drupal\system\CronController::run' + _content: '\Drupal\system\CronController::run' requirements: _access_system_cron: 'TRUE' system.machine_name_transliterate: pattern: '/machine_name/transliterate' defaults: - _controller: '\Drupal\system\MachineNameController::transliterate' + _content: '\Drupal\system\MachineNameController::transliterate' requirements: _permission: 'access content' @@ -91,7 +91,7 @@ date_format_edit: system_run_cron: pattern: '/admin/reports/status/run-cron' defaults: - _controller: '\Drupal\system\CronController::runManually' + _content: '\Drupal\system\CronController::runManually' requirements: _permission: 'administer site configuration' @@ -164,3 +164,10 @@ system_timezone: _controller: '\Drupal\system\Controller\TimezoneController::getTimezone' requirements: _access: 'TRUE' + +system_admin_config: + pattern: '/admin/config' + defaults: + _content: 'Drupal\system\Controller\ConfigController::overview' + requirements: + _permission: 'access administration pages'