You are here

public function TranslationRequestManager::isTranslationRequestReadyForDownload in TMGMT Translator Smartling 8.4

Check if job ready for download.

Parameters

\Drupal\tmgmt\JobInterface $job:

Return value

mixed

File

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

Class

TranslationRequestManager
Class TranslationRequestManager.

Namespace

Drupal\tmgmt_smartling\Smartling\Submission

Code

public function isTranslationRequestReadyForDownload(JobInterface $job) {
  $this
    ->initApiWrapper($job);
  $translation_request = $this
    ->getTranslationRequest($job);
  if (empty($translation_request) || $this
    ->isTranslationSubmissionMissed($translation_request)) {
    $this->logger
      ->error('Translation request does not contain translation submission. Translation request = @translation_request', [
      '@translation_request' => json_encode($translation_request),
    ]);
    $result = FALSE;
  }
  else {
    $result = in_array($translation_request['translationSubmissions'][0]['state'], [
      TranslationSubmissionStates::STATE_TRANSLATED,
      TranslationSubmissionStates::STATE_COMPLETED,
    ]);
  }
  if (empty($result)) {
    $this->logger
      ->info('Translation request submission is not ready for download. Translation request = @translation_request', [
      '@translation_request' => json_encode($translation_request),
    ]);
  }
  return $result;
}