You are here

function monitoring_clear_missing_sensor_submit in Monitoring 8

Same name and namespace in other branches
  1. 7 monitoring.module \monitoring_clear_missing_sensor_submit()

Submit callback to clear the disappeared sensors list.

See also

\Drupal\monitoring\Sensor\SensorDisappearedSensors::buildConfigurationForm()

1 string reference to 'monitoring_clear_missing_sensor_submit'
DisappearedSensorsSensorPlugin::buildConfigurationForm in src/Plugin/monitoring/SensorPlugin/DisappearedSensorsSensorPlugin.php
Adds UI to clear the missing sensor status.

File

./monitoring.module, line 372
Monitoring bootstrap file.

Code

function monitoring_clear_missing_sensor_submit($form, FormStateInterface $form_state) {
  $available_sensors = array();
  foreach (monitoring_sensor_manager()
    ->getAllSensorConfig() as $key => $sensor_config) {
    $available_sensors[$key] = array(
      'name' => $key,
      'label' => $sensor_config
        ->getLabel(),
      'enabled' => $sensor_config
        ->isEnabled(),
    );
  }
  \Drupal::state()
    ->set('monitoring.available_sensors', $available_sensors);
  \Drupal::messenger()
    ->addMessage(t('All missing sensors have been cleared.'));
}