public function LingotekFake::cancelDocumentTarget in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.2.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
- 3.8.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocumentTarget()
Cancels the document target with this document id and locale from the Lingotek service.
Parameters
string $doc_id: The document id in Lingotek.
string $locale: The locale target we want to cancel the translation.
Return value
bool TRUE if the document target was successfully cancelled. FALSE if not.
Throws
\Drupal\lingotek\Exception\LingotekDocumentTargetAlreadyCompletedException If the target was already completed.
Overrides LingotekInterface::cancelDocumentTarget
File
- tests/
modules/ lingotek_test/ src/ LingotekFake.php, line 394
Class
Namespace
Drupal\lingotek_testCode
public function cancelDocumentTarget($doc_id, $locale) {
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.cancel_target_already_completed', FALSE)) {
$msg = 'Error: "Unable to cancel translations which are already in a completed state. Current status: LATE"';
throw new LingotekDocumentTargetAlreadyCompletedException($msg, 400);
}
if (\Drupal::state()
->get('lingotek.must_document_not_found_error_in_cancel', FALSE)) {
throw new LingotekDocumentNotFoundException($doc_id . ' not found. Error was forced.');
}
$cancelled_locales = \Drupal::state()
->get('lingotek.cancelled_locales', []);
$cancelled_locales[$doc_id][] = $locale;
\Drupal::state()
->set('lingotek.cancelled_locales', $cancelled_locales);
// Cancelled locale target.
return TRUE;
}