From 321b74c97c3ad3c66b36f01fa37679c978554ec4 Mon Sep 17 00:00:00 2001 From: ekes Date: Wed, 29 Oct 2025 14:55:26 +0100 Subject: [PATCH 1/3] Fixes prefixes (subdirectory, language) being included in parent path pattern. See https://github.com/localgovdrupal/localgov_services/issues/335#issuecomment-3461396195 --- ...thauto.pattern.localgov_service_status.yml | 2 +- .../localgov_services_status.post_update.php | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 modules/localgov_services_status/localgov_services_status.post_update.php diff --git a/modules/localgov_services_status/config/optional/pathauto.pattern.localgov_service_status.yml b/modules/localgov_services_status/config/optional/pathauto.pattern.localgov_service_status.yml index 8b09ea6..fc624e6 100644 --- a/modules/localgov_services_status/config/optional/pathauto.pattern.localgov_service_status.yml +++ b/modules/localgov_services_status/config/optional/pathauto.pattern.localgov_service_status.yml @@ -6,7 +6,7 @@ dependencies: id: localgov_service_status label: 'Service Status Page' type: 'canonical_entities:node' -pattern: '[node:localgov_services_parent:entity:url:relative]/status/[node:title]' +pattern: '[node:localgov_services_parent:entity:url:path]/status/[node:title]' selection_criteria: fb899c5a-41f3-4482-9b7d-7f203c4290c4: id: 'entity_bundle:node' diff --git a/modules/localgov_services_status/localgov_services_status.post_update.php b/modules/localgov_services_status/localgov_services_status.post_update.php new file mode 100644 index 0000000..0407ad1 --- /dev/null +++ b/modules/localgov_services_status/localgov_services_status.post_update.php @@ -0,0 +1,22 @@ +getPattern() == '[node:localgov_services_parent:entity:url:relative]/status/[node:title]' + ) { + $alias->setPattern('[node:localgov_services_parent:entity:url:path]/status/[node:title]'); + $alias->save(); + } +} From d885a4d4ff2bb3d5773b5a4bbcb0b895cddc35de Mon Sep 17 00:00:00 2001 From: ekes Date: Wed, 29 Oct 2025 15:50:48 +0100 Subject: [PATCH 2/3] Fixes prefixes (subdirectory, language) being included in parent path pattern for other instances. See https://github.com/localgovdrupal/localgov_services/issues/335#issuecomment-3461396195 --- ...to.pattern.localgov_services_hierarchy.yml | 2 +- localgov_services.post_update.php | 22 +++++++++++++++++++ .../localgov_services_navigation.module | 4 ++-- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 localgov_services.post_update.php diff --git a/config/install/pathauto.pattern.localgov_services_hierarchy.yml b/config/install/pathauto.pattern.localgov_services_hierarchy.yml index 1fe2699..9235eff 100644 --- a/config/install/pathauto.pattern.localgov_services_hierarchy.yml +++ b/config/install/pathauto.pattern.localgov_services_hierarchy.yml @@ -6,7 +6,7 @@ dependencies: id: localgov_services_hierarchy label: 'Services Hierarchy' type: 'canonical_entities:node' -pattern: '[node:localgov_services_parent:entity:url:relative]/[node:title]' +pattern: '[node:localgov_services_parent:entity:url:path]/[node:title]' selection_criteria: 9dd1b1bc-3678-4642-8568-86d6d27c3dfd: id: 'entity_bundle:node' diff --git a/localgov_services.post_update.php b/localgov_services.post_update.php new file mode 100644 index 0000000..e4f20e1 --- /dev/null +++ b/localgov_services.post_update.php @@ -0,0 +1,22 @@ +getPattern() == '[node:localgov_services_parent:entity:url:relative]/[node:title]' + ) { + $alias->setPattern('[node:localgov_services_parent:entity:url:path]/[node:title]'); + $alias->save(); + } +} diff --git a/modules/localgov_services_navigation/localgov_services_navigation.module b/modules/localgov_services_navigation/localgov_services_navigation.module index cab41e2..333b8ec 100644 --- a/modules/localgov_services_navigation/localgov_services_navigation.module +++ b/modules/localgov_services_navigation/localgov_services_navigation.module @@ -65,8 +65,8 @@ function localgov_services_navigation_pathauto_pattern_alter(PathautoPattern $pa // it has opt-ed in with the field add the (optional) parent to the path. $entity = reset($context['data']); assert($entity instanceof ContentEntityInterface); - if ($entity->hasField('localgov_services_parent') && strpos($pattern->getPattern(), '[node:localgov_services_parent:entity:url:relative]') === FALSE) { - $pattern->setPattern('[node:localgov_services_parent:entity:url:relative]/' . $pattern->getPattern()); + if ($entity->hasField('localgov_services_parent') && strpos($pattern->getPattern(), '[node:localgov_services_parent:entity:url:path]') === FALSE) { + $pattern->setPattern('[node:localgov_services_parent:entity:url:path]/' . $pattern->getPattern()); } } From c8a486f81b3bc4b6073aa6ba66a8ed69b7c1563b Mon Sep 17 00:00:00 2001 From: ekes Date: Wed, 29 Oct 2025 17:10:57 +0100 Subject: [PATCH 3/3] Coding standards fix. --- localgov_services.post_update.php | 6 +++--- .../localgov_services_status.post_update.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/localgov_services.post_update.php b/localgov_services.post_update.php index e4f20e1..a6a6dfa 100644 --- a/localgov_services.post_update.php +++ b/localgov_services.post_update.php @@ -1,13 +1,13 @@