Final Class Yiisoft\DataResponse\Middleware\FormatDataResponseAsXml
| Inheritance | Yiisoft\DataResponse\Middleware\FormatDataResponseAsXml » Yiisoft\DataResponse\Middleware\FormatDataResponse |
|---|---|
| Implements | Psr\Http\Server\MiddlewareInterface |
FormatDataResponseAsXml adds an XML formatter {@see XmlDataResponseFormatter} 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\FormatDataResponseAsXml | |
| process() | Yiisoft\DataResponse\Middleware\FormatDataResponse |
Method Details
| public mixed __construct ( Yiisoft\DataResponse\Formatter\XmlDataResponseFormatter $responseFormatter ) | ||
| $responseFormatter | Yiisoft\DataResponse\Formatter\XmlDataResponseFormatter | |
public function __construct(XmlDataResponseFormatter $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.