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