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