src/Security/Voter/RequestVoter.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Security\Voter;
  4. use App\Entity\Cart;
  5. use App\Entity\Password\Request;
  6. use App\Entity\Show\Session;
  7. use App\Entity\User;
  8. use App\Manager\CartManager;
  9. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  10. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  11. use Symfony\Component\Security\Core\Security;
  12. class RequestVoter extends Voter
  13. {
  14.     protected function supports(string $attribute$subject): bool
  15.     {
  16.         return $attribute === 'REQUEST_NOT_EXPIRED' && $subject instanceof Request;
  17.     }
  18.     /**
  19.      * @param string $attribute
  20.      * @param Request $subject
  21.      * @param TokenInterface $token
  22.      * @return bool
  23.      */
  24.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token): bool
  25.     {
  26.         return $subject->getExpiredAt() > new \DateTimeImmutable();
  27.     }
  28. }