You are here

public function Lingotek::getUploadedTimestamp in Lingotek Translation 8

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

Gets the last edited timestamp from Lingotek service.

Parameters

string $doc_id: The document id in Lingotek.

Return value

int The timestamp.

Overrides LingotekInterface::getUploadedTimestamp

File

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

Class

Lingotek

Namespace

Drupal\lingotek

Code

public function getUploadedTimestamp($doc_id) {

  // For now, a passthrough to the API object so the controllers do not
  // need to include that class.
  $modified_date = FALSE;
  try {
    $response = $this->api
      ->getDocumentInfo($doc_id);
    if ($response
      ->getStatusCode() == Response::HTTP_OK) {
      $response_json = json_decode($response
        ->getBody(), TRUE);

      // We have millisecond precision in Lingotek.
      $modified_date = intval(floor($response_json['properties']['last_uploaded_date'] / 1000));
    }
  } catch (LingotekApiException $exception) {
    return FALSE;
  }
  return $modified_date;
}