function NegotiatorBase::ensureVersionExists

Same name in other branches
  1. 9 core/modules/jsonapi/src/Revisions/NegotiatorBase.php \Drupal\jsonapi\Revisions\NegotiatorBase::ensureVersionExists()
  2. 10 core/modules/jsonapi/src/Revisions/NegotiatorBase.php \Drupal\jsonapi\Revisions\NegotiatorBase::ensureVersionExists()
  3. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.