public function LingotekApi::deleteDocument in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteDocument()
Overrides LingotekApiInterface::deleteDocument
File
- src/
Remote/ LingotekApi.php, line 114 - Contains \Drupal\lingotek\Remote\LingotekApi.
Class
Namespace
Drupal\lingotek\RemoteCode
public function deleteDocument($id) {
try {
$this->logger
->debug('Lingotek::deleteDocument called with id ' . $id);
$response = $this->lingotekClient
->delete('/api/document' . '/' . $id);
} catch (\Exception $e) {
$http_status_code = $e
->getCode();
if ($http_status_code === Response::HTTP_NOT_FOUND) {
$this->logger
->error('Error deleting document: %message.', [
'%message' => $e
->getMessage(),
]);
return new Response($e
->getMessage(), Response::HTTP_NOT_FOUND);
}
$this->logger
->error('Error deleting document: %message.', [
'%message' => $e
->getMessage(),
]);
throw new LingotekApiException('Failed to delete document: ' . $e
->getMessage(), $http_status_code, $e);
}
$this->logger
->debug('deleteDocument response received, code %code and body %body', [
'%code' => $response
->getStatusCode(),
'%body' => (string) $response
->getBody(TRUE),
]);
return $response;
}