You are here

public function SensorInfo::toArray in Monitoring 7

Compiles sensor info values to an associative array.

Return value

array Sensor info associative array.

File

lib/Drupal/monitoring/Sensor/SensorInfo.php, line 276
Contains \Drupal\monitoring\Sensor\SensorInfo.

Class

SensorInfo
Represents a sensor info as defined in hook_monitoring_sensor_info().

Namespace

Drupal\monitoring\Sensor

Code

public function toArray() {
  $info_array = array(
    'sensor' => $this
      ->getName(),
    'label' => $this
      ->getLabel(),
    'category' => $this
      ->getCategory(),
    'description' => $this
      ->getDescription(),
    'numeric' => $this
      ->isNumeric(),
    'value_label' => $this
      ->getValueLabel(),
    'caching_time' => $this
      ->getCachingTime(),
    'time_interval' => $this
      ->getTimeIntervalValue(),
    'enabled' => $this
      ->isEnabled(),
  );
  if ($this
    ->isDefiningThresholds()) {
    $info_array['thresholds'] = $this
      ->getSetting('thresholds');
  }
  return $info_array;
}