public function LingotekContentTranslationService::setDocumentId in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.2.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
- 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::setDocumentId()
Sets the Lingotek document id for a given entity.
Parameters
\Drupal\Core\Entity\ContentEntityInterface &$entity: The entity which we want to set a document id.
$doc_id: The document id in the Lingotek platform.
Return value
ContentEntityInterface The entity.
Overrides LingotekContentTranslationServiceInterface::setDocumentId
1 call to LingotekContentTranslationService::setDocumentId()
- LingotekContentTranslationService::uploadDocument in src/
LingotekContentTranslationService.php - Uploads a document to the Lingotek service.
File
- src/
LingotekContentTranslationService.php, line 336 - Contains \Drupal\lingotek\LingotekContentTranslationService.
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
public function setDocumentId(ContentEntityInterface &$entity, $doc_id) {
$entity->lingotek_document_id = $doc_id;
// If the entity supports revisions, ensure we don't create a new one.
if ($entity
->getEntityType()
->hasKey('revision')) {
$entity
->setNewRevision(FALSE);
}
$entity->lingotek_processed = TRUE;
$entity
->save();
\Drupal::database()
->insert('lingotek_content_metadata')
->fields([
'document_id',
'entity_type',
'entity_id',
])
->values([
'document_id' => $doc_id,
'entity_type' => $entity
->getEntityTypeId(),
'entity_id' => $entity
->id(),
])
->execute();
return $entity;
}