Generated with the help of an LLM.

Problem/Motivation

Split from #3627256: IslandInterface: name the instance $instance, and settle the island API before RC1. build() and the on*() methods of an island return array, and the base returns [] for an event the island ignores. An empty array renders nothing, so it means "no update".
An island emptying its content in reaction to an event has no result of its own: it returns its wrapper with no content.
DisplayBuilderEventsSubscriber::dispatchToIslands() still skips a NULL result, which the return types rule out.

Proposed resolution

To decide: keep [] as "no update" and document how to empty an island, or let on*() return ?array with NULL as "no update".
The first is docs only. The second changes the interface, so it lands before RC1 or not before 2.0.

Remaining tasks

  • Decide.
  • Docblocks of IslandInterface and IslandEventSubscriberInterface, and docs/island-plugins.md.
  • Drop the dead NULL check, or make it live.

User interface changes

None.

API changes

None, or ?array on the on*() methods.

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.

pdureau’s picture

To decide: keep [] as "no update" and document how to empty an island, or let on*() return ?array with NULL as "no update".

As shared in #3627256, I would recommend to stick with the original plan (?array), to be able to express both:

  • empty array: update with empty renderable
  • NULL: no update

Is there something going against this?

mogtofu33’s picture

Issue tags: +RC blocker
mogtofu33’s picture

pdureau’s picture

Assigned: Unassigned » pdureau

I will add ?array on the on*() methods.

There is already this in DisplayBuilderEventsSubscriber::dispatchToIslands():

      $result = $island->{$method}(...$parameters);
      if ($result !== NULL) {
        $event->appendResult($island_id, $result);
    }

So we can guess it was the expected behaviour.

pdureau’s picture

Status: Active » Needs work

Just some linting and we are good

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Needs work » Needs review

Main changes:

  • IslandEventSubscriberInterface, of course
  • In Island plugins, return NULL instead of empty when no update
  • DisplayBuilderEventsSubscriber is hosting the added logic about NULL VS Empty.
  • So, ApiSseController doesn't need it own check anymore

Some added tests. IslandPluginBaseTest is the only one modified, which is comforting.

  • mogtofu33 committed 21a8d22d on 1.0.x authored by pdureau
    task: #3635780 Islands cannot tell "no update" from "empty me" in an...
mogtofu33’s picture

Status: Needs review » Fixed

MErging, thanks, keep a change record on my side.

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.