Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\update\Controller;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\update\UpdateManagerInterface;
|
Chris@0
|
6 use Symfony\Component\DependencyInjection\ContainerInterface;
|
Chris@0
|
7 use Drupal\Core\Controller\ControllerBase;
|
Chris@0
|
8
|
Chris@0
|
9 /**
|
Chris@0
|
10 * Controller routines for update routes.
|
Chris@0
|
11 */
|
Chris@0
|
12 class UpdateController extends ControllerBase {
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * Update manager service.
|
Chris@0
|
16 *
|
Chris@0
|
17 * @var \Drupal\update\UpdateManagerInterface
|
Chris@0
|
18 */
|
Chris@0
|
19 protected $updateManager;
|
Chris@0
|
20
|
Chris@0
|
21 /**
|
Chris@0
|
22 * Constructs update status data.
|
Chris@0
|
23 *
|
Chris@0
|
24 * @param \Drupal\update\UpdateManagerInterface $update_manager
|
Chris@0
|
25 * Update Manager Service.
|
Chris@0
|
26 */
|
Chris@0
|
27 public function __construct(UpdateManagerInterface $update_manager) {
|
Chris@0
|
28 $this->updateManager = $update_manager;
|
Chris@0
|
29 }
|
Chris@0
|
30
|
Chris@0
|
31 /**
|
Chris@0
|
32 * {@inheritdoc}
|
Chris@0
|
33 */
|
Chris@0
|
34 public static function create(ContainerInterface $container) {
|
Chris@0
|
35 return new static(
|
Chris@0
|
36 $container->get('update.manager')
|
Chris@0
|
37 );
|
Chris@0
|
38 }
|
Chris@0
|
39
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Returns a page about the update status of projects.
|
Chris@0
|
42 *
|
Chris@0
|
43 * @return array
|
Chris@0
|
44 * A build array with the update status of projects.
|
Chris@0
|
45 */
|
Chris@0
|
46 public function updateStatus() {
|
Chris@0
|
47 $build = [
|
Chris@17
|
48 '#theme' => 'update_report',
|
Chris@0
|
49 ];
|
Chris@0
|
50 if ($available = update_get_available(TRUE)) {
|
Chris@0
|
51 $this->moduleHandler()->loadInclude('update', 'compare.inc');
|
Chris@0
|
52 $build['#data'] = update_calculate_project_data($available);
|
Chris@0
|
53 }
|
Chris@0
|
54 return $build;
|
Chris@0
|
55 }
|
Chris@0
|
56
|
Chris@0
|
57 /**
|
Chris@0
|
58 * Manually checks the update status without the use of cron.
|
Chris@0
|
59 */
|
Chris@0
|
60 public function updateStatusManually() {
|
Chris@0
|
61 $this->updateManager->refreshUpdateData();
|
Chris@0
|
62 $batch = [
|
Chris@0
|
63 'operations' => [
|
Chris@0
|
64 [[$this->updateManager, 'fetchDataBatch'], []],
|
Chris@0
|
65 ],
|
Chris@0
|
66 'finished' => 'update_fetch_data_finished',
|
Chris@0
|
67 'title' => t('Checking available update data'),
|
Chris@0
|
68 'progress_message' => t('Trying to check available update data ...'),
|
Chris@0
|
69 'error_message' => t('Error checking available update data.'),
|
Chris@0
|
70 ];
|
Chris@0
|
71 batch_set($batch);
|
Chris@0
|
72 return batch_process('admin/reports/updates');
|
Chris@0
|
73 }
|
Chris@0
|
74
|
Chris@0
|
75 }
|