<?php
namespace App\Security\Odr;
use App\Model\User\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class OdrVoter extends Voter
{
public const GET_ODR_RECAP = 'get_odr_recap';
public const GET_ODR_DELIVERY = 'get_odr_delivery';
public const ARRAY_ODR_VOTER = [
self::GET_ODR_RECAP,
self::GET_ODR_DELIVERY,
];
protected function supports($attribute, $subject): bool
{
return in_array($attribute, self::ARRAY_ODR_VOTER);
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
$user = $token->getUser();
if (!$user instanceof User) {
return false;
}
return true;
}
}