public static function ContentImportTrait::finishImportBatch in Content Synchronization 3.0.x
Same name and namespace in other branches
- 8.2 src/Form/ContentImportTrait.php \Drupal\content_sync\Form\ContentImportTrait::finishImportBatch()
Finish batch.
This function is a static function to avoid serializing the ContentSync object unnecessarily.
File
- src/
Form/ ContentImportTrait.php, line 194
Class
- ContentImportTrait
- Defines the content import form.
Namespace
Drupal\content_sync\FormCode
public static function finishImportBatch($success, $results, $operations) {
if ($success) {
if (!empty($results['errors'])) {
foreach ($results['errors'] as $error) {
\Drupal::messenger()
->addError($error);
\Drupal::logger('config_sync')
->error($error);
}
\Drupal::messenger()
->addWarning(\Drupal::translation()
->translate('The content was imported with errors.'));
}
else {
\Drupal::messenger()
->addStatus(\Drupal::translation()
->translate('The content was imported successfully.'));
}
}
else {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
$message = \Drupal::translation()
->translate('An error occurred while processing %error_operation with arguments: @arguments', [
'%error_operation' => $error_operation[0],
'@arguments' => print_r($error_operation[1], TRUE),
]);
\Drupal::messenger()
->addError($message, 'error');
}
}