public static function VerboseTableResult::preRenderVerboseTableResult in Monitoring 8
Prepares a #type 'verbose_table_result' render element.
Parameters
array $element: An associative array containing the properties of the element. Properties used: #title, #header, #rows, #query, #arguments.
Return value
array The $element with prepared variables.
File
- src/
Element/ VerboseTableResult.php, line 60 - Contains \Drupal\monitoring\Element\VerboseTableResult.
Class
- VerboseTableResult
- Provides the verbose output for a table result of a sensor plugin.
Namespace
Drupal\monitoring\ElementCode
public static function preRenderVerboseTableResult(array $element) {
$id = $string = str_replace(" ", "_", strtolower($element['#title']));
$element[$id] = [
'#type' => 'fieldset',
'#title' => $element['#title'],
'#attributes' => [
'id' => $id,
],
'#description' => $element['#description'],
];
$element[$id]['table'] = [
'#type' => 'table',
'#header' => $element['#header'],
'#rows' => $element['#rows'],
'#empty' => t(':empty', [
':empty' => $element['#empty'],
]),
];
if (!empty($element['#query'])) {
$element[$id]['query'] = [
'#type' => 'details',
'#open' => FALSE,
'#title' => t('Query'),
'#attributes' => [
'class' => [
'monitoring-verbose-query',
],
],
];
$element[$id]['query']['query'] = [
'#type' => 'item',
'#markup' => '<pre>' . $element['#query'] . '</pre>',
];
if (!empty($element['#query_args'])) {
$element[$id]['query']['query_args'] = [
'#type' => 'item',
'#title' => t('Arguments'),
'#markup' => '<pre>' . var_export($element['#query_args'], TRUE) . '</pre>',
];
}
}
return $element;
}