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 __construct( \Psr\Http\Message\ResponseInterface $response, Closure $dataCallback ): mixed | ||
| $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 getBody( ): \Psr\Http\Message\StreamInterface |
public function getBody(): StreamInterface
{
if ($this->resolvedBody === null) {
$this->resolvedBody = ($this->dataCallback)();
}
return $this->resolvedBody;
}
| public getHeader( string $name ): array | ||
| $name | string | |
public function getHeader(string $name): array
{
return $this->response->getHeader($name);
}
| public getHeaderLine( string $name ): string | ||
| $name | string | |
public function getHeaderLine(string $name): string
{
return $this->response->getHeaderLine($name);
}
| public getHeaders( ): array |
public function getHeaders(): array
{
return $this->response->getHeaders();
}
| public getProtocolVersion( ): string |
public function getProtocolVersion(): string
{
return $this->response->getProtocolVersion();
}
| public getReasonPhrase( ): string |
public function getReasonPhrase(): string
{
return $this->response->getReasonPhrase();
}
| public getStatusCode( ): integer |
public function getStatusCode(): int
{
return $this->response->getStatusCode();
}
| public hasHeader( string $name ): boolean | ||
| $name | string | |
public function hasHeader(string $name): bool
{
return $this->response->hasHeader($name);
}
| public withAddedHeader( string $name, mixed $value ): self | ||
| $name | string | |
| $value | mixed | |
public function withAddedHeader(string $name, $value): self
{
$new = clone $this;
$new->response = $this->response->withAddedHeader($name, $value);
return $new;
}
| public withBody( \Psr\Http\Message\StreamInterface $body ): self | ||
| $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 withHeader( string $name, mixed $value ): self | ||
| $name | string | |
| $value | mixed | |
public function withHeader(string $name, $value): self
{
$new = clone $this;
$new->response = $this->response->withHeader($name, $value);
return $new;
}
| public withProtocolVersion( string $version ): self | ||
| $version | string | |
public function withProtocolVersion(string $version): self
{
$new = clone $this;
$new->response = $this->response->withProtocolVersion($version);
return $new;
}
| public withStatus( integer $code, string $reasonPhrase = '' ): self | ||
| $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 withoutHeader( string $name ): self | ||
| $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.