You are here

function SensorResult::__construct in Monitoring 7

Same name and namespace in other branches
  1. 8 src/Result/SensorResult.php \Drupal\monitoring\Result\SensorResult::__construct()

Instantiates a sensor result object.

By default, the sensor status is STATUS_UNKNOWN with empty message.

Parameters

SensorInfo $sensor_info: Sensor info object.

array $cached_data: Result data obtained from a cache.

File

lib/Drupal/monitoring/Result/SensorResult.php, line 75
Contains \Drupal\monitoring\Result\SensorResult.

Class

SensorResult
Generic container for the sensor result.

Namespace

Drupal\monitoring\Result

Code

function __construct(SensorInfo $sensor_info, array $cached_data = array()) {
  $this->sensorInfo = $sensor_info;
  if ($cached_data) {
    $this->data = $cached_data;
    $this->isCached = TRUE;
  }

  // Merge in defaults in case there is nothing cached for given sensor yet.
  $this->data += array(
    'sensor_status' => SensorResultInterface::STATUS_UNKNOWN,
    'sensor_message' => NULL,
    'sensor_expected_value' => NULL,
    'sensor_value' => NULL,
    'execution_time' => 0,
    'timestamp' => REQUEST_TIME,
  );
}