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