class VersionNegotiator (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.
 

Provides a version negotiator manager.

Constants

SEPARATOR

The separator between the version negotiator name and the version argument.

Properties

protected VersionNegotiatorInterface[] $negotiators

An array of named version negotiators.

Methods

addVersionNegotiator(VersionNegotiatorInterface $version_negotiator, string $negotiator_name)

Adds a version negotiator.

getRevision(EntityInterface $entity, string $resource_version_identifier)

Gets a negotiated entity revision.

static 
throwNotFoundHttpException(EntityInterface $entity, string $resource_version_identifier)

Throws a cacheable error exception.

static 
throwBadRequestHttpException(string $resource_version_identifier)

Throws a cacheable error exception.

Details

addVersionNegotiator(VersionNegotiatorInterface $version_negotiator, string $negotiator_name)

Adds a version negotiator.

Parameters

VersionNegotiatorInterface $version_negotiator

The version negotiator.

string $negotiator_name

The name of the negotiation strategy used by the version negotiator.

EntityInterface getRevision(EntityInterface $entity, string $resource_version_identifier)

Gets a negotiated entity revision.

Parameters

EntityInterface $entity

The entity.

string $resource_version_identifier

A value used to derive a revision for the given entity.

Return Value

EntityInterface

The loaded revision.

Exceptions

CacheableNotFoundHttpException
CacheableBadRequestHttpException

static protected throwNotFoundHttpException(EntityInterface $entity, string $resource_version_identifier)

Throws a cacheable error exception.

Parameters

EntityInterface $entity

The entity for which a revision was requested.

string $resource_version_identifier

The user input for the revision negotiation.

Exceptions

CacheableNotFoundHttpException

static protected throwBadRequestHttpException(string $resource_version_identifier)

Throws a cacheable error exception.

Parameters

string $resource_version_identifier

The user input for the revision negotiation.

Exceptions

CacheableBadRequestHttpException