From 9b43ff0c71584251420a3da7997571f343b9e36a Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 22 May 2024 10:42:31 +1200 Subject: [PATCH] DOC Update extension hook examples to be protected --- en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md | 4 ++-- .../00_Model/How_Tos/Dynamic_Default_Fields.md | 2 +- en/02_Developer_Guides/03_Forms/01_Validation.md | 2 +- .../03_Forms/Field_types/03_HTMLEditorField.md | 2 +- en/02_Developer_Guides/04_Configuration/01_SiteConfig.md | 2 +- en/02_Developer_Guides/05_Extending/01_Extensions.md | 4 ++-- .../05_Extending/How_Tos/03_Track_member_logins.md | 4 ++-- en/02_Developer_Guides/09_Security/00_Member.md | 2 +- en/02_Developer_Guides/14_Files/01_File_Management.md | 2 +- en/02_Developer_Guides/14_Files/03_File_Security.md | 2 +- en/02_Developer_Guides/14_Files/07_File_Usage.md | 6 +++--- .../15_Customising_the_Admin_Interface/01_ModelAdmin.md | 2 +- .../How_Tos/Customise_CMS_Pages_List.md | 2 +- .../How_Tos/Extend_CMS_Interface.md | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md b/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md index 6546da580..537d4af8d 100644 --- a/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md +++ b/en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md @@ -37,7 +37,7 @@ class Player extends DataObject 'Team' => Team::class, ]; - public function onBeforeWrite() + protected function onBeforeWrite() { // Use $this->isInDb() to check if the record is being written to the database for the first time if (!$this->isInDb() && $this->Team()->exists()) { @@ -73,7 +73,7 @@ class Player extends DataObject { // ... - public function onBeforeDelete() + protected function onBeforeDelete() { /* Do some cleanup here relevant to your project before deleting the actual database record */ diff --git a/en/02_Developer_Guides/00_Model/How_Tos/Dynamic_Default_Fields.md b/en/02_Developer_Guides/00_Model/How_Tos/Dynamic_Default_Fields.md index 089acc416..17931ba15 100644 --- a/en/02_Developer_Guides/00_Model/How_Tos/Dynamic_Default_Fields.md +++ b/en/02_Developer_Guides/00_Model/How_Tos/Dynamic_Default_Fields.md @@ -74,7 +74,7 @@ class Dog extends DataObject > { > // ... > -> public function onBeforeWrite() +> protected function onBeforeWrite() > { > // Only do this if the record hasn't been written to the database yet (optional) > if (!$this->isInDb()) { diff --git a/en/02_Developer_Guides/03_Forms/01_Validation.md b/en/02_Developer_Guides/03_Forms/01_Validation.md index f9f972e0b..f1d997b5e 100644 --- a/en/02_Developer_Guides/03_Forms/01_Validation.md +++ b/en/02_Developer_Guides/03_Forms/01_Validation.md @@ -87,7 +87,7 @@ use SilverStripe\Forms\Validator; class FormFieldValidationExtension extends Extension { - public function updateValidationResult(bool &$result, Validator $validator) + protected function updateValidationResult(bool &$result, Validator $validator) { if (str_ends_with($this->owner->Value(), '@example.com')) { $validator->validationError($this->owner->Name(), 'Please provide a valid email address'); diff --git a/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md b/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md index 8ac526c33..0c91aa9e7 100644 --- a/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md +++ b/en/02_Developer_Guides/03_Forms/Field_types/03_HTMLEditorField.md @@ -387,7 +387,7 @@ use SilverStripe\Forms\Form; class RemoteFileFormFactoryExtension extends Extension { - public function updateForm(Form $form) + protected function updateForm(Form $form) { $form->Fields()->removeByName('CaptionText'); } diff --git a/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md b/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md index 79e16040f..300c0714a 100644 --- a/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md +++ b/en/02_Developer_Guides/04_Configuration/01_SiteConfig.md @@ -51,7 +51,7 @@ class CustomSiteConfig extends Extension 'FooterContent' => 'HTMLText', ]; - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { $fields->addFieldToTab('Root.Main', HTMLEditorField::create('FooterContent', 'Footer Content')); } diff --git a/en/02_Developer_Guides/05_Extending/01_Extensions.md b/en/02_Developer_Guides/05_Extending/01_Extensions.md index f269e06d2..ba54289da 100644 --- a/en/02_Developer_Guides/05_Extending/01_Extensions.md +++ b/en/02_Developer_Guides/05_Extending/01_Extensions.md @@ -256,7 +256,7 @@ use SilverStripe\ORM\DataExtension; class MyMemberExtension extends DataExtension { - public function updateValidator($validator) + protected function updateValidator($validator) { // we want to make date of birth required for each member $validator->addRequiredField('DateOfBirth'); @@ -288,7 +288,7 @@ class MyMemberExtension extends DataExtension 'Image' => 'Image', ]; - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { $fields->push(TextField::create('Position')); $fields->push($upload = UploadField::create('Image', 'Profile Image')); diff --git a/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md b/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md index abe2826d5..b36e5c9f5 100644 --- a/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md +++ b/en/02_Developer_Guides/05_Extending/How_Tos/03_Track_member_logins.md @@ -43,12 +43,12 @@ class MyMemberExtension extends DataExtension /** * This extension hook is called when a member's session is restored from "remember me" cookies */ - public function memberAutoLoggedIn() + protected function memberAutoLoggedIn() { $this->logVisit(); } - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { $fields->addFieldsToTab('Root.Main', [ ReadonlyField::create('LastVisited', 'Last visited'), diff --git a/en/02_Developer_Guides/09_Security/00_Member.md b/en/02_Developer_Guides/09_Security/00_Member.md index e90f9adf0..e1f4e56da 100644 --- a/en/02_Developer_Guides/09_Security/00_Member.md +++ b/en/02_Developer_Guides/09_Security/00_Member.md @@ -128,7 +128,7 @@ class MyMemberExtension extends DataExtension /** * Modify the field set to be displayed in the CMS detail pop-up */ - public function updateCMSFields(FieldList $currentFields) + protected function updateCMSFields(FieldList $currentFields) { // Only show the additional fields on an appropriate kind of use if (Permission::checkMember($this->owner->ID, 'VIEW_FORUM')) { diff --git a/en/02_Developer_Guides/14_Files/01_File_Management.md b/en/02_Developer_Guides/14_Files/01_File_Management.md index 7b7a2f241..50dba024d 100644 --- a/en/02_Developer_Guides/14_Files/01_File_Management.md +++ b/en/02_Developer_Guides/14_Files/01_File_Management.md @@ -177,7 +177,7 @@ use SilverStripe\Forms\TextareaField; class MyFormFactoryExtension extends Extension { - public function updateFormFields(FieldList $fields) + protected function updateFormFields(FieldList $fields) { $fields->insertAfter( 'Title', diff --git a/en/02_Developer_Guides/14_Files/03_File_Security.md b/en/02_Developer_Guides/14_Files/03_File_Security.md index e55491f66..d75727bd1 100644 --- a/en/02_Developer_Guides/14_Files/03_File_Security.md +++ b/en/02_Developer_Guides/14_Files/03_File_Security.md @@ -381,7 +381,7 @@ class AssetStoreExtension extends Extension * to say if we are serving a public or protected file. It may contain a * `parsedFileID` detailing how FlysystemAssetStore has resolved $asset. */ - public function updateResponse( + protected function updateResponse( HTTPResponse $response, string $asset, array $context diff --git a/en/02_Developer_Guides/14_Files/07_File_Usage.md b/en/02_Developer_Guides/14_Files/07_File_Usage.md index 8051a4a8b..304ab0125 100644 --- a/en/02_Developer_Guides/14_Files/07_File_Usage.md +++ b/en/02_Developer_Guides/14_Files/07_File_Usage.md @@ -34,7 +34,7 @@ class UsedOnTableExtension extends Extension { // This extension hook will prevent type(s) of DataObjects from showing on the Used on tab in the Files section // This will prevent a MyDataObjectToExclude::get() call from being executed - public function updateUsageExcludedClasses(array &$excludedClasses) + protected function updateUsageExcludedClasses(array &$excludedClasses) { $excludedClasses[] = MyDataObjectToExclude::class; } @@ -42,7 +42,7 @@ class UsedOnTableExtension extends Extension // This extension hook will alter a DataObject after it was fetched via MyDataObject::get() // This allows a greater level of flexibility to exclude or modify individual DataObjects // It is less efficient to use this extension hook that `updateUsageExcludedClasses()` above - public function updateUsageDataObject(?DataObject &$dataObject) + protected function updateUsageDataObject(?DataObject &$dataObject) { if (!($dataObject instanceof MyDataObject)) { return; @@ -62,7 +62,7 @@ class UsedOnTableExtension extends Extension // - The DataObject may not have a `CMSEditLink()` implementation, though the ancestor DataObject does. // The CMS frontend will fallback to using the Ancestor `CMSEditLink()` for when a user clicks on a row on // the used on table - public function updateUsageAncestorDataObjects(array &$ancestorDataObjects, DataObject $dataObject) + protected function updateUsageAncestorDataObjects(array &$ancestorDataObjects, DataObject $dataObject) { if (!($dataObject instanceof MyDataObjectThatIWantToLink)) { return; diff --git a/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md b/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md index 1c1c80393..f9e5b2230 100644 --- a/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md +++ b/en/02_Developer_Guides/15_Customising_the_Admin_Interface/01_ModelAdmin.md @@ -473,7 +473,7 @@ use SilverStripe\Forms\GridField\GridFieldFilterHeader; */ class ModelAdminExtension extends Extension { - public function updateGridFieldConfig(GridFieldConfig &$config) + protected function updateGridFieldConfig(GridFieldConfig &$config) { $config->addComponent(GridFieldFilterHeader::create()); } diff --git a/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md b/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md index 6ec9b2b93..81d590d84 100644 --- a/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md +++ b/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_CMS_Pages_List.md @@ -64,7 +64,7 @@ use SilverStripe\Core\Extension; class NewsPageHolderCMSMainExtension extends Extension { - public function updateListView($listView) + protected function updateListView($listView) { $parentId = $listView->getController()->getRequest()->requestVar('ParentID'); $parent = ($parentId) ? Page::get()->byId($parentId) : Page::create(); diff --git a/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md b/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md index 70f2b094a..0e69b4a5f 100644 --- a/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md +++ b/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md @@ -105,7 +105,7 @@ class BookmarkedPageExtension extends DataExtension 'IsBookmarked' => 'Boolean', ]; - public function updateCMSFields(FieldList $fields) + protected function updateCMSFields(FieldList $fields) { $fields->addFieldToTab( 'Root.Main',