/** * @param ParametersInterface $parameters * * @return void */ protected function checkContentTypeHeader(ParametersInterface $parameters) { // Do not allow specify more than 1 media type for input data. Otherwise which one is correct? if (count($parameters->getContentTypeHeader()->getMediaTypes()) > 1) { $this->exceptionThrower->throwBadRequest(); } $this->codecMatcher->findDecoder($parameters->getContentTypeHeader()); // From spec: Servers MUST respond with a 415 Unsupported Media Type status code // if a request specifies the header Content-Type: application/vnd.api+json with // any media type parameters. // We return 415 if no match found for decoder (media type with or wo parameters) // If no decoders were configured for media types with parameters we return 415 anyway if ($this->codecMatcher->getDecoderHeaderMatchedType() === null) { $this->exceptionThrower->throwUnsupportedMediaType(); } }
/** * @return mixed */ protected function getDocument() { if ($this->codecMatcher->getDecoder() === null) { $this->codecMatcher->findDecoder($this->getParameters()->getContentTypeHeader()); } $decoder = $this->codecMatcher->getDecoder(); return $decoder->decode($this->getIntegration()->getContent()); }