class InheritedPermissions implements PermissionChecker, MemberCacheFlusher (View source)

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

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::class); $list = SiteTree::get();

Parameters

array ...$args

Return Value

Injectable

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

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

Construct new permissions object

Parameters

string $baseClass

Base class

CacheInterface $cache

__destruct()

Commits the cache

flushMemberCache(array $memberIDs = null)

Clear the cache for this instance only

Parameters

array $memberIDs

$this setDefaultPermissions(DefaultPermissionChecker $callback)

Parameters

DefaultPermissionChecker $callback

Return Value

$this

$this setGlobalEditPermissions(array $permissions)

Global permissions required to edit

Parameters

array $permissions

Return Value

$this

array getGlobalEditPermissions()

Return Value

array

DefaultPermissionChecker|null getDefaultPermissions()

Get root permissions handler, or null if no handler

Return Value

DefaultPermissionChecker|null

string getBaseClass()

Get base class

Return Value

string

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

Force pre-calculation of a list of permissions for optimisation

Parameters

string $permission
array $ids

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

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

Parameters

array $ids
Member $member
bool $useCached

Return Value

mixed

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

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

Parameters

int $id
Member $member

Return Value

bool

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

Parameters

int $id
Member $member

Return Value

bool

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

Parameters

int $id
Member $member

Return Value

bool

$this clearCache()

Return Value

$this