Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The EntityViewDisplay and EntityFormDisplay config entity would need to implement ThirdPartySettingsInterface
if we want to allow contrib modules to store module specific metadata to the entity displays. This will benefit modules like Display suite, Field group etc
Proposed resolution
Implement ThirdPartySettingsInterface
and ThirdPartySettingsTrait
in EntityViewDisplay and EntityFormDisplay.
Remaining tasks
Agree approach.
Review patch.
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff.txt | 801 bytes | swentel |
#13 | 2333501-13.patch | 5.39 KB | swentel |
#7 | interdiff.txt | 731 bytes | swentel |
#7 | 2333501-7.patch | 5.4 KB | swentel |
#6 | 2333501-6.patch | 5.4 KB | swentel |
Comments
Comment #1
marcvangendComment #2
swentel CreditAttribution: swentel commented+1 ! Should be able to work on this coming sunday
Comment #3
marcvangendAfter chatting with timplunkett and berdir, who explained the difference between EntityViewMode and EntityViewDisplay, I came to the conclusion that this issue should in fact be about implementing third party settings in EntityViewDisplay, because that is where the display settings of a view mode are stored.
Comment #4
swentel CreditAttribution: swentel commentedHa totally right, I've been misreading the title this whole time. Also, let's do this for entityFormDisplay at the same time as well.
Comment #5
swentel CreditAttribution: swentel commentedComment #6
swentel CreditAttribution: swentel commentedThis should do it
Comment #7
swentel CreditAttribution: swentel commentedsmall doc update
Comment #8
aspilicious CreditAttribution: aspilicious commentedLooks fine, in line with the referenced issue. Has tests and it's a step forward for contrib!
Comment #9
marcvangendThanks Swentel, that looks awesome. Please allow me to ask some questions, if only to help me understand what exactly is going on :-)
I'm not familiar with this, what does 'dependencies' do?
What is the reason for this change?
Shouldn't there be tests for getThirdPartySetting too? It seems to me that you're only testing if third party settings can be read, not written. And what about EntityFormDisplay, can we simply assume that it works if this test passes, or does it need its own tests?
Comment #10
swentel CreditAttribution: swentel commented@marcvangend
1. dependencies is used in every config entity to store the dependencies on either modules, themes. This is automatically calculated by calculateDependencies() method and stores information on which modules this config entity depends. e.g. if a entity views display config entity has information about a formatter which is provided by the image module, you'll find the image dependency there. This change just adds it to the schema because it was missing.
2. KernelTestBase is the successor of UnitTestBase which is deprecated (and will probably be removed one day)
3. The test itself calls getThirdPartySetting on a $display object so that's fine. EntityViewDisplay and EntityFormDisplay both implement EntityDisplayInterface so this should be fine by only testing EntityViewDisplay - unless a core committer decides otherwise.
Comment #11
Berdir1. Dependencies are used to track dependencies to other config entities. For example, displays depend on the bundle config entity and fields. however, this shouldn't be necessary if we use type: config_entity, which already contains this?
2. DrupalUnitTestBase was renamed to KernelTestBase (it is not a unit test and has nothing in common with unit/phpunit tests.
Comment #12
swentel CreditAttribution: swentel commentedSo yes, berdir is right config_entity has dependencies so this patch should not add it. core.entity_form_display still has it though, so we can remove it in the same run there.
Comment #13
swentel CreditAttribution: swentel commentedNew patch
Comment #14
BerdirLooks good!
Comment #15
marcvangendExcellent. I didn't do much here but I learned a lot, thanks guys!
Comment #16
alexpottCommitted 2735f12 and pushed to 8.0.x. Thanks!
Comment #18
yched CreditAttribution: yched commentedJust wondering: what kind of use cases do we have in mind for DS / field_group ?
Comment #19
swentel CreditAttribution: swentel commented@yched :
display suite needs to store the template we will switch to for a given type, bundle and view mode. We store some extra variables there as well
as for field group well, we now have a way to store the parents and children without having to come up with our own storage, however, for field group we could use the components if we get that one in soon enough. Aspilicious and I are going to look at that one in amsterdam as well.
Comment #20
yched CreditAttribution: yched commented@swentel: thanks, makes sense.
I was indeed more expecting f_g to need the "component types" patch, and getting that one in is definitely in my hitlist for Amsterdam :-)
Comment #22
yched CreditAttribution: yched commentedFYI : #2397807: EntityDisplay schema for third_party_settings is wrong