public function LingotekFake::cancelDocument in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.2.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.7.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
- 3.8.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::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.
Throws
\Drupal\lingotek\Exception\LingotekDocumentNotFoundException
\Drupal\lingotek\Exception\LingotekDocumentAlreadyCompletedException If the document was already completed.
Overrides LingotekInterface::cancelDocument
File
- tests/
modules/ lingotek_test/ src/ LingotekFake.php, line 377
Class
Namespace
Drupal\lingotek_testCode
public function cancelDocument($doc_id) {
if (\Drupal::state()
->get('lingotek.must_error_in_cancel', FALSE)) {
\Drupal::state()
->set('lingotek.must_error_in_cancel', FALSE);
throw new LingotekApiException('Error was forced.');
}
if (\Drupal::state()
->get('lingotek.must_document_not_found_error_in_cancel', FALSE)) {
throw new LingotekDocumentNotFoundException($doc_id . ' not found. Error was forced.');
}
$cancelled_docs = \Drupal::state()
->get('lingotek.cancelled_docs', []);
$cancelled_docs[] = $doc_id;
\Drupal::state()
->set('lingotek.cancelled_docs', $cancelled_docs);
return TRUE;
}