public function PeopleDelete::submitForm in Delete all 8
Same name and namespace in other branches
- 2.x src/Form/PeopleDelete.php \Drupal\delete_all\Form\PeopleDelete::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
- src/
Form/ PeopleDelete.php, line 93
Class
- PeopleDelete
- Form for user deleting option.
Namespace
Drupal\delete_all\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$delete_all_checkbox = $form_state
->getValue([
'select_all',
]);
$selected_role = $form_state
->getValue('role_type');
$userDeleteController = new UserDeleteController();
if ($delete_all_checkbox == 1) {
$users_to_delete = $userDeleteController
->getUserToDelete();
}
else {
$users_to_delete = $userDeleteController
->getUserToDelete([
$selected_role,
]);
}
$batch = $userDeleteController
->getUserDeleteBatch($users_to_delete);
batch_set($batch);
}