class TestingPrivilegeManager extends PrivilegeManager (View source)

An access decision manager that can be overridden for tests

Properties

protected ObjectManagerInterface $objectManager from  PrivilegeManager
protected Context $securityContext from  PrivilegeManager
protected bool $allowAccessIfAllAbstain

If set to true access will be granted for objects where all voters abstain from decision.

from  PrivilegeManager
protected bool|null $overrideDecision

Methods

__construct(ObjectManagerInterface $objectManager, Context $securityContext)

No description

bool
isGranted(string $privilegeType, mixed $subject, string $reason = '')

Returns true, if the given privilege type is granted for the given subject based on the current security context or if set based on the override decision value.

bool
isGrantedForRoles(array $roles, string $privilegeType, mixed $subject, string $reason = '')

Returns true, if the given privilege type would be granted for the given roles and subject

bool
isPrivilegeTargetGranted(string $privilegeTargetIdentifier, array $privilegeParameters = [])

Returns true if access is granted on the given privilege target in the current security context or if set based on the override decision value.

bool
isPrivilegeTargetGrantedForRoles(array $roles, string $privilegeTargetIdentifier, array $privilegeParameters = [])

Returns true if access is granted on the given privilege target in the current security context

getPrivilegeByTypeReducer(string $privilegeType)

No description

getPrivilegeSubjectFilter(mixed $subject)

No description

void
setOverrideDecision(bool $overrideDecision)

Set the decision override

void
reset()

Resets the AccessDecisionManager to behave transparently.

Details

__construct(ObjectManagerInterface $objectManager, Context $securityContext)

No description

Parameters

ObjectManagerInterface $objectManager

The object manager

Context $securityContext

The current security context

bool isGranted(string $privilegeType, mixed $subject, string $reason = '')

Returns true, if the given privilege type is granted for the given subject based on the current security context or if set based on the override decision value.

Parameters

string $privilegeType

The type of privilege that should be evaluated

mixed $subject

The subject to check privileges for

string $reason

This variable will be filled by a message giving information about the reasons for the result of this method

Return Value

bool

bool isGrantedForRoles(array $roles, string $privilegeType, mixed $subject, string $reason = '')

Returns true, if the given privilege type would be granted for the given roles and subject

Parameters

array $roles

The roles that should be evaluated

string $privilegeType

The type of privilege that should be evaluated

mixed $subject

The subject to check privileges for

string $reason

This variable will be filled by a message giving information about the reasons for the result of this method

Return Value

bool

bool isPrivilegeTargetGranted(string $privilegeTargetIdentifier, array $privilegeParameters = [])

Returns true if access is granted on the given privilege target in the current security context or if set based on the override decision value.

Parameters

string $privilegeTargetIdentifier

The identifier of the privilege target to decide on

array $privilegeParameters

Optional array of privilege parameters (simple key => value array)

Return Value

bool

true if access is granted, false otherwise

bool isPrivilegeTargetGrantedForRoles(array $roles, string $privilegeTargetIdentifier, array $privilegeParameters = [])

Returns true if access is granted on the given privilege target in the current security context

Parameters

array $roles

The roles that should be evaluated

string $privilegeTargetIdentifier

The identifier of the privilege target to decide on

array $privilegeParameters

Optional array of privilege parameters (simple key => value array)

Return Value

bool

true if access is granted, false otherwise

protected PrivilegePermissionResult applyPrivilegeToResult(PrivilegePermissionResult $result, PrivilegeInterface $privilege = null)

No description

Parameters

PrivilegePermissionResult $result
PrivilegeInterface $privilege

Return Value

PrivilegePermissionResult

protected Closure getPrivilegeByTypeReducer(string $privilegeType)

No description

Parameters

string $privilegeType

Return Value

Closure

protected Closure getPrivilegeSubjectFilter(mixed $subject)

No description

Parameters

mixed $subject

Return Value

Closure

void setOverrideDecision(bool $overrideDecision)

Set the decision override

Parameters

bool $overrideDecision

true or false to override the decision, NULL to use the access decision voter manager

Return Value

void

void reset()

Resets the AccessDecisionManager to behave transparently.

Return Value

void