bundles/PublicApiBundle/Security/Authorization/Voter/ApplicationVoter.php line 36

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * ApplicationVoter.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\Application;
  27. use Doctrine\Common\Util\ClassUtils;
  28. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  29. /**
  30. * Voter for application
  31. */
  32. class ApplicationVoter extends AbstractVoter
  33. {
  34. /**
  35. * @param string $sAttribute attribute
  36. * @param mixed $oSubject subject
  37. * @return bool
  38. */
  39. public function supports($sAttribute, $oSubject)
  40. {
  41. return $oSubject instanceof Application;
  42. }
  43. /**
  44. * @param string $sAttr attr
  45. * @param mixed $mEntity entity
  46. * @param TokenInterface $oToken token
  47. *
  48. * @return bool
  49. */
  50. protected function voteOnAttribute($sAttr, $mEntity, TokenInterface $oToken)
  51. {
  52. $oApplication = $this->getApplication($oToken);
  53. return $mEntity->getId() == $oApplication->getId();
  54. }
  55. }