Skip to content

Commit

Permalink
API Standardise extension hooks (#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Aug 27, 2024
1 parent 4b3bac7 commit 6f78dc5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
9 changes: 4 additions & 5 deletions tests/php/Controller/AssetAdminTest/FileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,28 @@

class FileExtension extends DataExtension implements TestOnly
{
public function canView($member = null)
protected function canView($member = null)
{
if ($this->owner->Name === 'disallowCanView.txt') {
return false;
}
}

public function canEdit($member = null)
protected function canEdit($member = null)
{
if ($this->owner->Name === 'disallowCanEdit.txt') {
return false;
}
}

public function canDelete($member = null)
protected function canDelete($member = null)
{
if ($this->owner->Name === 'disallowCanDelete.txt') {
return false;
}
}


public function canCreate($member = null, $context = [])
protected function canCreate($member = null, $context = [])
{
if (isset($context['Parent']) && $context['Parent']->Name === 'disallowCanAddChildren') {
return false;
Expand Down
8 changes: 4 additions & 4 deletions tests/php/Controller/AssetAdminTest/FolderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@

class FolderExtension extends DataExtension implements TestOnly
{
public function canView($member = null, $context = array())
protected function canView($member = null, $context = array())
{
if ($this->owner->Name === 'disallowCanView') {
return false;
}
}

public function canEdit($member = null, $context = array())
protected function canEdit($member = null, $context = array())
{
if ($this->owner->Name === 'disallowCanEdit') {
return false;
}
}

public function canDelete($member = null, $context = array())
protected function canDelete($member = null, $context = array())
{
if ($this->owner->Name === 'disallowCanDelete') {
return false;
}
}

public function canCreate($member = null, $context = array())
protected function canCreate($member = null, $context = array())
{
if (isset($context['Name']) && $context['Name'] === 'disallowCanCreate') {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Forms/FileFormBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function testEditFileFormWithPermissions()
// Add extension to simulate different permissions
File::add_extension(FileExtension::class);

$this->logInWithPermission('ADMIN');
$this->logInWithPermission('CMS_ACCESS_CampaignAdmin');

/** @var File $file */
$file = $this->objFromFixture(File::class, 'file1');
Expand Down
8 changes: 4 additions & 4 deletions tests/php/Forms/FileFormBuilderTest/FileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ class FileExtension extends DataExtension implements TestOnly
public static $canUnpublish = true;
public static $canEdit = true;

public function canDelete($member)
protected function canDelete($member)
{
return FileExtension::$canDelete;
}

public function canPublish($member = null)
protected function canPublish($member = null)
{
return FileExtension::$canPublish;
}

public function canUnpublish($member = null)
protected function canUnpublish($member = null)
{
return FileExtension::$canUnpublish;
}

public function canEdit($member = null)
protected function canEdit($member = null)
{
return FileExtension::$canEdit;
}
Expand Down

0 comments on commit 6f78dc5

Please sign in to comment.