Skip to content

Commit

Permalink
API Don't publicly expose extension hook methods
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 27, 2022
1 parent fc78763 commit 55fda28
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/Dev/Validation/DatabaseAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DatabaseAdminExtension extends Extension
* @param bool $testMode
* @throws ReflectionException
*/
public function onAfterBuild(bool $quiet, bool $populate, bool $testMode): void
protected function onAfterBuild(bool $quiet, bool $populate, bool $testMode): void
{
$service = RelationValidationService::singleton();

Expand Down
44 changes: 22 additions & 22 deletions src/ORM/DataExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function unload_extra_statics($class, $extension)
* @param ValidationResult $validationResult Local validation result
* @throws ValidationException
*/
public function validate(ValidationResult $validationResult)
protected function validate(ValidationResult $validationResult)
{
}

Expand All @@ -42,7 +42,7 @@ public function validate(ValidationResult $validationResult)
* @param SQLSelect $query Query to augment.
* @param DataQuery $dataQuery Container DataQuery for this SQLSelect
*/
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
protected function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{
}

Expand All @@ -52,7 +52,7 @@ public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
* When duplicating a table's structure, remember to duplicate the create options
* as well. See {@link Versioned->augmentDatabase} for an example.
*/
public function augmentDatabase()
protected function augmentDatabase()
{
}

Expand All @@ -61,7 +61,7 @@ public function augmentDatabase()
*
* @param array $manipulation Array of operations to augment.
*/
public function augmentWrite(&$manipulation)
protected function augmentWrite(&$manipulation)
{
}

Expand All @@ -70,7 +70,7 @@ public function augmentWrite(&$manipulation)
*
* See {@link DataObject::onBeforeWrite()} for context.
*/
public function onBeforeWrite()
protected function onBeforeWrite()
{
}

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

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

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

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

Expand All @@ -115,7 +115,7 @@ public function requireDefaultRecords()
*
* See {@link DataObject::populateDefaults()} for context.
*/
public function populateDefaults()
protected function populateDefaults()
{
}

Expand All @@ -124,7 +124,7 @@ public function populateDefaults()
*
* See {@link DataObject::onAfterBuild()} for context.
*/
public function onAfterBuild()
protected function onAfterBuild()
{
}

Expand All @@ -138,7 +138,7 @@ public function onAfterBuild()
* @param Member $member
* @return bool|null
*/
public function can($member)
protected function can($member)
{
}

Expand All @@ -152,7 +152,7 @@ public function can($member)
* @param Member $member
* @return bool|null
*/
public function canEdit($member)
protected function canEdit($member)
{
}

Expand All @@ -166,7 +166,7 @@ public function canEdit($member)
* @param Member $member
* @return bool|null
*/
public function canDelete($member)
protected function canDelete($member)
{
}

Expand All @@ -180,7 +180,7 @@ public function canDelete($member)
* @param Member $member
* @return bool|null
*/
public function canCreate($member)
protected function canCreate($member)
{
}

Expand All @@ -195,7 +195,7 @@ public function canCreate($member)
* @return array Returns a map where the keys are db, has_one, etc, and
* the values are additional fields/relations to be defined.
*/
public function extraStatics($class = null, $extension = null)
protected function extraStatics($class = null, $extension = null)
{
return [];
}
Expand All @@ -213,7 +213,7 @@ public function extraStatics($class = null, $extension = null)
*
* @param FieldList $fields FieldList with a contained TabSet
*/
public function updateCMSFields(FieldList $fields)
protected function updateCMSFields(FieldList $fields)
{
}

Expand All @@ -224,7 +224,7 @@ public function updateCMSFields(FieldList $fields)
*
* @param CompositeValidator $compositeValidator
*/
public function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void
protected function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void
{
}

Expand All @@ -236,7 +236,7 @@ public function updateCMSCompositeValidator(CompositeValidator $compositeValidat
*
* @param FieldList $fields FieldList without TabSet nesting
*/
public function updateFrontEndFields(FieldList $fields)
protected function updateFrontEndFields(FieldList $fields)
{
}

Expand All @@ -246,7 +246,7 @@ public function updateFrontEndFields(FieldList $fields)
*
* @param FieldList $actions FieldList
*/
public function updateCMSActions(FieldList $actions)
protected function updateCMSActions(FieldList $actions)
{
}

Expand All @@ -258,7 +258,7 @@ public function updateCMSActions(FieldList $actions)
*
* @param array $fields Array of field names
*/
public function updateSummaryFields(&$fields)
protected function updateSummaryFields(&$fields)
{
$summary_fields = Config::inst()->get(static::class, 'summary_fields');
if ($summary_fields) {
Expand All @@ -281,7 +281,7 @@ public function updateSummaryFields(&$fields)
*
* @param array $labels Array of field labels
*/
public function updateFieldLabels(&$labels)
protected function updateFieldLabels(&$labels)
{
$field_labels = Config::inst()->get(static::class, 'field_labels');
if ($field_labels) {
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Hierarchy/Hierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static function get_extra_config($class, $extension, $args)
*
* @param ValidationResult $validationResult
*/
public function validate(ValidationResult $validationResult)
protected function validate(ValidationResult $validationResult)
{
// The object is new, won't be looping.
/** @var DataObject|Hierarchy $owner */
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Control/RequestHandlingTest/ControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public function extendedMethod()
/**
* Called whenever there is an HTTP error
*/
public function onBeforeHTTPError()
protected function onBeforeHTTPError()
{
self::$called_error = true;
}

/**
* Called whenever there is an 404 error
*/
public function onBeforeHTTPError404()
protected function onBeforeHTTPError404()
{
self::$called_404_error = true;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/ObjectTest/ExtendTest1.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ExtendTest1 extends Extension implements TestOnly
{
public function extendableMethod(&$argument = null)
protected function extendableMethod(&$argument = null)
{
if ($argument) {
$argument = 'modified';
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/ObjectTest/ExtendTest2.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct()
$this->constructorArgs = func_get_args();
}

public function extendableMethod($argument = null)
protected function extendableMethod($argument = null)
{
$args = implode(',', array_filter(func_get_args()));
return "ExtendTest2($args)";
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Core/ObjectTest/ExtendTest3.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct()
$this->constructorArgs = func_get_args();
}

public function extendableMethod($argument = null)
protected function extendableMethod($argument = null)
{
return "ExtendTest3($argument)";
}
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 @@ -35,7 +35,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 @@ -56,7 +56,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/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
6 changes: 3 additions & 3 deletions tests/php/ORM/DataExtensionTest/Extension1.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
class Extension1 extends DataExtension implements TestOnly
{

public function canOne($member = null)
protected function canOne($member = null)
{
return true;
}

public function canTwo($member = null)
protected function canTwo($member = null)
{
return false;
}

public function canThree($member = null)
protected function canThree($member = null)
{
}
}
6 changes: 3 additions & 3 deletions tests/php/ORM/DataExtensionTest/Extension2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
class Extension2 extends DataExtension implements TestOnly
{

public function canOne($member = null)
protected function canOne($member = null)
{
return true;
}

public function canTwo($member = null)
protected function canTwo($member = null)
{
return true;
}

public function canThree($member = null)
protected function canThree($member = null)
{
}
}
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/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 @@ -8,17 +8,17 @@
class EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly
{

public function canView($member = null)
protected function canView($member = null)
{
return true;
}

public function canEdit($member = null)
protected function canEdit($member = null)
{
return true;
}

public function canDelete($member = null)
protected function canDelete($member = null)
{
return false;
}
Expand Down
Loading

0 comments on commit 55fda28

Please sign in to comment.