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
This commit is contained in:
Florian Thoma 2022-08-31 10:33:05 +10:00 committed by GitHub
parent f9a19e7429
commit 1711c0c88e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -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;
}
/**

View File

@ -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)
{
}
}