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

            
getBody() public method

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

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

            
getHeader() public method

public array getHeader ( string $name )
$name string

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

            
getHeaderLine() public method

public string getHeaderLine ( string $name )
$name string

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

            
getHeaders() public method

public array getHeaders ( )

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

            
getProtocolVersion() public method

public string getProtocolVersion ( )

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

            
getReasonPhrase() public method

public string getReasonPhrase ( )

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

            
getStatusCode() public method

public integer getStatusCode ( )

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

            
hasHeader() public method

public boolean hasHeader ( string $name )
$name string

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

            
withAddedHeader() public method

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

            
withBody() public method

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

            
withHeader() public method

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

            
withProtocolVersion() public method

public self withProtocolVersion ( string $version )
$version string

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

            
withStatus() public method

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

            
withoutHeader() public method

public self withoutHeader ( string $name )
$name string

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