From ff4faca3669637d026d17ed6a9159d089230e8ad Mon Sep 17 00:00:00 2001 From: core23 Date: Mon, 5 Feb 2024 16:31:17 +0100 Subject: [PATCH] Fix symfony 7 compatibility --- Voter/AclVoter.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Voter/AclVoter.php b/Voter/AclVoter.php index 14c5d56..897a189 100644 --- a/Voter/AclVoter.php +++ b/Voter/AclVoter.php @@ -26,8 +26,10 @@ * This voter can be used as a base class for implementing your own permissions. * * @author Johannes M. Schmitt + * + * @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); + } + } +}