0 follower

Final Class Yiisoft\DataResponse\DataResponseFactory

InheritanceYiisoft\DataResponse\DataResponseFactory
ImplementsYiisoft\DataResponse\DataResponseFactoryInterface
Deprecated since version Use {@see \Yiisoft\DataResponse\ResponseFactory\DataResponseFactory} instead.

DataResponseFactory creates an instance of the data response Yiisoft\DataResponse\DataResponse.

Method Details

Hide inherited methods

__construct() public method

public __construct( \Psr\Http\Message\ResponseFactoryInterface $responseFactory, \Psr\Http\Message\StreamFactoryInterface $streamFactory ): mixed
$responseFactory \Psr\Http\Message\ResponseFactoryInterface
$streamFactory \Psr\Http\Message\StreamFactoryInterface

                public function __construct(
    private ResponseFactoryInterface $responseFactory,
    private StreamFactoryInterface $streamFactory,
) {}

            
createResponse() public method

public createResponse( mixed $data null, integer $code Status::OK, string $reasonPhrase '' ): Yiisoft\DataResponse\DataResponse
$data mixed
$code integer
$reasonPhrase string

                public function createResponse($data = null, int $code = Status::OK, string $reasonPhrase = ''): DataResponse
{
    return new DataResponse($data, $code, $reasonPhrase, $this->responseFactory, $this->streamFactory);
}