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