public function RoleSettingsForm::submitForm in Drupal 9
Same name and namespace in other branches
- 10 core/modules/user/src/Form/RoleSettingsForm.php \Drupal\user\Form\RoleSettingsForm::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 FormInterface::submitForm
File
- core/
modules/ user/ src/ Form/ RoleSettingsForm.php, line 91
Class
- RoleSettingsForm
- Configure administrator role settings for this site.
Namespace
Drupal\user\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->hasValue('user_admin_role')) {
$admin_roles = $this->roleStorage
->getQuery()
->condition('is_admin', TRUE)
->execute();
foreach ($admin_roles as $rid) {
$this->roleStorage
->load($rid)
->setIsAdmin(FALSE)
->save();
}
$new_admin_role = $form_state
->getValue('user_admin_role');
if ($new_admin_role) {
$this->roleStorage
->load($new_admin_role)
->setIsAdmin(TRUE)
->save();
}
}
}