function monitoring_drush_purge_settings in Monitoring 7
Drush callback to purge sensor settings.
Parameters
string $sensor_name: Sensor name for which to purge settings.
1 string reference to 'monitoring_drush_purge_settings'
- monitoring_drush_command in ./
monitoring.drush.inc - Implements hook_drush_command().
File
- ./
monitoring.drush.inc, line 477 - Drush support for monitoring.
Code
function monitoring_drush_purge_settings($sensor_name = NULL) {
if (empty($sensor_name)) {
if (drush_confirm(dt('Do you want to purge all sensor settings?'))) {
$query = db_query('DELETE FROM {variable} WHERE name LIKE :name', array(
':name' => 'monitoring_%',
));
drush_print(dt('Purged settings of @count sensors.', array(
'@count' => $query
->rowCount(),
)));
}
return;
}
$sensor_manager = monitoring_sensor_manager();
try {
// Check if the given sensor exists.
$sensor_manager
->getSensorInfoByName($sensor_name);
$query = db_query('DELETE FROM {variable} WHERE name = :name', array(
':name' => monitoring_sensor_settings_key($sensor_name),
));
if ($query
->rowCount()) {
drush_print(dt('Purged settings of @sensor_name.', array(
'@sensor_name' => $sensor_name,
)));
}
else {
drush_print(dt('No settings to purge.'));
}
} catch (NonExistingSensorException $e) {
drush_set_error('MONITORING_SENSOR_INVALID_NAME', dt('Sensor "@name" does not exist.', array(
'@name' => $sensor_name,
)));
}
}