You are here

protected static function NegotiatorBase::ensureVersionExists in Drupal 8

Same name and namespace in other branches
  1. 9 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;
}