-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Use IteratorArgument for voters #21437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,16 +32,14 @@ class AccessDecisionManager implements AccessDecisionManagerInterface | |
private $allowIfEqualGrantedDeniedDecisions; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param VoterInterface[] $voters An array of VoterInterface instances | ||
* @param string $strategy The vote strategy | ||
* @param bool $allowIfAllAbstainDecisions Whether to grant access if all voters abstained or not | ||
* @param bool $allowIfEqualGrantedDeniedDecisions Whether to grant access if result are equals | ||
* @param iterable|VoterInterface[] $voters An iterator of VoterInterface instances | ||
* @param string $strategy The vote strategy | ||
* @param bool $allowIfAllAbstainDecisions Whether to grant access if all voters abstained or not | ||
* @param bool $allowIfEqualGrantedDeniedDecisions Whether to grant access if result are equals | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function __construct(array $voters = array(), $strategy = self::STRATEGY_AFFIRMATIVE, $allowIfAllAbstainDecisions = false, $allowIfEqualGrantedDeniedDecisions = true) | ||
public function __construct($voters = array(), $strategy = self::STRATEGY_AFFIRMATIVE, $allowIfAllAbstainDecisions = false, $allowIfEqualGrantedDeniedDecisions = true) | ||
{ | ||
$strategyMethod = 'decide'.ucfirst($strategy); | ||
if (!is_callable(array($this, $strategyMethod))) { | ||
|
@@ -58,9 +56,13 @@ public function __construct(array $voters = array(), $strategy = self::STRATEGY_ | |
* Configures the voters. | ||
* | ||
* @param VoterInterface[] $voters An array of VoterInterface instances | ||
* | ||
* @deprecated since version 3.3, to be removed in 4.0. Pass the voters to the constructor instead. | ||
*/ | ||
public function setVoters(array $voters) | ||
{ | ||
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Pass the voters to the constructor instead.', __METHOD__), E_USER_DEPRECATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we gain anything by deprecating this method? Does it hurt to keep it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the type of the |
||
|
||
$this->voters = $voters; | ||
} | ||
|
||
|
@@ -162,8 +164,8 @@ private function decideConsensus(TokenInterface $token, array $attributes, $obje | |
private function decideUnanimous(TokenInterface $token, array $attributes, $object = null) | ||
{ | ||
$grant = 0; | ||
foreach ($attributes as $attribute) { | ||
foreach ($this->voters as $voter) { | ||
foreach ($this->voters as $voter) { | ||
foreach ($attributes as $attribute) { | ||
$result = $voter->vote($token, $object, array($attribute)); | ||
|
||
switch ($result) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corresponding entry missing from UPGRADE-4.0.md (the ... has been removed. ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed