public static function PriceListItemExportForm::finishBatch in Commerce Pricelist 8.2
Batch finished callback: display batch statistics.
Parameters
bool $success: Indicates whether the batch has completed successfully.
mixed[] $results: The array of results gathered by the batch processing.
string[] $operations: If $success is FALSE, contains the operations that remained unprocessed.
File
- src/
Form/ PriceListItemExportForm.php, line 285
Class
Namespace
Drupal\commerce_pricelist\FormCode
public static function finishBatch($success, array $results, array $operations) {
$messenger = \Drupal::messenger();
if (!$success) {
$error_operation = reset($operations);
$messenger
->addError(t('An error occurred while processing @operation with arguments: @args', [
'@operation' => $error_operation[0],
'@args' => (string) print_r($error_operation[0], TRUE),
]));
return;
}
if (isset($results['error_message'])) {
$messenger
->addError($results['error_message']);
return;
}
$translation = \Drupal::translation();
if (!empty($results['export_count'])) {
$messenger
->addStatus($translation
->formatPlural($results['export_count'], 'Exported 1 price.', 'Exported @count prices.'));
}
if (isset($results['external_url'])) {
$messenger
->addStatus(t('The generated file can be downloaded at the following url: <a href="@url">@url</a>.', [
'@url' => $results['external_url'],
]));
}
}