You are here

function lingotek_operation_content_download_finished in Lingotek Translation 3.2.x

Same name and namespace in other branches
  1. 8 lingotek.batch.inc \lingotek_operation_content_download_finished()
  2. 8.2 lingotek.batch.inc \lingotek_operation_content_download_finished()
  3. 4.0.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  4. 3.0.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  5. 3.1.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  6. 3.3.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  7. 3.4.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  8. 3.5.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  9. 3.6.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  10. 3.7.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  11. 3.8.x lingotek.batch.inc \lingotek_operation_content_download_finished()
1 string reference to 'lingotek_operation_content_download_finished'
LingotekBatchController::downloadSingle in src/Controller/LingotekBatchController.php

File

./lingotek.batch.inc, line 159
Lingotek batch functions

Code

function lingotek_operation_content_download_finished($success, $results, $operations) {
  if (isset($results['error'])) {
    $error_message = [
      '#type' => 'inline_template',
      '#template' => 'Some operations failed: {{ errors }}',
      '#context' => [
        'errors' => [
          '#theme' => 'item_list',
          '#items' => $results['error'],
        ],
      ],
    ];
    \Drupal::messenger()
      ->addError(\Drupal::service('renderer')
      ->renderPlain($error_message));
  }
  $count = !empty($results['downloads']) ? $results['downloads'] : 0;
  $message = \Drupal::translation()
    ->formatPlural($count, 'Downloaded a document from Lingotek.', 'Downloaded @num documents from Lingotek.', [
    '@num' => $count,
  ]);
  if (isset($results['error'])) {
    \Drupal::messenger()
      ->addWarning($message);
  }
  else {
    \Drupal::messenger()
      ->addStatus($message);
  }
}