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