You are here

function lingotek_operation_content_download_finished in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 lingotek.batch.inc \lingotek_operation_content_download_finished()
  2. 4.0.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  3. 3.0.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  4. 3.1.x lingotek.batch.inc \lingotek_operation_content_download_finished()
  5. 3.2.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 111
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_set_message(\Drupal::service('renderer')
      ->renderPlain($error_message), 'error');
  }
  $count = !empty($results['downloads']) ? $results['downloads'] : 0;
  $message = \Drupal::translation()
    ->formatPlural($count, 'Downloaded a document from Lingotek.', 'Downloaded @num documents from Lingotek.', array(
    '@num' => $count,
  ));
  if (isset($results['error'])) {
    drupal_set_message($message, 'warning');
  }
  else {
    drupal_set_message($message);
  }
}