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