You are here

public function SmartlingApiWrapper::listJobs in TMGMT Translator Smartling 8.3

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

Returns list of jobs by name.

Parameters

null $name:

array $statuses:

Return value

array

File

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

Class

SmartlingApiWrapper
Class SmartlingApiWrapper @package Drupal\tmgmt_smartling\Smartling

Namespace

Drupal\tmgmt_smartling\Smartling

Code

public function listJobs($name = NULL, array $statuses = []) {
  $result = [];
  try {
    $params = new ListJobsParameters();
    if (!empty($name)) {
      $params
        ->setName($name);
    }
    if (!empty($statuses)) {
      $params
        ->setStatuses($statuses);
    }
    $result = $this
      ->getApi('jobs')
      ->listJobs($params);
  } catch (SmartlingApiException $e) {
    $this->logger
      ->error('Smartling failed to fetch list of available jobs:<br/>Error: @error', [
      '@error' => $e
        ->getMessage(),
    ]);
  }
  return $result;
}