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