public function MassPasswordResetForm::submitForm in Mass Password Reset 8
Same name and namespace in other branches
- 2.x src/Form/MassPasswordResetForm.php \Drupal\mass_pwreset\Form\MassPasswordResetForm::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/ MassPasswordResetForm.php, line 146
Class
- MassPasswordResetForm
- Mass Password Reset Form.
Namespace
Drupal\mass_pwreset\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Get 'uids' and 'roles' values set in form validation.
$uids = $form_state
->get('uids');
$roles = $form_state
->get('roles');
// If the admin user is to be included in the reset and the current user is
// NOT the super admin user, add the uid of 1 to the $uids array.
// A check to see if the current user is 1 is required because resetting
// your own password will make the batch fail.
if ($form_state
->getValue('include_admin_user') == 1 && $this
->currentUser()
->id() != 1) {
array_push($uids, 1);
}
// Construct the batch data array that will be used in the batch process.
$batch_data = [
'uids' => $uids,
'notify_active_users' => $form_state
->getValue('notify_active_users'),
'notify_blocked_users' => $form_state
->getValue('notify_blocked_users'),
'roles' => $roles,
];
// Store batch data in private tempstore.
$tempstore = \Drupal::service('tempstore.private')
->get('mass_pwreset');
$tempstore
->set('batch_data', $batch_data);
// Redirect to the confirm form.
$form_state
->setRedirect('mass_pwreset_confirm_form');
}