public function LingotekFake::downloadDocument in Lingotek Translation 3.2.x
Same name and namespace in other branches
- 8 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.7.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
- 3.8.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::downloadDocument()
Gets the translation of a document for a given locale.
Parameters
string $doc_id: The document ID in Lingotek.
$locale: The locale we want to know the translation status.
Return value
array Returns array with the content of the document.
Overrides LingotekInterface::downloadDocument
File
- tests/
modules/ lingotek_test/ src/ LingotekFake.php, line 365
Class
Namespace
Drupal\lingotek_testCode
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);
}