Skip to content

Commit

Permalink
API Standardise extension hooks (#2989)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Aug 27, 2024
1 parent 2d158e9 commit 48c64e3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion code/Controllers/LeftAndMainPageIconsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions code/Model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ public function MetaComponents()
];
}

$this->extend('MetaComponents', $tags);
$this->extend('updateMetaComponents', $tags);

return $tags;
}
Expand Down Expand Up @@ -1598,7 +1598,7 @@ public function MetaTags($includeTitle = true)
$tagString .= $this->obj('ExtraMeta')->forTemplate();
}

$this->extend('MetaTags', $tagString);
$this->extend('updateMetaTags', $tagString);

return $tagString;
}
Expand Down
6 changes: 3 additions & 3 deletions code/Model/SiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

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

Expand All @@ -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)
{
}
}
10 changes: 5 additions & 5 deletions tests/php/Model/SiteTreeTest_AdminDeniedExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Model/SiteTreeTest_ExtensionA.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Model/SiteTreeTest_ExtensionB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 48c64e3

Please sign in to comment.