Assigning this to the field system component because that's where I came at it from. Please update as needed.
Problem/Motivation
I want to encapsulate the public properties of FieldConfigBase, as per #2030637: Expand FieldConfig/BaseFieldOverride/FieldConfigBase with methods. FieldConfigBase implements DataDefinitionInterface.
This is difficult because DataDefinitionInterface doesn't allow for $settings to be protected or private, since it only supports a getter and not a setter.
Proposed resolution
Add setSettings() and setSetting() to DataDefinitionInterface, or perhaps create another interface with a name less cumbersome than DataDefinitionWithWritableSettingsInterface.
Remaining tasks
Waiting for a namespace, see #17 so that patch can be updated.
User interface changes
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff.txt | 836 bytes | mile23 |
| #7 | 2396713_7.patch | 2.57 KB | mile23 |
| #5 | 2396713_5.patch | 2.57 KB | mile23 |
| #1 | 2396713_1.patch | 2.32 KB | mile23 |
Comments
Comment #1
mile23This patch merely adds
setSettings()andsetSetting()toDataDefinitionInterface, and also changes docblocks onDataDefinition.I expect there are a number of classes which implement this interface which also don't have those methods. We'll probably need to add another intermediate interface.
Comment #5
mile23Added a new interface called
DataDefinitionMutableSettingsInterfacewhich shows you that I'm a computer scientist or something.No interdiff because it's a completely different approach.
Comment #6
yesct commentedchecked
https://www.drupal.org/node/1354#types
need to look at the implementations to see if should be $this
Comment #7
mile23Thanks for the review.
We don't look at the implementation to find out which to do. We define the interface, and then the implementations do what the interface says. :-)
Anyway, changed to
$this, because it says so right there in the docblock.We might need a better more Drupal-y name than
DataDefinitionMutableSettingsInterface, though it's accurate.Comment #8
mile23Comment #9
berdirDataDefinitionInterface has no setters. None. I don't see how this is needed.
Specific implementations might have a different way to set that information, someone working with DataDefinitionInterface does not need to be able change the settings.
Comment #10
mile23There are getters for settings, but no setters for settings.
The goal is to encapsulate the settings in
FieldConfigBase(and others).That's why I created a new interface to add the setters.
Comment #11
yched commentedDo we really need to add it at the level of DataDefinitionInterface ?
As @Berdir ponted, that interface currently has no setters at all, why would we make an exception for settings specifically ?
(aside from the fact that splitting in to a separate DataDefinitionMutableSettingsInterface really feels like pushing it ;-)
Comment #12
mile23Well the point is encapsulation, so let's figure out a solution.
In what way, specifically?
How can we solve #2030637: Expand FieldConfig/BaseFieldOverride/FieldConfigBase with methods for settings in a way that's reasonable?
Comment #13
berdirJust add them to the objects that need it? And the interfaces that need it, like FieldConfigInterface?
Comment #14
mile23Sounds like an answer to me. Thanks.
Comment #15
mile23Except kindasorta not really. #2398901: Image module makes fatal assumptions about EntityInterface
Comment #16
berdirCommented there.
Comment #17
mile23@yched #11:
No.
I put it there because it had some symmetry with
DataDefinitionInterface. It could be anywhere. Name the namespace and I'll reroll.Comment #18
mile23Comment #30
quietone commentedThis issue was reviewed during a group triage meeting in #bugsmash. smustgrave, larowlan and myself discussed the issue.
The last discussions here and in the related issue are a bit of back and forth on whether this is a problem or not. Is it? There is a patch here and in order to progress it needs a namespace. I have added that to the remaining tasks.
I am setting this to PMNMI for an answer to #17.
Comment #32
smustgrave commentedSince there hasn't been a follow up to #30 going to close out for now.
If still valid please reopen answering #17