You are here

public function LingotekFake::cancelDocumentTarget in Lingotek Translation 3.2.x

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

Overrides LingotekInterface::cancelDocumentTarget

File

tests/modules/lingotek_test/src/LingotekFake.php, line 411

Class

LingotekFake

Namespace

Drupal\lingotek_test

Code

public function cancelDocumentTarget($doc_id, $locale) {
  if (\Drupal::state()
    ->get('lingotek.must_error_in_cancel', FALSE)) {
    throw new LingotekApiException('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;
}