You are here

public function TranslationRequestManager::commitError in TMGMT Translator Smartling 8.4

Parameters

\Drupal\tmgmt\JobInterface $job:

array $translation_request:

\Exception $e:

Return value

mixed

File

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

Class

TranslationRequestManager
Class TranslationRequestManager.

Namespace

Drupal\tmgmt_smartling\Smartling\Submission

Code

public function commitError(JobInterface $job, array $translation_request, Exception $e) {
  $this
    ->initApiWrapper($job);
  if ($this
    ->isTranslationSubmissionMissed($translation_request)) {
    return FALSE;
  }
  $update_submission_params = new UpdateTranslationSubmissionParams();
  $update_submission_params
    ->setState(TranslationSubmissionStates::STATE_FAILED)
    ->setLastErrorMessage(mb_substr($e
    ->getMessage() . ': ' . $e
    ->getTraceAsString(), 0, 1024))
    ->setTranslationSubmissionUid($translation_request['translationSubmissions'][0]['translationSubmissionUid']);
  $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);
}