protected function NegotiatorBase::loadRevision in JSON:API 8.2
Loads an entity revision.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which to load a revision.
int $revision_id: The revision ID to be loaded.
Return value
\Drupal\Core\Entity\EntityInterface|null The revision or NULL if the revision does not exists.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if the entity type doesn't exist.
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException Thrown if the storage handler couldn't be loaded.
1 call to NegotiatorBase::loadRevision()
- NegotiatorBase::getRevision in src/
Revisions/ NegotiatorBase.php - Gets the identified revision.
File
- src/
Revisions/ NegotiatorBase.php, line 77
Class
- NegotiatorBase
- Base implementation for version negotiators.
Namespace
Drupal\jsonapi\RevisionsCode
protected function loadRevision(EntityInterface $entity, $revision_id) {
$storage = $this->entityTypeManager
->getStorage($entity
->getEntityTypeId());
$revision = static::ensureVersionExists($storage
->loadRevision($revision_id));
if ($revision
->id() !== $entity
->id()) {
throw new VersionNotFoundException(sprintf('The requested resource does not have a version with ID %s.', $revision_id));
}
return $revision;
}