public function OpenIDConnectSettingsForm::submitForm in OpenID Connect / OAuth client 8
Same name and namespace in other branches
- 2.x src/Form/OpenIDConnectSettingsForm.php \Drupal\openid_connect\Form\OpenIDConnectSettingsForm::submitForm()
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/ OpenIDConnectSettingsForm.php, line 265
Class
- OpenIDConnectSettingsForm
- Provides the OpenID Connect settings form.
Namespace
Drupal\openid_connect\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$this
->config('openid_connect.settings')
->set('always_save_userinfo', $form_state
->getValue('always_save_userinfo'))
->set('connect_existing_users', $form_state
->getValue('connect_existing_users'))
->set('override_registration_settings', $form_state
->getValue('override_registration_settings'))
->set('userinfo_mappings', array_filter($form_state
->getValue('userinfo_mappings')))
->set('user_login_display', $form_state
->getValue('user_login_display'))
->save();
// Get clients' enabled status.
$clients_enabled = $form_state
->getValue('clients_enabled');
// Get client plugins.
$clients = $this
->getClients();
// Save client settings.
foreach ($clients_enabled as $plugin_id => $status) {
$this
->configFactory()
->getEditable('openid_connect.settings.' . $plugin_id)
->set('enabled', (bool) $status)
->save();
// Whether the client is not enabled.
if (!(bool) $status) {
continue;
}
// Get subform and subform state.
$subform = $form['clients'][$plugin_id]['settings'];
$subform_state = SubformState::createForSubform($subform, $form, $form_state);
// Let the plugin preprocess submitted values.
$clients[$plugin_id]
->submitConfigurationForm($subform, $subform_state);
// Save plugin settings.
$this
->configFactory()
->getEditable('openid_connect.settings.' . $plugin_id)
->set('settings', $subform_state
->getValues())
->save();
}
}