You are here

public function LingotekContentTranslationService::updateDocument in Lingotek Translation 8

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

Resends a document to the translation service.

Parameters

\Drupal\Core\Entity\ContentEntityInterface &$entity: The entity being updated.

Return value

boolean TRUE if the document was updated successfully, FALSE if not.

Overrides LingotekContentTranslationServiceInterface::updateDocument

1 call to LingotekContentTranslationService::updateDocument()
LingotekContentTranslationService::uploadDocument in src/LingotekContentTranslationService.php
Uploads a document to the Lingotek service.

File

src/LingotekContentTranslationService.php, line 690
Contains \Drupal\lingotek\LingotekContentTranslationService.

Class

LingotekContentTranslationService
Service for managing Lingotek content translations.

Namespace

Drupal\lingotek

Code

public function updateDocument(ContentEntityInterface &$entity) {
  $source_data = $this
    ->getSourceData($entity);
  $document_id = $this
    ->getDocumentId($entity);
  $url = $entity
    ->hasLinkTemplate('canonical') ? $entity
    ->toUrl()
    ->setAbsolute(TRUE)
    ->toString() : NULL;
  $document_name = $entity
    ->bundle() . ' (' . $entity
    ->getEntityTypeId() . '): ' . $entity
    ->label();

  // Allow other modules to alter the data before is uploaded.
  \Drupal::moduleHandler()
    ->invokeAll('lingotek_content_entity_document_upload', [
    &$source_data,
    &$entity,
    &$url,
  ]);
  $encoded_data = json_encode($source_data);
  if ($this->lingotek
    ->updateDocument($document_id, $encoded_data, $url, $document_name)) {
    $this
      ->setSourceStatus($entity, Lingotek::STATUS_IMPORTING);
    $this
      ->setTargetStatuses($entity, Lingotek::STATUS_PENDING);
    return $document_id;
  }
  return FALSE;
}