-
-
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
!!!TASK: Bootstrap instantiates request handlers internally #3371
base: 9.0
Are you sure you want to change the base?
Conversation
de760a5
to
6c611a6
Compare
This cannot ever be green on CI as the necessary changes to the BuildEssentials (register/preselect testing request handlers) are a hard block in either direction, whichever comes first breaks it.So you would have to run tests locally or trust me and we fix anything that comes up after.... |
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.
thanks for this ;) We also stumbled upon this complexity for the neos/setup
part ... this change does make things easier. Though we do have to live with the fact that the 6.0.0 tag of neos/setup
will not be compatible with Flow 9.0 anymore which it is currently and tagged: https://github.com/neos/setup/blob/ecd193d814aea502aad71b0907f193de08fc9d0d/composer.json#L8 (im stupid sorry lol).
It seems unnecessarily complex to have code register a request handler as build instance. Instead it is now registered by class name. The Flow Bootstrap will then create instances while determining the best matching request handler. To facilitate this being lazy the RequestHandlerInterface::getPriority method is now declared static so that we can decide beforehand if the priority is higher than any previously found best match. Depending on possibly request handlers and specifically in all preselected cases this all reduces the amount of created objects and possibly the amount of canHandle calls. A microptimization but which affects all requests. Primary concern was to make registration easier and internalize instantiation. As small simplification the `Bootstrap->setPreselectedRequestHandlerClassName` will also register the given class name as possible request handler removing one step. This is breaking if you have your own request handler implementation. The `getPrioritty` method needs to declare an `int` return type and must be static. Additionally the registration happens via `Bootstrap->registerRequestHandlerClassName(YourRequestHandler::class)`.
6c611a6
to
ae54ccd
Compare
It seems unnecessarily complex to have code register a request handler as build instance. Instead it is now registered by class name. The Flow Bootstrap will then create instances while determining the best matching request handler. To facilitate this being lazy the RequestHandlerInterface::getPriority method is now declared static so that we can decide beforehand if the priority is higher than any previously found best match.
Depending on possibly request handlers and specifically in all preselected cases this all reduces the amount of created objects and possibly the amount of canHandle calls. A microptimization but which affects all requests. Primary concern was to make registration easier and internalize instantiation.
As small simplification the
Bootstrap->setPreselectedRequestHandlerClassName
will also register the given class name as possible request handler removing one step.This is breaking if you have your own request handler implementation. The
getPrioritty
method needs to declare anint
return type and must be static. Additionally the registration happens viaBootstrap->registerRequestHandlerClassName(YourRequestHandler::class)
.Also the RequestHandler now needs a static constructor
RequestHandlerInterface::fromBootstrap(Bootstrap $bootstrap): self
that the Bootstrap will call when instantiating one.If the RequestHandler for some reason was used as a bridge to the outside world and the instance carried more information besides the bootstrap, you can "sneak in" your instance with anything you want by setting it via
Bootstrap->setEarlyInstance(YourRequestHandler::class, $yourInstance)
and this will be used instead of creating a new instance via the static constructor. You still need to register the class as possible request handler though.