final class ActionResponse (View source)

The minimal MVC response object.

It allows for simple interactions with the HTTP response from within MVC actions. More specific requirements can be implemented via HTTP Components.

Properties

protected Stream $content
protected array $componentParameters
protected UriInterface $redirectUri
protected int|null $statusCode

The HTTP status code

protected string $contentType
protected Cookie[] $cookies

Methods

__construct()

No description

void
setContent(string|StreamInterface $content)

No description

void
setContentType(string $contentType)

Set content mime type for this response.

void
setRedirectUri(UriInterface $uri, int $statusCode = 303)

Set a redirect URI and according status for this response.

void
setStatusCode(int $statusCode)

Set the status code for this response as HTTP status code.

void
setCookie(Cookie $cookie)

Set a cookie in the HTTP response This leads to a corresponding Set-Cookie header to be set in the HTTP response

void
deleteCookie(string $cookieName)

Delete a cooke from the HTTP response This leads to a corresponding Set-Cookie header with an expired Cookie to be set in the HTTP response

void
setComponentParameter(string $componentClassName, string $parameterName, mixed $value)

Set a (HTTP) component parameter for use later in the chain.

string
getContent()

No description

array
getComponentParameters()

No description

UriInterface|null
getRedirectUri()

No description

int
getStatusCode()

No description

bool
hasContentType()

No description

string
getContentType()

No description

mergeIntoParentResponse(ActionResponse $actionResponse)

No description

mergeIntoComponentContext(ComponentContext $componentContext)

No description

ResponseInterface
applyToHttpResponse(ResponseInterface $httpResponse)

Note this is a special use case method that will apply the internal properties (Content-Type, StatusCode, Location, Set-Cookie and Content) to the given PSR-7 Response and return a modified response. This is used to merge the ActionResponse properties into a possible HttpResponse created in a View (see ActionController::renderView()) because those would be overwritten otherwise. Note that any component parameters will still run through the component chain and will not be propagated here.

Details

__construct()

No description

void setContent(string|StreamInterface $content)

No description

Parameters

string|StreamInterface $content

Return Value

void

void setContentType(string $contentType)

Set content mime type for this response.

Parameters

string $contentType

Return Value

void

void setRedirectUri(UriInterface $uri, int $statusCode = 303)

Set a redirect URI and according status for this response.

Parameters

UriInterface $uri
int $statusCode

Return Value

void

void setStatusCode(int $statusCode)

Set the status code for this response as HTTP status code.

Other codes than HTTP status may end in unpredictable results.

Parameters

int $statusCode

Return Value

void

void setCookie(Cookie $cookie)

Set a cookie in the HTTP response This leads to a corresponding Set-Cookie header to be set in the HTTP response

Parameters

Cookie $cookie

Cookie to be set in the HTTP response

Return Value

void

void deleteCookie(string $cookieName)

Delete a cooke from the HTTP response This leads to a corresponding Set-Cookie header with an expired Cookie to be set in the HTTP response

Parameters

string $cookieName

Name of the cookie to delete

Return Value

void

void setComponentParameter(string $componentClassName, string $parameterName, mixed $value)

Set a (HTTP) component parameter for use later in the chain.

This can be used to adjust all aspects of the later processing if needed.

Parameters

string $componentClassName
string $parameterName
mixed $value

Return Value

void

string getContent()

No description

Return Value

string

array getComponentParameters()

No description

Return Value

array

UriInterface|null getRedirectUri()

No description

Return Value

UriInterface|null

int getStatusCode()

No description

Return Value

int

bool hasContentType()

No description

Return Value

bool

string getContentType()

No description

Return Value

string

ActionResponse mergeIntoParentResponse(ActionResponse $actionResponse)

No description

Parameters

ActionResponse $actionResponse

Return Value

ActionResponse

ComponentContext mergeIntoComponentContext(ComponentContext $componentContext)

No description

Parameters

ComponentContext $componentContext

Return Value

ComponentContext

ResponseInterface applyToHttpResponse(ResponseInterface $httpResponse)

internal  
 

Note this is a special use case method that will apply the internal properties (Content-Type, StatusCode, Location, Set-Cookie and Content) to the given PSR-7 Response and return a modified response. This is used to merge the ActionResponse properties into a possible HttpResponse created in a View (see ActionController::renderView()) because those would be overwritten otherwise. Note that any component parameters will still run through the component chain and will not be propagated here.

WARNING: Should this ActionResponse contain body content it would replace any content in the given HttpReponse.

Parameters

ResponseInterface $httpResponse

Return Value

ResponseInterface