ActionResponse deprecated
final class ActionResponse (View source)
deprecated
The legacy MVC response object.
Previously Flows MVC needed a single mutable response which was passed from dispatcher to controllers and even further to the view and other places via the controller context: {\Neos\Flow\Mvc\Controller\ControllerContext::getResponse()}. This allowed to manipulate the response at every place.
With the dispatcher and controllers now directly returning a response, the mutability is no longer required. Additionally, the abstraction offers naturally nothing, that cant be archived by the psr response, as it directly translates to one: {[\Neos\Flow\Mvc\ActionResponse::buildHttpResponse()}
So](../../../Neos/Flow/Mvc/ActionResponse.html) you can and should use the immutable psr {\Psr\Http\Message\ResponseInterface} instead where-ever possible.
For backwards compatibility, each controller will might now manage an own instance of the action response
via $this->response
{\Neos\Flow\Mvc\Controller\AbstractController::$response} and pass it along to places.
But this behaviour is deprecated!
Instead, you can directly return a PSR repose {\GuzzleHttp\Psr7\Response} from a controller:
public function myAction()
{
return (new Response(status: 200, body: $output))
->withAddedHeader('X-My-Header', 'foo');
}
Properties
protected StreamInterface | $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
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 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
Unsafe. Please avoid the use of this escape hatch as the behaviour is partly unspecified https://github.com/neos/flow-development-collection/issues/2492
During the migration of {ActionResponse} to {HttpResponse} this might come in handy.
Details
__construct()
No description
void
setContent(string|StreamInterface $content)
deprecated
deprecated
No description
void
setContentType(string $contentType)
deprecated
deprecated
Set content mime type for this response.
void
setRedirectUri(UriInterface $uri, int $statusCode = 303)
deprecated
deprecated
Set a redirect URI and according status for this response.
void
setStatusCode(int $statusCode)
deprecated
deprecated
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)
deprecated
deprecated
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)
deprecated
deprecated
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
setHttpHeader(string $headerName, array|string|DateTime $headerValue)
Set the specified header in the response, overwriting any previous value set for this header.
This behaviour is unsafe and partially unspecified: https://github.com/neos/flow-development-collection/issues/2492
void
addHttpHeader(string $headerName, array|string|DateTime $headerValue)
Add the specified header to the response, without overwriting any previous value set for this header.
This behaviour is unsafe and partially unspecified: https://github.com/neos/flow-development-collection/issues/2492
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
getContentType()
No description
void
replaceHttpResponse(ResponseInterface $response)
Unsafe. Please avoid the use of this escape hatch as the behaviour is partly unspecified https://github.com/neos/flow-development-collection/issues/2492
ActionResponse
mergeIntoParentResponse(ActionResponse $actionResponse)
No description
ResponseInterface
buildHttpResponse()
During the migration of {ActionResponse} to {HttpResponse} this might come in handy.
Note this is a special use case method that will apply the internal properties (Content-Type, StatusCode, Location, Set-Cookie and Content) to a new or replaced PSR-7 Response and return it.
Possibly unsafe when used in combination with {\Neos\Flow\Mvc\self::replaceHttpResponse()} https://github.com/neos/flow-development-collection/issues/2492