Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 22 additions & 0 deletions localgov_services.post_update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @file
* Post update functions for LocalGov Services.
*/

use Drupal\pathauto\Entity\PathautoPattern;
use Drupal\pathauto\PathautoPatternInterface;

/**
* Update pathauto patterns to avoid inclusion of subdirectory, language, etc.
*/
function localgov_services_post_update_pathauto_parent(): void {
$alias = PathautoPattern::load('localgov_services_hierarchy');
if ($alias instanceof PathautoPatternInterface &&
$alias->getPattern() == '[node:localgov_services_parent:entity:url:relative]/[node:title]'
) {
$alias->setPattern('[node:localgov_services_parent:entity:url:path]/[node:title]');
$alias->save();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @file
* Post update functions for LocalGov Services Status.
*/

use Drupal\pathauto\Entity\PathautoPattern;
use Drupal\pathauto\PathautoPatternInterface;

/**
* Update pathauto patterns to avoid inclusion of subdirectory, language, etc.
*/
function localgov_services_status_post_update_pathauto_parent(): void {
$alias = PathautoPattern::load('localgov_service_status');
if ($alias instanceof PathautoPatternInterface &&
$alias->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();
}
}