public function CasSettings::submitForm in CAS 8
Same name and namespace in other branches
- 2.x src/Form/CasSettings.php \Drupal\cas\Form\CasSettings::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/ CasSettings.php, line 564
Class
- CasSettings
- Class CasSettings.
Namespace
Drupal\cas\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('cas.settings');
$server_data = $form_state
->getValue('server');
$config
->set('server.version', $server_data['version'])
->set('server.protocol', $server_data['protocol'])
->set('server.hostname', $server_data['hostname'])
->set('server.port', $server_data['port'])
->set('server.path', $server_data['path'])
->set('server.verify', $server_data['verify'])
->set('server.cert', $server_data['cert']);
$general_data = $form_state
->getValue('general');
$config
->set('login_link_enabled', $general_data['login_link_enabled'])
->set('login_link_label', $general_data['login_link_label'])
->set('login_success_message', $general_data['login_success_message']);
$condition_values = (new FormState())
->setValues($form_state
->getValue([
'gateway',
'paths',
]));
$this->gatewayPaths
->submitConfigurationForm($form, $condition_values);
$config
->set('gateway.check_frequency', $form_state
->getValue([
'gateway',
'check_frequency',
]))
->set('gateway.paths', $this->gatewayPaths
->getConfiguration());
$condition_values = (new FormState())
->setValues($form_state
->getValue([
'forced_login',
'paths',
]));
$this->forcedLoginPaths
->submitConfigurationForm($form, $condition_values);
$config
->set('forced_login.enabled', $form_state
->getValue([
'forced_login',
'enabled',
]))
->set('forced_login.paths', $this->forcedLoginPaths
->getConfiguration());
$config
->set('logout.logout_destination', $form_state
->getValue([
'logout',
'logout_destination',
]))
->set('logout.enable_single_logout', $form_state
->getValue([
'logout',
'enable_single_logout',
]))
->set('logout.cas_logout', $form_state
->getValue([
'logout',
'cas_logout',
]))
->set('logout.single_logout_session_lifetime', $form_state
->getValue([
'logout',
'single_logout_session_lifetime',
]));
$config
->set('proxy.initialize', $form_state
->getValue([
'proxy',
'initialize',
]))
->set('proxy.can_be_proxied', $form_state
->getValue([
'proxy',
'can_be_proxied',
]))
->set('proxy.proxy_chains', $form_state
->getValue([
'proxy',
'proxy_chains',
]));
$config
->set('user_accounts.prevent_normal_login', $form_state
->getValue([
'user_accounts',
'prevent_normal_login',
]))
->set('user_accounts.auto_register', $form_state
->getValue([
'user_accounts',
'auto_register',
]))
->set('user_accounts.email_assignment_strategy', $form_state
->getValue([
'user_accounts',
'email_assignment_strategy',
]))
->set('user_accounts.email_hostname', $form_state
->getValue([
'user_accounts',
'email_hostname',
]))
->set('user_accounts.email_attribute', $form_state
->getValue([
'user_accounts',
'email_attribute',
]))
->set('user_accounts.restrict_password_management', $form_state
->getValue([
'user_accounts',
'restrict_password_management',
]))
->set('user_accounts.restrict_email_management', $form_state
->getValue([
'user_accounts',
'restrict_email_management',
]));
$auto_assigned_roles = [];
if ($form_state
->getValue([
'user_accounts',
'auto_assigned_roles_enable',
])) {
$auto_assigned_roles = array_keys($form_state
->getValue([
'user_accounts',
'auto_assigned_roles',
]));
}
$config
->set('user_accounts.auto_assigned_roles', $auto_assigned_roles);
$config
->set('error_handling.login_failure_page', trim($form_state
->getValue([
'error_handling',
'login_failure_page',
])));
$messages = $form_state
->getValue([
'error_handling',
'messages',
]);
$config
->set('error_handling.message_validation_failure', trim($messages['message_validation_failure']))
->set('error_handling.message_no_local_account', trim($messages['message_no_local_account']))
->set('error_handling.message_subscriber_denied_reg', trim($messages['message_subscriber_denied_reg']))
->set('error_handling.message_subscriber_denied_login', trim($messages['message_subscriber_denied_login']))
->set('error_handling.message_account_blocked', trim($messages['message_account_blocked']))
->set('error_handling.message_username_already_exists', trim($messages['message_username_already_exists']))
->set('error_handling.message_prevent_normal_login', trim($messages['message_prevent_normal_login']))
->set('error_handling.message_restrict_password_management', trim($messages['message_restrict_password_management']));
$config
->set('advanced.debug_log', $form_state
->getValue([
'advanced',
'debug_log',
]))
->set('advanced.connection_timeout', $form_state
->getValue([
'advanced',
'connection_timeout',
]));
$config
->save();
parent::submitForm($form, $form_state);
}