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