From a90da0d23e80e9091dc7881a5356398b01d23139 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 8 May 2013 18:49:27 +0100 Subject: [PATCH] Issue #1938822 by sandhya.m, EllaTheHarpy, tim.plunkett, alexpott, YesCT: Convert update_status() to a new-style Controller. --- .../update/Controller/UpdateController.php | 65 +++++++++++++++++++ core/modules/update/update.module | 7 +- core/modules/update/update.report.inc | 16 ----- core/modules/update/update.routing.yml | 7 ++ 4 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 core/modules/update/lib/Drupal/update/Controller/UpdateController.php diff --git a/core/modules/update/lib/Drupal/update/Controller/UpdateController.php b/core/modules/update/lib/Drupal/update/Controller/UpdateController.php new file mode 100644 index 00000000000..a2a73c5f6d9 --- /dev/null +++ b/core/modules/update/lib/Drupal/update/Controller/UpdateController.php @@ -0,0 +1,65 @@ +moduleHandler = $module_handler; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('module_handler') + ); + } + + /** + * Returns a page about the update status of projects. + * + * @return array + * A build array with the update status of projects. + */ + public function updateStatus() { + $build = array( + '#theme' => 'update_report' + ); + if ($available = update_get_available(TRUE)) { + $this->moduleHandler->loadInclude('update', 'compare.inc'); + $build['#data'] = update_calculate_project_data($available); + } + else { + $build['#data'] = _update_no_data(); + } + return $build; + } + +} diff --git a/core/modules/update/update.module b/core/modules/update/update.module index 7dee311259f..ddbc398fc2d 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -158,10 +158,8 @@ function update_menu() { $items['admin/reports/updates'] = array( 'title' => 'Available updates', 'description' => 'Get a status report about available updates for your installed modules and themes.', - 'page callback' => 'update_status', - 'access arguments' => array('administer site configuration'), + 'route_name' => 'update_status', 'weight' => -50, - 'file' => 'update.report.inc', ); $items['admin/reports/updates/list'] = array( 'title' => 'List', @@ -266,12 +264,15 @@ function update_theme() { ), 'update_report' => array( 'variables' => array('data' => NULL), + 'file' => 'update.report.inc', ), 'update_version' => array( 'variables' => array('version' => NULL, 'tag' => NULL, 'class' => array()), + 'file' => 'update.report.inc', ), 'update_status_label' => array( 'variables' => array('status' => NULL), + 'file' => 'update.report.inc', ), ); } diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc index 607b523137c..35677d88924 100644 --- a/core/modules/update/update.report.inc +++ b/core/modules/update/update.report.inc @@ -5,22 +5,6 @@ * Code required only when rendering the available updates report. */ -/** - * Page callback: Generates a page about the update status of projects. - * - * @see update_menu() - */ -function update_status() { - if ($available = update_get_available(TRUE)) { - module_load_include('inc', 'update', 'update.compare'); - $data = update_calculate_project_data($available); - return theme('update_report', array('data' => $data)); - } - else { - return theme('update_report', array('data' => _update_no_data())); - } -} - /** * Returns HTML for the project status report. * diff --git a/core/modules/update/update.routing.yml b/core/modules/update/update.routing.yml index f201302d814..16ac4b4d805 100644 --- a/core/modules/update/update.routing.yml +++ b/core/modules/update/update.routing.yml @@ -4,3 +4,10 @@ update_settings: _form: '\Drupal\update\UpdateSettingsForm' requirements: _permission: 'administer site configuration' + +update_status: + pattern: '/admin/reports/updates' + defaults: + _content: '\Drupal\update\Controller\UpdateController::updateStatus' + requirements: + _permission: 'administer site configuration'