-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(DeclarativeSettings): Allow to define getter and setters in declarative settings form class #48721
Conversation
… directly in Form Instead of implementing the form class, a setter event listener and a getter event listener, this allows to simply write a basic class that provides `getSchema`, `setValue` and `getValue` functions. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
…ve settings Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
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.
Mh sure :D
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.
Hum wouldn’t listening to the three events with the same listener results in the same code more or less?
yes, but with "a lot" more boilerplate code (register event listener, wrapping things in the listener). And also potentially slower as all event listeners are called, no problem if only one app is using this, but if there are many apps then every app would be called to handle other settings. For exapps this makes sense but for native PHP apps this I would say is cleaner. |
I don’t get it. Why is it more code to register for the 3 events a listener rather than registering a "Declarative settings"? "all event listeners are called", yes but also with your solution they are all called, no? I do not see the performance difference. |
Switch on event listener + registering the event listener in the first place.
No the |
Summary
Instead of being required to write 3 event listeners this short cuts the declarative settings by being able to implement the
DeclarativeSettingsFormWithHandlers
interface to have a class providinggetSchema
,setValue
andgetValue
.There is also an example implementation in the files app that I migrated for demonstration purpose.
Checklist