You are here

public function FileApi::lastModified in TMGMT Translator Smartling 8.2

Same name in this branch
  1. 8.2 api-sdk-php/src/File/FileApi.php \Smartling\File\FileApi::lastModified()
  2. 8.2 vendor/smartling/api-sdk-php/src/File/FileApi.php \Smartling\File\FileApi::lastModified()
Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/src/File/FileApi.php \Smartling\File\FileApi::lastModified()
  2. 8.3 vendor/smartling/api-sdk-php/src/File/FileApi.php \Smartling\File\FileApi::lastModified()

Requests last-modified value for all locales for file

Parameters

string $fileUri: Value that uniquely identifies the uploaded file. This ID can be used to request the file back.

Return value

array Data about uploaded file.

Throws

\Smartling\Exceptions\SmartlingApiException

See also

http://docs.smartling.com/pages/API/v2/FileAPI/Last-Modified/All-Locales/

File

api-sdk-php/src/File/FileApi.php, line 116

Class

FileApi
Class FileApi

Namespace

Smartling\File

Code

public function lastModified($fileUri) {
  $params['fileUri'] = $fileUri;
  $requestData = $this
    ->getDefaultRequestData('query', $params);
  $result = $this
    ->sendRequest('file/last-modified', $requestData, self::HTTP_METHOD_GET);

  /** @noinspection OffsetOperationsInspection */
  if (is_array($result) && array_key_exists('items', $result) && is_array($result['items'])) {

    /** @noinspection OffsetOperationsInspection */
    foreach ($result['items'] as &$item) {
      $date = \DateTime::createFromFormat(self::PATTERN_DATE_TIME_ISO_8601, $item['lastModified']);
      if (!$date instanceof \DateTime) {
        $date = \DateTime::createFromFormat(self::PATTERN_DATE_TIME_ISO_8601, '1970-01-01T00:00:00Z');
      }
      $item['lastModified'] = $date;
    }
  }
  return $result;
}