You are here

protected static function NegotiatorBase::ensureVersionExists in JSON:API 8.2

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 src/Revisions/NegotiatorBase.php
Loads an entity revision.
VersionByRel::getRevisionId in src/Revisions/VersionByRel.php
Gets the revision ID.

File

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;
}