<?php
declare(strict_types=1);
namespace App\Bundles\CatalogBundle\Security\Voter;
use App\Bundles\CatalogBundle\Entity\Catalog;
use App\Bundles\UserBundle\Enum\SystemPermissionEnum;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class ViewCatalogVoter extends Voter
{
protected function supports(string $attribute, $subject): bool
{
return $attribute === SystemPermissionEnum::SINGLE_CATALOG_VIEW->value;
}
/**
* @param Catalog $subject
*/
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
return !$subject->isHidden();
}
}