ActionResponse
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
No description
No description
Set content mime type for this response.
Set a redirect URI and according status for this response.
Set the status code for this response as HTTP status code.
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
Set a (HTTP) component parameter for use later in the chain.
No description
No description
No description
No description
No description
No description
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
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.
Other codes than HTTP status may end in unpredictable results.
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.
This can be used to adjust all aspects of the later processing if needed.
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
ActionResponse
mergeIntoParentResponse(ActionResponse $actionResponse)
No description
ComponentContext
mergeIntoComponentContext(ComponentContext $componentContext)
No description
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.