Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
Problem/Motivation
Content entities are required to specify the view builder, to be able to view fields. This is for example needed to view configurable fields in views and soon also for the base fields as well: #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency
Proposed resolution
1. Specify the view builder in ContentEntityType
2. refactor FieldItemBase::view()
Remaining tasks
User interface changes
API changes
Beta phase evaluation
Issue category | Task |
---|---|
Issue priority | Normal because nice tags improvement |
Disruption | Zero Disruption, Will not break any code |
Comment | File | Size | Author |
---|---|---|---|
#4 | viewing_configurable-2446483-4.patch | 1.66 KB | Anushka-mp |
#4 | viewing_configurable-2446483-4-interdiff.txt | 1.13 KB | Anushka-mp |
#2 | viewing_configurable-2446483-2.patch | 538 bytes | Anushka-mp |
Comments
Comment #1
Anushka-mp CreditAttribution: Anushka-mp commentedComment #2
Anushka-mp CreditAttribution: Anushka-mp commentedapproach 1. added the view builder as a handler to the ContentEntityType::
Comment #3
BerdirRemember to also remove any occurence of "view_builder" = "Drupal\Core\Entity\EntityViewBuilder" from core.
Comment #4
Anushka-mp CreditAttribution: Anushka-mp commentedview builder (EntityViewBuilder) removed from the User & File entities.
Comment #5
dawehnerThis is also kinda a blocker for views, isn't it?
Comment #6
olli CreditAttribution: olli commentedDoes this work for shortcut and menulinkcontent which currently dont have a view_builder?
Comment #7
BerdirUpdated issue summary a bit.
@dawehner: It's not a blocker, just a DX improvement, you can always specify it yourself, but you have to figure that out and find the right class and so on. And apparently our code relies on its existence.
Comment #8
dawehner@berdir
Well, the point is the following: Let's assume you have an entity type with some base fields, but without any kind of view builder.
These views should be available in views, but well, the following code in
FIeldItemList
will simply fail:as long there is no view builder defined.
Comment #9
dawehnerI think this is ready to go.
Comment #10
dawehnerA beta eval would be nicel
Comment #11
Anushka-mp CreditAttribution: Anushka-mp commentedComment #12
Anushka-mp CreditAttribution: Anushka-mp commentedComment #13
Anushka-mp CreditAttribution: Anushka-mp commentedComment #14
alexpottIt seems sensible to provide a default if we rely on it. I agree that this reduces fragility and improves DX with zero disruption. Committed 6fe3616 and pushed to 8.0.x. Thanks!
Thank you for adding the beta evaluation to the issue summary.