<?php
namespace App\Security\Voter;
use App\Entity\Tag;
use App\Utils\VoterHelper;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class TagVoter extends Voter
{
private const SEE = 'see';
private const EDIT = 'edit';
private const DELETE = 'delete';
/**
* TagVoter constructor.
*/
public function __construct()
{
}
protected function supports(string $attribute, mixed $subject): bool
{
return $subject instanceof Tag && in_array($attribute, [self::SEE, self::EDIT, self::DELETE], true);
}
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
return VoterHelper::voteOnAttribute($attribute, $subject, $token, 'tag');
}
}