Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC Update extension hook examples to be protected #519

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions en/02_Developer_Guides/00_Model/05_Extending_DataObjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion en/02_Developer_Guides/03_Forms/01_Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion en/02_Developer_Guides/04_Configuration/01_SiteConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down
4 changes: 2 additions & 2 deletions en/02_Developer_Guides/05_Extending/01_Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion en/02_Developer_Guides/09_Security/00_Member.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion en/02_Developer_Guides/14_Files/01_File_Management.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion en/02_Developer_Guides/14_Files/03_File_Security.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions en/02_Developer_Guides/14_Files/07_File_Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ 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;
}

// 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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class BookmarkedPageExtension extends DataExtension
'IsBookmarked' => 'Boolean',
];

public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab(
'Root.Main',
Expand Down
Loading