<?php
namespace App\Security\Draw;
use App\Model\User\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class DrawVoter extends Voter
{
public const GET_DRAW_RECAP = 'get_draw_recap';
public const GET_DRAW_DELIVERY = 'get_draw_delivery';
public const ARRAY_DRAW_VOTER = [
self::GET_DRAW_RECAP,
self::GET_DRAW_DELIVERY,
];
protected function supports($attribute, $subject)
{
return in_array($attribute, self::ARRAY_DRAW_VOTER);
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
{
$user = $token->getUser();
if (!$user instanceof User) {
return false;
}
return true;
}
}