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