-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
!!! FEATURE: Dispatcher psr overhaul #3311
Conversation
WIP This change needs an accompanying adjustment to Neos to adjust the PluginImplementation as well as Modules. The new `SimpleActionController` gives you a direct and simple way to route an ActionRequest and return an ActionReponse with nothing in between. Routing should work just like with other ActionControllers. This is breaking if you implemented your own ControllerInterface or overwrote or expect some of the api methods of the ActionController. We now use a direct pattern of f(ActionRequest) => ActionResponse in more places. Adjusting existing controllers should be easy though. We discourage to manipulate `$this->reponse` in controllers, although it should still work fine in actions for now, please consider other options.
…er-simplecontroller
Original this method and logic was introduced via: b780118 The previous try catch would still work but mutating `$this->response` AFTER throwing an exception is pretty ugly.
…ler.php Co-authored-by: Marc Henry Schultz <[email protected]>
…`afterControllerInvocation` The parameter `$response` was removed from the `beforeControllerInvocation` signal, as it would be just always empty at that point and misleading and any mutations would be ignored. The parameter `$response` was made nullable for the `afterControllerInvocation` signal, as it's not set after a `forwardToRequest`. Also, it's to be noted, that modifying the response in an `afterControllerInvocation` is not always going to take effect, for example if the dispatcher is still in the loop.
Explain that the details/exception message dont matter, and set a default.
…stionmark !!! TASK: Separate `ForwardException` from `StopActionException`
Will be split up into an own pr #3297
Will be split up into an own pr #3298
…econtroller !!! FEATURE: WIP Dispatcher and controller return `ActionResponse` (simpler controller pattern)
This will not open a memory stream
`replaceHttpResponse` is unsafe to use and has hard to tell behaviour. Instead, we up-merge the headers explicitly
!!! TASK: Deprecate and replace `ActionResponse` in dispatcher
…urns-psr-responses
Neos passes an object for the node frontend routing: expects array<string, string>, array<string, Neos\Neos\FrontendRouting\NodeAddress> given.
…urns-psr-responses
29694c2
to
f4c5479
Compare
} | ||
return $parentResponse; | ||
// TODO $response is never _null_ at this point, except a `forwardToRequest` and the `nextRequest` is already dispatched == true, which seems illegal af |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be fixed via #3301
This method threw an exception since Flow 6. > The HTTP response only exists after the innermost middleware (dispatch) is done. For that stage use a middleware instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this by reading and it makes a lots of sense. Would lite to test this before finally approving. Will take some tome. Maybe count this as +0.5 in the meantime
To ease the implementation of a custom controller now use a direct pattern of
f(ActionRequest) => PsrResponseInterface
.This is breaking if you implemented your own
ControllerInterface
or overwrote low level parts and methods of theActionController
.Also, it's discouraged to manipulate
$this->response
in controllers (theActionResponse
is deprecated), although it's still supported in actions for now, please consider returning a new response instead.Explanation of 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:
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:
ActionResponse::buildHttpResponse()
So you can and should use the immutable psr {@see ResponseInterface} instead where-ever possible.
For backwards compatibility, each controller will might now manage an own instance of the action response
via
$this->response
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:Further the
ForwardException
does not extend theStopActionException
anymore, meaning a try catch must be adjusted.This is the main PR and it contains
ActionResponse
(simpler controller pattern) #3232ActionResponse
in dispatcher #3294Followup: #3301
Resolves: #3289
This change needs an accompanying adjustment to Neos to adjust the
PluginImplementation as well as Modules: neos/neos-development-collection#4738
Upgrade instructions
WIP Upgrade notes: #3232 (comment)
Review instructions
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions