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