You are here

function monitoring_drush_result_output_json in Monitoring 8

Same name and namespace in other branches
  1. 7 monitoring.drush.inc \monitoring_drush_result_output_json()

Results output in JSON format.

Parameters

\Drupal\monitoring\Result\SensorResultInterface[] $results: List of sensor result objects.

string $expand: Additional data to be expanded.

1 call to monitoring_drush_result_output_json()
monitoring_drush_run in ./monitoring.drush.inc
Drush callback to get sensor results.

File

./monitoring.drush.inc, line 333
Drush support for monitoring.

Code

function monitoring_drush_result_output_json(array $results, $expand = NULL) {
  $json_output = array();
  foreach ($results as $result) {
    $sensor_id = $result
      ->getSensorId();
    $json_output[$sensor_id] = $result
      ->toArray();
    if ($expand == 'sensor') {
      $json_output[$sensor_id]['sensor'] = $result
        ->getSensorConfig()
        ->toArray();
    }
  }
  drush_print(Json::encode($json_output));
}