bundles/PublicApiBundle/Security/Authorization/Voter/TransactionVoter.php line 10

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Bdm\PublicApiBundle\Security\Authorization\Voter;
  4. use Bdm\CheckoutBundle\Entity\Transaction;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. class TransactionVoter extends AbstractVoter
  7. {
  8. /**
  9. * @param string $sAttribute attribute
  10. * @param mixed $oSubject subject
  11. * @return bool
  12. */
  13. public function supports($sAttribute, $oSubject)
  14. {
  15. return $oSubject instanceof Transaction;
  16. }
  17. /**
  18. * @param string $sAttr attr
  19. * @param mixed $mEntity entity
  20. * @param TokenInterface $oToken token
  21. *
  22. * @return bool
  23. */
  24. protected function voteOnAttribute($sAttr, $mEntity, TokenInterface $oToken)
  25. {
  26. $oApplication = $this->getApplication($oToken);
  27. return $mEntity->getPayment()->getApplication() === $oApplication;
  28. }
  29. }