VersionById
class VersionById extends NegotiatorBase implements VersionNegotiatorInterface (View source)
| internal | JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it. |
Defines a revision ID implementation for entity revision ID values.
Properties
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager to load the revision. |
from NegotiatorBase |
Methods
Constructs a version negotiator instance.
Helper method that ensures that a version exists.
Details
__construct(EntityTypeManagerInterface $entity_type_manager)
Constructs a version negotiator instance.
protected int
getRevisionId(EntityInterface $entity, string $version_argument)
Gets the revision ID.
EntityInterface
getRevision(EntityInterface $entity, string $version_argument)
Gets the identified revision.
The JSON:API module exposes revisions in terms of RFC5829. As such, the public API always refers to "versions" and "working copies" instead of "revisions". There are multiple ways to request a specific revision. For example, one might like to load a particular revision by its ID. On the other hand, it may be useful if an HTTP consumer is able to always request the "latest version" regardless of its ID. It is possible to imagine other scenarios as well, like fetching a revision based on a date or time.
Each version negotiator provides one of these strategies and is able to map a version argument to an existing revision.
protected EntityInterface|null
loadRevision(EntityInterface $entity, int $revision_id)
Loads an entity revision.
static protected int|EntityInterface
ensureVersionExists(int|EntityInterface $revision)
Helper method that ensures that a version exists.