diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php index 90e367e..6121bf0 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php @@ -7,11 +7,12 @@ namespace Drupal\system\Controller; -use Drupal\Core\ControllerInterface; -use Drupal\Core\Extension\ModuleHandler; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; +use Drupal\Core\ControllerInterface; use Drupal\Core\Database\Connection; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\system\SystemManager; /** * Returns responses for System Info routes. @@ -19,79 +20,50 @@ class SystemInfoController implements ControllerInterface { /** - * Module handler service. + * System Manager Service. * - * @var \Drupal\Core\Extension\ModuleHandler + * @var \Drupal\system\SystemManager */ - protected $moduleHandler; + protected $systemManager; /** - * The database connection object for this controller. + * Module handler service. * - * @var \Drupal\Core\Database\Connection + * @var \Drupal\Core\Extension\ModuleHandlerInterface */ - protected $database; + protected $moduleHandler; /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( - $container->get('module_handler'), - $container->get('database') + $container->get('system.manager'), + $container->get('module_handler') ); } /** * Constructs a SystemInfoController object. * - * @param \Drupal\Core\Extension\ModuleHandler $module_handler + * @param \Drupal\system\SystemManager $systemManager * Module handler service. - * @param \Drupal\Core\Database\Connection $database + * @param \Drupal\Core\Database\ModuleHandlerInterface $moduleHandler * Database connection. */ - public function __construct(ModuleHandler $module_handler, Connection $database) { - $this->moduleHandler = $module_handler; - $this->database = $database; + public function __construct(SystemManager $systemManager, ModuleHandlerInterface $moduleHandler) { + $this->systemManager = $systemManager; + $this->moduleHandler = $moduleHandler; } /** - * Displays the site status report. Can also be used as a pure check. - * - * @param $check - * If true, only returns a boolean whether there are system status errors. + * Displays the site status report. * - * @return bool|string + * @return string + * The current status of the Drupal installation. */ - public function status($check = FALSE) { - // Load .install files - include_once DRUPAL_ROOT . '/core/includes/install.inc'; - drupal_load_updates(); - - // Check run-time requirements and status information. - $requirements = $this->moduleHandler->invokeAll('requirements', array('runtime')); - usort($requirements, function($a, $b) { - if (!isset($a['weight'])) { - if (!isset($b['weight'])) { - return strcmp($a['title'], $b['title']); - } - return -$b['weight']; - } - return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight']; - }); - - if ($check) { - return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR; - } - // MySQL import might have set the uid of the anonymous user to autoincrement - // value. Let's try fixing it. See http://drupal.org/node/204411 - $this->database->update('users') - ->expression('uid', 'uid - uid') - ->condition('name', '') - ->condition('pass', '') - ->condition('status', 0) - ->execute(); - return theme('status_report', array('requirements' => $requirements)); + public function status() { + return $this->systemManager->status(); } /** diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php b/core/modules/system/lib/Drupal/system/SystemManager.php similarity index 54% copy from core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php copy to core/modules/system/lib/Drupal/system/SystemManager.php index 90e367e..7b46fd0 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php +++ b/core/modules/system/lib/Drupal/system/SystemManager.php @@ -1,56 +1,38 @@ get('module_handler'), - $container->get('database') - ); - } - - /** - * Constructs a SystemInfoController object. - * - * @param \Drupal\Core\Extension\ModuleHandler $module_handler - * Module handler service. - * @param \Drupal\Core\Database\Connection $database - * Database connection. - */ - public function __construct(ModuleHandler $module_handler, Connection $database) { + public function __construct(ModuleHandlerInterface $module_handler, Connection $database) { $this->moduleHandler = $module_handler; $this->database = $database; } @@ -58,9 +40,6 @@ public function __construct(ModuleHandler $module_handler, Connection $database) /** * Displays the site status report. Can also be used as a pure check. * - * @param $check - * If true, only returns a boolean whether there are system status errors. - * * @return bool|string */ public function status($check = FALSE) { @@ -83,6 +62,7 @@ public function status($check = FALSE) { if ($check) { return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR; } + // MySQL import might have set the uid of the anonymous user to autoincrement // value. Let's try fixing it. See http://drupal.org/node/204411 $this->database->update('users') @@ -94,17 +74,4 @@ public function status($check = FALSE) { return theme('status_report', array('requirements' => $requirements)); } - /** - * Returns the contents of phpinfo(). - * - * @return \Symfony\Component\HttpFoundation\Response - * A response object to be sent to the client. - */ - public function php() { - ob_start(); - phpinfo(); - $output = ob_get_clean(); - return new Response($output); - } - } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 90624a0..3b619f1 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -19,7 +19,8 @@ */ function system_admin_config_page() { // Check for status report errors. - if (system_status(TRUE) && user_access('administer site configuration')) { + // @todo Use depedancy injection in http://drupal.org/node/1987810. + if (Drupal::service('system.manager')->status(TRUE) && 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(); diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 83fdf4d..82d8841 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -89,10 +89,9 @@ date_format_localize_reset: _permission: 'administer site configuration' system_status: - pattern: '/admin/reports/status/{check}' + pattern: '/admin/reports/status' defaults: _controller: 'Drupal\system\Controller\SystemInfoController::status' - check: FALSE requirements: _permission: 'administer site configuration' diff --git a/core/modules/system/system.services.yml b/core/modules/system/system.services.yml index c049b0a..8f0d232 100644 --- a/core/modules/system/system.services.yml +++ b/core/modules/system/system.services.yml @@ -6,3 +6,6 @@ services: plugin.manager.system.plugin_ui: class: Drupal\system\Plugin\Type\PluginUIManager arguments: ['@container.namespaces'] + system.manager: + class: Drupal\system\SystemManager + arguments: ['@module_handler', '@database']