You are here

public function TranslationRequestManager::commitSuccessfulDownload in TMGMT Translator Smartling 8.4

Parameters

\Drupal\tmgmt\JobInterface $job:

array $translation_request:

Return value

mixed

File

src/Smartling/Submission/TranslationRequestManager.php, line 274

Class

TranslationRequestManager
Class TranslationRequestManager.

Namespace

Drupal\tmgmt_smartling\Smartling\Submission

Code

public function commitSuccessfulDownload(JobInterface $job, array $translation_request) {
  $this
    ->initApiWrapper($job);
  if ($this
    ->isTranslationSubmissionMissed($translation_request)) {
    return FALSE;
  }
  $update_submission_params = new UpdateTranslationSubmissionParams();
  $update_submission_params
    ->setLastExportedDate(new \DateTime('now', new \DateTimeZone('UTC')))
    ->setTranslationSubmissionUid($translation_request['translationSubmissions'][0]['translationSubmissionUid']);
  if ($translation_request['translationSubmissions'][0]['state'] === TranslationSubmissionStates::STATE_TRANSLATED) {
    $update_submission_params
      ->setState(TranslationSubmissionStates::STATE_COMPLETED);
  }
  $update_request_params = new UpdateTranslationRequestParams();
  $update_request_params
    ->addTranslationSubmission($update_submission_params);
  return $this->apiWrapper
    ->updateTranslationRequest($this
    ->getBucketName($job), $translation_request['translationRequestUid'], $update_request_params);
}