public static function BulkAddCasUsers::userAddFinished in CAS 8
Same name and namespace in other branches
- 2.x src/Form/BulkAddCasUsers.php \Drupal\cas\Form\BulkAddCasUsers::userAddFinished()
Complete CAS user creation batch process.
Callback for batch_set().
Consolidates message output.
File
- src/
Form/ BulkAddCasUsers.php, line 163
Class
- BulkAddCasUsers
- Class BulkAddCasUsers.
Namespace
Drupal\cas\FormCode
public static function userAddFinished($success, $results, $operations) {
$messenger = \Drupal::messenger();
if ($success) {
if (!empty($results['messages']['errors'])) {
$messenger
->addError(t('An error was encountered creating accounts for the following users (check logs for more details): %usernames', [
'%usernames' => implode(', ', $results['messages']['errors']),
]));
}
if (!empty($results['messages']['already_exists'])) {
$messenger
->addError(t('The following accounts were not registered because existing accounts are already using the usernames: %usernames', [
'%usernames' => implode(', ', $results['messages']['already_exists']),
]));
}
if (!empty($results['messages']['created'])) {
$userLinks = Markup::create(implode(', ', $results['messages']['created']));
$messenger
->addStatus(t('Successfully created accounts for the following usernames: %usernames', [
'%usernames' => $userLinks,
]));
}
}
else {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
$messenger
->addError(t('An error occurred while processing %error_operation with arguments: @arguments', [
'%error_operation' => $error_operation[0],
'@arguments' => print_r($error_operation[1], TRUE),
]));
}
}