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