AccessDecisionManager
in package
implements
AccessDecisionManagerInterface
AccessDecisionManager is the base class for all access decision managers that use decision voters.
Tags
Interfaces, Classes, Traits and Enums
- AccessDecisionManagerInterface
- AccessDecisionManagerInterface makes authorization decisions.
Table of Contents
- STRATEGY_AFFIRMATIVE = 'affirmative'
- STRATEGY_CONSENSUS = 'consensus'
- STRATEGY_UNANIMOUS = 'unanimous'
- $allowIfAllAbstainDecisions : mixed
- $allowIfEqualGrantedDeniedDecisions : mixed
- $strategy : mixed
- $voters : mixed
- __construct() : mixed
- decide() : bool
- Decides whether the access is possible or not.
- decideAffirmative() : bool
- Grants access if any voter returns an affirmative response.
- decideConsensus() : bool
- Grants access if there is consensus of granted against denied responses.
- decideUnanimous() : bool
- Grants access if only grant (or abstain) votes were received.
Constants
STRATEGY_AFFIRMATIVE
public
mixed
STRATEGY_AFFIRMATIVE
= 'affirmative'
STRATEGY_CONSENSUS
public
mixed
STRATEGY_CONSENSUS
= 'consensus'
STRATEGY_UNANIMOUS
public
mixed
STRATEGY_UNANIMOUS
= 'unanimous'
Properties
$allowIfAllAbstainDecisions
private
mixed
$allowIfAllAbstainDecisions
$allowIfEqualGrantedDeniedDecisions
private
mixed
$allowIfEqualGrantedDeniedDecisions
$strategy
private
mixed
$strategy
$voters
private
mixed
$voters
Methods
__construct()
public
__construct([iteratable<string|int, mixed>|array<string|int, VoterInterface> $voters = [] ][, string $strategy = self::STRATEGY_AFFIRMATIVE ][, bool $allowIfAllAbstainDecisions = false ][, bool $allowIfEqualGrantedDeniedDecisions = true ]) : mixed
Parameters
- $voters : iteratable<string|int, mixed>|array<string|int, VoterInterface> = []
-
An array or an iterator of VoterInterface instances
- $strategy : string = self::STRATEGY_AFFIRMATIVE
-
The vote strategy
- $allowIfAllAbstainDecisions : bool = false
-
Whether to grant access if all voters abstained or not
- $allowIfEqualGrantedDeniedDecisions : bool = true
-
Whether to grant access if result are equals
Tags
Return values
mixed —decide()
Decides whether the access is possible or not.
public
decide(TokenInterface $token, array<string|int, mixed> $attributes[, mixed $object = null ]) : bool
Parameters
- $token : TokenInterface
- $attributes : array<string|int, mixed>
-
An array of attributes associated with the method being invoked
- $object : mixed = null
-
The object to secure
Return values
bool —true if the access is granted, false otherwise
decideAffirmative()
Grants access if any voter returns an affirmative response.
private
decideAffirmative(TokenInterface $token, array<string|int, mixed> $attributes[, mixed $object = null ]) : bool
If all voters abstained from voting, the decision will be based on the allowIfAllAbstainDecisions property value (defaults to false).
Parameters
- $token : TokenInterface
- $attributes : array<string|int, mixed>
- $object : mixed = null
Return values
bool —decideConsensus()
Grants access if there is consensus of granted against denied responses.
private
decideConsensus(TokenInterface $token, array<string|int, mixed> $attributes[, mixed $object = null ]) : bool
Consensus means majority-rule (ignoring abstains) rather than unanimous agreement (ignoring abstains). If you require unanimity, see UnanimousBased.
If there were an equal number of grant and deny votes, the decision will be based on the allowIfEqualGrantedDeniedDecisions property value (defaults to true).
If all voters abstained from voting, the decision will be based on the allowIfAllAbstainDecisions property value (defaults to false).
Parameters
- $token : TokenInterface
- $attributes : array<string|int, mixed>
- $object : mixed = null
Return values
bool —decideUnanimous()
Grants access if only grant (or abstain) votes were received.
private
decideUnanimous(TokenInterface $token, array<string|int, mixed> $attributes[, mixed $object = null ]) : bool
If all voters abstained from voting, the decision will be based on the allowIfAllAbstainDecisions property value (defaults to false).
Parameters
- $token : TokenInterface
- $attributes : array<string|int, mixed>
- $object : mixed = null