You are here

protected function VersionById::getRevisionId in JSON:API 8.2

Gets the revision ID.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity.

string $version_argument: A value used to derive a revision ID for the given entity.

Return value

int The revision ID.

Throws

\Drupal\jsonapi\Revisions\VersionNotFoundException When the revision does not exist.

\Drupal\jsonapi\Revisions\InvalidVersionIdentifierException When the revision ID is not valid.

Overrides NegotiatorBase::getRevisionId

File

src/Revisions/VersionById.php, line 21

Class

VersionById
Defines a revision ID implementation for entity revision ID values.

Namespace

Drupal\jsonapi\Revisions

Code

protected function getRevisionId(EntityInterface $entity, $version_argument) {
  if (!is_numeric($version_argument)) {
    throw new InvalidVersionIdentifierException('The revision ID must be an integer.');
  }
  return $version_argument;
}