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 middlewares.
Properties
protected Stream | $content | ||
protected UriInterface | $redirectUri | ||
protected int|null | $statusCode | The HTTP status code |
|
protected string | $contentType | ||
protected Cookie[] | $cookies | ||
protected array | $headers | ||
protected ResponseInterface|null | $httpResponse |
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.
Set the specified header in the response, overwriting any previous value set for this header.
Add the specified header to the response, without overwriting any previous value set for this header.
Return the specified HTTP header that was previously set.
No description
No description
No description
No description
No description
Use this if you want build your own HTTP Response inside your action
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)
deprecated
deprecated
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.
void
setHttpHeader(string $headerName, array|string|DateTime $headerValue)
Set the specified header in the response, overwriting any previous value set for this header.
void
addHttpHeader(string $headerName, array|string|DateTime $headerValue)
Add the specified header to the response, without overwriting any previous value set for this header.
array|string|null
getHttpHeader(string $headerName)
Return the specified HTTP header that was previously set.
string
getContent()
No description
UriInterface|null
getRedirectUri()
No description
int
getStatusCode()
No description
bool
hasContentType()
No description
string|null
getContentType()
No description
void
replaceHttpResponse(ResponseInterface $response)
Use this if you want build your own HTTP Response inside your action
ActionResponse
mergeIntoParentResponse(ActionResponse $actionResponse)
No description
ResponseInterface
buildHttpResponse()
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.