ConfigEntityRevisionsStorage.php in Config Entity Revisions 8
File
src/Entity/Handler/ConfigEntityRevisionsStorage.php
View source
<?php
namespace Drupal\config_entity_revisions\Entity\Handler;
use Drupal\config_entity_revisions\ConfigEntityRevisionsStorageInterface;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
class ConfigEntityRevisionsStorage extends SqlContentEntityStorage implements ConfigEntityRevisionsStorageInterface {
public function getLatestPublishedRevisionID($config_entity_id) {
$revision = $this->database
->select("config_entity_revisions_revision", 'c')
->fields('c', [
'revision',
])
->condition($this->entityType
->getKey('id'), $config_entity_id)
->condition('published', TRUE)
->orderby('revision', 'DESC')
->range(0, 1)
->execute()
->fetchField();
return $revision;
}
public function getLatestPublishedRevision($config_entity_id) {
$revision = NULL;
$revision_id = $this
->getLatestPublishedRevisionId($config_entity_id);
if ($revision_id) {
$revision = $this
->loadRevision($revision_id);
}
return $revision;
}
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;
}
}