コード例 #1
0
 public function validateMessageBody(MessageInterface $message, MessageDefinition $definition)
 {
     $bodyString = (string) $message->getBody();
     if ($bodyString !== '' && $definition->hasBodySchema()) {
         $contentType = $message->getHeaderLine('Content-Type');
         $decodedBody = $this->decoder->decode($bodyString, DecoderUtils::extractFormatFromContentType($contentType));
         $this->validate($decodedBody, $definition->getBodySchema(), 'body');
     }
 }
コード例 #2
0
 /**
  * Transform a given response into a denormalized PHP object
  * If the config option "returnResponse" is set to TRUE, it return a Response instead
  *
  * @param ResponseInterface $response
  * @param ResponseDefinition $definition
  * @param RequestInterface $request
  *
  * @return Resource|mixed
  */
 private function getDataFromResponse(ResponseInterface $response, ResponseDefinition $definition, RequestInterface $request)
 {
     if ($this->config['returnResponse'] === true) {
         return $response;
     }
     return $this->serializer->deserialize((string) $response->getBody(), Resource::class, DecoderUtils::extractFormatFromContentType($response->getHeaderLine('Content-Type')), ['response' => $response, 'responseDefinition' => $definition, 'request' => $request]);
 }