You are here

public function LingotekFake::downloadDocument in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 8 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  2. 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  3. 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  4. 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  5. 3.2.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  6. 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  7. 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  8. 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  9. 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  10. 3.7.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
  11. 3.8.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()

Overrides LingotekInterface::downloadDocument

File

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

Class

LingotekFake

Namespace

Drupal\lingotek_test

Code

public function downloadDocument($doc_id, $locale) {
  if (\Drupal::state()
    ->get('lingotek.must_error_in_download', FALSE)) {
    throw new LingotekApiException('Error was forced.');
  }

  // We need to avoid this in some cases.
  if (\Drupal::state()
    ->get('lingotek.document_completion', NULL) === NULL) {
    $requested_locales = \Drupal::state()
      ->get('lingotek.requested_locales', []);
    if (!in_array($locale, $requested_locales[$doc_id])) {
      throw new LingotekApiException('Locale was not requested before.');
    }
  }
  \Drupal::state()
    ->set('lingotek.downloaded_locale', $locale);
  $type = \Drupal::state()
    ->get('lingotek.uploaded_content_type', 'node');
  $path = drupal_get_path('module', 'lingotek') . '/tests/modules/lingotek_test/document_responses/' . $type . '.json';
  $input = file_get_contents($path);
  return json_decode($input, TRUE);
}