You are here

function lingotek_operation_content_upload_finished in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 lingotek.batch.inc \lingotek_operation_content_upload_finished()
  2. 8.2 lingotek.batch.inc \lingotek_operation_content_upload_finished()
  3. 4.0.x lingotek.batch.inc \lingotek_operation_content_upload_finished()
  4. 3.0.x lingotek.batch.inc \lingotek_operation_content_upload_finished()
  5. 3.1.x lingotek.batch.inc \lingotek_operation_content_upload_finished()
  6. 3.2.x lingotek.batch.inc \lingotek_operation_content_upload_finished()
  7. 3.3.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 92
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::messenger()
      ->addError(\Drupal::service('renderer')
      ->renderPlain($error_message));
  }
  $count = !empty($results['uploads']) ? $results['uploads'] : 0;
  $message = \Drupal::translation()
    ->formatPlural($count, 'Uploaded 1 document to Lingotek.', 'Uploaded @num documents to Lingotek.', [
    '@num' => $count,
  ]);
  if (isset($results['error'])) {
    \Drupal::messenger()
      ->addWarning($message);
  }
  else {
    \Drupal::messenger()
      ->addStatus($message);
  }
}