From 48c64e310b42d616ebc62e97ff9ea1122a82a3c5 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:39:17 +1200 Subject: [PATCH] API Standardise extension hooks (#2989) --- code/Controllers/LeftAndMainPageIconsExtension.php | 2 +- code/Model/SiteTree.php | 4 ++-- code/Model/SiteTreeExtension.php | 6 +++--- tests/php/Model/SiteTreeTest_AdminDeniedExtension.php | 10 +++++----- tests/php/Model/SiteTreeTest_ExtensionA.php | 4 ++-- tests/php/Model/SiteTreeTest_ExtensionB.php | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/code/Controllers/LeftAndMainPageIconsExtension.php b/code/Controllers/LeftAndMainPageIconsExtension.php index e962322f06..ed0e7e69fd 100644 --- a/code/Controllers/LeftAndMainPageIconsExtension.php +++ b/code/Controllers/LeftAndMainPageIconsExtension.php @@ -26,7 +26,7 @@ class LeftAndMainPageIconsExtension extends Extension implements Flushable * @throws InvalidArgumentException * @throws ReflectionException */ - public function init() + protected function onInit() { Requirements::customCSS($this->generatePageIconsCss(), CMSMain::PAGE_ICONS_ID); } diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 1ab304dfe5..348365e9c1 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -1494,7 +1494,7 @@ public function MetaComponents() ]; } - $this->extend('MetaComponents', $tags); + $this->extend('updateMetaComponents', $tags); return $tags; } @@ -1598,7 +1598,7 @@ public function MetaTags($includeTitle = true) $tagString .= $this->obj('ExtraMeta')->forTemplate(); } - $this->extend('MetaTags', $tagString); + $this->extend('updateMetaTags', $tagString); return $tagString; } diff --git a/code/Model/SiteTreeExtension.php b/code/Model/SiteTreeExtension.php index e2cce8ed0d..f3260e77b0 100644 --- a/code/Model/SiteTreeExtension.php +++ b/code/Model/SiteTreeExtension.php @@ -70,7 +70,7 @@ protected function onAfterUnpublish() * logged in user * @return boolean|null Return false to deny rights, or null to yield to default */ - public function canAddChildren($member) + protected function canAddChildren($member) { } @@ -83,7 +83,7 @@ public function canAddChildren($member) * logged in user * @return boolean|null Return false to deny rights, or null to yield to default */ - public function canPublish($member) + protected function canPublish($member) { } @@ -100,7 +100,7 @@ public function canPublish($member) * (Legacy support) If this is true, then do not reduce the 'home' urlsegment * to an empty link */ - public function updateRelativeLink(&$link, $base, $action) + protected function updateRelativeLink(&$link, $base, $action) { } } diff --git a/tests/php/Model/SiteTreeTest_AdminDeniedExtension.php b/tests/php/Model/SiteTreeTest_AdminDeniedExtension.php index b2ff7d90b9..b73f19a251 100644 --- a/tests/php/Model/SiteTreeTest_AdminDeniedExtension.php +++ b/tests/php/Model/SiteTreeTest_AdminDeniedExtension.php @@ -10,27 +10,27 @@ */ class SiteTreeTest_AdminDeniedExtension extends DataExtension implements TestOnly { - public function canCreate($member) + protected function canCreate($member) { return false; } - public function canEdit($member) + protected function canEdit($member) { return false; } - public function canDelete($member) + protected function canDelete($member) { return false; } - public function canAddChildren() + protected function canAddChildren() { return false; } - public function canView() + protected function canView() { return false; } diff --git a/tests/php/Model/SiteTreeTest_ExtensionA.php b/tests/php/Model/SiteTreeTest_ExtensionA.php index 9d3cd427aa..0e9e0baae6 100644 --- a/tests/php/Model/SiteTreeTest_ExtensionA.php +++ b/tests/php/Model/SiteTreeTest_ExtensionA.php @@ -10,12 +10,12 @@ class SiteTreeTest_ExtensionA extends SiteTreeExtension implements TestOnly { public static $can_publish = true; - public function canPublish($member) + protected function canPublish($member) { return static::$can_publish; } - public function updateLink(&$link, $action = null) + protected function updateLink(&$link, $action = null) { $link = Controller::join_links($link, '?extra=1'); } diff --git a/tests/php/Model/SiteTreeTest_ExtensionB.php b/tests/php/Model/SiteTreeTest_ExtensionB.php index cf42dbbc30..be93b57195 100644 --- a/tests/php/Model/SiteTreeTest_ExtensionB.php +++ b/tests/php/Model/SiteTreeTest_ExtensionB.php @@ -10,12 +10,12 @@ class SiteTreeTest_ExtensionB extends SiteTreeExtension implements TestOnly { public static $can_publish = true; - public function canPublish($member) + protected function canPublish($member) { return static::$can_publish; } - public function updateLink(&$link, $action = null) + protected function updateLink(&$link, $action = null) { $link = Controller::join_links('http://www.updatedhost.com', $link); }