public function LingotekApi::getDocumentTranslationStatus in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 8 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 8.2 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 4.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.1.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.2.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.3.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.4.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.5.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.6.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
- 3.8.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getDocumentTranslationStatus()
Gets the document target translation status for a given locale from the Lingotek service.
Parameters
string $id: The document id.
string $locale: The target locale.
Return value
\Psr\Http\Message\ResponseInterface A response.
Overrides LingotekApiInterface::getDocumentTranslationStatus
File
- src/
Remote/ LingotekApi.php, line 297
Class
- LingotekApi
- A simple connector to the Lingotek Translation API.
Namespace
Drupal\lingotek\RemoteCode
public function getDocumentTranslationStatus($id, $locale) {
try {
$this->logger
->debug('Lingotek::getDocumentTranslationStatus called with %id and %locale', [
'%id' => $id,
'%locale' => $locale,
]);
$response = $this->lingotekClient
->get('/api/document/' . $id . '/translation');
} catch (ClientException $e) {
if ($e
->getCode() === Response::HTTP_NOT_FOUND) {
$responseBody = json_decode($e
->getResponse()
->getBody(), TRUE);
$message = $responseBody['messages'][0];
throw new LingotekDocumentNotFoundException($message, Response::HTTP_NOT_FOUND);
}
throw new LingotekApiException('Failed to get document translation status: ' . $e
->getMessage(), $e
->getCode(), $e);
} catch (\Exception $e) {
$this->logger
->error('Error getting document translation status (%id, %locale): %message.', [
'%id' => $id,
'%locale' => $locale,
'%message' => $e
->getMessage(),
]);
throw new LingotekApiException('Failed to get document translation status: ' . $e
->getMessage());
}
$this->logger
->debug('getDocumentTranslationStatus response received, code %code and body %body', [
'%code' => $response
->getStatusCode(),
'%body' => (string) $response
->getBody(TRUE),
]);
return $response;
}