<?php
namespace Kobizo\Bundle\CmsBundle\Security\Voter;
use Kobizo\Component\Entity\Term;
use Kobizo\Component\Resources\AccessControl\TermResource;
use Kobizo\Bundle\CoreBundle\Security\Voter\KobizoVoter;
class TermVoter extends KobizoVoter
{
protected function supports($attribute, $subject): bool
{
if (!in_array($attribute, TermResource::getAllResources())) {
return false;
}
if (!$subject instanceof Term
&& !in_array($attribute, [TermResource::INDEX, TermResource::CREATE])
) {
return false;
}
return true;
}
}