public function DatabaseAggregatorSensorPluginBase::submitConfigurationForm in Monitoring 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides SensorPluginBase::submitConfigurationForm
2 calls to DatabaseAggregatorSensorPluginBase::submitConfigurationForm()
- ContentEntityAggregatorSensorPlugin::submitConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ ContentEntityAggregatorSensorPlugin.php - Form submission handler.
- DatabaseAggregatorSensorPlugin::submitConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php - Form submission handler.
2 methods override DatabaseAggregatorSensorPluginBase::submitConfigurationForm()
- ContentEntityAggregatorSensorPlugin::submitConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ ContentEntityAggregatorSensorPlugin.php - Form submission handler.
- DatabaseAggregatorSensorPlugin::submitConfigurationForm in src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php - Form submission handler.
File
- src/
SensorPlugin/ DatabaseAggregatorSensorPluginBase.php, line 118 - Contains \Drupal\monitoring\SensorPlugin\DatabaseAggregatorSensorPluginBase.
Class
- DatabaseAggregatorSensorPluginBase
- Base class for database aggregator sensors.
Namespace
Drupal\monitoring\SensorPluginCode
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
/** @var \Drupal\monitoring\Form\SensorForm $sensor_form */
$sensor_form = $form_state
->getFormObject();
/** @var \Drupal\monitoring\SensorConfigInterface $sensor_config */
$sensor_config = $sensor_form
->getEntity();
// Copy time interval field & value into settings if the field is specified.
if ($interval_field = $form_state
->getValue(array(
'settings',
'aggregation',
'time_interval_field',
))) {
$sensor_config->settings['time_interval_field'] = $interval_field;
$interval_value = $form_state
->getValue(array(
'settings',
'aggregation',
'time_interval_value',
));
$sensor_config->settings['time_interval_value'] = $interval_value;
// Remove UI structure originated settings leftover.
}
else {
// For consistency, empty the field + value setting if no field defined.
unset($sensor_config->settings['time_interval_field']);
unset($sensor_config->settings['time_interval_value']);
}
unset($sensor_config->settings['aggregation']);
}