Skip to content

Commit

Permalink
ENH Add generic types (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jan 18, 2024
1 parent 2734649 commit 2e8f342
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/MemberReportExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
use SilverStripe\Security\Group;
use SilverStripe\Security\Permission;
use SilverStripe\Security\LoginAttempt;
use SilverStripe\Security\Member;
use SilverStripe\Subsites\Model\Subsite;

/**
* Extends the {@see Member} class with additional descriptions for elements.
* See {@see UserSecurityReport} for usage.
*
* @extends DataExtension<Member>
*/
class MemberReportExtension extends DataExtension
{
Expand Down Expand Up @@ -63,7 +66,6 @@ public function getGroupsDescription()
// Collect the group names
$groupNames = array();
foreach ($groups as $group) {
/** @var Group $group */
$groupNames[] = html_entity_decode($group->getTreeTitle() ?? '');
}
// return a csv string of the group names, sans-markup
Expand Down
9 changes: 6 additions & 3 deletions src/Subsites/SubsiteMemberReportExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
namespace SilverStripe\SecurityReport\Subsites;

use SilverStripe\ORM\DataExtension;
use SilverStripe\Security\Member;
use SilverStripe\Subsites\Model\Subsite;

/**
* Adds 'SubsiteDescription' for to show which subsites this Member has edit access to
*
* @author Damian Mooyman <[email protected]>
*
* @extends DataExtension<Member>
*/
class SubsiteMemberReportExtension extends DataExtension
{

/**
* Set cast of additional field
*
Expand All @@ -22,15 +25,15 @@ class SubsiteMemberReportExtension extends DataExtension
private static $casting = array(
'SubsiteDescription' => 'Text'
);

/**
* Default permission to filter for
*
* @var string
* @config
*/
private static $subsite_description_permission = 'SITETREE_EDIT_ALL';

/**
* Describes the subsites this user has SITETREE_EDIT_ALL access to
*
Expand Down
7 changes: 3 additions & 4 deletions src/UserSecurityReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class UserSecurityReport extends Report
'GroupsDescription' => 'Groups',
'PermissionsDescription' => 'Permissions',
);

protected $dataClass = Member::class;

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ public function sortColumns()
/**
* Get the source records for the report gridfield
*
* @return DataList
* @return DataList<Member>
*/
public function sourceRecords()
{
Expand All @@ -133,11 +133,10 @@ public function canView($member = null)
* Return a field, such as a {@link GridField} that is
* used to show and manipulate data relating to this report.
*
* @return FormField subclass
* @return GridField subclass
*/
public function getReportField()
{
/** @var GridField $gridField */
$gridField = parent::getReportField();
$gridField->setModelClass(self::class);
$gridConfig = $gridField->getConfig();
Expand Down
2 changes: 0 additions & 2 deletions tests/php/UserSecurityReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class UserSecurityReportTest extends SapphireTest

/**
* Utility method for all tests to use.
*
* @return ArrayList
*/
protected function setUp(): void
{
Expand Down

0 comments on commit 2e8f342

Please sign in to comment.