You are here

public function LingotekFake::cancelDocument in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  2. 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  3. 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  4. 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  5. 3.2.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  6. 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  7. 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  8. 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  9. 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::cancelDocument()
  10. 3.7.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

LingotekFake

Namespace

Drupal\lingotek_test

Code

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;
}