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