-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathDriver.php
More file actions
95 lines (85 loc) · 2.75 KB
/
Driver.php
File metadata and controls
95 lines (85 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace BeatSwitch\Lock\Drivers;
use BeatSwitch\Lock\Callers\Caller;
use BeatSwitch\Lock\Permissions\Permission;
use BeatSwitch\Lock\Roles\Role;
use BeatSwitch\Lock\Resources\Resource;
/**
* A contract to identify an implementation to store permissions to
*
* Drivers can both be persistent or static depending on their implementation.
* A default, static ArrayDriver implementation comes with this package.
*/
interface Driver
{
/**
* Returns all the permissions for a caller
*
* @param \BeatSwitch\Lock\Callers\Caller $caller
* @return \BeatSwitch\Lock\Permissions\Permission[]
*/
public function getCallerPermissions(Caller $caller);
/**
* Stores a new permission for a caller
*
* @param \BeatSwitch\Lock\Callers\Caller $caller
* @param \BeatSwitch\Lock\Permissions\Permission
* @return void
*/
public function storeCallerPermission(Caller $caller, Permission $permission);
/**
* Removes a permission for a caller
*
* @param \BeatSwitch\Lock\Callers\Caller $caller
* @param \BeatSwitch\Lock\Permissions\Permission
* @return void
*/
public function removeCallerPermission(Caller $caller, Permission $permission);
/**
* Checks if a permission is stored for a caller
*
* @param \BeatSwitch\Lock\Callers\Caller $caller
* @param \BeatSwitch\Lock\Permissions\Permission
* @return bool
*/
public function hasCallerPermission(Caller $caller, Permission $permission);
/**
* Returns all the permissions for a role
*
* @param \BeatSwitch\Lock\Roles\Role $role
* @return \BeatSwitch\Lock\Permissions\Permission[]
*/
public function getRolePermissions(Role $role);
/**
* Stores a new permission for a role
*
* @param \BeatSwitch\Lock\Roles\Role $role
* @param \BeatSwitch\Lock\Permissions\Permission
* @return void
*/
public function storeRolePermission(Role $role, Permission $permission);
/**
* Removes a permission for a role
*
* @param \BeatSwitch\Lock\Roles\Role $role
* @param \BeatSwitch\Lock\Permissions\Permission
* @return void
*/
public function removeRolePermission(Role $role, Permission $permission);
/**
* Checks if a permission is stored for a role
*
* @param \BeatSwitch\Lock\Roles\Role $role
* @param \BeatSwitch\Lock\Permissions\Permission
* @return bool
*/
public function hasRolePermission(Role $role, Permission $permission);
/**
* Removes all permissions for a resource, used
* for performance-critical massive removals.
*
* @param \BeatSwitch\Lock\Resources\Resource
* @return void
*/
public function clearPermissionsForResource(Resource $resource);
}