public function DatabaseAggregatorSensorPlugin::verboseResultUnaggregated in Monitoring 8
Adds unaggregated verbose output to the render array $output.
Parameters
array &$output: Render array where the result will be added.
2 calls to DatabaseAggregatorSensorPlugin::verboseResultUnaggregated()
- DatabaseAggregatorSensorPlugin::resultVerbose in src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php - Provide additional info about sensor call.
- WatchdogAggregatorSensorPlugin::verboseResultUnaggregated in src/
Plugin/ monitoring/ SensorPlugin/ WatchdogAggregatorSensorPlugin.php - Adds unaggregated verbose output to the render array $output.
1 method overrides DatabaseAggregatorSensorPlugin::verboseResultUnaggregated()
- WatchdogAggregatorSensorPlugin::verboseResultUnaggregated in src/
Plugin/ monitoring/ SensorPlugin/ WatchdogAggregatorSensorPlugin.php - Adds unaggregated verbose output to the render array $output.
File
- src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php, line 255 - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\DatabaseAggregatorSensorPlugin.
Class
- DatabaseAggregatorSensorPlugin
- Database aggregator able to query a single db table.
Namespace
Drupal\monitoring\Plugin\monitoring\SensorPluginCode
public function verboseResultUnaggregated(array &$output) {
$output['verbose_sensor_result'] = array(
'#type' => 'verbose_table_result',
'#title' => t('Unaggregated result'),
);
// Fetch the last 10 matching entries, unaggregated.
$query = $this
->getQuery();
$query_result = $query
->range(0, 10)
->execute();
$rows = $this
->buildTableRows($query_result
->fetchAll());
// Reformat the timestamp.
$fields = $this->sensorConfig
->getSetting('verbose_fields');
$timestamp_field_name = $this
->getTimeIntervalField();
if ($timestamp_field_name && in_array($timestamp_field_name, $fields)) {
foreach ($rows as $key => $row) {
$rows[$key][$timestamp_field_name] = \Drupal::service('date.formatter')
->format($row[$timestamp_field_name], 'short');
}
}
$output['verbose_sensor_result']['#header'] = $this
->buildTableHeader($rows);
$output['verbose_sensor_result']['#rows'] = $rows;
// Show query.
$output['verbose_sensor_result']['#query'] = $query_result
->getQueryString();
$output['verbose_sensor_result']['#query_args'] = $query
->getArguments();
}