src/Security/Voter/JournalArticleFileVoter.php line 11
<?php
namespace App\Security\Voter;
use Symfony\Component\Security\Core\Authorization\Voter\Voter,
Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use App\Enum\JournalArticleFileType,
App\Entity\JournalArticleFile,
App\Lib\Actions;
final class JournalArticleFileVoter extends Voter
{
const CREATE_MESSAGE = 'Predefined file cannot be created.';
const DELETE_MESSAGE = 'Predefined file cannot be deleted.';
protected function supports($attribute, $subject): bool
{
if (
! $subject instanceof JournalArticleFile ||
! in_array($attribute, [Actions::CREATE, Actions::DELETE])
) {
return false;
}
return true;
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
return $subject->getType() === JournalArticleFileType::CUSTOM;
}
}