API Set extension hook implementation visibility to protected

This commit is contained in:
Steve Boyd 2024-05-21 09:51:51 +12:00
parent 5ccd361426
commit 3e70cfed1e
20 changed files with 30 additions and 27 deletions

View File

@ -63,7 +63,7 @@ abstract class DataExtension extends Extension
*
* See {@link DataObject::onBeforeWrite()} for context.
*/
public function onBeforeWrite()
protected function onBeforeWrite()
{
}
@ -72,7 +72,7 @@ abstract class DataExtension extends Extension
*
* See {@link DataObject::onAfterWrite()} for context.
*/
public function onAfterWrite()
protected function onAfterWrite()
{
}
@ -81,7 +81,7 @@ abstract class DataExtension extends Extension
*
* See {@link DataObject::onBeforeDelete()} for context.
*/
public function onBeforeDelete()
protected function onBeforeDelete()
{
}
@ -90,7 +90,7 @@ abstract class DataExtension extends Extension
*
* See {@link DataObject::onAfterDelete()} for context.
*/
public function onAfterDelete()
protected function onAfterDelete()
{
}

View File

@ -532,7 +532,7 @@ class Group extends DataObject
return $validator;
}
public function onBeforeWrite()
protected function onBeforeWrite()
{
parent::onBeforeWrite();
@ -547,7 +547,7 @@ class Group extends DataObject
$this->dedupeCode();
}
public function onBeforeDelete()
protected function onBeforeDelete()
{
parent::onBeforeDelete();

View File

@ -733,7 +733,7 @@ class Member extends DataObject
/**
* Event handler called before writing to the database.
*/
public function onBeforeWrite()
protected function onBeforeWrite()
{
// Remove any line-break or space characters accidentally added during a copy-paste operation
if ($this->Email) {
@ -818,7 +818,7 @@ class Member extends DataObject
parent::onBeforeWrite();
}
public function onAfterWrite()
protected function onAfterWrite()
{
parent::onAfterWrite();
@ -829,7 +829,7 @@ class Member extends DataObject
}
}
public function onAfterDelete()
protected function onAfterDelete()
{
parent::onAfterDelete();

View File

@ -636,7 +636,7 @@ class Permission extends DataObject implements TemplateGlobalProvider, Resettabl
}
}
public function onBeforeWrite()
protected function onBeforeWrite()
{
parent::onBeforeWrite();

View File

@ -69,7 +69,7 @@ class PermissionRole extends DataObject
return $fields;
}
public function onAfterDelete()
protected function onAfterDelete()
{
parent::onAfterDelete();

View File

@ -25,7 +25,7 @@ class ControllerExtension extends Extension implements TestOnly
/**
* Called whenever there is an HTTP error
*/
public function onBeforeHTTPError()
protected function onBeforeHTTPError()
{
self::$called_error = true;
}

View File

@ -38,7 +38,7 @@ class ControllerExtension extends Extension
* @param string $name
* @param array $context
*/
public function updateFormActions(FieldList &$actions, Controller $controller, $name, $context = [])
protected function updateFormActions(FieldList &$actions, Controller $controller, $name, $context = [])
{
// Add publish button if record is versioned
if (empty($context['Record'])) {
@ -59,7 +59,7 @@ class ControllerExtension extends Extension
* @param string $name
* @param array $context
*/
public function updateFormFields(FieldList &$fields, Controller $controller, $name, $context = [])
protected function updateFormFields(FieldList &$fields, Controller $controller, $name, $context = [])
{
// Add preview link
if (empty($context['Record'])) {

View File

@ -12,7 +12,7 @@ class FieldValidationExtension extends Extension implements TestOnly
protected bool $triggerTestValidationError = false;
public function updateValidationResult(bool &$result, Validator $validator)
protected function updateValidationResult(bool &$result, Validator $validator)
{
if ($this->excludeFromValidation) {
$result = true;

View File

@ -8,7 +8,7 @@ use SilverStripe\Dev\TestOnly;
class TestExtension extends Extension implements TestOnly
{
public function updateAttributes(&$attrs)
protected function updateAttributes(&$attrs)
{
$attrs['extended'] = true;
}

View File

@ -13,7 +13,7 @@ class ArticleExtension extends DataExtension implements TestOnly
'ExtendedField' => 'Varchar'
];
public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab(
'Root.Main',

View File

@ -9,7 +9,7 @@ use SilverStripe\Forms\Tests\GridField\GridFieldTest\StadiumExtension;
class StadiumExtension extends DataExtension implements TestOnly
{
public function updateSearchableFields(&$fields)
protected function updateSearchableFields(&$fields)
{
$fields['Type']['filter'] = new FulltextFilter();
}

View File

@ -17,7 +17,7 @@ class CMSFieldsBaseExtension extends DataExtension implements TestOnly
'ExtendedFieldRemove' => 'Varchar(255)'
];
public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.Test', new TextField('ExtendedFieldRemove'));
$fields->addFieldToTab('Root.Test', new TextField('ExtendedFieldKeep'));

View File

@ -24,7 +24,7 @@ class Team_Extension extends DataExtension implements TestOnly
return "extended dynamic field";
}
public function augmentHydrateFields()
protected function augmentHydrateFields()
{
return [
'CustomHydratedField' => true,

View File

@ -7,7 +7,7 @@ use SilverStripe\Dev\TestOnly;
class ExtraKeysExtension extends Extension implements TestOnly
{
public function cacheKeyComponent(): string
protected function cacheKeyComponent(): string
{
return 'extra-key';
}

View File

@ -34,6 +34,7 @@ use SilverStripe\Security\RememberLoginHash;
use SilverStripe\Security\Security;
use SilverStripe\Security\Tests\MemberTest\FieldsExtension;
use SilverStripe\SessionManager\Models\LoginSession;
use ReflectionMethod;
class MemberTest extends FunctionalTest
{
@ -1605,7 +1606,9 @@ class MemberTest extends FunctionalTest
$this->assertFalse($fail, 'Missing FirstName');
$ext = new MemberTest\ValidatorExtension();
$ext->updateValidator($validator);
$method = new ReflectionMethod(MemberTest\ValidatorExtension::class, 'updateValidator');
$method->setAccessible(true);
$method->invokeArgs($ext, [$validator]);
$pass = $validator->php(
[

View File

@ -10,7 +10,7 @@ use SilverStripe\ORM\DataExtension;
*/
class AlwaysFailExtension extends DataExtension implements TestOnly
{
public function updatePHP($data, $form)
protected function updatePHP($data, $form)
{
return false;
}

View File

@ -11,7 +11,7 @@ use SilverStripe\ORM\ValidationResult;
*/
class ExtendedChangePasswordExtension extends DataExtension implements TestOnly
{
public function onBeforeChangePassword($newPassword, $valid)
protected function onBeforeChangePassword($newPassword, $valid)
{
$valid->addError('Extension failed to handle Mary changing her password');
}

View File

@ -9,7 +9,7 @@ use SilverStripe\ORM\DataExtension;
class FieldsExtension extends DataExtension implements TestOnly
{
public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.Main', new TextField('TestMemberField', 'Test'));
}

View File

@ -10,7 +10,7 @@ use SilverStripe\ORM\DataExtension;
*/
class SurnameMustMatchFirstNameExtension extends DataExtension implements TestOnly
{
public function updatePHP($data, $form)
protected function updatePHP($data, $form)
{
return $data['FirstName'] == $data['Surname'];
}

View File

@ -8,7 +8,7 @@ use SilverStripe\ORM\DataExtension;
class ValidatorExtension extends DataExtension implements TestOnly
{
public function updateValidator(&$validator)
protected function updateValidator($validator)
{
$validator->addRequiredField('Surname');
$validator->removeRequiredField('FirstName');