-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractAuthorizer.php
More file actions
68 lines (54 loc) · 1.57 KB
/
AbstractAuthorizer.php
File metadata and controls
68 lines (54 loc) · 1.57 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
<?php
namespace Vayes\Auth;
abstract class AbstractAuthorizer implements AuthorizerInterface
{
/** @var array */
protected $permissions;
/** @var array */
protected $userPermissions;
abstract public function isAuthenticated(): bool;
abstract public function isGranted(string $permissionNam): bool;
abstract protected function loadPermissions(): array;
abstract protected function loadUserPermissions(): bool;
abstract public function addPermission(string $permissionName, ?UserInterface $user = null): bool;
abstract public function removePermission(string $permissionName, ?UserInterface $user = null): bool;
/**
* @param $permissionName
* @return int|null
*/
protected function getPermissionIdByName($permissionName): ?int
{
return isset($this->permissions[$permissionName])
? $this->permissions[$permissionName]
: null;
}
public function getPermissions(): array
{
return $this->permissions;
}
/**
* @param array $permissions
* @return $this
*/
public function setPermissions(array $permissions): self
{
$this->permissions = $permissions;
return $this;
}
/**
* @return array
*/
public function getUserPermissions(): array
{
return $this->userPermissions;
}
/**
* @param array $userPermissions
* @return $this
*/
public function setUserPermissions(array $userPermissions): self
{
$this->userPermissions = $userPermissions;
return $this;
}
}