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