From c7e9ec89480b78cacf3beab69b78a49e58ff605d Mon Sep 17 00:00:00 2001 From: Philip Frilling <32192-pfrilling@users.noreply.drupalcode.org> Date: Mon, 26 Aug 2024 12:23:00 +0000 Subject: [PATCH] Update the preprocess page to use cache tags/contexts. --- .../{gaa_quick_exit.schema.yml => quick_exit.schema.yml} | 0 quick_exit.module | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) rename config/schema/{gaa_quick_exit.schema.yml => quick_exit.schema.yml} (100%) diff --git a/config/schema/gaa_quick_exit.schema.yml b/config/schema/quick_exit.schema.yml similarity index 100% rename from config/schema/gaa_quick_exit.schema.yml rename to config/schema/quick_exit.schema.yml diff --git a/quick_exit.module b/quick_exit.module index 7b91d8b..c06707a 100644 --- a/quick_exit.module +++ b/quick_exit.module @@ -7,6 +7,8 @@ declare(strict_types=1); +use Drupal\Core\Cache\Cache; + /** * Implements hook_page_attachments_alter(). */ @@ -22,6 +24,8 @@ function quick_exit_page_attachments(array &$attachments): void { * Implements hook_preprocess_page(). */ function quick_exit_preprocess_page(array &$variables): void { - $exit_urls = \Drupal::config('quick_exit.settings')->get('exit_urls'); - $variables['#attached']['drupalSettings']['quick_exit']['exit_urls'] = $exit_urls; + $config = \Drupal::config('quick_exit.settings'); + $variables['#attached']['drupalSettings']['quick_exit']['exit_urls'] = $config->get('exit_urls'); + $variables['page']['#cache']['tags'] = Cache::mergeTags($variables['page']['#cache']['tags'], $config->getCacheTags()); + $variables['page']['#cache']['contexts'] = Cache::mergeContexts($variables['page']['#cache']['contexts'], $config->getCacheContexts()); } -- GitLab