Problem/Motivation
InstanceInterface cannot list the nodes of a slot. A caller digs into the source data, knowing where each source plugin keeps its slots. display_builder_ai counts a slot's children through ['source']['component']['slots'], which only works for components.
Proposed resolution
Add getSlotNodeIds(string $parent_id, string $slot_id): ?array to SourceTree, and delegate to it from InstanceInterface: the node IDs of a slot in order, empty for an empty or unknown slot, NULL when the parent node does not exist.
The other queries first proposed here had no caller, see #3627027-5: InstanceInterface: list the nodes of a slot. Kernel tests on SourceTree and on the instance.
API changes
One new method on InstanceInterface, one on SourceTree. Nothing existing changes.
Issue fork display_builder-3627027
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
mogtofu33 commentedComment #4
pdureau commentedI was expecting the opposite about " Harden InstanceInterface": less public methods, smaller public interfaces, safer commitment for us.
Also, I understood
SourceTreeas an internal black box to consolidate tricky and risky logic directly used by Display Builder, not as public interface to extends. If we don't use the 2 new methods, why others project would needs them?So, I am not putting this ticket in RTBC. However, if you own this strategy of extending interfaces and deeply believe in it, go for it.
Comment #5
mogtofu33 commented[deleted] wrong comment
Comment #6
mogtofu33 commentedComment #7
mogtofu33 commentedI think you misread the Plan, it is not to make smaller but more open to contrib. Makes thinner could be a side effect but not the intended purpose. Example with display_builder_ai that revealed a case we didn't had, and it started a broader plan to ease contrib. Note the plan is not rigid, it's a direction.
For the next part, fair question, and it cuts this issue down to one method.
The plan shrinks too: items 3, 6 and 9 of #3624396: Plan: Harden InstanceInterface, IslandInterface and DisplayBuildableInterface as public API before RC1 deprecate, remove, and mark
@internaleverything that is not a contract,SourceTreeincluded. But here I derived the methods from whatSourceTreecan answer, not from callers. Your test is the better one: a public method needs a caller.Checked against display_builder_ai, the one contrib module changing instances:
getSlotNodeIds(): it counts a slot's children through['source']['component']['slots'], wrong for any parent that is not a component. Kept.getRootNodeIds(): it walksgetSources(), which is fine once its node shape is documented. Dropped.hasNode():getNode()returningNULLcovers it. Dropped.isNodeInRoot(),isNodeInSlot(),isRootFull(),isSlotFull(): no caller anywhere. Dropped.Comment #8
mogtofu33 commentedComment #9
mogtofu33 commentedComment #10
pdureau commentedA single addition to
InstanceInterface(::getSlotNodeIds()) to address an identified need in contrib 👍Comment #12
mogtofu33 commented