function monitoring_preprocess_views_view_table in Monitoring 8
Same name and namespace in other branches
- 7 monitoring.module \monitoring_preprocess_views_view_table()
Implements hook_preprocess_HOOK().
Display a view as a table style.
@todo - this needs review. Is it the right way how to inject custom css classes?
File
- ./
monitoring.module, line 191 - Monitoring bootstrap file.
Code
function monitoring_preprocess_views_view_table(&$vars) {
/** @var \Drupal\views\ViewExecutable $view */
$view = $vars['view'];
// We want to alter only the monitoring sensor results view.
// @todo - really?? we do not have the view machine name available here?
if (!in_array('monitoring_sensor_results', $view
->getBaseTables())) {
return;
}
foreach ($vars['rows'] as $num => $row) {
if (isset($vars['result'][$num]->_entity->sensor_status->value)) {
$vars['rows'][$num]['attributes'] = new Attribute(array(
'class' => 'monitoring-' . strtolower($vars['result'][$num]->_entity->sensor_status->value),
));
}
}
$vars['#attached']['library'][] = 'monitoring/monitoring';
}