0 follower

Final Class Yiisoft\Yii\View\Renderer\ViewResponse

InheritanceYiisoft\Yii\View\Renderer\ViewResponse
ImplementsPsr\Http\Message\ResponseInterface

A PSR-7 response decorator that supports deferred body rendering via a callable.

Method Details

Hide inherited methods

__construct() public method

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,
) {}

            
getBody() public method

public getBody( ): \Psr\Http\Message\StreamInterface

                public function getBody(): StreamInterface
{
    if ($this->resolvedBody === null) {
        $this->resolvedBody = ($this->dataCallback)();
    }
    return $this->resolvedBody;
}

            
getHeader() public method

public getHeader( string $name ): array
$name string

                public function getHeader(string $name): array
{
    return $this->response->getHeader($name);
}

            
getHeaderLine() public method

public getHeaderLine( string $name ): string
$name string

                public function getHeaderLine(string $name): string
{
    return $this->response->getHeaderLine($name);
}

            
getHeaders() public method

public getHeaders( ): array

                public function getHeaders(): array
{
    return $this->response->getHeaders();
}

            
getProtocolVersion() public method

public getProtocolVersion( ): string

                public function getProtocolVersion(): string
{
    return $this->response->getProtocolVersion();
}

            
getReasonPhrase() public method

public getReasonPhrase( ): string

                public function getReasonPhrase(): string
{
    return $this->response->getReasonPhrase();
}

            
getStatusCode() public method

public getStatusCode( ): integer

                public function getStatusCode(): int
{
    return $this->response->getStatusCode();
}

            
hasHeader() public method

public hasHeader( string $name ): boolean
$name string

                public function hasHeader(string $name): bool
{
    return $this->response->hasHeader($name);
}

            
withAddedHeader() public method

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;
}

            
withBody() public method

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;
}

            
withHeader() public method

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;
}

            
withProtocolVersion() public method

public withProtocolVersion( string $version ): self
$version string

                public function withProtocolVersion(string $version): self
{
    $new = clone $this;
    $new->response = $this->response->withProtocolVersion($version);
    return $new;
}

            
withStatus() public method

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;
}

            
withoutHeader() public method

public withoutHeader( string $name ): self
$name string

                public function withoutHeader(string $name): self
{
    $new = clone $this;
    $new->response = $this->response->withoutHeader($name);
    return $new;
}