public function SensorManager::disableSensor in Monitoring 7
Same name and namespace in other branches
- 8 src/Sensor/SensorManager.php \Drupal\monitoring\Sensor\SensorManager::disableSensor()
Disable a sensor.
Checks if the sensor is enabled and if so it will disable it and remove from the active sensor list.
Parameters
string $sensor_name: Sensor name to be disabled.
Throws
\Drupal\monitoring\Sensor\NonExistingSensorException Thrown if the requested sensor does not exist.
File
- lib/
Drupal/ monitoring/ Sensor/ SensorManager.php, line 153 - Contains \Drupal\monitoring\Sensor\SensorManager.
Class
- SensorManager
- Manages sensor definitions and settings.
Namespace
Drupal\monitoring\SensorCode
public function disableSensor($sensor_name) {
$sensor_info = $this
->getSensorInfoByName($sensor_name);
if ($sensor_info
->isEnabled()) {
$settings = monitoring_sensor_settings_get($sensor_name);
$settings['enabled'] = FALSE;
monitoring_sensor_settings_save($sensor_name, $settings);
$available_sensors = variable_get('monitoring_available_sensors', array());
$available_sensors[$sensor_name]['enabled'] = FALSE;
$available_sensors[$sensor_name]['name'] = $sensor_name;
variable_set('monitoring_available_sensors', $available_sensors);
}
}