src/Security/IsCustomerCreatedFullyVoter.php line 11

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Security;
  4. use App\Entity\System\Customer;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  7. class IsCustomerCreatedFullyVoter extends Voter
  8. {
  9. public const IS_CUSTOMER_CREATED_FULLY = 'IS_CUSTOMER_CREATED_FULLY';
  10. protected function supports($attribute, $subject): bool
  11. {
  12. return $attribute === self::IS_CUSTOMER_CREATED_FULLY;
  13. }
  14. protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
  15. {
  16. $user = $token->getUser();
  17. return $user instanceof Customer && Customer::ACCOUNT_COMPLETE === $user->getPartialCreation();
  18. }
  19. }