Final Class Yiisoft\DataResponse\ResponseFactory\DataResponseFactory
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Factory that creates responses with {@see DataStream} body without applying a formatter.
The formatter should be applied later using middleware.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| createResponse() | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $responseFactory | \ |
The PSR-17 response factory. |
public function __construct(
private readonly ResponseFactoryInterface $responseFactory,
) {}
| public \ | ||
| $data | mixed | |
| $code | integer | |
| $reasonPhrase | string | |
public function createResponse(
mixed $data = null,
int $code = Status::OK,
string $reasonPhrase = '',
): ResponseInterface {
$body = new DataStream($data);
return $this->responseFactory
->createResponse($code, $reasonPhrase)
->withBody($body);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.