function monitoring_node_type_update in Monitoring 8
File
- ./
monitoring.module, line 469 - Monitoring bootstrap file.
Code
function monitoring_node_type_update(NodeTypeInterface $type) {
// Don't do anything if we are syncing, the sensor does not exists or if the
// type was not renamed.
$config_id = 'node_new_' . $type
->id();
$new_config_id = 'node_new_' . $type->original
->id();
if ($config_id == $new_config_id || $type
->isSyncing() || !SensorConfig::load($config_id)) {
return;
}
$sensor = SensorConfig::load($config_id);
// If the new sensor already exists, just drop this one.
if (SensorConfig::load($new_config_id)) {
$sensor
->delete();
}
else {
$sensor->id = $new_config_id;
$sensor->label = new FormattableMarkup('New @type nodes', array(
'@type' => $type
->label(),
));
$sensor->description = new FormattableMarkup('New nodes of type @type', array(
'@type' => $type
->label(),
));
$sensor->value_label = new FormattableMarkup('@type nodes', array(
'@type' => $type
->label(),
));
$sensor->settings['conditions'][0]['value'] = $type
->id();
$sensor
->save();
}
}