public function Lingotek::cancelDocument in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 8.2 src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 4.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.1.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.2.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.3.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.4.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.5.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.7.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
- 3.8.x src/Lingotek.php \Drupal\lingotek\Lingotek::cancelDocument()
Cancels the document with this document id from the Lingotek service.
Parameters
string $doc_id: The document id in Lingotek.
Return value
bool TRUE if the document was successfully cancelled. FALSE if not.
Overrides LingotekInterface::cancelDocument
File
- src/
Lingotek.php, line 508
Class
- Lingotek
- The connecting class between Drupal and Lingotek
Namespace
Drupal\lingotekCode
public function cancelDocument($doc_id) {
$result = FALSE;
try {
$response = $this->api
->cancelDocument($doc_id);
$status_code = $response
->getStatusCode();
if ($status_code == Response::HTTP_NO_CONTENT) {
$result = TRUE;
}
} catch (LingotekApiException $ltkException) {
if ($ltkException
->getCode() === 400) {
if (strpos($ltkException
->getMessage(), '"Unable to cancel documents which are already in a completed state. Current status: COMPLETE"') > 0) {
// We ignore errors for complete documents.
$result = TRUE;
}
}
}
return $result;
}