Problem/Motivation
While working on #3594228: Remove explicit references to Layout Builder & #3542276: Embedding a display in an other with a formatter, I have noticed some complexity to orchestrate in a safe and explicit manner the relationship between EntityView and EntityViewOverride.
For example:
- we have a
display_builder_entity_viewspecific logic inStateButtons Instance::revert()is currently emptying the sources. It is never supposed to happen from UI, but the logic exists and is dangerous- it is hard to implement those changes we may want sooner or later: do we disable and/or empty and override when the parent is disable? Do we fallback to the overridden when the overridable when some conditions are not met?
We need an official, "first class", overriding "contract", instead of relying on loosely specified snippets from the early days of the project.
Proposed resolution
Add a DisplayBuildableOverrideInterface extending DisplayBuildableInterface with:
public const OVERRIDE_FIELD_PROPERTY = 'override_field';from DisplayBuildableInterfacepublic const OVERRIDE_PROFILE_PROPERTY = 'override_profile';from DisplayBuildableInterfacepublic function revertSources(): array;from DisplayBuildableInterface- a new
public function getOverriden(): DisplayBuildableInterface;
Implement it in EntityViewOverride and adapt the logic in Instance entity, StateButtons and elsewhere.
Issue fork display_builder-3618424
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pdureau commentedDone. Pipeline green.
The main benefit of such a change can be seen in the simplification of
StateButtons::isOverridden()in the MR. I expect similar simplification when we will work on #3594228: Remove explicit references to Layout Builder & #3542276: Embedding a display in an other with a formatter.Other nice stuff:
display_builder_entity_viewin the maindisplay_buildermoduleHowever, I am not sure about terminology:
DisplayBuildableOverrideInterfaceVSOverridingDisplayBuildableInterface::getOverriden()vs::getOverridenBuildable()What do you think?
Comment #4
mogtofu33 commentedCurrent semantic is good for me. Just some cleanup to do.
Comment #5
pdureau commentedThanks you for the feedback. I did the changes.
Comment #7
mogtofu33 commented