You are here

public function Lingotek::updateDocument in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  2. 4.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  3. 3.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  4. 3.1.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  5. 3.2.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  6. 3.3.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  7. 3.4.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  8. 3.5.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  9. 3.6.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  10. 3.7.x src/Lingotek.php \Drupal\lingotek\Lingotek::updateDocument()
  11. 3.8.x src/Lingotek.php \Drupal\lingotek\Lingotek::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

src/Lingotek.php, line 202
Contains \Drupal\lingotek\Lingotek.

Class

Lingotek

Namespace

Drupal\lingotek

Code

public function updateDocument($doc_id, $content, $url = NULL, $title = NULL) {
  $args = array(
    'format' => 'JSON',
    'content' => $content,
    'fprm_subfilter_id' => '0e79f34d-f27b-4a0c-880e-cd9181a5d265',
  );
  if ($url !== NULL) {
    $args['external_url'] = $url;
  }
  if ($title !== NULL) {
    $args['title'] = $title;
  }
  $response = $this->api
    ->patchDocument($doc_id, $args);
  if ($response
    ->getStatusCode() == Response::HTTP_ACCEPTED) {
    return TRUE;
  }
  return FALSE;
}