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