Follow up from #1950632: Create a FieldDefinitionInterface and use it for formatters and widgets. If code isn't specifically working with configuring Field API fields and instances (e.g., providing settings forms), then it has no business dealing with those objects/interfaces directly, and should instead interact only via FieldDefinitionInterface. That allows future core or contrib code to pass in nonconfigurable fields and still have everything work.
This doesn't fix all of core to do this, but does the parts that were found in the course of #1988612: Apply formatters and widgets to rendered entity base fields, starting with node.title. Extracting this part because it's an API change, so would be good to have land before API freeze, but the rest of that issue requires more work and review.
Because this includes changes to the getConstraints() methods of text field type classes, it also removes that method from TextWithSummaryItem and TextItemBase, and leaves it only on TextItem, since that is the only type that actually provides a max_length setting.
Comment | File | Size | Author |
---|---|---|---|
#4 | field_definition-3.patch | 25.67 KB | effulgentsia |
#4 | interdiff.txt | 892 bytes | effulgentsia |
field_definition.patch | 25.61 KB | effulgentsia | |
Comments
Comment #1
effulgentsia CreditAttribution: effulgentsia commentedI think this might be the only controversial part of this patch. The implementation of a nonconfigurable field definition class is still under discussion in #1988612-40: Apply formatters and widgets to rendered entity base fields, starting with node.title, but I still think it makes sense to add the interface for field types to be able to get their definition in this issue, since that's part of the API change being made here.
Comment #2
BerdirNitpick: needs a description.
Comment #3
Wim LeersThe patch looks sane to me. But since I'm not deeply familiar with all things Entity & Field API, I cannot RTBC this.
Comment #4
effulgentsia CreditAttribution: effulgentsia commentedAddressed #2.
Comment #5
yched CreditAttribution: yched commentedMakes sense and looks good !
Comment #6
YesCT CreditAttribution: YesCT commentedThis issue was RTBC and passing tests on July 1, the beginning of API freeze.
Comment #7
alexpottCommitted 5207055 and pushed to 8.x. Thanks!
Comment #8
BerdirUntagging.
Comment #10
effulgentsia CreditAttribution: effulgentsia commentedI grepped the rest of core for where there are typehints to Field, FieldInstance, FieldInterface, or FieldInstanceInterface that should be replaced with FieldDefinitionInterface, and only found one remaining function: #2058299: Fix content_translation_field_sync_widget() to act on FieldDefinitionInterface rather than $field, $instance.