You are here

public function ModerationInformation::getLatestRevision in Drupal 8

Loads the latest revision of a specific entity.

Parameters

string $entity_type_id: The entity type ID.

int $entity_id: The entity ID.

Return value

\Drupal\Core\Entity\ContentEntityInterface|null The latest entity revision or NULL, if the entity type / entity doesn't exist.

Overrides ModerationInformationInterface::getLatestRevision

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId and RevisionableStorageInterface::loadRevision instead.

See also

https://www.drupal.org/node/3087295

File

core/modules/content_moderation/src/ModerationInformation.php, line 88

Class

ModerationInformation
General service for moderation-related questions about Entity API.

Namespace

Drupal\content_moderation

Code

public function getLatestRevision($entity_type_id, $entity_id) {
  @trigger_error(__METHOD__ . ' is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use RevisionableStorageInterface::getLatestRevisionId() and RevisionableStorageInterface::loadRevision() instead. See https://www.drupal.org/node/3087295', E_USER_DEPRECATED);

  /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
  $storage = $this->entityTypeManager
    ->getStorage($entity_type_id);
  return $storage
    ->loadRevision($storage
    ->getLatestRevisionId($entity_id));
}