diff --git a/src/Element/ComponentElementBuilder.php b/src/Element/ComponentElementBuilder.php index 2b2902a23570c92702649f9530363dbe1b7a49a6..d890b3599b5123ebcde07d5bba5639816d3a6f7f 100644 --- a/src/Element/ComponentElementBuilder.php +++ b/src/Element/ComponentElementBuilder.php @@ -91,7 +91,7 @@ class ComponentElementBuilder implements TrustedCallbackInterface { $build = $source->alterComponent($build); $prop_type = $definition['ui_patterns']['type_definition']; $data = $source->getValue($prop_type); - $this->moduleHandler->alter('ui_patterns_source_value', $data, $source); + $this->moduleHandler->alter('ui_patterns_source_value', $data, $source, $configuration); if (empty($data) && $prop_type->getPluginId() !== 'attributes') { // For JSON Schema validator, empty value is not the same as missing // value, and we want to prevent some of the prop types rules to be @@ -186,7 +186,7 @@ class ComponentElementBuilder implements TrustedCallbackInterface { } $build = $source->alterComponent($build); $source_value = $source->getValue($slot_prop_type) ?? []; - $this->moduleHandler->alter('ui_patterns_source_value', $source_value, $source); + $this->moduleHandler->alter('ui_patterns_source_value', $source_value, $source, $source_configuration); if (Element::isRenderArray($source_value)) { $build["#slots"][$slot_id][] = $this->isSingletonRenderArray($source_value) ? array_values($source_value)[0] : $source_value; } diff --git a/ui_patterns.api.php b/ui_patterns.api.php index 17504cf6beef4679ba2176d7de6c537dde9f595b..97384c7ef136302467643703831fdca2f79f5190 100644 --- a/ui_patterns.api.php +++ b/ui_patterns.api.php @@ -24,8 +24,16 @@ function hook_component_info_alter(array &$definitions) { * Value produced by the source. * @param \Drupal\ui_patterns\SourceInterface $source * The source object which has produced the value. + * @param array $source_configuration + * The full raw configuration used to build the source. * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ -function hook_ui_patterns_source_value_alter(mixed &$value, \Drupal\ui_patterns\SourceInterface $source) : void { +function hook_ui_patterns_source_value_alter(mixed &$value, \Drupal\ui_patterns\SourceInterface $source, array &$source_configuration) : void { + $type_definition = $source->getPropDefinition()['ui_patterns']['type_definition']; + if ($type_definition instanceof \Drupal\ui_patterns\Plugin\UiPatterns\PropType\SlotPropType) { + if (is_array($value)) { + $value['#cache']['tags'][] = 'custom_cache_tag'; + } + } }