function mass_pwreset_batch_finished in Mass Password Reset 8
Same name and namespace in other branches
- 7 mass_pwreset.batch.inc \mass_pwreset_batch_finished()
- 2.x mass_pwreset.batch.inc \mass_pwreset_batch_finished()
Batch finish callback.
Logs finished results and set message to user.
1 string reference to 'mass_pwreset_batch_finished'
- mass_pwreset_multiple_reset in ./
mass_pwreset.module - Establish batch operation for resetting passwords.
File
- ./
mass_pwreset.batch.inc, line 77 - Contains batch process functions for resetting passwords.
Code
function mass_pwreset_batch_finished($success, $results, $operations) {
if ($success) {
$passwords_reset = count($results['passwords_reset']);
// Display message to user.
$message = t('Mass password reset batch finished resetting @count passwords.', [
'@count' => $passwords_reset,
]);
\Drupal::messenger()
->addMessage($message);
// Log password reset batch finished.
$log_message = t('Mass password reset finished. @count passwords reset with roles: @roles', [
'@count' => $passwords_reset,
'@roles' => implode(', ', $results['roles']),
]);
\Drupal::logger('mass_pwreset')
->notice($log_message);
return new RedirectResponse('/admin/people/mass-pwreset');
}
else {
// Log password reset batch failure.
\Drupal::logger('mass_pwreset')
->error(t('Mass password reset batch failed.'));
\Drupal::messenger()
->addError(t('Password reset batch has failed.'));
}
}