diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php new file mode 100644 index 0000000..84981cd --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php @@ -0,0 +1,46 @@ +get('system.manager')); + } + + /** + * Constructs a SystemController object. + */ + public function __construct(SystemManager $systemManager) { + $this->systemManager = $systemManager; + } + + /** + * Provide a single block from the administration menu as a page. + */ + public function systemAdminMenuBlockPage() { + return $this->systemManager->getBlockContents(); + } +} diff --git a/core/modules/system/lib/Drupal/system/SystemManager.php b/core/modules/system/lib/Drupal/system/SystemManager.php index 2712169..86712a7 100644 --- a/core/modules/system/lib/Drupal/system/SystemManager.php +++ b/core/modules/system/lib/Drupal/system/SystemManager.php @@ -124,4 +124,31 @@ public function getMaxSeverity(&$requirements) { return $severity; } + /** + * Loads the contents of a menu block. + * + * This function is often a destination for these blocks. + * For example, 'admin/structure/types' needs to have a destination to be + * valid in the Drupal menu system, but too much information there might be + * hidden, so we supply the contents of the block. + * + * @return array + * A render array suitable for drupal_render. + */ + public function getBlockContents() { + $item = menu_get_item(); + if ($content = system_admin_menu_block($item)) { + $output = array( + '#content' => $content, + '#theme' => 'admin_block_content', + ); + } + else { + $output = array( + '#type' => 'markup', + '#markup' => t('You do not have any administrative items.'), + ); + } + return $output; + } } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 6d3a89b..253eb3c 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -68,29 +68,7 @@ function system_admin_config_page() { } } -/** - * Provide a single block from the administration menu as a page. - * - * This function is often a destination for these blocks. - * For example, 'admin/structure/types' needs to have a destination to be valid - * in the Drupal menu system, but too much information there might be - * hidden, so we supply the contents of the block. - * - * @return - * The output HTML. - */ -function system_admin_menu_block_page() { - $item = menu_get_item(); - if ($content = system_admin_menu_block($item)) { - $output = theme('admin_block_content', array('content' => $content)); - } - else { - $output = t('You do not have any administrative items.'); - } - return $output; -} - -/** + /** * Menu callback; displays a listing of all themes. */ function system_themes_page() { diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 6a1f766..1374957 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -648,11 +648,9 @@ function system_menu() { ); $items['admin'] = array( 'title' => 'Administration', - 'access arguments' => array('access administration pages'), - 'page callback' => 'system_admin_menu_block_page', + 'route_name' => 'system_admin', 'weight' => 9, 'menu_name' => 'admin', - 'file' => 'system.admin.inc', ); $items['admin/compact'] = array( 'title' => 'Compact mode', @@ -679,9 +677,7 @@ function system_menu() { 'description' => 'Administer blocks, content types, menus, etc.', 'position' => 'right', 'weight' => -8, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_structure', ); // Appearance. $items['admin/appearance'] = array( @@ -782,9 +778,7 @@ function system_menu() { 'description' => 'Media tools.', 'position' => 'left', 'weight' => -10, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_media', ); $items['admin/config/media/file-system'] = array( 'title' => 'File system', @@ -805,9 +799,7 @@ function system_menu() { 'description' => 'Tools related to web services.', 'position' => 'right', 'weight' => 0, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_services', ); $items['admin/config/services/rss-publishing'] = array( 'title' => 'RSS publishing', @@ -821,9 +813,7 @@ function system_menu() { 'description' => 'Development tools.', 'position' => 'right', 'weight' => -10, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_development', ); $items['admin/config/development/maintenance'] = array( 'title' => 'Maintenance mode', @@ -850,9 +840,7 @@ function system_menu() { 'description' => 'Regional settings, localization and translation.', 'position' => 'left', 'weight' => -5, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_regional', ); $items['admin/config/regional/settings'] = array( 'title' => 'Regional settings', @@ -902,9 +890,7 @@ function system_menu() { 'description' => 'Local site search, metadata and SEO.', 'position' => 'left', 'weight' => -10, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_search', ); // System settings. @@ -913,9 +899,7 @@ function system_menu() { 'description' => 'General system related configuration.', 'position' => 'right', 'weight' => -20, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_system', ); $items['admin/config/system/site-information'] = array( 'title' => 'Site information', @@ -934,9 +918,7 @@ function system_menu() { 'title' => 'User interface', 'description' => 'Tools that enhance the user interface.', 'position' => 'right', - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_ui', 'weight' => -15, ); $items['admin/config/workflow'] = array( @@ -944,29 +926,23 @@ function system_menu() { 'description' => 'Content workflow, editorial workflow tools.', 'position' => 'right', 'weight' => 5, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_workflow', ); $items['admin/config/content'] = array( 'title' => 'Content authoring', 'description' => 'Settings related to formatting and authoring content.', 'position' => 'left', 'weight' => -15, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', + 'route_name' => 'system_admin_config_content', ); // Reports. $items['admin/reports'] = array( 'title' => 'Reports', 'description' => 'View reports, updates, and errors.', - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access site reports'), + 'route_name' => 'system_admin_reports', 'weight' => 5, 'position' => 'left', - 'file' => 'system.admin.inc', ); $items['admin/reports/status'] = array( 'title' => 'Status report', diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 0ba8674..97575a2 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -1,3 +1,75 @@ +system_admin: + pattern: '/admin' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_structure: + pattern: '/admin/structure' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_reports: + pattern: '/admin/reports' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access site reports' +system_admin_config_media: + pattern: '/admin/config/media' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_services: + pattern: '/admin/config/services' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_development: + pattern: '/admin/config/development' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_regional: + pattern: '/admin/config/regional' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_search: + pattern: '/admin/config/search' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_system: + pattern: '/admin/config/system' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_ui: + pattern: '/admin/config/user-interface' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_workflow: + pattern: '/admin/config/workflow' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' +system_admin_config_content: + pattern: '/admin/config/content' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' system.cron: pattern: '/cron/{key}' defaults: diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module index bdcebcd..79a4303 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.module +++ b/core/modules/system/tests/modules/menu_test/menu_test.module @@ -24,14 +24,12 @@ function menu_test_menu() { 'type' => MENU_CALLBACK, 'access arguments' => array('access content'), ); - // This item uses system_admin_menu_block_page() to list child items. + // This item uses SystemController::systemAdminMenuBlockPage() to list child + // items. $items['menu_callback_description'] = array( 'title' => 'Menu item title', - 'page callback' => 'system_admin_menu_block_page', 'description' => 'Menu item description parent', - 'access arguments' => array('access content'), - 'file' => 'system.admin.inc', - 'file path' => drupal_get_path('module', 'system'), + 'route_name' => 'menu_callback_description', ); $items['menu_callback_description/description-plain'] = array( 'title' => 'Menu item with a regular description', @@ -295,8 +293,8 @@ function menu_test_menu() { ); // File inheritance tests. This menu item should inherit the page callback - // system_admin_menu_block_page() and therefore render its children as links - // on the page. + // SystemController::systemAdminMenuBlockPage() and therefore render its + // children as links on the page. $items['admin/config/development/file-inheritance'] = array( 'title' => 'File inheritance', 'description' => 'Test file inheritance', diff --git a/core/modules/system/tests/modules/menu_test/menu_test.routing.yml b/core/modules/system/tests/modules/menu_test/menu_test.routing.yml index 09b42ba..92e02e9 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.routing.yml +++ b/core/modules/system/tests/modules/menu_test/menu_test.routing.yml @@ -1,3 +1,10 @@ +menu_callback_description: + pattern: 'menu_callback_description' + defaults: + _content: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access content' + menu_router_test1: pattern: '/foo/{bar}' defaults: diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 9663af5..a288418 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -989,15 +989,13 @@ function user_menu() { // Administration pages. $items['admin/config/people'] = array( - 'title' => 'People', - 'description' => 'Configure user accounts.', - 'position' => 'left', - 'weight' => -20, - 'page callback' => 'system_admin_menu_block_page', - 'access arguments' => array('access administration pages'), - 'file' => 'system.admin.inc', - 'file path' => drupal_get_path('module', 'system'), + 'title' => 'People', + 'description' => 'Configure user accounts.', + 'position' => 'left', + 'weight' => -20, + 'route_name' => 'user_accounts', ); + $items['admin/config/people/accounts'] = array( 'title' => 'Account settings', 'description' => 'Configure default behavior of users, including registration requirements, e-mails, and fields.', diff --git a/core/modules/user/user.routing.yml b/core/modules/user/user.routing.yml index b48c808..2b6b22b 100644 --- a/core/modules/user/user.routing.yml +++ b/core/modules/user/user.routing.yml @@ -26,6 +26,13 @@ user_autocomplete_anonymous: requirements: _permission: 'access user profiles' +user_accounts: + pattern: '/admin/config/people' + defaults: + _form: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + requirements: + _permission: 'access administration pages' + user_account_settings: pattern: '/admin/config/people/accounts' defaults: