protected function LingotekContentTranslationService::loadUploadedRevision in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 8 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.2.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
- 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::loadUploadedRevision()
Loads the correct revision is loaded from the database, bypassing caches.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity we want to load a revision from.
int|null $revision: The revision id. NULL if we don't know it.
Return value
\Drupal\Core\Entity\ContentEntityInterface The wanted revision of the entity.
1 call to LingotekContentTranslationService::loadUploadedRevision()
- LingotekContentTranslationService::saveTargetData in src/
LingotekContentTranslationService.php - Save the entity translation.
File
- src/
LingotekContentTranslationService.php, line 1537
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
protected function loadUploadedRevision(ContentEntityInterface $entity, $revision = NULL) {
$the_revision = NULL;
$entity_type = $entity
->getEntityType();
$entity_type_id = $entity
->getEntityTypeId();
$entity_storage = $this->entityTypeManager
->getStorage($entity_type_id);
if ($entity_type
->isRevisionable()) {
// If the entity type is revisionable, we need to check the proper revision.
// This may come from the uploaded data, but in case we didn't have it, we
// have to infer using the timestamp.
if ($revision !== NULL) {
$the_revision = $entity_storage
->loadRevision($revision);
}
elseif ($revision === NULL && $entity
->hasField('revision_timestamp')) {
// Let's find the better revision based on the timestamp.
$timestamp = $this->lingotek
->getUploadedTimestamp($this
->getDocumentId($entity));
$revision = $this
->getClosestRevisionToTimestamp($entity, $timestamp);
if ($revision !== NULL) {
$the_revision = $entity_storage
->loadRevision($revision);
}
}
if ($the_revision === NULL) {
// We didn't find a better option, but let's reload this one so it's not
// cached.
$the_revision = $entity_storage
->loadRevision($entity
->getRevisionId());
}
}
else {
$entity_storage
->resetCache([
$entity
->id(),
]);
$the_revision = $entity_storage
->load($entity
->id());
}
return $the_revision;
}