src/Security/Voter/MenuVoter.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Security\Voter;
  3. use App\Entity\Menu;
  4. use App\Utils\VoterHelper;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  7. class MenuVoter extends Voter
  8. {
  9.     private const SEE  'see';
  10.     private const EDIT 'edit';
  11.     /**
  12.      * MenuVoter constructor.
  13.      */
  14.     public function __construct()
  15.     {
  16.     }
  17.     protected function supports(string $attributemixed $subject): bool
  18.     {
  19.         return $subject instanceof Menu && in_array($attribute, [self::SEEself::EDIT], true);
  20.     }
  21.     protected function voteOnAttribute(string $attributemixed $subjectTokenInterface $token): bool
  22.     {
  23.         return VoterHelper::voteOnAttribute($attribute$subject$token'menu');
  24.     }
  25. }