Neos\Flow\Http\Request::getNegotiatedMediaType PHP Метод

getNegotiatedMediaType() публичный Метод

Returns the best fitting IANA media type after applying the content negotiation rules on a possible Accept header.
public getNegotiatedMediaType ( array $supportedMediaTypes, boolean $trim = true ) : string
$supportedMediaTypes array A list of media types which are supported by the application / controller
$trim boolean If TRUE, only the type/subtype of the media type is returned. If FALSE, the full original media type string is returned.
Результат string The media type and sub type which matched, NULL if none matched
    public function getNegotiatedMediaType(array $supportedMediaTypes, $trim = true)
    {
        $negotiatedMediaType = null;
        $acceptedMediaTypes = $this->getAcceptedMediaTypes();
        foreach ($acceptedMediaTypes as $acceptedMediaType) {
            foreach ($supportedMediaTypes as $supportedMediaType) {
                if (MediaTypes::mediaRangeMatches($acceptedMediaType, $supportedMediaType)) {
                    $negotiatedMediaType = $supportedMediaType;
                    break 2;
                }
            }
        }
        return $trim ? MediaTypes::trimMediaType($negotiatedMediaType) : $negotiatedMediaType;
    }