Copied!

PermissionService

PermissionService.php : 11

This service provides methods for resolving permissions.

Methods

publiccanUser()

PermissionResolver.php : 82

Indicates if the current user is allowed to perform an action given by the function on the given objects.

public canUser(string $module, string $function, ValueObject $object[, array<string|int, ValueObject$targets = [] ]) : bool

Example: canUser( 'content', 'edit', $content, [$location] ); This will check edit permission on content given the specific location, if skipped if will check on all locations.

Example2: canUser( 'section', 'assign', $content, [$section] ); Check if user has access to assign $content to $section.

Parameters

Name Type Default value Description
$module string -

The module, aka controller identifier to check permissions on

$function string -

The function, aka the controller action to check permissions on

$object ValueObject -

The object to check if the user has access to

$targets array<string|int, ValueObject> []

An array of location, parent or "assignment" value objects

Return values

bool

Tags
Throws
InvalidArgumentException

If any of the arguments are invalid

Throws
BadStateException

If value of the LimitationValue is unsupported

publicgetCurrentUserReference()

PermissionResolver.php : 25

Get current user reference.

public getCurrentUserReference() : UserReference

Return values

UserReference

publicgetPermissionsCriterion()

PermissionCriterionResolver.php : 32

Get criteria representation for a permission.

public getPermissionsCriterion([string $module = 'content' ][, string $function = 'read' ][, array<string|int, mixed>|null $targets = null ]) : bool|Criterion

Will return a criteria if current user has limited access to the given module/function, however if user has either full or no access then boolean is returned.

Parameters

Name Type Default value Description
$module string 'content' -
$function string 'read' -
$targets array<string|int, mixed>|null null -

Return values

bool|Criterion

publicgetQueryPermissionsCriterion()

PermissionCriterionResolver.php : 41

Get composite Criterion for Querying permissions.

public getQueryPermissionsCriterion() : Criterion

MatchAll and MatchNone are returned for a user with full and no access respectively.

Return values

Criterion

publichasAccess()

PermissionResolver.php : 59

Low level permission function: Returns boolean value, or an array of limitations that user permission depends on.

public hasAccess(string $module, string $function[, UserReference|null $userReference = null ]) : bool|array<string|int, mixed>

Note: boolean value describes full access (true) or no access at all (false), array can be seen as a maybe..

WARNING: This is a low level method, if possible strongly prefer to use canUser() as it is able to handle limitations. This includes Role Assignment limitations, but also future policy limitations added in kernel, or as plain user configuration and/or extending the system.

Parameters

Name Type Default value Description
$module string -

The module, aka controller identifier to check permissions on

$function string -

The function, aka the controller action to check permissions on

$userReference UserReference|null null

User for which the information is returned, current user will be used if null

Return values

bool|array<string|int, mixed>

if limitations are on this function an array of limitations is returned

Tags
Throws
InvalidArgumentException

If module or function is invalid.

publiclookupLimitations()

PermissionResolver.php : 96
public lookupLimitations(string $module, string $function, ValueObject $object[, array<string|int, ValueObject$targets = [] ][, array<string|int, string> $limitationsIdentifiers = [] ]) : LookupLimitationResult

Parameters

Name Type Default value Description
$module string -

The module, aka controller identifier to check permissions on

$function string -

The function, aka the controller action to check permissions on

$object ValueObject -

The object to check if the user has access to

$targets array<string|int, ValueObject> []

An array of location, parent or "assignment" value objects

$limitationsIdentifiers array<string|int, string> []

An array of Limitations identifiers to filter from all which will pass

Return values

LookupLimitationResult

Tags
Throws
InvalidArgumentException
Throws
BadStateException

publicsetCurrentUserReference()

PermissionResolver.php : 32

Sets the current user to the given $user.

public setCurrentUserReference(UserReference $userReference) : void

Parameters

Name Type Default value Description
$userReference UserReference - -