0 follower

Final Class Yiisoft\DataResponse\Middleware\FormatDataResponseAsHtml

InheritanceYiisoft\DataResponse\Middleware\FormatDataResponseAsHtml » Yiisoft\DataResponse\Middleware\FormatDataResponse
ImplementsPsr\Http\Server\MiddlewareInterface
Deprecated since version Use {@see \Yiisoft\DataResponse\Middleware\HtmlDataResponseMiddleware} instead.

FormatDataResponseAsHtml adds an HTML formatter Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter instance to the instance of the data response Yiisoft\DataResponse\DataResponse, if the formatter was not added earlier.

Method Details

Hide inherited methods

__construct() public method

public __construct( Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter $responseFormatter ): mixed
$responseFormatter Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter

                public function __construct(HtmlDataResponseFormatter $responseFormatter)
{
    parent::__construct($responseFormatter);
}

            
process() public method
public process( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler ): \Psr\Http\Message\ResponseInterface
$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;
}