Find the best Rector rule to solve your problem. Searching through 823 rules.
Found 2 rules:
Replaces AuthorizationCheckerInterface with AccessDecisionManagerInterface inside Symfony Voters
-use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
+use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
final class AuthorizationCheckerVoter extends Voter
{
public function __construct(
- private AuthorizationCheckerInterface $authorizationChecker
+ private AccessDecisionManagerInterface $accessDecisionManager
) {}
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
- return $this->authorizationChecker->isGranted('ROLE_ADMIN');
+ return $this->accessDecisionManager->decide($token, ['ROLE_ADMIN']);
}
}
Adds a new $voter argument in protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?Vote $vote = null): bool
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
final class MyVoter extends Voter
{
protected function supports(string $attribute, mixed $subject): bool
{
return true;
}
- protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
+ protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
{
return true;
}
}