Skip to content

Commit

Permalink
API Set extension hook implementation visibility to protected
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed May 20, 2024
1 parent 5ccd361 commit f6941e0
Show file tree
Hide file tree
Showing 20 changed files with 30 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/ORM/DataExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function augmentWrite(&$manipulation)
*
* See {@link DataObject::onBeforeWrite()} for context.
*/
public function onBeforeWrite()
protected function onBeforeWrite()
{
}

Expand All @@ -72,7 +72,7 @@ public function onBeforeWrite()
*
* See {@link DataObject::onAfterWrite()} for context.
*/
public function onAfterWrite()
protected function onAfterWrite()
{
}

Expand All @@ -81,7 +81,7 @@ public function onAfterWrite()
*
* See {@link DataObject::onBeforeDelete()} for context.
*/
public function onBeforeDelete()
protected function onBeforeDelete()
{
}

Expand All @@ -90,7 +90,7 @@ public function onBeforeDelete()
*
* See {@link DataObject::onAfterDelete()} for context.
*/
public function onAfterDelete()
protected function onAfterDelete()
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Security/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public function getCMSCompositeValidator(): CompositeValidator
return $validator;
}

public function onBeforeWrite()
protected function onBeforeWrite()
{
parent::onBeforeWrite();

Expand All @@ -547,7 +547,7 @@ public function onBeforeWrite()
$this->dedupeCode();
}

public function onBeforeDelete()
protected function onBeforeDelete()
{
parent::onBeforeDelete();

Expand Down
6 changes: 3 additions & 3 deletions src/Security/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public static function actAs($member, $callback)
/**
* 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) {
Expand Down Expand Up @@ -818,7 +818,7 @@ public function onBeforeWrite()
parent::onBeforeWrite();
}

public function onAfterWrite()
protected function onAfterWrite()
{
parent::onAfterWrite();

Expand All @@ -829,7 +829,7 @@ public function onAfterWrite()
}
}

public function onAfterDelete()
protected function onAfterDelete()
{
parent::onAfterDelete();

Expand Down
2 changes: 1 addition & 1 deletion src/Security/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public static function sort_permissions($a, $b)
}
}

public function onBeforeWrite()
protected function onBeforeWrite()
{
parent::onBeforeWrite();

Expand Down
2 changes: 1 addition & 1 deletion src/Security/PermissionRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getCMSFields()
return $fields;
}

public function onAfterDelete()
protected function onAfterDelete()
{
parent::onAfterDelete();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function extendedMethod()
/**
* Called whenever there is an HTTP error
*/
public function onBeforeHTTPError()
protected function onBeforeHTTPError()
{
self::$called_error = true;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Forms/FormFactoryTest/ControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand All @@ -59,7 +59,7 @@ public function updateFormActions(FieldList &$actions, Controller $controller, $
* @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'])) {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Forms/FormFieldTest/FieldValidationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Forms/FormFieldTest/TestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class TestExtension extends Extension implements TestOnly
{

public function updateAttributes(&$attrs)
protected function updateAttributes(&$attrs)
{
$attrs['extended'] = true;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Forms/FormScaffolderTest/ArticleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class StadiumExtension extends DataExtension implements TestOnly
{
public function updateSearchableFields(&$fields)
protected function updateSearchableFields(&$fields)
{
$fields['Type']['filter'] = new FulltextFilter();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/ORM/DataExtensionTest/CMSFieldsBaseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion tests/php/ORM/DataObjectTest/Team_Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getExtendedDynamicField()
return "extended dynamic field";
}

public function augmentHydrateFields()
protected function augmentHydrateFields()
{
return [
'CustomHydratedField' => true,
Expand Down
2 changes: 1 addition & 1 deletion tests/php/ORM/UniqueKey/ExtraKeysExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ExtraKeysExtension extends Extension implements TestOnly
{
public function cacheKeyComponent(): string
protected function cacheKeyComponent(): string
{
return 'extra-key';
}
Expand Down
5 changes: 4 additions & 1 deletion tests/php/Security/MemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use SilverStripe\Security\Security;
use SilverStripe\Security\Tests\MemberTest\FieldsExtension;
use SilverStripe\SessionManager\Models\LoginSession;
use ReflectionMethod;

class MemberTest extends FunctionalTest
{
Expand Down Expand Up @@ -1605,7 +1606,9 @@ public function testCustomMemberValidator()
$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(
[
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Security/MemberTest/AlwaysFailExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class AlwaysFailExtension extends DataExtension implements TestOnly
{
public function updatePHP($data, $form)
protected function updatePHP($data, $form)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
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');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Security/MemberTest/FieldsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class FieldsExtension extends DataExtension implements TestOnly
{
public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab('Root.Main', new TextField('TestMemberField', 'Test'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class SurnameMustMatchFirstNameExtension extends DataExtension implements TestOnly
{
public function updatePHP($data, $form)
protected function updatePHP($data, $form)
{
return $data['FirstName'] == $data['Surname'];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Security/MemberTest/ValidatorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ValidatorExtension extends DataExtension implements TestOnly
{

public function updateValidator(&$validator)
protected function updateValidator(&$validator)
{
$validator->addRequiredField('Surname');
$validator->removeRequiredField('FirstName');
Expand Down

0 comments on commit f6941e0

Please sign in to comment.