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 15, 2024
1 parent 15b96b5 commit 523d98b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 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
28 changes: 27 additions & 1 deletion Voter/AclVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,39 @@
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;

if (class_exists(\Symfony\Component\Security\Core\Security::class)) {
/**
* @internal
*/
trait AclVoterTrait
{
public function vote(TokenInterface $token, $subject, array $attributes)
{
return $this->doVote($token, $subject, $attributes);
}
}
} else {
/**
* @internal
*/
trait AclVoterTrait
{
public function vote(TokenInterface $token, mixed $subject, array $attributes): int
{
return $this->doVote($token, $subject, $attributes);
}
}
}

/**
* This voter can be used as a base class for implementing your own permissions.
*
* @author Johannes M. Schmitt <[email protected]>
*/
class AclVoter implements VoterInterface
{
use AclVoterTrait;

private $aclProvider;
private $permissionMap;
private $objectIdentityRetrievalStrategy;
Expand All @@ -51,7 +77,7 @@ public function supportsAttribute($attribute)
return \is_string($attribute) && $this->permissionMap->contains($attribute);
}

public function vote(TokenInterface $token, $subject, array $attributes)
private function doVote(TokenInterface $token, $subject, array $attributes)
{
foreach ($attributes as $attribute) {
if (!$this->supportsAttribute($attribute)) {
Expand Down

0 comments on commit 523d98b

Please sign in to comment.