src/Security/Voter/API/Crypto/PreKey/ViewVoter.php line 13
<?phpdeclare(strict_types=1);namespace App\Security\Voter\API\Crypto\PreKey;use ApiPlatform\Core\Bridge\Doctrine\Orm\Paginator;use App\Data\Crypto\Key\PreKey;use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;use Symfony\Component\Security\Core\Authorization\Voter\Voter;class ViewVoter extends Voter{protected function supports(string $attribute, mixed $subject): bool{return $attribute === 'VIEW_PRE_KEYS';}protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool{/** @var ?PreKey[] $items */$items = null;if ($subject instanceof PreKey) {$items = [$subject];}else if ($subject instanceof Paginator) {$items = [];foreach ($subject as $item) {$items[] = $item;}}if ($items !== null) {foreach ($items as $key) {if ($key->getUser() !== $token->getUser()) {return false;}}return true;}return false;}}