serialize() public method

public serialize ( Psr\Http\Message\ResponseInterface $response, integer $responseCode, array $content ) : Psr\Http\Message\ResponseInterface
$response Psr\Http\Message\ResponseInterface
$responseCode integer
$content array
return Psr\Http\Message\ResponseInterface
示例#1
0
 /**
  * Returns a response with a status code of $responseCode, containing all the provided sections of the error
  * document. You can also pass additional meta information for the document in the $additionalMeta argument.
  *
  * @param SerializerInterface $serializer
  * @param \Psr\Http\Message\ResponseInterface $response
  * @param int $responseCode
  * @param array $additionalMeta
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function getResponse(SerializerInterface $serializer, ResponseInterface $response, $responseCode = null, array $additionalMeta = [])
 {
     return $serializer->serialize($response, $this->getResponseCode($responseCode), $this->transformContent($additionalMeta));
 }
 /**
  * Returns a response with a status code of $responseCode, containing the $relationshipName relationship object as
  * the primary data, assembled based on the $domainObject. You can also pass additional meta information to the
  * document in the $additionalMeta argument.
  *
  * @param string $relationshipName
  * @param \WoohooLabs\Yin\JsonApi\Request\RequestInterface $request
  * @param \Psr\Http\Message\ResponseInterface $response
  * @param \WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory
  * @param mixed $domainObject
  * @param int $responseCode
  * @param array $additionalMeta
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function getRelationshipResponse($relationshipName, RequestInterface $request, ResponseInterface $response, ExceptionFactoryInterface $exceptionFactory, SerializerInterface $serializer, $domainObject, $responseCode, array $additionalMeta = [])
 {
     $transformation = new Transformation($request, $this->createData(), $exceptionFactory, "");
     $this->initializeDocument($domainObject);
     $content = $this->transformRelationshipContent($relationshipName, $transformation, $additionalMeta);
     return $serializer->serialize($response, $responseCode, $content);
 }