bundles/PublicApiBundle/Security/Authorization/Voter/SubscriptionVoter.php line 38

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SubscriptionVoter.php File.
  5. * This file is part of the Payment.net Project.
  6. *
  7. * PHP version 5
  8. *
  9. * @category Public Api
  10. * @package Bdm\BackofficeBundle\Security\Authorization\Voter
  11. * @author Pavel Baraulya <pbaraulya@bdmultimedia.fr>
  12. * @link http://www.payment.net/
  13. *
  14. * FEATURES :
  15. * ==========
  16. *
  17. * TODO-LIST :
  18. * ===========
  19. *
  20. * HISTORY :
  21. * =========
  22. * 20150709 - Pavel Baraulya
  23. *
  24. **/
  25. namespace Bdm\PublicApiBundle\Security\Authorization\Voter;
  26. use Bdm\BackofficeBundle\Entity\Merchant;
  27. use Bdm\CheckoutBundle\Entity\Subscription;
  28. use Bdm\CheckoutBundle\Entity\SubscriptionPlan;
  29. use Doctrine\Common\Util\ClassUtils;
  30. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  31. /**
  32. * Voter for subscriptions
  33. */
  34. class SubscriptionVoter extends AbstractVoter
  35. {
  36. const ATTRIBUTE_DEFAULT = 'default';
  37. /**
  38. * @param string $sAttribute attribute
  39. * @param mixed $oSubject subject
  40. * @return bool
  41. */
  42. public function supports($sAttribute, $oSubject)
  43. {
  44. return $oSubject instanceof Subscription;
  45. }
  46. /**
  47. * @param string $sAttr attr
  48. * @param mixed $mEntity entity
  49. * @param TokenInterface $oToken token
  50. *
  51. * @return bool
  52. */
  53. protected function voteOnAttribute($sAttr, $mEntity, TokenInterface $oToken)
  54. {
  55. $oApplication = $this->getApplication($oToken);
  56. return $mEntity->getApplication()->getId() == $oApplication->getId();
  57. }
  58. }