<?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\SelfServeResource;
class SelfServeVoter extends KobizoVoter
{
protected function supports($attribute, $subject): bool
{
if (!in_array($attribute, SelfServeResource::getAllResources())) {
return false;
}
if (!$subject instanceof Voucher
&& !in_array($attribute, [SelfServeResource::ALL])
) {
return false;
}
return true;
}
}