Problem/Motivation
We currently have UiPatternsSource plugins that define the available SourceField for a given need (using tags). Those plugins only generate the list of the available fields but never their values. The values recovery is hardcoded where those plugins are used (FieldGroupFormatter, FieldFormatter, ViewsRow, etc.). This absolutely negates the interest of having plugins to extend the available options.
For example, in #3341586: Allow to get the label from the field_display_label module we would like to integrate with a contrib modules that defines a field label dedicated to display. With an appropriate implementation, this contrib module should provide its own Source plugin to declare the new field then return its value if it's used in any pattern.
It would be the same if someone would like to add a custom value based on whatever logic they want. It's not possible without altering the contrib code.
Proposed resolution
Refactor the Source plugins so they are called to provide the field value too.
Try to find a way to prevent BC break.
Remaining tasks
Implement without breaking tests
Extend test coverage with some custom Source plugin implementation
User interface changes
None
API changes
Source plugins will have to implement a new method.
Data model changes
None
Comments
Comment #2
grimreaperHi,
Thanks for the issue.
I think you have more deep dived into those plugins mecanism than me.
I agree that it is confusing to have on one almost emply plugins which only declares fields and on the other side plugins which need to use the first plugins and then load themselves the data.
I propose either:
- 1) do as you proposed and it is the plugin declareing the field that is also repsonsible to provide the data
- 2) remove the source plugins
But as mentioned, I think you have more manipulated Ui patterns plugins than me.
Comment #3
duaelfrComment #4
pdureau commentedComment #5
pdureau commentedWe have a new source plugin in UI Patterns 2.x which is now able to retrieve the data:
Source: https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/SourceIn...
Because form widgets (successor of UI Patterns Settings plugins) are also source plugins, the base plugin implementation will often be good enough:
Source: https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/SourcePl...
Some plugins will override this method to do more complex processing. Example: https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/Plugin/U...
Dualefr, is it what you expected?
Comment #6
pdureau commentedComment #7
pdureau commentedComment #8
pdureau commentedComment #9
pdureau commented