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