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
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
"type": "drupal-module",
"homepage": "https://github.com/localgovdrupal/localgov_subsites_extras",
"license": "GPL-2.0-or-later",
"minimum-stability": "dev"
"minimum-stability": "dev",
"require-dev": {
"drupal/localgov_base": "^2.0",
"drupal/localgov_guides": "^2.1",
"drupal/localgov_subsites": "^2.0",
"drupal/localgov_services": "^2.0",
"drupal/localgov_step_by_step": "^2.1"
}
}
4 changes: 3 additions & 1 deletion localgov_subsites_extras.module
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ function localgov_subsites_extras_pathauto_alias_alter(&$alias, array &$context)
return;
}

$subsite_home_path_alias = $subsite_home->toUrl()->toString();
// Get the subsite homepage path alias, not using toUrl() as that could
// cause duplicate sub-directories in the alias.
$subsite_home_path_alias = $subsite_home->path->alias;
$has_no_subsite_home_path_alias = $subsite_home_path_alias === "/node/{$subsite_home->id()}";
if ($has_no_subsite_home_path_alias) {
return;
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Functional/PathAliasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class PathAliasTest extends BrowserTestBase {
* Checks that the Subsite homepage path alias is prepended to child page path
* aliases.
*/
public function testPathAlias() {
public function testPathAlias(): void {

$subsiteHome = $this->getNodeByTitle(self::SUBSITE_HOMEPAGE_TITLE);
$subsiteChild = $this->getNodeByTitle(self::SUBSITE_CHILDPAGE_TITLE);
self::assertStringStartsWith($subsiteHome->path->alias, $subsiteChild->path->alias);
self::assertStringStartsWith($subsiteHome->toUrl()->toString(), $subsiteChild->toUrl()->toString());
}

/**
Expand Down