public function ModerationInformation::getLatestRevisionId in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/ModerationInformation.php \Drupal\workbench_moderation\ModerationInformation::getLatestRevisionId()
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 ModerationInformationInterface::getLatestRevisionId
3 calls to ModerationInformation::getLatestRevisionId()
- ModerationInformation::getLatestRevision in src/
ModerationInformation.php - Loads the latest revision of a specific entity.
- ModerationInformation::hasForwardRevision in src/
ModerationInformation.php - Determines if a forward revision exists for the specified entity.
- ModerationInformation::isLatestRevision in src/
ModerationInformation.php - Determines if an entity is a latest revision.
File
- src/
ModerationInformation.php, line 158
Class
- ModerationInformation
- General service for moderation-related questions about Entity API.
Namespace
Drupal\workbench_moderationCode
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')
->range(0, 1)
->execute();
if ($revision_ids) {
$revision_id = array_keys($revision_ids)[0];
return $revision_id;
}
}
}