1 | <?php |
||
22 | class AccessVoter extends Voter |
||
23 | { |
||
24 | /** |
||
25 | * View action for exchange rate |
||
26 | */ |
||
27 | const VIEW = 'view'; |
||
28 | |||
29 | /** |
||
30 | * Create new exchange rate action |
||
31 | */ |
||
32 | const CREATE = 'create'; |
||
33 | |||
34 | /** |
||
35 | * Edit exchange rate action |
||
36 | */ |
||
37 | const EDIT = 'edit'; |
||
38 | |||
39 | /** |
||
40 | * Delete exchange rate action |
||
41 | */ |
||
42 | const DELETE = 'delete'; |
||
43 | |||
44 | /** |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $roles; |
||
48 | |||
49 | /** |
||
50 | * @var boolean |
||
51 | */ |
||
52 | protected $enabled; |
||
53 | |||
54 | /** |
||
55 | * AccessVoter constructor. |
||
56 | * |
||
57 | * @param array $roles |
||
58 | * |
||
59 | * @codeCoverageIgnore |
||
60 | */ |
||
61 | public function __construct(array $roles = [], $enabled = true) |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 22 | protected function supports($attribute, $subject) |
|
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | 21 | protected function voteOnAttribute($attribute, $subject, TokenInterface $token) |
|
108 | |||
109 | /** |
||
110 | * Check if token has any of given roles. |
||
111 | * |
||
112 | * @param TokenInterface $token |
||
113 | * @param array $roles |
||
114 | * |
||
115 | * @return bool |
||
116 | */ |
||
117 | private function hasAnyRole(TokenInterface $token, array $roles) |
||
133 | } |
||
134 |