function VersionByRel::getRevisionId
Same name in other branches
- 9 core/modules/jsonapi/src/Revisions/VersionByRel.php \Drupal\jsonapi\Revisions\VersionByRel::getRevisionId()
- 10 core/modules/jsonapi/src/Revisions/VersionByRel.php \Drupal\jsonapi\Revisions\VersionByRel::getRevisionId()
- 11.x core/modules/jsonapi/src/Revisions/VersionByRel.php \Drupal\jsonapi\Revisions\VersionByRel::getRevisionId()
Overrides NegotiatorBase::getRevisionId
File
-
core/
modules/ jsonapi/ src/ Revisions/ VersionByRel.php, line 47
Class
- VersionByRel
- Revision ID implementation for the default or latest revisions.
Namespace
Drupal\jsonapi\RevisionsCode
protected function getRevisionId(EntityInterface $entity, $version_argument) {
assert($entity instanceof RevisionableInterface);
switch ($version_argument) {
case static::WORKING_COPY:
/* @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */
$entity_storage = $this->entityTypeManager
->getStorage($entity->getEntityTypeId());
return static::ensureVersionExists($entity_storage->getLatestRevisionId($entity->id()));
case static::LATEST_VERSION:
// The already loaded revision will be the latest version by default.
// @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::buildQuery().
return $entity->getLoadedRevisionId();
default:
$message = sprintf('The version specifier must be either `%s` or `%s`, `%s` given.', static::LATEST_VERSION, static::WORKING_COPY, $version_argument);
throw new InvalidVersionIdentifierException($message);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.