You are here

public function SmartlingApiWrapper::createBatch in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 src/Smartling/SmartlingApiWrapper.php \Drupal\tmgmt_smartling\Smartling\SmartlingApiWrapper::createBatch()

Creates Smartling batch.

Parameters

$job_id:

$authorize:

Return value

array

File

src/Smartling/SmartlingApiWrapper.php, line 265
SmartlingApiWrapper.php.

Class

SmartlingApiWrapper
Class SmartlingApiWrapper @package Drupal\tmgmt_smartling\Smartling

Namespace

Drupal\tmgmt_smartling\Smartling

Code

public function createBatch($job_id, $authorize) {
  $batch_uid = NULL;
  try {
    $params = new CreateBatchParameters();
    $params
      ->setTranslationJobUid($job_id);
    $params
      ->setAuthorize($authorize);
    $response = $this
      ->getApi('batch')
      ->createBatch($params);
    $batch_uid = $response['batchUid'];
    $this->logger
      ->info('Smartling created a batch:<br/>Id: @id', [
      '@id' => $batch_uid,
    ]);
  } catch (SmartlingApiException $e) {
    $this->logger
      ->error('Smartling failed to create a batch:<br/>Error: @error', [
      '@error' => $e
        ->getMessage(),
    ]);
  }
  return $batch_uid;
}