public function ContentExportTrait::finishContentExportBatch in Content Synchronization 8.2
Same name and namespace in other branches
- 3.0.x src/Form/ContentExportTrait.php \Drupal\content_sync\Form\ContentExportTrait::finishContentExportBatch()
Finish batch.
Provide information about the Content Batch results.
File
- src/
Form/ ContentExportTrait.php, line 245
Class
- ContentExportTrait
- Defines the content export form.
Namespace
Drupal\content_sync\FormCode
public function finishContentExportBatch($success, $results, $operations) {
if ($success) {
if (isset($results['errors'])) {
$errors = $results['errors'];
unset($results['errors']);
}
$results = array_unique($results);
// Log all the items processed
foreach ($results as $key => $result) {
if ($key != 'errors') {
//drupal_set_message(t('Processed UUID @title.', array('@title' => $result)));
$this
->getExportLogger()
->info('Processed UUID @title.', [
'@title' => $result,
'link' => 'Export',
]);
}
}
if (isset($errors) && !empty($errors)) {
// Log the errors
$errors = array_unique($errors);
foreach ($errors as $error) {
//drupal_set_message($error, 'error');
$this
->getExportLogger()
->error($error);
}
// Log the note that the content was exported with errors.
\Drupal::messenger()
->addWarning($this
->t('The content was exported with errors. <a href=":content-overview">Logs</a>', [
':content-overview' => Url::fromRoute('content.overview')
->toString(),
]));
$this
->getExportLogger()
->warning('The content was exported with errors.', [
'link' => 'Export',
]);
}
else {
// Log the new created export link if applicable.
\Drupal::messenger()
->addStatus($this
->t('The content was exported successfully. <a href=":export-download">Download tar file</a>', [
':export-download' => Url::fromRoute('content.export_download')
->toString(),
]));
$this
->getExportLogger()
->info('The content was exported successfully. <a href=":export-download">Download tar file</a>', [
':export-download' => Url::fromRoute('content.export_download')
->toString(),
'link' => 'Export',
]);
}
}
else {
// Log that there was an error.
$message = $this
->t('Finished with an error.<a href=":content-overview">Logs</a>', [
':content-overview' => Url::fromRoute('content.overview')
->toString(),
]);
\Drupal::messenger()
->addStatus($message);
$this
->getExportLogger()
->error('Finished with an error.', [
'link' => 'Export',
]);
}
}