You are here

public function ConfigEntityRevisionsStorage::getLatestRevision in Config Entity Revisions 8

Same name and namespace in other branches
  1. 1.x src/Entity/Handler/ConfigEntityRevisionsStorage.php \Drupal\config_entity_revisions\Entity\Handler\ConfigEntityRevisionsStorage::getLatestRevision()

Gets the latest revision ID of the entity.

Parameters

int: The config entity ID to match.

Return value

int The identifier of the latest published revision of the entity, or NULL if the entity does not have a published revision.

Overrides ConfigEntityRevisionsStorageInterface::getLatestRevision

File

src/Entity/Handler/ConfigEntityRevisionsStorage.php, line 68

Class

ConfigEntityRevisionsStorage
Class SqlConfigEntityRevisionsStorage

Namespace

Drupal\config_entity_revisions\Entity\Handler

Code

public function getLatestRevision($config_entity_id) {
  $revision = NULL;
  $revision_id = $this->database
    ->select("config_entity_revisions_revision", 'c')
    ->fields('c', [
    'revision',
  ])
    ->condition($this->entityType
    ->getKey('id'), $config_entity_id)
    ->orderby('revision', 'DESC')
    ->range(0, 1)
    ->execute()
    ->fetchField();
  if ($revision_id) {
    $revision = $this
      ->loadRevision($revision_id);
  }
  return $revision;
}