vendor/nellapp/sdk-bundle/src/Developers/Security/Voter/GlobalScopeVoter.php line 9

Open in your IDE?
  1. <?php
  2. namespace Nellapp\Bundle\SDKBundle\Developers\Security\Voter;
  3. use Nellapp\Bundle\SDKBundle\Developers\GlobalScopeAuthorizationService;
  4. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. class GlobalScopeVoter extends Voter
  7. {
  8.     public function __construct(
  9.         private GlobalScopeAuthorizationService $authorizationService,
  10.     ) {
  11.     }
  12.     public function supportsType(string $subjectType): bool
  13.     {
  14.         return true;
  15.     }
  16.     public function supportsAttribute(string $attribute): bool
  17.     {
  18.         return is_string($attribute)
  19.         && str_starts_with($attribute, 'global:');
  20.     }
  21.     protected function supports($attribute, $subject): bool
  22.     {
  23.         return $this->supportsAttribute($attribute) && $this->supportsType('');
  24.     }
  25.     protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
  26.     {
  27.         return $this->authorizationService->canAccess($attribute);
  28.     }
  29. }