public static function NodeImport::nodeImportFinishedCallback in Node export 8
Batch finish callback method. Handles results & display messages to user.
Parameters
bool $success: Whether or not any fatal PHP errors were detected.
array $results: An array containing the results key of context array.
array $operations: An array containing batch operations.
File
- src/
NodeImport.php, line 145
Class
- NodeImport
- Provides a Node Import function.
Namespace
Drupal\node_exportCode
public static function nodeImportFinishedCallback($success, array $results, array $operations) {
// The 'success' parameter means no fatal PHP errors were detected. All
// other error management should be handled using 'results'.
if ($success) {
$message = '';
if (array_key_exists('imported', $results) && count($results['imported']) > 0) {
$message .= \Drupal::translation()
->formatPlural(count($results['imported']), 'One node imported.', '@count nodes imported.');
}
if (array_key_exists('not_imported', $results) && count($results['not_imported']) > 0) {
$message .= "\n" . \Drupal::translation()
->formatPlural(count($results['not_imported']), 'One node could not be imported.', '@count nodes could not be imported.');
}
}
else {
$message = $this
->t('Finished with an error.');
}
\Drupal::messenger()
->addStatus($message);
}