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