mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Merge pull request #2942 from creative-commoners/pulls/6/protect-hooks
API Set extension hook implementation visibility to protected
This commit is contained in:
commit
e69dc90096
@ -11,7 +11,7 @@ use SilverStripe\Core\Extension;
|
|||||||
*/
|
*/
|
||||||
class LeftAndMainBatchActionsExtension extends Extension
|
class LeftAndMainBatchActionsExtension extends Extension
|
||||||
{
|
{
|
||||||
public function updateBatchActionsForm(&$form)
|
protected function updateBatchActionsForm(&$form)
|
||||||
{
|
{
|
||||||
$cmsMain = singleton(CMSMain::class);
|
$cmsMain = singleton(CMSMain::class);
|
||||||
$form->Fields()->insertAfter('Action', $cmsMain->BatchActionParameters());
|
$form->Fields()->insertAfter('Action', $cmsMain->BatchActionParameters());
|
||||||
|
@ -872,7 +872,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
* @param SiteTree $original
|
* @param SiteTree $original
|
||||||
* @param bool $doWrite
|
* @param bool $doWrite
|
||||||
*/
|
*/
|
||||||
public function onBeforeDuplicate($original, $doWrite)
|
protected function onBeforeDuplicate($original, $doWrite)
|
||||||
{
|
{
|
||||||
$this->Sort = 0;
|
$this->Sort = 0;
|
||||||
}
|
}
|
||||||
@ -1755,7 +1755,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
$this->extend('augmentSyncLinkTracking');
|
$this->extend('augmentSyncLinkTracking');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBeforeDelete()
|
protected function onBeforeDelete()
|
||||||
{
|
{
|
||||||
parent::onBeforeDelete();
|
parent::onBeforeDelete();
|
||||||
|
|
||||||
@ -1767,7 +1767,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAfterDelete()
|
protected function onAfterDelete()
|
||||||
{
|
{
|
||||||
$this->updateDependentPages();
|
$this->updateDependentPages();
|
||||||
parent::onAfterDelete();
|
parent::onAfterDelete();
|
||||||
@ -2621,7 +2621,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAfterPublish()
|
protected function onAfterPublish()
|
||||||
{
|
{
|
||||||
// Force live sort order to match stage sort order
|
// Force live sort order to match stage sort order
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
@ -2638,7 +2638,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
/**
|
/**
|
||||||
* Update draft dependant pages
|
* Update draft dependant pages
|
||||||
*/
|
*/
|
||||||
public function onAfterRevertToLive()
|
protected function onAfterRevertToLive()
|
||||||
{
|
{
|
||||||
// Use an alias to get the updates made by $this->publish
|
// Use an alias to get the updates made by $this->publish
|
||||||
/** @var SiteTree $stageSelf */
|
/** @var SiteTree $stageSelf */
|
||||||
|
@ -19,7 +19,7 @@ abstract class SiteTreeExtension extends DataExtension
|
|||||||
*
|
*
|
||||||
* @param SiteTree &$original The current Live SiteTree record prior to publish
|
* @param SiteTree &$original The current Live SiteTree record prior to publish
|
||||||
*/
|
*/
|
||||||
public function onBeforePublish(&$original)
|
protected function onBeforePublish(&$original)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,14 +28,14 @@ abstract class SiteTreeExtension extends DataExtension
|
|||||||
*
|
*
|
||||||
* @param SiteTree &$original The current Live SiteTree record prior to publish
|
* @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
|
* Hook called before the page's {@link Versioned::doUnpublish()} action is completed
|
||||||
*/
|
*/
|
||||||
public function onBeforeUnpublish()
|
protected function onBeforeUnpublish()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ abstract class SiteTreeExtension extends DataExtension
|
|||||||
/**
|
/**
|
||||||
* Hook called after the page's {@link SiteTree::doUnpublish()} action is completed
|
* Hook called after the page's {@link SiteTree::doUnpublish()} action is completed
|
||||||
*/
|
*/
|
||||||
public function onAfterUnpublish()
|
protected function onAfterUnpublish()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class SiteTreeLinkTracking extends DataExtension
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBeforeWrite()
|
protected function onBeforeWrite()
|
||||||
{
|
{
|
||||||
// Trigger link tracking (unless this would also be triggered by FileLinkTracking)
|
// Trigger link tracking (unless this would also be triggered by FileLinkTracking)
|
||||||
if (!$this->owner->hasExtension(FileLinkTracking::class)) {
|
if (!$this->owner->hasExtension(FileLinkTracking::class)) {
|
||||||
@ -107,7 +107,7 @@ class SiteTreeLinkTracking extends DataExtension
|
|||||||
/**
|
/**
|
||||||
* Find HTMLText fields on {@link owner} to scrape for links that need tracking
|
* 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 owner is versioned, skip tracking on live
|
||||||
if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) {
|
if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) {
|
||||||
@ -143,7 +143,7 @@ class SiteTreeLinkTracking extends DataExtension
|
|||||||
$this->owner->LinkTracking()->setByIDList($linkedPages);
|
$this->owner->LinkTracking()->setByIDList($linkedPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onAfterDelete()
|
protected function onAfterDelete()
|
||||||
{
|
{
|
||||||
// If owner is versioned, skip tracking on live
|
// If owner is versioned, skip tracking on live
|
||||||
if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) {
|
if (Versioned::get_stage() == Versioned::LIVE && $this->owner->hasExtension(Versioned::class)) {
|
||||||
@ -215,7 +215,7 @@ class SiteTreeLinkTracking extends DataExtension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCMSFields(FieldList $fields)
|
protected function updateCMSFields(FieldList $fields)
|
||||||
{
|
{
|
||||||
if (!$this->owner->config()->get('show_sitetree_link_tracking')) {
|
if (!$this->owner->config()->get('show_sitetree_link_tracking')) {
|
||||||
$fields->removeByName('LinkTracking');
|
$fields->removeByName('LinkTracking');
|
||||||
|
@ -285,7 +285,7 @@ class VirtualPage extends Page
|
|||||||
return parent::getCMSFields();
|
return parent::getCMSFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBeforeWrite()
|
protected function onBeforeWrite()
|
||||||
{
|
{
|
||||||
$this->refreshFromCopied();
|
$this->refreshFromCopied();
|
||||||
parent::onBeforeWrite();
|
parent::onBeforeWrite();
|
||||||
|
@ -6,7 +6,7 @@ use SilverStripe\Core\Extension;
|
|||||||
|
|
||||||
class AdditionalAnchorPageExtension extends Extension
|
class AdditionalAnchorPageExtension extends Extension
|
||||||
{
|
{
|
||||||
public function updateAnchorsOnPage(array &$anchors): void
|
protected function updateAnchorsOnPage(array &$anchors): void
|
||||||
{
|
{
|
||||||
$anchors[] = 'dataobject-anchor';
|
$anchors[] = 'dataobject-anchor';
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use SilverStripe\Dev\TestOnly;
|
|||||||
|
|
||||||
class RedirectorPageTest_RedirectExtension extends Extension implements TestOnly
|
class RedirectorPageTest_RedirectExtension extends Extension implements TestOnly
|
||||||
{
|
{
|
||||||
public function onBeforeInit()
|
protected function onBeforeInit()
|
||||||
{
|
{
|
||||||
$this->owner->redirect('/foo');
|
$this->owner->redirect('/foo');
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly
|
|||||||
'ExtraContent' => 'HTMLText',
|
'ExtraContent' => 'HTMLText',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function updateCMSFields(FieldList $fields)
|
protected function updateCMSFields(FieldList $fields)
|
||||||
{
|
{
|
||||||
$fields->addFieldToTab("Root.Content", new HTMLEditorField("ExtraContent"));
|
$fields->addFieldToTab("Root.Content", new HTMLEditorField("ExtraContent"));
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use SilverStripe\ORM\DataExtension;
|
|||||||
|
|
||||||
class SiteTreeLinkTracking_Extension extends DataExtension implements TestOnly
|
class SiteTreeLinkTracking_Extension extends DataExtension implements TestOnly
|
||||||
{
|
{
|
||||||
public function updateAnchorsOnPage(&$anchors)
|
protected function updateAnchorsOnPage(&$anchors)
|
||||||
{
|
{
|
||||||
array_push(
|
array_push(
|
||||||
$anchors,
|
$anchors,
|
||||||
|
@ -2153,8 +2153,10 @@ class SiteTreeTest extends SapphireTest
|
|||||||
$obj->Content = '<a href="[sitetree_link,id='. $id .']">Link to Page</a>';
|
$obj->Content = '<a href="[sitetree_link,id='. $id .']">Link to Page</a>';
|
||||||
$obj->write();
|
$obj->write();
|
||||||
|
|
||||||
//Test that method doesn't throw exception
|
// Test that method doesn't throw exception
|
||||||
$this->expectNotToPerformAssertions();
|
$this->expectNotToPerformAssertions();
|
||||||
$page->onAfterRevertToLive();
|
$method = new ReflectionMethod(SiteTree::class, 'onAfterRevertToLive');
|
||||||
|
$method->setAccessible(true);
|
||||||
|
$method->invoke($page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use SilverStripe\ORM\DataExtension;
|
|||||||
|
|
||||||
class SiteTreeTest_Extension extends DataExtension implements TestOnly
|
class SiteTreeTest_Extension extends DataExtension implements TestOnly
|
||||||
{
|
{
|
||||||
public function augmentValidURLSegment()
|
protected function augmentValidURLSegment()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user