public function Mapping::submitForm in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 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 FormInterface::submitForm
File
- src/
Form/ Mapping.php, line 247 - Contains Attribute and Role Mapping for miniOrange SAML Login Module.
Class
Namespace
Drupal\miniorange_saml\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state
->getValues();
$username_attribute = $form_values['miniorange_saml_username_attribute'];
$email_attribute = $form_values['miniorange_saml_email_attribute'];
$enable_rolemapping = $form_values['miniorange_saml_enable_rolemapping'];
$default_mapping = $form_values['miniorange_saml_default_mapping'];
$i = 0;
$mrole = user_role_names(TRUE);
foreach ($mrole as $key => $value) {
$def_role[$i] = $value;
$i++;
}
$enable_rolemapping_value = $enable_rolemapping == 1 ? TRUE : FALSE;
if ($enable_rolemapping_value) {
\Drupal::configFactory()
->getEditable('miniorange_saml.settings')
->set('miniorange_saml_default_role', $def_role[$default_mapping]);
\Drupal::configFactory()
->getEditable('miniorange_saml.settings')
->set('miniorange_saml_default_role_index', $default_mapping);
}
else {
\Drupal::configFactory()
->getEditable('miniorange_saml.settings')
->set('miniorange_saml_default_role', $mrole['authenticated'])
->save();
}
\Drupal::configFactory()
->getEditable('miniorange_saml.settings')
->set('miniorange_saml_username_attribute', $username_attribute)
->save();
\Drupal::configFactory()
->getEditable('miniorange_saml.settings')
->set('miniorange_saml_email_attribute', $email_attribute)
->save();
\Drupal::configFactory()
->getEditable('miniorange_saml.settings')
->set('miniorange_saml_enable_rolemapping', $enable_rolemapping_value)
->save();
\Drupal::messenger()
->addMessage(t('Mapping Settings successfully saved'), 'status');
}