You are here

public function OpenIDConnectSettingsForm::submitForm in OpenID Connect / OAuth client 2.x

Same name and namespace in other branches
  1. 8 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 229

Class

OpenIDConnectSettingsForm
Provides the OpenID Connect settings form.

Namespace

Drupal\openid_connect\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $role_mappings = [];
  foreach ($form_state
    ->getValue('role_mappings') as $role => $mapping) {
    $role_mappings[$role] = array_values(array_filter(str_getcsv($mapping, ' ')));
  }
  $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('end_session_enabled', $form_state
    ->getValue('end_session_enabled'))
    ->set('user_login_display', $form_state
    ->getValue('user_login_display'))
    ->set('redirect_login', $form_state
    ->getValue('redirect_login'))
    ->set('redirect_logout', $form_state
    ->getValue('redirect_logout'))
    ->set('userinfo_mappings', array_filter($form_state
    ->getValue('userinfo_mappings')))
    ->set('role_mappings', $role_mappings)
    ->save();
}