-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,10 @@ | |
* This voter can be used as a base class for implementing your own permissions. | ||
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
class AclVoter implements VoterInterface | ||
abstract class InternalAclVoter implements VoterInterface | ||
{ | ||
private $aclProvider; | ||
private $permissionMap; | ||
|
@@ -51,7 +53,10 @@ public function supportsAttribute($attribute) | |
return \is_string($attribute) && $this->permissionMap->contains($attribute); | ||
} | ||
|
||
public function vote(TokenInterface $token, $subject, array $attributes) | ||
/** | ||
* @internal | ||
*/ | ||
protected function internalVote(TokenInterface $token, $subject, array $attributes) | ||
{ | ||
foreach ($attributes as $attribute) { | ||
if (!$this->supportsAttribute($attribute)) { | ||
|
@@ -145,3 +150,21 @@ public function supportsClass($class) | |
return true; | ||
} | ||
} | ||
|
||
if (class_exists(\Symfony\Component\Security\Core\Security::class)) { | ||
class AclVoter extends InternalAclVoter | ||
{ | ||
public function vote(TokenInterface $token, $subject, array $attributes) | ||
{ | ||
return $this->internalVote($token, $subject, $attributes); | ||
} | ||
} | ||
} else { | ||
class AclVoter extends InternalAclVoter | ||
{ | ||
public function vote(TokenInterface $token, mixed $subject, array $attributes): int | ||
{ | ||
return $this->internalVote($token, $subject, $attributes); | ||
} | ||
} | ||
} |