1 | <?php |
||
26 | class Authorizer extends AbstractAuthorizer |
||
27 | { |
||
28 | const DEFAULT_RESOURCE = 'DEFAULT_RESOURCE'; |
||
29 | |||
30 | /** |
||
31 | * The default ACL resource identifier. |
||
32 | * |
||
33 | * @var string|null |
||
34 | */ |
||
35 | private $defaultResource; |
||
36 | |||
37 | /** |
||
38 | * @param array $data Class dependencies. |
||
39 | */ |
||
40 | public function __construct(array $data) |
||
48 | |||
49 | /** |
||
50 | * Determine if access is granted by checking the role(s) for permission(s). |
||
51 | * |
||
52 | * @deprecated In favour of AbstractAuthorizer::anyRolesGrantedAll() |
||
53 | * |
||
54 | * @param string[] $aclRoles The ACL role(s) to check. |
||
55 | * @param string[] $aclPermissions The ACL privilege(s) to check. |
||
56 | * @return boolean Returns TRUE if and only if the $aclPermissions are granted against one of the $aclRoles. |
||
57 | * Returns TRUE if an empty array of permissions is given. |
||
58 | * Returns NULL if no applicable roles or permissions could be checked. |
||
59 | */ |
||
60 | public function rolesAllowed(array $aclRoles, array $aclPermissions) |
||
68 | |||
69 | /** |
||
70 | * Determine if access is granted by checking the user's role(s) for permission(s). |
||
71 | * |
||
72 | * @deprecated In favour of AbstractAuthorizer::isUserGranted() |
||
73 | * |
||
74 | * @param UserInterface $user The user to check. |
||
75 | * @param string[] $aclPermissions The ACL privilege(s) to check. |
||
76 | * @return boolean |
||
77 | * Returns TRUE if and only if the $aclPermissions are granted against one of the roles of the $user. |
||
78 | * Returns TRUE if an empty array of permissions is given. |
||
79 | * Returns NULL if no applicable roles or permissions could be checked. |
||
80 | */ |
||
81 | public function userAllowed(UserInterface $user, array $aclPermissions) |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | * |
||
93 | * This method overrides {@see AbstractAuthorizer::isAllowed()} |
||
94 | * as proxy to {@see \Laminas\Permissions\Acl\Acl::isAllowed()} |
||
95 | * to provide support for the special class constant `Authorizer::DEFAULT_RESOURCE`. |
||
96 | * |
||
97 | * @param AclRoleInterface|string $role The ACL role to check. |
||
98 | * @param AclResourceInterface|string $resource The ACL resource to check. |
||
99 | * @param string $privilege The ACL privilege to check. |
||
100 | * @return boolean Returns TRUE if and only if the $role has access to the $resource. |
||
101 | */ |
||
102 | public function isAllowed($role = null, $resource = null, $privilege = null) |
||
110 | |||
111 | /** |
||
112 | * @return string|null |
||
113 | */ |
||
114 | protected function getDefaultResource() |
||
118 | |||
119 | /** |
||
120 | * @param string|null $resource The ACL resource identifier. |
||
121 | * @throws InvalidArgumentException If the resource identifier is not a string. |
||
122 | * @return void |
||
123 | */ |
||
124 | private function setDefaultResource($resource) |
||
134 | } |
||
135 |