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