From 7bf7ff1edb1bba72b5f7040e183f17e8cc31bb53 Mon Sep 17 00:00:00 2001
From: just_like_good_vibes <mickael@meulle.com>
Date: Mon, 10 Mar 2025 15:57:53 +0100
Subject: [PATCH] updated

---
 src/Element/ComponentElementBuilder.php |  4 ++--
 ui_patterns.api.php                     | 10 +++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/Element/ComponentElementBuilder.php b/src/Element/ComponentElementBuilder.php
index 2b2902a2..d890b359 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 17504cf6..97384c7e 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';
+    }
+  }
 }
-- 
GitLab