Final Class Yiisoft\Yii\View\Renderer\ViewResponse
| Inheritance | Yiisoft\Yii\View\Renderer\ViewResponse |
|---|---|
| Implements | Psr\Http\Message\ResponseInterface |
A PSR-7 response decorator that supports deferred body rendering via a callable.
Public Methods
Method Details
| public mixed __construct ( \Psr\Http\Message\ResponseInterface $response, Closure $dataCallback ) | ||
| $response | \Psr\Http\Message\ResponseInterface |
The wrapped PSR-7 response. |
| $dataCallback | Closure |
The callable that produces the response body string. |
public function __construct(
private ResponseInterface $response,
private readonly Closure $dataCallback,
) {}
| public \Psr\Http\Message\StreamInterface getBody ( ) |
public function getBody(): StreamInterface
{
if ($this->resolvedBody === null) {
$this->resolvedBody = ($this->dataCallback)();
}
return $this->resolvedBody;
}
| public array getHeader ( string $name ) | ||
| $name | string | |
public function getHeader(string $name): array
{
return $this->response->getHeader($name);
}
| public string getHeaderLine ( string $name ) | ||
| $name | string | |
public function getHeaderLine(string $name): string
{
return $this->response->getHeaderLine($name);
}
| public array getHeaders ( ) |
public function getHeaders(): array
{
return $this->response->getHeaders();
}
| public string getProtocolVersion ( ) |
public function getProtocolVersion(): string
{
return $this->response->getProtocolVersion();
}
| public string getReasonPhrase ( ) |
public function getReasonPhrase(): string
{
return $this->response->getReasonPhrase();
}
| public integer getStatusCode ( ) |
public function getStatusCode(): int
{
return $this->response->getStatusCode();
}
| public boolean hasHeader ( string $name ) | ||
| $name | string | |
public function hasHeader(string $name): bool
{
return $this->response->hasHeader($name);
}
| public self withAddedHeader ( string $name, mixed $value ) | ||
| $name | string | |
| $value | mixed | |
public function withAddedHeader(string $name, $value): self
{
$new = clone $this;
$new->response = $this->response->withAddedHeader($name, $value);
return $new;
}
| public self withBody ( \Psr\Http\Message\StreamInterface $body ) | ||
| $body | \Psr\Http\Message\StreamInterface | |
public function withBody(StreamInterface $body): self
{
$new = clone $this;
$new->response = $this->response->withBody($body);
$new->resolvedBody = $body;
return $new;
}
| public self withHeader ( string $name, mixed $value ) | ||
| $name | string | |
| $value | mixed | |
public function withHeader(string $name, $value): self
{
$new = clone $this;
$new->response = $this->response->withHeader($name, $value);
return $new;
}
| public self withProtocolVersion ( string $version ) | ||
| $version | string | |
public function withProtocolVersion(string $version): self
{
$new = clone $this;
$new->response = $this->response->withProtocolVersion($version);
return $new;
}
| public self withStatus ( integer $code, string $reasonPhrase = '' ) | ||
| $code | integer | |
| $reasonPhrase | string | |
public function withStatus(int $code, string $reasonPhrase = ''): self
{
$new = clone $this;
$new->response = $this->response->withStatus($code, $reasonPhrase);
return $new;
}
| public self withoutHeader ( string $name ) | ||
| $name | string | |
public function withoutHeader(string $name): self
{
$new = clone $this;
$new->response = $this->response->withoutHeader($name);
return $new;
}
Signup or Login in order to comment.