Neomerx\JsonApi\Contracts\Codec\CodecMatcherInterface::getEncoderHeaderMatchedType PHP Method

getEncoderHeaderMatchedType() public method

Get media type from 'Accept' header that matched to one of the registered encoder media types.
public getEncoderHeaderMatchedType ( ) : Neomerx\JsonApi\Contracts\Http\Headers\AcceptMediaTypeInterface | null
return Neomerx\JsonApi\Contracts\Http\Headers\AcceptMediaTypeInterface | null
    public function getEncoderHeaderMatchedType();

Usage Example

Beispiel #1
0
 /**
  * Check accept header
  *
  * @param AcceptHeaderInterface $header
  * @return Error
  */
 private function checkAcceptHeader(AcceptHeaderInterface $header)
 {
     $this->matcher->matchEncoder($header);
     if (null === $this->matcher->getEncoderHeaderMatchedType()) {
         throw new JsonApiException($this->createApiError(JsonApiException::HTTP_CODE_UNSUPPORTED_MEDIA_TYPE, self::UNSUPPORTED_ACCEPT_ERROR, 'Unsupported media type'), JsonApiException::HTTP_CODE_UNSUPPORTED_MEDIA_TYPE);
     }
 }
All Usage Examples Of Neomerx\JsonApi\Contracts\Codec\CodecMatcherInterface::getEncoderHeaderMatchedType