public function UpdateUtils::getLatestRevisionId in Scheduled Updates 8
Returns the revision ID of the latest revision of the given entity.
Parameters
string $entity_type_id: The entity type ID.
int $entity_id: The entity ID.
Return value
int The revision ID of the latest revision for the specified entity, or NULL if there is no such entity.
Overrides UpdateUtilsInterface::getLatestRevisionId
1 call to UpdateUtils::getLatestRevisionId()
- UpdateUtils::getLatestRevision in src/
UpdateUtils.php - Loads the latest revision of a specific entity.
File
- src/
UpdateUtils.php, line 129
Class
- UpdateUtils
- Service to determine information about Scheduled Update Types.
Namespace
Drupal\scheduled_updatesCode
public function getLatestRevisionId($entity_type_id, $entity_id) {
if ($storage = $this->entityTypeManager
->getStorage($entity_type_id)) {
$revision_ids = $storage
->getQuery()
->allRevisions()
->condition($this->entityTypeManager
->getDefinition($entity_type_id)
->getKey('id'), $entity_id)
->sort($this->entityTypeManager
->getDefinition($entity_type_id)
->getKey('revision'), 'DESC')
->pager(1)
->execute();
if ($revision_ids) {
$revision_id = array_keys($revision_ids)[0];
return $revision_id;
}
}
return NULL;
}