PHP Class WoohooLabs\Yin\JsonApi\Response\Responder

Inheritance: extends AbstractResponder
Datei anzeigen Open project: woohoolabs/yin

Public Methods

Method Description
__construct ( WoohooLabs\Yin\JsonApi\Request\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, WoohooLabs\Yin\JsonApi\Serializer\SerializerInterface $serializer )
accepted ( ) : Psr\Http\Message\ResponseInterface Returns a "202 Accepted" response.
conflict ( AbstractErrorDocument $document, array $errors = [], array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface Returns a "409 Conflict" response, containing a document in the body with the errors. You can also pass additional meta information for the error document in the $additionalMeta argument.
created ( AbstractSuccessfulDocument $document, mixed $domainObject, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface Returns a "201 Created" response, containing a document in the body with the newly created resource. You can also pass additional meta information for the document in the $additionalMeta argument.
forbidden ( AbstractErrorDocument $document, array $errors = [], array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface Returns a "403 Forbidden" response, containing a document in the body with the errors. You can also pass additional meta information for the error document in the $additionalMeta argument.
genericError ( AbstractErrorDocument $document, array $errors = [], integer | null $statusCode = null, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface Returns an error response, containing a document in the body with the errors. You can also pass additional meta information to the document in the $additionalMeta argument.
genericSuccess ( integer $statusCode ) : Psr\Http\Message\ResponseInterface Returns a successful response with the given status code.
noContent ( ) : Psr\Http\Message\ResponseInterface Returns a "204 No Content" response.
notFound ( AbstractErrorDocument $document, array $errors = [], array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface Returns a "404 Not Found" response, containing a document in the body with the errors. You can also pass additional meta information for the error document in the $additionalMeta argument.
ok ( AbstractSuccessfulDocument $document, mixed $domainObject, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface Returns a "200 Ok" response, containing a document in the body with the resource.
okWithMeta ( AbstractSuccessfulDocument $document, mixed $domainObject, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface Returns a "200 Ok" response, containing a document in the body with the resource meta data.

Method Details

__construct() public method

public __construct ( WoohooLabs\Yin\JsonApi\Request\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory, WoohooLabs\Yin\JsonApi\Serializer\SerializerInterface $serializer )
$request WoohooLabs\Yin\JsonApi\Request\RequestInterface
$response Psr\Http\Message\ResponseInterface
$exceptionFactory WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface
$serializer WoohooLabs\Yin\JsonApi\Serializer\SerializerInterface

accepted() public method

Returns a "202 Accepted" response.
public accepted ( ) : Psr\Http\Message\ResponseInterface
return Psr\Http\Message\ResponseInterface $response

conflict() public method

Returns a "409 Conflict" response, containing a document in the body with the errors. You can also pass additional meta information for the error document in the $additionalMeta argument.
public conflict ( AbstractErrorDocument $document, array $errors = [], array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface
$document WoohooLabs\Yin\JsonApi\Document\AbstractErrorDocument
$errors array
$additionalMeta array
return Psr\Http\Message\ResponseInterface $response

created() public method

Returns a "201 Created" response, containing a document in the body with the newly created resource. You can also pass additional meta information for the document in the $additionalMeta argument.
public created ( AbstractSuccessfulDocument $document, mixed $domainObject, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface
$document WoohooLabs\Yin\JsonApi\Document\AbstractSuccessfulDocument
$domainObject mixed
$additionalMeta array
return Psr\Http\Message\ResponseInterface

forbidden() public method

Returns a "403 Forbidden" response, containing a document in the body with the errors. You can also pass additional meta information for the error document in the $additionalMeta argument.
public forbidden ( AbstractErrorDocument $document, array $errors = [], array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface
$document WoohooLabs\Yin\JsonApi\Document\AbstractErrorDocument
$errors array
$additionalMeta array
return Psr\Http\Message\ResponseInterface $response

genericError() public method

Returns an error response, containing a document in the body with the errors. You can also pass additional meta information to the document in the $additionalMeta argument.
public genericError ( AbstractErrorDocument $document, array $errors = [], integer | null $statusCode = null, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface
$document WoohooLabs\Yin\JsonApi\Document\AbstractErrorDocument
$errors array
$statusCode integer | null
$additionalMeta array
return Psr\Http\Message\ResponseInterface $response

genericSuccess() public method

Returns a successful response with the given status code.
public genericSuccess ( integer $statusCode ) : Psr\Http\Message\ResponseInterface
$statusCode integer
return Psr\Http\Message\ResponseInterface $response

noContent() public method

Returns a "204 No Content" response.
public noContent ( ) : Psr\Http\Message\ResponseInterface
return Psr\Http\Message\ResponseInterface $response

notFound() public method

Returns a "404 Not Found" response, containing a document in the body with the errors. You can also pass additional meta information for the error document in the $additionalMeta argument.
public notFound ( AbstractErrorDocument $document, array $errors = [], array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface
$document WoohooLabs\Yin\JsonApi\Document\AbstractErrorDocument
$errors array
$additionalMeta array
return Psr\Http\Message\ResponseInterface $response

ok() public method

According to the JSON API specification, this response is applicable in the following conditions: "A server MUST respond to a successful request to fetch an individual resource or resource collection with a 200 OK response."
public ok ( AbstractSuccessfulDocument $document, mixed $domainObject, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface
$document WoohooLabs\Yin\JsonApi\Document\AbstractSuccessfulDocument
$domainObject mixed
$additionalMeta array
return Psr\Http\Message\ResponseInterface

okWithMeta() public method

According to the JSON API specification, this response is applicable in the following conditions: "A server MUST return a 200 OK status code if a deletion request is successful and the server responds with only top-level meta data."
public okWithMeta ( AbstractSuccessfulDocument $document, mixed $domainObject, array $additionalMeta = [] ) : Psr\Http\Message\ResponseInterface
$document WoohooLabs\Yin\JsonApi\Document\AbstractSuccessfulDocument
$domainObject mixed
$additionalMeta array
return Psr\Http\Message\ResponseInterface