From 96700ef0109b683006e8913d43fc22ada1a6c6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Kalij=C3=A4rvi?= Date: Wed, 23 Oct 2024 09:41:52 +0300 Subject: [PATCH] UHF-8650: Fixed the privacy policy URL for the journey planner. --- .../custom/hdbt_subtheme/hdbt_subtheme.theme | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme b/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme index 78c7b831..bd53d5aa 100644 --- a/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme +++ b/public/themes/custom/hdbt_subtheme/hdbt_subtheme.theme @@ -98,11 +98,22 @@ function hdbt_subtheme_preprocess_node(array &$variables) { * Implements hook_preprocess_HOOK(). */ function hdbt_subtheme_preprocess_paragraph__journey_planner(array &$variables): void { + // Attach the embedded content cookie compliance library. $variables['#attached']['library'][] = 'hdbt/embedded-content-cookie-compliance'; - $langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); - $variables['privacy_policy_url'] = helfi_eu_cookie_compliance_get_privacy_policy_url(); + // Set the necessary variables for the journey planner. $variables['media_service_url'] = 'https://reittiopas.hsl.fi'; - $variables['media_url'] = 'https://reittiopas.hsl.fi/haku?bikeOnly=1&lang=' . $langcode; + $variables['media_url'] = 'https://reittiopas.hsl.fi/haku?bikeOnly=1&lang=' . $variables['language']->getId(); $variables['media_id'] = 'journey-map'; + + // Set the privacy policy URL. + if (Drupal::moduleHandler()->moduleExists('hdbt_cookie_banner')) { + /** @var \Drupal\hdbt_cookie_banner\Services\CookieSettings $cookie_settings */ + $cookie_settings = \Drupal::service('hdbt_cookie_banner.cookie_settings'); + $variables['privacy_policy_url'] = $cookie_settings->getCookieSettingsPageUrl(); + } + // @todo UHF-10862 Remove once the HDBT cookie banner module is in use. + elseif (Drupal::moduleHandler()->moduleExists('helfi_eu_cookie_compliance')) { + $variables['privacy_policy_url'] = helfi_eu_cookie_compliance_get_privacy_policy_url(); + } }