You are here

protected function UpdateStatusSensorPlugin::calculateStatus in Monitoring 8

Executes the update requirements hook and calculates the status for it.

Parameters

string $type: Which types of updates to check for, core or contrib.

Return value

string One of the SensorResultInterface status constants.

1 call to UpdateStatusSensorPlugin::calculateStatus()
UpdateStatusSensorPlugin::runSensor in src/Plugin/monitoring/SensorPlugin/UpdateStatusSensorPlugin.php
Runs the sensor, updating $sensor_result.

File

src/Plugin/monitoring/SensorPlugin/UpdateStatusSensorPlugin.php, line 183
Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\UpdateStatusSensorPlugin.

Class

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

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

Code

protected function calculateStatus($type) {
  \Drupal::service('module_handler')
    ->loadInclude('update', 'install');
  $requirements = update_requirements('runtime');
  $update_info = array();
  if (isset($requirements['update_' . $type])) {
    $update_info = $requirements['update_' . $type];
  }
  $update_info += array(
    'severity' => REQUIREMENT_OK,
  );
  if ($update_info['severity'] == REQUIREMENT_OK) {
    return SensorResultInterface::STATUS_OK;
  }
  elseif ($update_info['severity'] == REQUIREMENT_INFO) {
    return SensorResultInterface::STATUS_INFO;
  }
  elseif ($update_info['severity'] == REQUIREMENT_WARNING) {
    return SensorResultInterface::STATUS_INFO;
  }
  else {
    return SensorResultInterface::STATUS_CRITICAL;
  }
}