SettingsFormBase.php in Mass Contact 8
File
src/Form/SettingsFormBase.php
View source
<?php
namespace Drupal\mass_contact\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
abstract class SettingsFormBase extends ConfigFormBase {
protected abstract function getConfigKeys();
protected function getEditableConfigNames() {
return [
'mass_contact.settings',
];
}
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$config = $this->configFactory
->getEditable('mass_contact.settings');
foreach ($this
->getConfigKeys() as $key) {
$config
->set($key, $form_state
->getValue($key));
}
$config
->save();
}
}