From 276b2461e788838578c4217901016a3a9a96a7ed Mon Sep 17 00:00:00 2001 From: Dale Frey Date: Mon, 28 Oct 2024 17:12:25 -0400 Subject: [PATCH] USAGOV-1996: fixing lint errors --- web/modules/custom/usagov_wizard/usagov_wizard.module | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/modules/custom/usagov_wizard/usagov_wizard.module b/web/modules/custom/usagov_wizard/usagov_wizard.module index a958abb3c2..c916ef754a 100644 --- a/web/modules/custom/usagov_wizard/usagov_wizard.module +++ b/web/modules/custom/usagov_wizard/usagov_wizard.module @@ -229,16 +229,22 @@ function usagov_wizard_preprocess_html(&$variables) { $variables['wizardTitleUrl'] = $wizard_title_url; } else { + // Lookup the top-most taxonomy parent $topParent = $taxonomy_term; while (!empty($topParent->parent)) { $thisParent = Term::load($topParent->parent->target_id); - if (empty($thisParent)) break; + if (empty($thisParent)) { + break; + } $topParent = $thisParent; } + $variables['wizardTitle'] = $topParent->getName(); $variables['wizardTitleUrl'] = \Drupal::service('path_alias.manager')->getAliasByPath('/taxonomy/term/' . $topParent->id()); + + // Make sure Spanish-paths are prefixed with /es/ $langCode = $taxonomy_term->language()->getId(); - if ($langCode == 'es') { + if ($langCode == 'es' && !str_starts_with($variables['wizardTitleUrl'], '/es/')) { $variables['wizardTitleUrl'] = '/' . $langCode . $variables['wizardTitleUrl']; } }