You are here

protected function TranslationRequestManager::createNewTranslationRequest in TMGMT Translator Smartling 8.4

Creates translation request.

Parameters

\Drupal\tmgmt\JobInterface $job:

Return value

bool

2 calls to TranslationRequestManager::createNewTranslationRequest()
TranslationRequestManager::upsertTranslationRequest in src/Smartling/Submission/TranslationRequestManager.php
Send jobs to Submission service.
TranslationRequestManagerTested::createNewTranslationRequest in tests/src/Kernel/TranslationRequestManagerTest.php
Creates translation request.
1 method overrides TranslationRequestManager::createNewTranslationRequest()
TranslationRequestManagerTested::createNewTranslationRequest in tests/src/Kernel/TranslationRequestManagerTest.php
Creates translation request.

File

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

Class

TranslationRequestManager
Class TranslationRequestManager.

Namespace

Drupal\tmgmt_smartling\Smartling\Submission

Code

protected function createNewTranslationRequest(JobInterface $job) {
  $asset_key = [
    'tmgmt_job_id' => $job
      ->id(),
  ];
  $create_submission_params = new CreateTranslationSubmissionParams();
  $create_submission_params
    ->setTargetAssetKey($asset_key)
    ->setTargetLocaleId($job
    ->getRemoteTargetLanguage())
    ->setCustomTranslationData([
    'batch_uid' => $job
      ->getSetting('batch_uid'),
    'batch_execute_on_job' => $job
      ->getSetting('batch_execute_on_job'),
  ])
    ->setState(TranslationSubmissionStates::STATE_NEW)
    ->setSubmitterName($this
    ->getSubmitterName($job));
  $create_request_params = new CreateTranslationRequestParams();
  $create_request_params
    ->setOriginalAssetKey($asset_key)
    ->setTitle($job
    ->label())
    ->setFileUri($job
    ->getTranslatorPlugin()
    ->getFileName($job))
    ->setOriginalLocaleId($job
    ->getSourceLangcode())
    ->addTranslationSubmission($create_submission_params);
  return $this->apiWrapper
    ->createTranslationRequest($this
    ->getBucketName($job), $create_request_params);
}