You are here

function lingotek_operation_content_upload_finished in Lingotek Translation 8

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

File

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

Code

function lingotek_operation_content_upload_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['uploads']) ? $results['uploads'] : 0;
  $message = \Drupal::translation()
    ->formatPlural($count, 'Uploaded 1 document to Lingotek.', 'Uploaded @num documents to Lingotek.', array(
    '@num' => $count,
  ));
  if (isset($results['error'])) {
    drupal_set_message($message, 'warning');
  }
  else {
    drupal_set_message($message);
  }
}