@@ -222,33 +222,33 @@ Checking for Roles inside a Voter
222222---------------------------------
223223
224224What if you want to call ``isGranted() `` from *inside * your voter - e.g. you want
225- to see if the current user has ``ROLE_SUPER_ADMIN ``. That's possible by injecting
226- the :class: `Symfony\\ Component\\ Security\\ Core\\ Security `
227- into your voter. You can use this to, for example, *always * allow access to a user
225+ to see if the current user has ``ROLE_SUPER_ADMIN ``. That's possible by using an
226+ :class: `access decision manager < Symfony\\ Component\\ Security\\ Core\\ Authorization \\ AccessDecisionManagerInterface> `
227+ inside your voter. You can use this to, for example, *always * allow access to a user
228228with ``ROLE_SUPER_ADMIN ``::
229229
230230 // src/Security/PostVoter.php
231231
232232 // ...
233- use Symfony\Component\Security\Core\Security ;
233+ use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface ;
234234
235235 class PostVoter extends Voter
236236 {
237237 // ...
238238
239- private $security ;
239+ private $accessDecisionManager ;
240240
241- public function __construct(Security $security )
241+ public function __construct(AccessDecisionManagerInterface $accessDecisionManager )
242242 {
243- $this->security = $security ;
243+ $this->accessDecisionManager = $accessDecisionManager ;
244244 }
245245
246246 protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
247247 {
248248 // ...
249249
250250 // ROLE_SUPER_ADMIN can do anything! The power!
251- if ($this->security ->isGranted('ROLE_SUPER_ADMIN')) {
251+ if ($this->accessDecisionManager ->isGranted($token, [ 'ROLE_SUPER_ADMIN'] )) {
252252 return true;
253253 }
254254
0 commit comments