abstract class MediaTypeHelper (View source)

Helper for dealing with HTTP media type resolution.

Methods

static array
determineAcceptedMediaTypes(RequestInterface $request)

Get accepted media types for the given request.

static string|null
negotiateMediaType(array $acceptedMediaTypes, array $supportedMediaTypes, bool $trim = true)

Returns the best fitting IANA media type after applying the content negotiation rules on the accepted media types.

static array
parseContentNegotiationQualityValues(string $rawValues)

Parses a RFC 2616 content negotiation header field by evaluating the Quality Values and splitting the options into an array list, ordered by user preference.

Details

static array determineAcceptedMediaTypes(RequestInterface $request)

Get accepted media types for the given request.

If no "Accept" header was found all media types are acceptable.

Parameters

RequestInterface $request

Return Value

array

static string|null negotiateMediaType(array $acceptedMediaTypes, array $supportedMediaTypes, bool $trim = true)

Returns the best fitting IANA media type after applying the content negotiation rules on the accepted media types.

Parameters

array $acceptedMediaTypes

A list of accepted media types according to a request.

array $supportedMediaTypes

A list of media types which are supported by the application / controller

bool $trim

If TRUE, only the type/subtype of the media type is returned. If FALSE, the full original media type string is returned.

Return Value

string|null

The media type and sub type which matched, NULL if none matched

static array parseContentNegotiationQualityValues(string $rawValues)

Parses a RFC 2616 content negotiation header field by evaluating the Quality Values and splitting the options into an array list, ordered by user preference.

Parameters

string $rawValues

The raw Accept* Header field value

Return Value

array

The parsed list of field values, ordered by user preference