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