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