automatic_updates.install 1.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
<?php

/**
 * @file
 * Install, update and uninstall functions for the automatic_updates module.
 */

/**
 * Implements hook_uninstall().
 */
function automatic_updates_uninstall() {
12
13
  variable_del('automatic_updates_psa_endpoint');
  variable_del('automatic_updates_enable_psa');
14
}
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

/**
 * Implements hook_requirements().
 */
function automatic_updates_requirements($phase) {
  if ($phase !== 'runtime') {
    return;
  }

  $requirements = array();
  _automatic_updates_psa_requirements($requirements);
  return $requirements;
}

/**
 * Display requirements from public service announcements.
 *
 * @param array $requirements
 *   The requirements array.
 */
function _automatic_updates_psa_requirements(array &$requirements) {
  if (!variable_get('automatic_updates_enable_psa', TRUE)) {
    return;
  }
  $requirements['automatic_updates_psa'] = [
    'title' => t('<a href="@link">Drupal public service announcements</a>', ['@link' => 'https://www.drupal.org/docs/8/update/automatic-updates#psas']),
    'severity' => REQUIREMENT_OK,
    'value' => t('No announcements requiring attention.'),
  ];
  $messages = AutomaticUpdatesPsa::getPublicServiceMessages();
  if (!empty($messages)) {
    $requirements['automatic_updates_psa']['severity'] = REQUIREMENT_ERROR;
    $requirements['automatic_updates_psa']['value'] = format_plural(count($messages), '@count urgent announcement requires your attention:', '@count urgent announcements require your attention:');
    $requirements['automatic_updates_psa']['description'] = theme('item_list', array(
      'items' => $messages,
    ));
  }
}