You are here

public function SmartlingApiWrapper::cancelJob 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::cancelJob()

Cancels job.

Parameters

$job_id:

string $reason:

Return value

array

File

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

Class

SmartlingApiWrapper
Class SmartlingApiWrapper @package Drupal\tmgmt_smartling\Smartling

Namespace

Drupal\tmgmt_smartling\Smartling

Code

public function cancelJob($job_id, $reason = '') {
  $result = [];
  try {
    $params = new CancelJobParameters();
    $params
      ->setReason($reason);
    $result = $this
      ->getApi('jobs')
      ->cancelJobSync($job_id, $params);
  } catch (SmartlingApiException $e) {
    $this->logger
      ->error('Smartling failed to cancel a job:<br/>
      Job id: @job_id
      Error: @error', [
      '@job_id' => $job_id,
      '@error' => $e
        ->getMessage(),
    ]);
  }
  return $result;
}