Final Class Yiisoft\DataResponse\Middleware\FormatDataResponseAsHtml
| Inheritance | Yiisoft\DataResponse\Middleware\FormatDataResponseAsHtml » Yiisoft\DataResponse\Middleware\FormatDataResponse |
|---|---|
| Implements | Psr\Http\Server\MiddlewareInterface |
FormatDataResponseAsHtml adds an HTML formatter {@see HtmlDataResponseFormatter} 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\DataResponse\Middleware\FormatDataResponseAsHtml | |
| process() | Yiisoft\DataResponse\Middleware\FormatDataResponse |
Method Details
| public mixed __construct ( Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter $responseFormatter ) | ||
| $responseFormatter | Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter | |
public function __construct(HtmlDataResponseFormatter $responseFormatter)
{
parent::__construct($responseFormatter);
}
| public \Psr\Http\Message\ResponseInterface process ( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler ) | ||
| $request | \Psr\Http\Message\ServerRequestInterface | |
| $handler | \Psr\Http\Server\RequestHandlerInterface | |
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;
}
Signup or Login in order to comment.