Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #72

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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