UpdateController.php in Drupal 8
File
core/modules/update/src/Controller/UpdateController.php
View source
<?php
namespace Drupal\update\Controller;
use Drupal\update\UpdateManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Controller\ControllerBase;
class UpdateController extends ControllerBase {
protected $updateManager;
public function __construct(UpdateManagerInterface $update_manager) {
$this->updateManager = $update_manager;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('update.manager'));
}
public function updateStatus() {
$build = [
'#theme' => 'update_report',
];
if ($available = update_get_available(TRUE)) {
$this
->moduleHandler()
->loadInclude('update', 'compare.inc');
$build['#data'] = update_calculate_project_data($available);
}
return $build;
}
public function updateStatusManually() {
$this->updateManager
->refreshUpdateData();
$batch = [
'operations' => [
[
[
$this->updateManager,
'fetchDataBatch',
],
[],
],
],
'finished' => 'update_fetch_data_finished',
'title' => t('Checking available update data'),
'progress_message' => t('Trying to check available update data ...'),
'error_message' => t('Error checking available update data.'),
];
batch_set($batch);
return batch_process('admin/reports/updates');
}
}