Problem/Motivation

Child of #3624396: Plan: Harden InstanceInterface, IslandInterface and DisplayBuildableInterface as public API before RC1. Three names leave the module's namespace or its conventions, and get expensive once 1.0 ships:

  • hook_island_info_alter(). Hooks share one namespace, and drupal.org has a project named island, whose hooks are hook_island_*.
  • plugin.manager.db_island, the one service ID with an abbreviation, where "db" reads as database.
  • The other service IDs are strings, display_builder.* and their submodule equivalents. Core gives services their class name as ID, and keeps string IDs for plugin managers only.
  • The 11 builder events are named onUpdate, onAttachToRoot and so on: event names are global, and core prefixes them with the module. Their docblocks also promise more than happens: "Fired when a new node is attached directly at root level", while they fire only from the builder UI, never for a change made through InstanceInterface.

Proposed resolution

  • hook_island_info_alter() becomes hook_display_builder_island_info_alter().
  • plugin.manager.db_island becomes plugin.manager.display_builder_island. plugin.manager.display_buildable stays: it already follows the convention, and the instance's buildable field stores it.
  • Every other service of the module and its submodules takes its class name as ID. The existing class name aliases become the IDs.
  • The discovery cache key island_plugins becomes display_builder_island_plugins.
  • No deprecated alias. The known users, UI Controls and display_builder_ai, change and release at the same time, and require the release that renames.
  • Document the renamed hook in display_builder.api.php, as #3627266: Mark the API boundary: @api on what contrib extends, @internal on the rest plans for both alter hooks.
  • The values of the 11 DisplayBuilderEvents constants take the module prefix: display_builder.update, display_builder.attach_to_root, display_builder.attach_to_slot, display_builder.move, display_builder.active, display_builder.delete, display_builder.history_change, display_builder.restore, display_builder.revert, display_builder.publish, display_builder.preset_save. The constant names stay, so a subscriber using them is unaffected. No code relies on the values: the island fan-out maps each constant to a method of its own.
  • Their docblocks say what they are: builder UI events, fired by the builder after an action, carrying the islands' updates back to the browser. One line on the class: a change made through InstanceInterface outside the builder fires none of them.

Remaining tasks

  • Update UI Controls: IslandInfoHooks and StylesIslandTest.
  • Update display_builder_ai: AddComponent and SetLayout.
  • Write the change record.

User interface changes

None.

API changes

  • hook_island_info_alter() renamed hook_display_builder_island_info_alter().
  • plugin.manager.db_island renamed plugin.manager.display_builder_island.
  • Service IDs display_builder.*, display_builder_entity_view.*, display_builder_page_layout.* and display_builder_views.* replaced by class names.
  • DisplayBuilderEvents values prefixed with display_builder., constant names unchanged.

Data model changes

None. The island discovery cache rebuilds under its new key.

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

pdureau’s picture

Hooks share one namespace, and drupal.org has a project named island, whose hooks are hook_island_*.

This island project is a placeholder to host a shared implementation of the island & profile mechanism between many projects. Already 2 teams has expressed their interest for using the islands system of their upcoming contrib projects (a kanban board and a task manager), it will be discussed in DrupalCamp Germany later this year.

So I guess we would want to share the namespace.

plugin.manager.db_island, the one service ID with an abbreviation, where "db" reads as database.

The other service IDs are strings, display_builder.* and their submodule equivalents. Core gives services their class name as ID, and keeps string IDs for plugin managers only.

Renaming the services with namespaced class names is already the goal of #3613447: More autowire for plugins DI, but the codebase was moving too much, so postponed until we stabilized it.

The 11 builder events are named onUpdate, onAttachToRoot and so on: event names are global, and core prefixes them with the module. Their docblocks also promise more than happens: "Fired when a new node is attached directly at root level", while they fire only from the builder UI, never for a change made through InstanceInterface.

Indeed, Core prefixes services with the module name (most of the time):

  const BLOCK_CONTENT_GET_DEPENDENCY = 'block_content.get_dependency';
  const FLOOD_BLOCKED_USER = 'user.flood_blocked_user';
  const FLOOD_BLOCKED_IP = 'user.flood_blocked_ip';
  const POPULATE_MAPPER = 'config_translation.populate_mapper';

👌Let's do the change.

pdureau’s picture

Status: Active » Needs review

Events renamed.

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

Assigned: csakiistvan » Unassigned

✅ Tested and works — applied MR !511, rebuilt caches and listed the DisplayBuilderEvents values with their listeners: all 11 now carry the display_builder. prefix and each keeps its listeners, and ApiControllerTest, IslandEventTest and PresetMessagesSubscriberTest pass. I pushed the missing class docblock line (builder UI events, none fired for changes made through InstanceInterface), so this needs another reviewer.

Notes
  • The remaining 'onUpdate'-style strings in the module are subscriber method names, so nothing depends on the old values.
  • The hook and service ID renames are out of the MR, in line with the maintainer comment (shared island namespace, services moved to #3613447); the IS could be updated to match.
pdureau’s picture

Assigned: Unassigned » mogtofu33
Status: Needs review » Reviewed & tested by the community
mogtofu33’s picture

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

Little doc fix added, 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.

  • mogtofu33 committed 7feb8232 on 1.0.x authored by pdureau
    task: #3627272 Rename the island alter hook and the service IDs before...
pdureau’s picture

Status: Fixed » Closed (fixed)

Shipped in beta10 release.