class InheritedPermissions implements PermissionChecker, MemberCacheFlusher

Calculates batch permissions for nested objects for: - canView: Supports 'Anyone' type - canEdit - canDelete: Includes special logic for ensuring parent objects can only be deleted if their children can be deleted also.

Traits

A class that can be instantiated or replaced via DI

Constants

DELETE

Delete permission

VIEW

View permission

EDIT

Edit permission

ANYONE

Anyone canView permission

LOGGED_IN_USERS

Restrict to logged in users

ONLY_THESE_USERS

Restrict to specific groups

INHERIT

Inherit from parent

Methods

static Injectable
create(array $args)

An implementation of the factory method, allows you to create an instance of a class

static Injectable
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

__construct(string $baseClass, CacheInterface $cache = null)

Construct new permissions object

__destruct()

Commits the cache

flushMemberCache(array $memberIDs = null)

Clear the cache for this instance only

$this
$this
setGlobalEditPermissions(array $permissions)

Global permissions required to edit

array
getGlobalEditPermissions()

No description

getDefaultPermissions()

Get root permissions handler, or null if no handler

string
getBaseClass()

Get base class

prePopulatePermissionCache(string $permission = 'edit', array $ids = [])

Force pre-calculation of a list of permissions for optimisation

array
canEditMultiple(array $ids, Member $member = null, bool $useCached = true)

No description

mixed
canViewMultiple(array $ids, Member $member = null, bool $useCached = true)

No description

array
canDeleteMultiple(array $ids, Member $member = null, bool $useCached = true)

No description

bool
canDelete(int $id, Member $member = null)

No description

bool
canEdit(int $id, Member $member = null)

No description

bool
canView(int $id, Member $member = null)

No description

$this
clearCache()

No description

Details

in Injectable at line 26
static Injectable create(array $args)

An implementation of the factory method, allows you to create an instance of a class

This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.

This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();

Parameters

array $args

Return Value

Injectable

in Injectable at line 43
static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class Optional classname to create, if the called class should not be used

Return Value

Injectable The singleton instance

at line 100
__construct(string $baseClass, CacheInterface $cache = null)

Construct new permissions object

Parameters

string $baseClass Base class
CacheInterface $cache

at line 115
__destruct()

Commits the cache

at line 132
flushMemberCache(array $memberIDs = null)

Clear the cache for this instance only

Parameters

array $memberIDs

at line 157
$this setDefaultPermissions(DefaultPermissionChecker $callback)

Parameters

DefaultPermissionChecker $callback

Return Value

$this

at line 169
$this setGlobalEditPermissions(array $permissions)

Global permissions required to edit

Parameters

array $permissions

Return Value

$this

at line 178
array getGlobalEditPermissions()

Return Value

array

at line 188
DefaultPermissionChecker|null getDefaultPermissions()

Get root permissions handler, or null if no handler

Return Value

DefaultPermissionChecker|null

at line 198
string getBaseClass()

Get base class

Return Value

string

at line 209
prePopulatePermissionCache(string $permission = 'edit', array $ids = [])

Force pre-calculation of a list of permissions for optimisation

Parameters

string $permission
array $ids

at line 439
array canEditMultiple(array $ids, Member $member = null, bool $useCached = true)

Parameters

array $ids An array of IDs of the objects to look up
Member $member Member object
bool $useCached Return values from the permission cache if they exist

Return Value

array A map where the IDs are keys and the values are booleans stating whether the given object can be edited

at line 456
mixed canViewMultiple(array $ids, Member $member = null, bool $useCached = true)

Parameters

array $ids
Member $member
bool $useCached

Return Value

mixed

at line 467
array canDeleteMultiple(array $ids, Member $member = null, bool $useCached = true)

Parameters

array $ids An array of IDs of the objects pages to look up
Member $member Member object
bool $useCached Return values from the permission cache if they exist

Return Value

array

at line 541
bool canDelete(int $id, Member $member = null)

Parameters

int $id
Member $member

Return Value

bool

at line 563
bool canEdit(int $id, Member $member = null)

Parameters

int $id
Member $member

Return Value

bool

at line 585
bool canView(int $id, Member $member = null)

Parameters

int $id
Member $member

Return Value

bool

at line 687
$this clearCache()

Return Value

$this