public function BakerySettingsForm::submitForm in Bakery Single Sign-On System 8.2
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/
Forms/ BakerySettingsForm.php, line 126
Class
- BakerySettingsForm
- Configure bakery settings for this site.
Namespace
Drupal\bakery\FormsCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('bakery.settings');
$config
->set('bakery_is_master', $form_state
->getValue('bakery_is_master'))
->set('bakery_master', trim($form_state
->getValue('bakery_master'), '/') . '/')
->set('subsite_login', (bool) $form_state
->getValue('subsite_login'))
->set('bakery_help_text', $form_state
->getValue('bakery_help_text'))
->set('bakery_freshness', $form_state
->getValue('bakery_freshness'))
->set('bakery_key', $form_state
->getValue('bakery_key'))
->set('bakery_domain', $form_state
->getValue('bakery_domain'))
->set('bakery_supported_fields', $form_state
->getValue('bakery_supported_fields'));
if ($form_state
->getValue('bakery_slaves') && !empty($form_state
->getValue('bakery_slaves'))) {
// Transform the text string into an array.
$slaves = explode("\n", trim(str_replace("\r", '', $form_state
->getValue('bakery_slaves'))));
// For each entry, remove the trailing slash
// (if present) and concatenate with a new trailing slash.
foreach ($slaves as &$slave) {
$slave = trim($slave, '/') . '/';
}
$config
->set('bakery_slaves', $slaves);
}
else {
$config
->set('bakery_slaves', []);
}
$config
->save();
// Trigger some rebuilds that might be required by main/child changes.
\Drupal::service('router.builder')
->setRebuildNeeded();
parent::submitForm($form, $form_state);
}