-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
refactor: migrate OC_EventSource to dependency injection #38386
Conversation
77fdb97
to
cab73bc
Compare
cab73bc
to
08fd49b
Compare
* @since 8.0.0 | ||
* @deprecated 20.0.0 have it injected or fetch it through \Psr\Container\ContainerInterface::get | ||
*/ | ||
public function createEventSource(); |
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.
Fine to be removed because deprecated but needs docs
08fd49b
to
22e5898
Compare
I overlooked that createEventSource always creates a new object. Can't say if a new instance makes sense, but that was the old behavior. |
22e5898
to
922ea47
Compare
PR for docs: nextcloud/documentation#10479 |
Example: Rello/audioplayer#586 |
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.
In this instance I find it clearer to use createEventSource, as it makes it clear this is not a singleton. What are the pros of DI for non-singletons?
I find that a valid point. @ChristophWurst you deprecated it a while ago. Are you okay to keep Should we also add createEventSource to https://github.com/nextcloud/server/blob/master/lib/public/Server.php so apps can use it without using a private api? |
Might be worth adding an |
Yes let's go with a injectable and mockable factory instead of a static function |
581e7d8
to
43d7ab6
Compare
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.
Clean
43d7ab6
to
e6073f1
Compare
Signed-off-by: Daniel Kesselberg <[email protected]>
e6073f1
to
a2afc7b
Compare
Summary
Test: Increase the version number in version.php and visit Nextcloud.
The update should work as before.
Tip: Set a breakpoint in OC_EventSource.send and watch the request in your browser.
TODO
Checklist