1 | <?php |
||
14 | class HandleCommandVoter extends Voter |
||
15 | { |
||
16 | /** |
||
17 | * The decision manager. |
||
18 | * |
||
19 | * @var AccessDecisionManagerInterface |
||
20 | */ |
||
21 | private $decisionManager; |
||
22 | |||
23 | /** |
||
24 | * Default required role. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | private $defaultRole; |
||
29 | |||
30 | /** |
||
31 | * Command - Require role mapping |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | private $commandRoleMapping; |
||
36 | |||
37 | /** |
||
38 | * Create a new HandleCommandVoter. |
||
39 | * |
||
40 | * @param AccessDecisionManagerInterface $decisionManager |
||
41 | * @param array $commandRoleMapping |
||
42 | * @param string $defaultRole |
||
43 | */ |
||
44 | public function __construct(AccessDecisionManagerInterface $decisionManager, array $commandRoleMapping = [], $defaultRole = null) |
||
50 | |||
51 | /** |
||
52 | * The voter supports checking handle commands |
||
53 | * |
||
54 | * @param string $attribute |
||
55 | * @param object $subject |
||
56 | * @return bool |
||
57 | */ |
||
58 | protected function supports($attribute, $subject) |
||
62 | |||
63 | /** |
||
64 | * Checks if the currently logged on user may handle $subject. |
||
65 | * |
||
66 | * @param type $attribute |
||
67 | * @param type $subject |
||
68 | * @param TokenInterface $token |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | protected function voteOnAttribute($attribute, $subject, TokenInterface $token) |
||
83 | |||
84 | /** |
||
85 | * Gets the roles allowed to handle a command of $type |
||
86 | * |
||
87 | * @param string $type |
||
88 | * @return array |
||
89 | */ |
||
90 | private function getAllowedRoles($type) |
||
102 | |||
103 | /** |
||
104 | * Returns the decisionManager. |
||
105 | * |
||
106 | * @return AccessDecisionManagerInterface |
||
107 | */ |
||
108 | private function getDecisionManager() |
||
112 | } |
||
113 |