diff --git a/src/Extensions/ElementalAreaUsedOnTableExtension.php b/src/Extensions/ElementalAreaUsedOnTableExtension.php index 0fd8ff33..3d828407 100644 --- a/src/Extensions/ElementalAreaUsedOnTableExtension.php +++ b/src/Extensions/ElementalAreaUsedOnTableExtension.php @@ -20,7 +20,7 @@ class ElementalAreaUsedOnTableExtension extends DataExtension * * @var array $excludedClasses */ - public function updateUsageExcludedClasses(array &$excludedClasses) + protected function updateUsageExcludedClasses(array &$excludedClasses) { $excludedClasses[] = ElementalArea::class; } @@ -31,7 +31,7 @@ public function updateUsageExcludedClasses(array &$excludedClasses) * @param bool $excludeDataObject * @param DataObject $dataObject|null */ - public function updateUsageDataObject(?DataObject &$dataObject) + protected function updateUsageDataObject(?DataObject &$dataObject) { if (!($dataObject instanceof BaseElement)) { return; @@ -51,7 +51,7 @@ public function updateUsageDataObject(?DataObject &$dataObject) * @param array $ancestorDataObjects * @param DataObject $dataObject */ - public function updateUsageAncestorDataObjects(array &$ancestorDataObjects, DataObject $dataObject) + protected function updateUsageAncestorDataObjects(array &$ancestorDataObjects, DataObject $dataObject) { if (!($dataObject instanceof BaseElement)) { return; diff --git a/src/Extensions/ElementalAreasExtension.php b/src/Extensions/ElementalAreasExtension.php index 565e2618..09562b5f 100644 --- a/src/Extensions/ElementalAreasExtension.php +++ b/src/Extensions/ElementalAreasExtension.php @@ -175,7 +175,7 @@ public function getElementalRelations() * * @param FieldList */ - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { if (!$this->supportsElemental()) { return; diff --git a/src/Extensions/ElementalCMSMainExtension.php b/src/Extensions/ElementalCMSMainExtension.php index 530b8135..c4bdc1f6 100644 --- a/src/Extensions/ElementalCMSMainExtension.php +++ b/src/Extensions/ElementalCMSMainExtension.php @@ -18,7 +18,7 @@ class ElementalCMSMainExtension extends Extension * * @param Form $form */ - public function updateSearchForm(Form $form) + protected function updateSearchForm(Form $form) { /** @var DropdownField $filterField */ $filterField = $form->Fields()->fieldByName('Search__FilterClass'); diff --git a/src/Extensions/ElementalPageExtension.php b/src/Extensions/ElementalPageExtension.php index e775f508..c63fa4dd 100644 --- a/src/Extensions/ElementalPageExtension.php +++ b/src/Extensions/ElementalPageExtension.php @@ -103,7 +103,7 @@ public function getContentFromElementsForCmsSearch(): string /** * @see SiteTree::getAnchorsOnPage() */ - public function updateAnchorsOnPage(array &$anchors): void + protected function updateAnchorsOnPage(array &$anchors): void { if (!($this->owner instanceof SiteTree)) { return; diff --git a/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php b/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php index 1da3c610..975fb75b 100644 --- a/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php +++ b/src/Extensions/GridFieldAddNewMultiClassHandlerExtension.php @@ -15,7 +15,7 @@ class GridFieldAddNewMultiClassHandlerExtension extends Extension /** * @param Form $form */ - public function updateItemEditForm(Form $form) + protected function updateItemEditForm(Form $form) { // NOTE: this extension is applied to new item edit form only diff --git a/src/Extensions/GridFieldDetailFormItemRequestExtension.php b/src/Extensions/GridFieldDetailFormItemRequestExtension.php index 2e562f63..b2e8264b 100644 --- a/src/Extensions/GridFieldDetailFormItemRequestExtension.php +++ b/src/Extensions/GridFieldDetailFormItemRequestExtension.php @@ -12,7 +12,7 @@ */ class GridFieldDetailFormItemRequestExtension extends Extension { - public function updateBreadcrumbs($crumbs) + protected function updateBreadcrumbs($crumbs) { $record = $this->owner->getRecord(); diff --git a/src/TopPage/DataExtension.php b/src/TopPage/DataExtension.php index a2d0d602..b70d216c 100644 --- a/src/TopPage/DataExtension.php +++ b/src/TopPage/DataExtension.php @@ -64,7 +64,7 @@ public function onAfterWrite(): void /** * Extension point in @see DataObject::duplicate() */ - public function onBeforeDuplicate(): void + protected function onBeforeDuplicate(): void { $this->clearTopPage(); } @@ -72,7 +72,7 @@ public function onBeforeDuplicate(): void /** * Extension point in @see DataObject::duplicate() */ - public function onAfterDuplicate(): void + protected function onAfterDuplicate(): void { $this->updateTopPage(); } @@ -198,7 +198,7 @@ public function withFixedTopPage(int $topPageID, callable $callback) } } - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { $fields->removeByName('TopPageID'); } diff --git a/src/TopPage/FluentExtension.php b/src/TopPage/FluentExtension.php index d81e86ae..fa802875 100644 --- a/src/TopPage/FluentExtension.php +++ b/src/TopPage/FluentExtension.php @@ -29,7 +29,7 @@ class FluentExtension extends DataExtension 'TopPageLocale' => 'Varchar', ]; - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { $fields->removeByName('TopPageID'); $fields->removeByName('TopPageLocale'); diff --git a/src/TopPage/SiteTreeExtension.php b/src/TopPage/SiteTreeExtension.php index 320576d6..58789bf0 100644 --- a/src/TopPage/SiteTreeExtension.php +++ b/src/TopPage/SiteTreeExtension.php @@ -48,7 +48,7 @@ public function onAfterWrite(): void * * @param SiteTree $original */ - public function onBeforeDuplicate(SiteTree $original): void + protected function onBeforeDuplicate(SiteTree $original): void { $this->initDuplication($original); } @@ -60,7 +60,7 @@ public function onBeforeDuplicate(SiteTree $original): void * @param bool $doWrite * @throws ValidationException */ - public function onAfterDuplicate(SiteTree $original, $doWrite): void + protected function onAfterDuplicate(SiteTree $original, $doWrite): void { $this->processDuplication($original, (bool) $doWrite); } diff --git a/tests/Extensions/ElementalCMSMainExtensionTest.php b/tests/Extensions/ElementalCMSMainExtensionTest.php index 464007d3..f5a022c2 100644 --- a/tests/Extensions/ElementalCMSMainExtensionTest.php +++ b/tests/Extensions/ElementalCMSMainExtensionTest.php @@ -7,6 +7,7 @@ use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; +use \ReflectionMethod; class ElementalCMSMainExtensionTest extends SapphireTest { @@ -19,7 +20,10 @@ public function testRemovesDefaultEmptyStringFromClassFilter() $fields = new FieldList($field); $form = new Form(null, null, $fields, new FieldList()); - $extension->updateSearchForm($form); + // Call extension method ElementalCMSMainExtension::updateSearchForm($form) which is protected + $method = new ReflectionMethod(ElementalCMSMainExtension::class, 'updateSearchForm'); + $method->setAccessible(true); + $method->invoke($extension, $form); $this->assertEmpty($field->getEmptyString(), 'Empty string should be empty'); $this->assertFalse($field->getHasEmptyDefault(), 'Empty string should not have an empty default');