function monitoring_drush_result_output_table_multiple in Monitoring 8
Same name and namespace in other branches
- 7 monitoring.drush.inc \monitoring_drush_result_output_table_multiple()
Outputs sensor results table for multiple results.
Parameters
\Drupal\monitoring\Result\SensorResultInterface[] $results: List of sensor result objects.
bool $show_exec_time: If TRUE the multi results view will display also execution time.
1 call to monitoring_drush_result_output_table_multiple()
- monitoring_drush_result_output_table in ./monitoring.drush.inc 
- Outputs human readable table with results.
File
- ./monitoring.drush.inc, line 393 
- Drush support for monitoring.
Code
function monitoring_drush_result_output_table_multiple(array $results, $show_exec_time = FALSE) {
  $rows['header'] = array(
    dt('Sensor'),
    dt('Status'),
    dt('Message'),
    dt('Result age'),
  );
  if ($show_exec_time) {
    $rows['header'][] = dt('Execution time');
  }
  foreach ($results as $result) {
    $rows[$result
      ->getSensorId()] = array(
      new FormattableMarkup("@label\n(@id)", array(
        '@label' => Unicode::truncate($result
          ->getSensorConfig()
          ->getLabel(), 40, TRUE, TRUE),
        '@id' => $result
          ->getSensorId(),
      )),
      $result
        ->getStatusLabel(),
      Unicode::truncate($result
        ->getMessage(), 40, TRUE, TRUE),
      \Drupal::service('date.formatter')
        ->formatInterval(time() - $result
        ->getTimestamp()),
    );
    if ($show_exec_time) {
      $rows[$result
        ->getSensorId()][] = $result
        ->getExecutionTime() . 'ms';
    }
  }
  drush_print_table($rows);
}