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