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