You are here

public function LingotekFakeBC::updateDocument in Lingotek Translation 3.2.x

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

Updates a document in the Lingotek service.

Parameters

string $doc_id: The document id to update.

string|array $content: The content of the document. It can be a json string or an array that will be json encoded.

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.

\Drupal\lingotek\LingotekProfileInterface $profile: (optional) The profile being used.

string $job_id: (optional) The job ID that will be associated.

Return value

bool|string TRUE if the document was successfully updated. FALSE if not (v5.1). New document ID if the document was successfully updated. FALSE if not (v5.2).

Throws

\Drupal\lingotek\Exception\LingotekPaymentRequiredException

\Drupal\lingotek\Exception\LingotekDocumentArchivedException

\Drupal\lingotek\Exception\LingotekDocumentLockedException

\Drupal\lingotek\Exception\LingotekApiException

Overrides LingotekFake::updateDocument

File

tests/modules/lingotek_test/src/LingotekFakeBC.php, line 11

Class

LingotekFakeBC

Namespace

Drupal\lingotek_test

Code

public function updateDocument($doc_id, $content, $url = NULL, $title = NULL, LingotekProfileInterface $profile = NULL, $job_id = NULL) {
  if (\Drupal::state()
    ->get('lingotek.must_error_in_upload', FALSE)) {
    throw new LingotekApiException('Error was forced.');
  }
  if (is_array($content)) {
    $content = json_encode($content);
  }
  \Drupal::state()
    ->set('lingotek.uploaded_content', $content);
  \Drupal::state()
    ->set('lingotek.uploaded_content_url', $url);
  \Drupal::state()
    ->set('lingotek.uploaded_title', $title);
  \Drupal::state()
    ->set('lingotek.uploaded_job_id', $job_id);

  // Save the timestamp of the upload.
  $timestamps = \Drupal::state()
    ->get('lingotek.upload_timestamps', []);
  $timestamps[$doc_id] = \Drupal::time()
    ->getRequestTime();
  \Drupal::state()
    ->set('lingotek.upload_timestamps', $timestamps);

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