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 4f067d9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Tests/Domain/SecurityIdentityRetrievalStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function getRoles(): array
return [];
}

public function eraseCredentials()
public function eraseCredentials(): void
{
}

Expand Down
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 <[email protected]>
*
* @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 4f067d9

Please sign in to comment.