You are here

protected function SensorDrupalUpdate::checkContrib in Monitoring 7

Checks contrib status and sets sensor status message.

Parameters

SensorResultInterface $result:

array $project_data:

1 call to SensorDrupalUpdate::checkContrib()
SensorDrupalUpdate::runSensor in lib/Drupal/monitoring/Sensor/Sensors/SensorDrupalUpdate.php
Runs the sensor, updating $sensor_result.

File

lib/Drupal/monitoring/Sensor/Sensors/SensorDrupalUpdate.php, line 72
Contains \Drupal\monitoring\Sensor\Sensors\SensorDrupalUpdate.

Class

SensorDrupalUpdate
Monitors for available updates of Drupal core and installed contrib modules.

Namespace

Drupal\monitoring\Sensor\Sensors

Code

protected function checkContrib(SensorResultInterface $result, $project_data) {
  unset($project_data['drupal']);
  $updates = array();
  $important_updates = array();
  foreach ($project_data as $info) {
    $status_text = $this
      ->getStatusText($info['status']);
    if (!isset($updates[$status_text])) {
      $updates[$status_text] = 0;
    }
    $updates[$status_text]++;
    if ($status_text == 'NOT SECURE' || $status_text == 'not supported') {
      if (!isset($important_updates[$status_text])) {
        $important_updates[$status_text] = array();
      }
      $important_updates[$status_text][] = $info;
    }
  }
  foreach ($updates as $status_text => $count) {
    $result
      ->addStatusMessage($count . ' ' . $status_text);
  }
  foreach ($important_updates as $status_text => $update_info) {
    foreach ($update_info as $info) {
      if ($status_text == 'NOT SECURE') {
        $result
          ->addStatusMessage('@module (@status, @current => @recommended)', array(
          '@module' => $info['info']['name'],
          '@status' => $status_text,
          '@current' => isset($info['existing_version']) ? $info['existing_version'] : NULL,
          '@recommended' => isset($info['recommended']) ? $info['recommended'] : NULL,
        ));
      }
      else {
        $result
          ->addStatusMessage('@module (@status, @current)', array(
          '@module' => $info['info']['name'],
          '@status' => $status_text,
          '@current' => isset($info['existing_version']) ? $info['existing_version'] : NULL,
        ));
      }
    }
  }
}