You are here

private function JobsApi::wait in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/src/Jobs/JobsApi.php \Smartling\Jobs\JobsApi::wait()

Makes async operation sync.

Parameters

mixed $response:

Throws

SmartlingApiException

3 calls to JobsApi::wait()
JobsApi::addFileToJobSync in vendor/smartling/api-sdk-php/src/Jobs/JobsApi.php
Adds file to a job synchronously.
JobsApi::addLocaleToJobSync in vendor/smartling/api-sdk-php/src/Jobs/JobsApi.php
Adds locale to a job synchronously.
JobsApi::cancelJobSync in vendor/smartling/api-sdk-php/src/Jobs/JobsApi.php
Cancels a job synchronously.

File

vendor/smartling/api-sdk-php/src/Jobs/JobsApi.php, line 54

Class

JobsApi
Class JobsApi

Namespace

Smartling\Jobs

Code

private function wait($response) {
  if (is_array($response) && !empty($response['url'])) {
    $explodedUrl = explode('/', $response['url']);
    $arrayLength = count($explodedUrl);
    $processId = $explodedUrl[$arrayLength - 1];
    $jobId = $explodedUrl[$arrayLength - 3];
    $start_time = time();
    do {
      $delta = time() - $start_time;
      if ($delta > $this
        ->getSyncTimeOut()) {
        throw new SmartlingApiException(vsprintf('No response received after %s seconds.', [
          $delta,
        ]));
      }
      sleep(1);
      $result = $this
        ->checkAsynchronousProcessingStatus($jobId, $processId);
    } while ($result['processState'] != 'COMPLETED');
  }
}