From 0ad092be9102c00cb1b8160b808772e058ee4e33 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen.haas@lakedrops.com> Date: Fri, 29 Nov 2024 11:00:38 +0100 Subject: [PATCH] Add patch to group module --- patches/d10-3.json | 3 +++ patches/d10-4.json | 3 +++ patches/d10/3416324.diff | 26 ++++++++++++++++++++++++++ patches/d11.json | 3 +++ 4 files changed, 35 insertions(+) create mode 100644 patches/d10/3416324.diff diff --git a/patches/d10-3.json b/patches/d10-3.json index aa39589..edfc3eb 100644 --- a/patches/d10-3.json +++ b/patches/d10-3.json @@ -124,6 +124,9 @@ "drupal/glossify": { "#3360633 HTML entities": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3360633.diff" }, + "drupal/group": { + "#3416324 Related entity tokens": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3416324.diff" + }, "drupal/http_client_manager": { "#3385117 Code generator": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3385117.diff" }, diff --git a/patches/d10-4.json b/patches/d10-4.json index 8955800..a80498f 100644 --- a/patches/d10-4.json +++ b/patches/d10-4.json @@ -124,6 +124,9 @@ "drupal/glossify": { "#3360633 HTML entities": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3360633.diff" }, + "drupal/group": { + "#3416324 Related entity tokens": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3416324.diff" + }, "drupal/http_client_manager": { "#3385117 Code generator": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3385117.diff" }, diff --git a/patches/d10/3416324.diff b/patches/d10/3416324.diff new file mode 100644 index 0000000..e7c7eda --- /dev/null +++ b/patches/d10/3416324.diff @@ -0,0 +1,26 @@ +diff --git a/group.tokens.inc b/group.tokens.inc +index 686b2756bd7d49bbd89b4ea7a3633473c933bc7b..1f904fdcb11ee3c11fa628c4304eeb2a44ecdca4 100644 +--- a/group.tokens.inc ++++ b/group.tokens.inc +@@ -272,5 +272,21 @@ function group_tokens($type, $tokens, array $data, array $options, BubbleableMet + if ($changed_tokens = $token_service->findWithPrefix($tokens, 'changed')) { + $replacements += $token_service->generate('date', $changed_tokens, ['date' => $group_relationship->getChangedTime()], $options, $bubbleable_metadata); + } ++ ++ // Provide access to tokens of the related entity. ++ if (str_starts_with($name, 'entity:')) { ++ $entity = $group_relationship->getEntity(); ++ $entityTypeId = $entity->getEntityTypeId(); ++ $bubbleable_metadata->addCacheableDependency($entity); ++ $parts = explode(':', $name); ++ $parts[0] = $entityTypeId; ++ $realTokens = [ ++ implode(':', $parts) => $original, ++ ]; ++ if ($entity_tokens = $token_service->findWithPrefix($realTokens, $entityTypeId)) { ++ $replacements += $token_service->generate($entityTypeId, $entity_tokens, [$entityTypeId => $entity], $options, $bubbleable_metadata); ++ } ++ } ++ + } + } diff --git a/patches/d11.json b/patches/d11.json index ec032ca..a3083da 100644 --- a/patches/d11.json +++ b/patches/d11.json @@ -118,6 +118,9 @@ "drupal/gin_toolbar": { "#3319445 Permission check": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3319445.diff" }, + "drupal/group": { + "#3416324 Related entity tokens": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3416324.diff" + }, "drupal/glossify": { "#3360633 HTML entities": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3360633.diff" }, -- GitLab