Problem/Motivation

Working on a project, we need to open a little more the internal APIs of ui_patterns.
i will post here a few minor adjustments to allow a better interoperability of the code from outside.

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

just_like_good_vibes created an issue. See original summary.

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Active » Needs review

Pierre, please check the hook name "component_built", we need a better name

pdureau’s picture

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

Naming is hard :)

We are allowing the alteration of a slot source value:

  protected function buildSlot(array $build, string $slot_id, array $definition, array $configuration, array $contexts): array {
   ...
    foreach ($configuration["sources"] as $source_configuration) {
      ...
      $source_value = $source->getValue($slot_prop_type) ?? [];
      $this->moduleHandler->alter('component_built', $source_value, $source_configuration);
  }

So, instead of hook_component_built_alter (component_built), we can propose

  • hook_component_slot_source_alter (component_slot_source)
  • hook_sdc_slot_source_alter (sdc_slot_source)
  • hook_ui_patterns_slot_source_alter (ui_patterns_slot_source)
  • hook_slot_source_alter (slot_source) if the previous ones are too long
pdureau’s picture

Discussed with Mikael. We are not altering the source but the source value:

  • hook_component_slot_value_alter (component_slot_value)
  • hook_sdc_slot_value_alter (sdc_slot_value)
  • hook_ui_patterns_slot_value_alter (ui_patterns_slot_value)
  • hook_slot_value_alter (slot_value) if the previous ones are too long

But I still prefer the "slot_source" one ;)

pdureau’s picture

Thinking aloud: Is it limited to slot sources ? Why not opening this alter to prop sources?

  • hook_component_source_value_alter (component_source_value)
  • hook_sdc_source_value_alter (sdc_source_value)
  • hook_ui_patterns_source_value_alter (ui_patterns_source_value)
  • hook_source_value_alter (source_value) if the previous ones are too long
just_like_good_vibes’s picture

we voted for ui_patterns_source_value, let the magic happens now

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » Unassigned
Status: Needs work » Fixed

just_like_good_vibes’s picture

Status: Fixed » Closed (fixed)

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