final class ResourceVersionRouteEnhancer implements EnhancerInterface (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.
 

Loads an appropriate revision for the requested resource version.

Constants

REVISION_ID_KEY

The route default parameter name.

RESOURCE_VERSION_QUERY_PARAMETER

The query parameter for providing a version (revision) value.

WORKING_COPIES_REQUESTED

A route parameter key which indicates that working copies were requested.

CACHE_CONTEXT

The cache context by which vary the loaded entity revision.

VERSION_IDENTIFIER_VALIDATOR

Resource version validation regex.

Properties

protected VersionNegotiator $versionNegotiator

The revision ID negotiator.

Methods

__construct(VersionNegotiator $version_negotiator_manager)

ResourceVersionRouteEnhancer constructor.

array
enhance(array $defaults, Request $request)

Updates the defaults for a route definition based on the request.

static bool
isValidVersionIdentifier(string $resource_version)

Validates the user input.

Details

__construct(VersionNegotiator $version_negotiator_manager)

ResourceVersionRouteEnhancer constructor.

Parameters

VersionNegotiator $version_negotiator_manager

The version negotiator.

array enhance(array $defaults, Request $request)

Updates the defaults for a route definition based on the request.

Parameters

array $defaults

The defaults, maps to '_defaults' in the route definition YAML.

Request $request

The Request instance.

Return Value

array

The modified defaults. Each enhancer MUST return the $defaults but may add or remove values.

static protected bool isValidVersionIdentifier(string $resource_version)

Validates the user input.

Parameters

string $resource_version

The requested resource version identifier.

Return Value

bool

TRUE if the received resource version value is valid, FALSE otherwise.