Skip to content

Commit

Permalink
Fix symfony 7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 5, 2024
1 parent 15b96b5 commit ff4faca
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Voter/AclVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
* This voter can be used as a base class for implementing your own permissions.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @internal
*/
class AclVoter implements VoterInterface
abstract class InternalAclVoter implements VoterInterface
{
private $aclProvider;
private $permissionMap;
Expand All @@ -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)) {
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit ff4faca

Please sign in to comment.