You are here

protected static function NegotiatorBase::ensureVersionExists in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/src/Revisions/NegotiatorBase.php \Drupal\jsonapi\Revisions\NegotiatorBase::ensureVersionExists()

Helper method that ensures that a version exists.

Parameters

int|\Drupal\Core\Entity\EntityInterface $revision: A revision ID, or NULL if one was not found.

Return value

int|\Drupal\Core\Entity\EntityInterface A revision or revision ID, if one was found.

Throws

\Drupal\jsonapi\Revisions\VersionNotFoundException Thrown if the given value is NULL, meaning the requested version was not found.

2 calls to NegotiatorBase::ensureVersionExists()
NegotiatorBase::loadRevision in core/modules/jsonapi/src/Revisions/NegotiatorBase.php
Loads an entity revision.
VersionByRel::getRevisionId in core/modules/jsonapi/src/Revisions/VersionByRel.php
Gets the revision ID.

File

core/modules/jsonapi/src/Revisions/NegotiatorBase.php, line 99

Class

NegotiatorBase
Base implementation for version negotiators.

Namespace

Drupal\jsonapi\Revisions

Code

protected static function ensureVersionExists($revision) {
  if (is_null($revision)) {
    throw new VersionNotFoundException();
  }
  return $revision;
}