src/Security/Voter/ArchivableVoter.php line 10
<?php
namespace App\Security\Voter;
use Symfony\Component\Security\Core\Authorization\Voter\Voter,
Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use App\Entity\Interface\ArchivableInterface,
App\Lib\Actions;
final class ArchivableVoter extends Voter
{
const MESSAGE = 'Cannot delete unarchived resource.';
protected function supports($attribute, $subject): bool
{
if (! $subject instanceof ArchivableInterface || Actions::DELETE !== $attribute) {
return false;
}
return true;
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
if (! $subject->getIsArchived()) {
return false;
}
return true;
}
}