Final Class Yiisoft\DataResponse\Middleware\FormatDataResponseAsPlainText
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Psr\ |
| Deprecated since version | Use {@see \ |
FormatDataResponseAsPlainText adds a plain text formatter {@see PlainTextDataResponseFormatter} instance to the
instance of the data response {@see DataResponse}, if the formatter was not added earlier.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| process() | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $responseFormatter | Yiisoft\ |
|
public function __construct(PlainTextDataResponseFormatter $responseFormatter)
{
parent::__construct($responseFormatter);
}
| public \ | ||
| $request | \ |
|
| $handler | \ |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
if ($response instanceof DataResponse && !$response->hasResponseFormatter()) {
$response = $response->withResponseFormatter($this->responseFormatter);
}
return $response;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.