src/Security/Voter/FileExportVoter.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Security\Voter;
  3. use App\Entity\Channel\Export\FileExport;
  4. use App\Service\Export\FileExportService;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  7. class FileExportVoter extends Voter
  8. {
  9.     public const CHANNEL_USER_PERM_EXPORT 'CHANNEL_USER_PERM_EXPORT';
  10.     public function __construct(
  11.         private FileExportService $fileExportService,
  12.     ) {}
  13.     protected function supports(string $attribute$subject): bool
  14.     {
  15.         return $subject instanceof FileExport && $attribute === self::CHANNEL_USER_PERM_EXPORT;
  16.     }
  17.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  18.     {
  19.         return $this->fileExportService->hasPerm($subject);
  20.     }
  21. }