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