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