You are here

function _automatic_updates_psa_requirements in Automatic Updates 8

Same name and namespace in other branches
  1. 7 automatic_updates.install \_automatic_updates_psa_requirements()

Display requirements from Public service announcements.

Parameters

array $requirements: The requirements array.

1 call to _automatic_updates_psa_requirements()
automatic_updates_requirements in ./automatic_updates.install
Implements hook_requirements().

File

./automatic_updates.install, line 101
Automatic updates install file.

Code

function _automatic_updates_psa_requirements(array &$requirements) {
  if (!\Drupal::config('automatic_updates.settings')
    ->get('enable_psa')) {
    return;
  }

  /** @var \Drupal\automatic_updates\Services\AutomaticUpdatesPsa $psa */
  $psa = \Drupal::service('automatic_updates.psa');
  $messages = $psa
    ->getPublicServiceMessages();
  $requirements['automatic_updates_psa'] = [
    'title' => t('<a href="@link">Public service announcements</a>', [
      '@link' => 'https://www.drupal.org/docs/8/update/automatic-updates#psas',
    ]),
    'severity' => REQUIREMENT_OK,
    'value' => t('No announcements requiring attention.'),
  ];
  if (!empty($messages)) {
    $requirements['automatic_updates_psa']['severity'] = REQUIREMENT_ERROR;
    $requirements['automatic_updates_psa']['value'] = new PluralTranslatableMarkup(count($messages), '@count urgent announcement requires your attention:', '@count urgent announcements require your attention:');
    $requirements['automatic_updates_psa']['description'] = [
      '#theme' => 'item_list',
      '#items' => $messages,
    ];
  }
}