You are here

public function LingotekFake::updateDocument in Lingotek Translation 8

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

Updates a document in the Lingotek service.

Parameters

string $doc_id: The document id to update.

$content: The content of the document

string $url: (optional) The document url in the site if any. This allows support for in-context review.

string $title: (optional) The title of the document as it will be seen in the TMS.

Return value

boolean

Overrides LingotekInterface::updateDocument

File

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

Class

LingotekFake

Namespace

Drupal\lingotek_test

Code

public function updateDocument($doc_id, $content, $url = NULL, $title = NULL) {
  if (\Drupal::state()
    ->get('lingotek.must_error_in_upload', FALSE)) {
    throw new LingotekApiException();
  }
  \Drupal::state()
    ->set('lingotek.uploaded_content', $content);
  \Drupal::state()
    ->set('lingotek.uploaded_content_url', $url);
  \Drupal::state()
    ->set('lingotek.uploaded_content_title', $title);

  // 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);

  // Our document is always imported correctly.
  return TRUE;
}