public function SettingsForm::submitForm in Drupalmonitor 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ SettingsForm.php, line 135
Class
- SettingsForm
- Class SettingsForm.
Namespace
Drupal\drupalmonitor\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
// Get Config.
$config = $this
->getConfig();
// Set Hash.
$config
->set(Settings::CONFIG_KEY_HASH, $form_state
->getValue(Settings::CONFIG_KEY_HASH));
// Set Metrics.
$metrics_to_save = [
Settings::CONFIG_KEY_SERVER_MONITORING,
Settings::CONFIG_KEY_USER_MONITORING,
Settings::CONFIG_KEY_FILES_MONITORING,
Settings::CONFIG_KEY_NODE_MONITORING,
Settings::CONFIG_KEY_MODULES_MONITORING,
Settings::CONFIG_KEY_VARIABLES_MONITORING,
];
foreach ($metrics_to_save as $metric_key) {
$config
->set($metric_key, (int) $form_state
->getValue($metric_key));
}
$config
->save();
}