public function DisappearedSensorsSensorPlugin::buildConfigurationForm in Monitoring 8
Adds UI to clear the missing sensor status.
Overrides SensorPluginBase::buildConfigurationForm
File
- src/
Plugin/ monitoring/ SensorPlugin/ DisappearedSensorsSensorPlugin.php, line 43 - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\DisappearedSensorsSensorPlugin.
Class
- DisappearedSensorsSensorPlugin
- Monitors if sensors disappeared without prior being disabled.
Namespace
Drupal\monitoring\Plugin\monitoring\SensorPluginCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
try {
$result = monitoring_sensor_run($this->sensorConfig
->id());
} catch (\Exception $e) {
// @todo: Figure out why this happens.
$this
->messenger()
->addError($e
->getMessage());
return array();
}
$form = parent::buildConfigurationForm($form, $form_state);
if ($result
->isCritical()) {
$form['clear_missing_sensors_wrapper'] = array(
'#type' => 'fieldset',
'#title' => t('Missing sensors'),
'#description' => t('This action will clear the missing sensors and the critical sensor status will go away.'),
'#weight' => -10,
);
$form['clear_missing_sensors_wrapper']['info'] = array(
'#type' => 'item',
'#title' => t('Sensor message'),
'#markup' => $result
->getMessage(),
);
$form['clear_missing_sensors_wrapper']['clear_missing_sensor'] = array(
'#type' => 'submit',
'#submit' => array(
'monitoring_clear_missing_sensor_submit',
),
'#value' => t('Clear missing sensors'),
);
}
return $form;
}