From d0f65ed0549af5ea85a46ecc56cbd827c20403b3 Mon Sep 17 00:00:00 2001 From: Furrioxx <114649898+Furrioxx@users.noreply.github.com> Date: Thu, 30 Jul 2026 20:18:54 +0200 Subject: [PATCH] [docs-voters-granted] docs: replace security type hints by AccessDecisionManagerInterface to be aligned with symfony doc --- symfony/security.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/symfony/security.md b/symfony/security.md index 005ff7d6b7e..04d48648b0c 100644 --- a/symfony/security.md +++ b/symfony/security.md @@ -319,16 +319,16 @@ namespace App\Security\Voter; use App\Entity\Book; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\Voter\Voter; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Symfony\Component\Security\Core\User\UserInterface; class BookVoter extends Voter { - private $security = null; + private $accessDecisionManager = null; - public function __construct(Security $security) + public function __construct(AccessDecisionManagerInterface $accessDecisionManager) { - $this->security = $security; + $this->accessDecisionManager = $accessDecisionManager; } protected function supports($attribute, $subject): bool @@ -351,7 +351,7 @@ class BookVoter extends Voter switch ($attribute) { case 'BOOK_CREATE': - if ( $this->security->isGranted(Role::ADMIN) ) { return true; } // only admins can create books + if ( $this->accessDecisionManager->decide($token, ['ROLE_ADMIN']) ) { return true; } // only admins can create books break; case 'BOOK_READ': /** ... other authorization rules ... **/