bundles/AdminBundle/Security/Authorization/Voter/AdminPermissiveVoter.php line 36

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * AdminPermissiveVoter.php File.
  5. * This file is part of the Payment.net Project.
  6. *
  7. * PHP version 5
  8. *
  9. * @category Admin private api
  10. * @package Bdm\AdminBundle\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\AdminBundle\Security\Authorization\Voter;
  26. use Bdm\AdminBundle\Entity\User;
  27. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  28. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  29. /**
  30. * Voter for admin users, everything is allowed
  31. */
  32. class AdminPermissiveVoter extends Voter
  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 true;
  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. return $oToken->getUser() instanceof User;
  53. }
  54. }