public function LingotekFake::uploadDocument in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.2.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.7.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
- 3.8.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::uploadDocument()
Uploads a document to the Lingotek service.
Parameters
string $title: The title of the document as it will be seen in the TMS.
$content: The content of the document
string $locale: The Lingotek locale.
string $url: The document url in the site if any. This allows support for in-context review.
\Drupal\lingotek\LingotekProfileInterface $profile: The profile being used.
Return value
mixed
Overrides LingotekInterface::uploadDocument
File
- tests/
modules/ lingotek_test/ src/ LingotekFake.php, line 158
Class
Namespace
Drupal\lingotek_testCode
public function uploadDocument($title, $content, $locale, $url = NULL, LingotekProfileInterface $profile = NULL) {
if (\Drupal::state()
->get('lingotek.must_error_in_upload', FALSE)) {
throw new LingotekApiException();
}
// If the upload is successful, we must return a valid hash.
\Drupal::state()
->set('lingotek.uploaded_title', $title);
\Drupal::state()
->set('lingotek.uploaded_content', $content);
\Drupal::state()
->set('lingotek.uploaded_locale', $locale);
\Drupal::state()
->set('lingotek.uploaded_url', $url);
\Drupal::state()
->set('lingotek.used_profile', $profile ? $profile
->id() : NULL);
$count = \Drupal::state()
->get('lingotek.uploaded_docs', 0);
$doc_id = 'dummy-document-hash-id';
if ($count > 0) {
$doc_id .= '-' . $count;
}
++$count;
\Drupal::state()
->set('lingotek.uploaded_docs', $count);
// Save the timestamp of the upload.
$timestamps = \Drupal::state()
->get('lingotek.upload_timestamps', []);
$timestamps[$doc_id] = REQUEST_TIME;
\Drupal::state()
->set('lingotek.upload_timestamps', $timestamps);
return $doc_id;
}