src/Security/TenderStatus/Closed.php line 13

  1. <?php
  2. namespace App\Security\TenderStatus;
  3. use App\Enum\TenderStatusEnum;
  4. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  5. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  6. /**
  7.  * Class Closed
  8.  * @package App\Security\TenderStatus
  9.  */
  10. class Closed extends Voter
  11. {
  12.     /**
  13.      * @param string $attribute
  14.      * @param mixed $subject
  15.      * @return bool
  16.      */
  17.     protected function supports(string $attribute$subject) :bool
  18.     {
  19.         if ($attribute === 'tender_closed_status') {
  20.             return true;
  21.         }
  22.         return false;
  23.     }
  24.     /**
  25.      * @param string $attribute
  26.      * @param mixed $subject
  27.      * @param TokenInterface $token
  28.      * @return bool
  29.      */
  30.     protected function voteOnAttribute(string $attribute$subjectTokenInterface $token) :bool
  31.     {
  32.         $status $subject->getStatus();
  33.         if ($status === TenderStatusEnum::ZATVORENO) {
  34.             return true;
  35.         }
  36.         return false;
  37.     }
  38. }