You are here

public function LingotekDocument::getImportStatus in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.7 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::getImportStatus()
  2. 7.5 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::getImportStatus()
  3. 7.6 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::getImportStatus()

File

lib/Drupal/lingotek/LingotekDocument.php, line 144
Defines LingotekDocument.

Class

LingotekDocument
A class representing a Lingotek Document

Code

public function getImportStatus($include_details = TRUE) {
  $response = $this->api
    ->request('getDocumentImportStatus', array(
    'id' => $this->document_id,
  ));
  $status = self::IMPORT_STATUS__UNKNOWN;
  $status_message = $status;
  if ($response->results == 'success') {
    $status = $response->status;
    if ($status === self::IMPORT_STATUS__PROCESSING) {
      $status_message = $status . " (" . $response->process->percentComplete . "% complete)";
    }
    elseif ($status === self::IMPORT_STATUS__ERROR) {
      $status_message = $status . " (" . $response->process->error . ")";
    }
    else {
      $status_message = $status;
    }
  }
  elseif ($response->results == 'fail') {
    $status = self::IMPORT_STATUS__ERROR;
    $status_message = $status . " (" . $response->error . ")";
  }
  return $include_details ? $status_message : $status;
}