Skip to content

Commit

Permalink
Merge pull request #1749 from creative-commoners/pulls/3/protect-hooks
Browse files Browse the repository at this point in the history
API Set extension hook implementation visibility to protected
  • Loading branch information
GuySartorelli authored May 21, 2024
2 parents a7d3099 + 2c1bb7e commit 728887f
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion code/AdminErrorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AdminErrorExtension extends Extension
/**
* Used by {@see RequestHandler::httpError}
*/
public function onBeforeHTTPError($statusCode, HTTPRequest $request, $errorMessage = null)
protected function onBeforeHTTPError($statusCode, HTTPRequest $request, $errorMessage = null)
{
$controller = $this->getAdminController();
if (!$controller || Director::is_ajax($request) || $errorMessage === null) {
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/GridFieldDetailFormPreviewExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class GridFieldDetailFormPreviewExtension extends Extension
{
public function updateItemEditForm(Form $form): void
protected function updateItemEditForm(Form $form): void
{
$record = $this->owner->getRecord();
// See LeftAndMain::getEditForm()
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/GridFieldPrintButtonExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class GridFieldPrintButtonExtension extends Extension
{
public function updatePrintData($data)
protected function updatePrintData($data)
{
Requirements::css('silverstripe/admin:client/dist/styles/GridField_print.css');
}
Expand Down
2 changes: 1 addition & 1 deletion code/Forms/UsedOnTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function usage(HTTPRequest $request)
// Legacy extension hook kept for backwards compatibility
// Use 'updateUsageExcludedClasses' extension hook instead which prevents database from being queried
//
// Example: public function updateUsage(ArrayList &$usage, DataObject &$record)
// Example: protected function updateUsage(ArrayList &$usage, DataObject &$record)
// $dataObjects = $usage->exclude('ClassName', MyDataObject::class);
$this->extend('updateUsage', $usage, $record);
}
Expand Down
4 changes: 2 additions & 2 deletions code/LeftAndMainExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public function init()
{
}

public function accessedCMS()
protected function accessedCMS()
{
}

public function augmentNewSiteTreeItem(&$item)
protected function augmentNewSiteTreeItem(&$item)
{
}
}
2 changes: 1 addition & 1 deletion code/ModelAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public function getExportFields()
* Archived flag is set to false. That would be best done as an extension, for example:
*
* <code>
* public function updateList(\SilverStripe\ORM\DataList $list)
* protected function updateList(\SilverStripe\ORM\DataList $list)
* {
* return $list->filter('Archived', false);
* }
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/src/Extension/MemberEmailLinkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class MemberEmailLinkExtension extends Extension implements TestOnly
{
public function updateGridField(GridField $gridField)
protected function updateGridField(GridField $gridField)
{
if (is_a($this->getOwner()->getModelClass(), Member::class, true)) {
$columns = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
Expand Down
4 changes: 2 additions & 2 deletions tests/php/ModelAdminTest/ModelAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
class ModelAdminExtension extends Extension implements TestOnly
{

public function updateGridField(GridField &$field)
protected function updateGridField(GridField &$field)
{
$this->getOwner()->calls[__FUNCTION__]++;
$field->setAttribute('ModelAdminExtension', 'called');
}

public function updateGridFieldConfig(GridFieldConfig &$config)
protected function updateGridFieldConfig(GridFieldConfig &$config)
{
$this->getOwner()->calls[__FUNCTION__]++;
$config->removeComponentsByType(GridFieldExportButton::class);
Expand Down
4 changes: 2 additions & 2 deletions tests/php/UsedOnTableTest/ExtTest_Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
class ExtTest_Extension extends Extension implements TestOnly
{

public function updateUsageExcludedClasses(array &$excludedClasses)
protected function updateUsageExcludedClasses(array &$excludedClasses)
{
$excludedClasses[] = ExtTest_Middle::class;
}

public function updateUsageAncestorDataObjects(array &$ancestorDataObjects, DataObject $dataObject)
protected function updateUsageAncestorDataObjects(array &$ancestorDataObjects, DataObject $dataObject)
{
if (!($dataObject instanceof ExtTest_Outer)) {
return;
Expand Down

0 comments on commit 728887f

Please sign in to comment.