From 1711c0c88eeaf24c4170a2ab511398e719c57f89 Mon Sep 17 00:00:00 2001 From: Florian Thoma Date: Wed, 31 Aug 2022 10:33:05 +1000 Subject: [PATCH] API Move updateRelativeLink hook after concatination (#2770) * move updateRelativeLink hook after concatination to make it actually updatable * keep existing parameters the same * revert to link parameter be first * update updateRelativeLink method signature in SiteTreeExtension * don't pass old parameters by reference --- code/Model/SiteTree.php | 8 +++++--- code/Model/SiteTreeExtension.php | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 8fe1c0ef..961b9b37 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -688,15 +688,17 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi $base = $this->URLSegment; } - $this->extend('updateRelativeLink', $base, $action); - // Legacy support: If $action === true, retain URLSegment for homepages, // but don't append any action if ($action === true) { $action = null; } - return Controller::join_links($base, '/', $action); + $link = Controller::join_links($base, '/', $action); + + $this->extend('updateRelativeLink', $link, $base, $action); + + return $link; } /** diff --git a/code/Model/SiteTreeExtension.php b/code/Model/SiteTreeExtension.php index 8813c61d..dd1cfab2 100644 --- a/code/Model/SiteTreeExtension.php +++ b/code/Model/SiteTreeExtension.php @@ -75,13 +75,15 @@ abstract class SiteTreeExtension extends DataExtension * before {@link SiteTree::RelativeLink()} calls {@link Controller::join_links()} * on the $base and $action * - * @param string &$base The URL of this page relative to siteroot, not including + * @param string &$link The URL of this page relative to siteroot including * the action - * @param string|boolean &$action The action or subpage called on this page. + * @param string $base The URL of this page relative to siteroot, not including + * the action + * @param string|boolean $action The action or subpage called on this page. * (Legacy support) If this is true, then do not reduce the 'home' urlsegment * to an empty link */ - public function updateRelativeLink(&$base, &$action) + public function updateRelativeLink(&$link, $base, $action) { } }