src/Bundles/CatalogBundle/Security/Voter/ViewCatalogVoter.php line 12

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Bundles\CatalogBundle\Security\Voter;
  4. use App\Bundles\CatalogBundle\Entity\Catalog;
  5. use App\Bundles\UserBundle\Enum\SystemPermissionEnum;
  6. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  7. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  8. class ViewCatalogVoter extends Voter
  9. {
  10.     protected function supports(string $attribute$subject): bool
  11.     {
  12.         return  $attribute === SystemPermissionEnum::SINGLE_CATALOG_VIEW->value;
  13.     }
  14.     /**
  15.      * @param Catalog $subject
  16.      */
  17.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  18.     {
  19.         return !$subject->isHidden();
  20.     }
  21. }