Skip to content

Commit

Permalink
optimize sf voter
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Aug 10, 2024
1 parent d74d469 commit a79f8df
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Security/Voter/AclVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ protected function supports(string $attribute, mixed $subject): bool
return is_numeric($attribute) && $subject instanceof AclObjectInterface;
}

public function supportsAttribute(string $attribute): bool
{
return is_numeric($attribute);
}

public function supportsType(string $subjectType): bool
{
return is_a($subjectType, AclObjectInterface::class, true);
}

protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
$user = $token->getUser();
Expand Down
19 changes: 18 additions & 1 deletion Security/Voter/SetPermissionVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,27 @@ protected function supports(string $attribute, mixed $subject): bool
$attribute, [
self::ACL_READ,
self::ACL_WRITE,
]
],
true
) && $subject instanceof AclObjectInterface;
}

public function supportsAttribute(string $attribute): bool
{
return in_array(
$attribute, [
self::ACL_READ,
self::ACL_WRITE,
],
true
);
}

public function supportsType(string $subjectType): bool
{
return is_a($subjectType, AclObjectInterface::class, true);
}

/**
* @param AclObjectInterface $subject
*/
Expand Down

0 comments on commit a79f8df

Please sign in to comment.