Skip to content

Commit

Permalink
API Set extension hook implementation visibility to protected
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Aug 19, 2024
1 parent ad675e2 commit e884b12
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion code/Controllers/LeftAndMainBatchActionsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class LeftAndMainBatchActionsExtension extends Extension
{
public function updateBatchActionsForm(&$form)
protected function updateBatchActionsForm(&$form)
{
$cmsMain = singleton(CMSMain::class);
$form->Fields()->insertAfter('Action', $cmsMain->BatchActionParameters());
Expand Down
10 changes: 5 additions & 5 deletions code/Model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ public function InSection($sectionName)
* @param SiteTree $original
* @param bool $doWrite
*/
public function onBeforeDuplicate($original, $doWrite)
protected function onBeforeDuplicate($original, $doWrite)
{
$this->Sort = 0;
}
Expand Down Expand Up @@ -1756,7 +1756,7 @@ public function syncLinkTracking()
$this->extend('augmentSyncLinkTracking');
}

public function onBeforeDelete()
protected function onBeforeDelete()
{
parent::onBeforeDelete();

Expand All @@ -1768,7 +1768,7 @@ public function onBeforeDelete()
}
}

public function onAfterDelete()
protected function onAfterDelete()
{
$this->updateDependentPages();
parent::onAfterDelete();
Expand Down Expand Up @@ -2625,7 +2625,7 @@ public function getCMSActions()
return $actions;
}

public function onAfterPublish()
protected function onAfterPublish()
{
// Force live sort order to match stage sort order
$sql = sprintf(
Expand All @@ -2642,7 +2642,7 @@ public function onAfterPublish()
/**
* Update draft dependant pages
*/
public function onAfterRevertToLive()
protected function onAfterRevertToLive()
{
// Use an alias to get the updates made by $this->publish
/** @var SiteTree $stageSelf */
Expand Down
8 changes: 4 additions & 4 deletions code/Model/SiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class SiteTreeExtension extends DataExtension
*
* @param SiteTree &$original The current Live SiteTree record prior to publish
*/
public function onBeforePublish(&$original)
protected function onBeforePublish(&$original)
{
}

Expand All @@ -28,22 +28,22 @@ public function onBeforePublish(&$original)
*
* @param SiteTree &$original The current Live SiteTree record prior to publish
*/
public function onAfterPublish(&$original)
protected function onAfterPublish(&$original)
{
}

/**
* Hook called before the page's {@link Versioned::doUnpublish()} action is completed
*/
public function onBeforeUnpublish()
protected function onBeforeUnpublish()
{
}


/**
* Hook called after the page's {@link SiteTree::doUnpublish()} action is completed
*/
public function onAfterUnpublish()
protected function onAfterUnpublish()
{
}

Expand Down
8 changes: 4 additions & 4 deletions code/Model/SiteTreeLinkTracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function setParser(SiteTreeLinkTracking_Parser $parser = null)
return $this;
}

public function onBeforeWrite()
protected function onBeforeWrite()
{
// Trigger link tracking (unless this would also be triggered by FileLinkTracking)
if (!$this->owner->hasExtension(FileLinkTracking::class)) {
Expand All @@ -107,7 +107,7 @@ public function syncLinkTracking()
/**
* Find HTMLText fields on {@link owner} to scrape for links that need tracking
*/
public function augmentSyncLinkTracking()
protected function augmentSyncLinkTracking()
{
// If owner is versioned, skip tracking on live
if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) {
Expand Down Expand Up @@ -143,7 +143,7 @@ public function augmentSyncLinkTracking()
$this->owner->LinkTracking()->setByIDList($linkedPages);
}

public function onAfterDelete()
protected function onAfterDelete()
{
// If owner is versioned, skip tracking on live
if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) {
Expand Down Expand Up @@ -215,7 +215,7 @@ protected function toggleElementClass(DOMElement $domReference, $class, $toggle)
}
}

public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
if (!$this->owner->config()->get('show_sitetree_link_tracking')) {
$fields->removeByName('LinkTracking');
Expand Down
2 changes: 1 addition & 1 deletion code/Model/VirtualPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function getCMSFields()
return parent::getCMSFields();
}

public function onBeforeWrite()
protected function onBeforeWrite()
{
$this->refreshFromCopied();
parent::onBeforeWrite();
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/src/AdditionalAnchorPageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class AdditionalAnchorPageExtension extends Extension
{
public function updateAnchorsOnPage(array &$anchors): void
protected function updateAnchorsOnPage(array &$anchors): void
{
$anchors[] = 'dataobject-anchor';
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Model/RedirectorPageTest_RedirectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class RedirectorPageTest_RedirectExtension extends Extension implements TestOnly
{
public function onBeforeInit()
protected function onBeforeInit()
{
$this->owner->redirect('/foo');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Model/SiteTreeBacklinksTest_DOD.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly
'ExtraContent' => 'HTMLText',
];

public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab("Root.Content", new HTMLEditorField("ExtraContent"));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Model/SiteTreeLinkTracking_Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SiteTreeLinkTracking_Extension extends DataExtension implements TestOnly
{
public function updateAnchorsOnPage(&$anchors)
protected function updateAnchorsOnPage(&$anchors)
{
array_push(
$anchors,
Expand Down
6 changes: 4 additions & 2 deletions tests/php/Model/SiteTreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2153,8 +2153,10 @@ public function testOnAfterRevertToLive()
$obj->Content = '<a href="[sitetree_link,id='. $id .']">Link to Page</a>';
$obj->write();

//Test that method doesn't throw exception
// Test that method doesn't throw exception
$this->expectNotToPerformAssertions();
$page->onAfterRevertToLive();
$method = new ReflectionMethod(SiteTree::class, 'onAfterRevertToLive');
$method->setAccessible(true);
$method->invoke($page);
}
}
2 changes: 1 addition & 1 deletion tests/php/Model/SiteTreeTest_Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SiteTreeTest_Extension extends DataExtension implements TestOnly
{
public function augmentValidURLSegment()
protected function augmentValidURLSegment()
{
return false;
}
Expand Down

0 comments on commit e884b12

Please sign in to comment.