<?php
namespace App\Voter\__Marketing;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\User\UserInterface;
class MarketingDepartureVoter extends Voter
{
const LIST = "MARKETING_DEPARTURE_LIST";
const MERGE = "MARKETING_DEPARTURE_MERGE";
protected function supports($attribute, $subject): bool
{
return in_array($attribute, [
self::LIST,
self::MERGE,
]);
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
$loggedUser = $token->getUser();
if (!$loggedUser instanceof UserInterface) {
return false;
}
return in_array($attribute, $loggedUser->getRoles());
}
}