Problem/Motivation

Child 5 of #3624396: Plan: Harden InstanceInterface, IslandInterface and DisplayBuildableInterface as public API before RC1. Islands are what contrib extends most, so their API has to be right before RC1.

  • An island calls the instance a builder: build(InstanceInterface $builder), buildContent(), getHtmlId(string $builder_id), and the protected $builder and $builderId of IslandPluginBase. The 11 on*() methods of the same island say $instance, as does the rest of the API.
  • keyboardShortcuts() is a static method, called on the class, so an island cannot answer from its configuration. Its docblock promises a map of keys to descriptions.
  • type is optional on #[Island], while an island without a type does not work.
  • afterBuild() is declared twice, on IslandInterface and on IslandWithFormInterface. reloadWithNodeData() has no caller.

Proposed resolution

  • $builder becomes $instance and $builderId becomes $instanceId: the protected properties of IslandPluginBase, and the arguments of build(), buildContent() and getHtmlId(). Renamed outright, as every API change before RC1.
  • getKeyboardShortcuts(): array replaces the static keyboardShortcuts(). The base returns none.
  • type required on #[Island], after label. Every island passes named arguments.
  • afterBuild() leaves IslandWithFormInterface. reloadWithNodeData() is removed.

ThirdPartySettingsInterface keeps its name, see #7. What an empty result of an island means moves to #3635780: Islands cannot tell "no update" from "empty me" in an event result.

Remaining tasks

  • Update display_builder_ai and raise its constraint on drupal/display_builder.
  • Publish the change record with beta10.

User interface changes

None.

API changes

  • IslandPluginBase::$builder and $builderId renamed $instance and $instanceId, with the arguments of build(), buildContent() and getHtmlId().
  • IslandInterface::getKeyboardShortcuts() replaces the static keyboardShortcuts().
  • type required on #[Island].
  • reloadWithNodeData() removed. afterBuild() removed from IslandWithFormInterface.

Data model changes

None.

Command icon 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

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

Issue summary: View changes
mogtofu33’s picture

Issue summary: View changes
mogtofu33’s picture

Status: Active » Needs work
pdureau’s picture

beta9 has been released. Changing the tag.

pdureau’s picture

$builder becomes $instance and $builderId becomes $instanceId: the protected properties of IslandPluginBase, and the arguments of build(), buildContent() and getHtmlId(), in every island. Renamed outright before RC1, with a change record, as every API change up to beta9. No contrib island is known, and display_builder_ai and the dev tools change in lockstep, requiring the release that renames.

It is the good time to do such a change, which is a leftover of the big instance/node/builder confusion of summer 2025. I don't see how it breaks compatibility thoughts:

  • Those parameters are positioned, and not used as named arguments
  • The positions stay the same, only the name change
  • Then, their use is internal to each method

👌 It worth to check.

The other protected members contrib uses stay as they are: $nodeId, $data, the promoted services, buildButton() and reloadWithLocalData(). Child 9 lists them as supported.

👌 OK, let's not change too much so close to 1.0.0

getKeyboardShortcuts(): array on the interface replaces the static keyboardShortcuts(), which is removed. The base default returns no shortcut, the islands that declare one override it, and ProfileViewBuilder calls it. Its docblock gives the shape it really returns.

👌OK, let's do this.

type required on #[Island]. Every island passes named arguments, so moving it after label breaks none of them. Fallback: keep the default, and throw from the plugin manager for an island without a type.

👌OK, let's do this.

afterBuild() leaves IslandWithFormInterface, and stays on IslandInterface. reloadWithNodeData(), which has no caller, is removed.

👌OK, let's do this.

ThirdPartySettingsInterface renamed outright.

⚠️ Why? It was named like the Core interface for familiarity reason. It has only one method but it is expected to host more. Third party settings will be the most movable part of the API, we have only scratched the surface with our curent panels.

Docblocks of IslandInterface and the on*() methods. docs/island-plugins.md drops the promise that build() may return NULL.

⚠️ We need a way of making the distinction between:

  • an island not reacting to an event ("I pass"): it was the purpose of NULL
  • one emptying its renderable as a reaction to an event: it was the purpose of an empty array

Maybe it is not properly documented, or not properly implemented, and I would advise to address such topic in a dedicated ticket.

pdureau’s picture

I would like to give a try, but I see it is "Needs work". Do you already have something local ?

pdureau’s picture

Issue tags: +Breaking Change (BC)
mogtofu33’s picture

Issue summary: View changes

Trimmed to land before beta10. ThirdPartySettingsInterface keeps its name, you are right that it will grow.
The empty result question is real and wider than build(), so it gets #3635780: Islands cannot tell "no update" from "empty me" in an event result.

MR in for review.

mogtofu33’s picture

Assigned: mogtofu33 » pdureau
Status: Needs work » Needs review
pdureau’s picture

Assigned: pdureau » mogtofu33

$builder becomes $instance and $builderId becomes $instanceId: the protected properties of IslandPluginBase, and the arguments of build(), buildContent() and getHtmlId(), in every island. Renamed outright before RC1, with a change record, as every API change up to beta9. No contrib island is known, and display_builder_ai and the dev tools change in lockstep, requiring the release that renames.

✅ MR looks good. No changes in PHP tests except renaming. No changes in playwright tests.

getKeyboardShortcuts(): array on the interface replaces the static keyboardShortcuts(), which is removed. The base default returns no shortcut, the islands that declare one override it, and ProfileViewBuilder calls it. Its docblock gives the shape it really returns.

✅ MR looks good. No changes in PHP tests except renaming. No changes in playwright tests.

type required on #[Island]. Every island passes named arguments, so moving it after label breaks none of them. Fallback: keep the default, and throw from the plugin manager for an island without a type.

✅ MR looks good. I see the change in src/Attribute/Island.php. No changes in tests.

afterBuild() leaves IslandWithFormInterface, and stays on IslandInterface. reloadWithNodeData(), which has no caller, is removed.

✅ MR looks good. I see the changes in src/Island/IslandWithFormInterface.php and IslandPluginBase. No changes in tests.

ThirdPartySettingsInterface renamed outright.

✅ kept.

Docblocks of IslandInterface and the on*() methods. docs/island-plugins.md drops the promise that build() may return NULL.

✅ OK, let's discuss there: #3635780: Islands cannot tell "no update" from "empty me" in an event result

pdureau’s picture

Status: Needs review » Reviewed & tested by the community

  • mogtofu33 committed 979657d6 on 1.0.x
    task: #3627256 IslandInterface: name the instance $instance, and settle...
mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Reviewed & tested by the community » Fixed

Thanks !

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

pdureau’s picture

Status: Fixed » Closed (fixed)

Shipped in beta10 release.