You are here

function monitoring_drush_result_output_json in Monitoring 7

Same name and namespace in other branches
  1. 8 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 344
Drush support for monitoring.

Code

function monitoring_drush_result_output_json(array $results, $expand = NULL) {
  $json_output = array();
  foreach ($results as $result) {
    $json_output[$result
      ->getSensorName()] = $result
      ->toArray();
    if ($expand == 'sensor_info') {
      $json_output[$result
        ->getSensorName()]['sensor_info'] = $result
        ->getSensorInfo()
        ->toArray();
    }
  }
  drush_print(drupal_json_encode($json_output));
}