You are here

public function Lingotek::getDocumentTranslationStatuses in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  2. 4.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  3. 3.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  4. 3.1.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  5. 3.2.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  6. 3.3.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  7. 3.4.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  8. 3.5.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  9. 3.6.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  10. 3.7.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()
  11. 3.8.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatuses()

Overrides LingotekInterface::getDocumentTranslationStatuses

File

src/Lingotek.php, line 358
Contains \Drupal\lingotek\Lingotek.

Class

Lingotek

Namespace

Drupal\lingotek

Code

public function getDocumentTranslationStatuses($doc_id) {
  $statuses = array();
  try {
    $response = $this->api
      ->getDocumentTranslationStatuses($doc_id);
  } catch (LingotekApiException $e) {

    // No targets found for this doc
    return $statuses;
  }
  if ($response
    ->getStatusCode() == Response::HTTP_OK) {
    $progress_json = json_decode($response
      ->getBody(), TRUE);
    if (!empty($progress_json['entities'])) {
      foreach ($progress_json['entities'] as $index => $data) {
        $lingotek_locale = $data['properties']['locale_code'];
        $statuses[$lingotek_locale] = $data['properties']['percent_complete'];
      }
    }
  }
  return $statuses;
}