|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ubiquity\security\acl\models; |
|
4
|
|
|
|
|
5
|
|
|
use Ubiquity\attributes\items\Transient; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Ubiquity\security\acl\models$AclElement |
|
9
|
|
|
* This class is part of Ubiquity |
|
10
|
|
|
* |
|
11
|
|
|
* @author jc |
|
12
|
|
|
* @version 1.0.2 |
|
13
|
|
|
* |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
class AclElement { |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* |
|
20
|
|
|
* @id |
|
21
|
|
|
* @column("name"=>"id","nullable"=>false,"dbType"=>"int(11)") |
|
22
|
|
|
*/ |
|
23
|
|
|
#[\Ubiquity\attributes\items\Id()] |
|
24
|
|
|
#[\Ubiquity\attributes\items\Column(name:'id',nullable:false,dbType:'int(11)')] |
|
25
|
|
|
protected $id; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* |
|
29
|
|
|
* @var Role |
|
30
|
|
|
* @manyToOne |
|
31
|
|
|
* @joinColumn("className"=>"Ubiquity\\security\\acl\\models\\Role","name"=>"roleName","nullable"=>false) |
|
32
|
|
|
*/ |
|
33
|
|
|
#[\Ubiquity\attributes\items\ManyToOne()] |
|
34
|
|
|
#[\Ubiquity\attributes\items\JoinColumn(className:"Ubiquity\\security\\acl\\models\\Role",name: "roleName", nullable: false)] |
|
35
|
|
|
protected $role; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* |
|
39
|
|
|
* @var Permission |
|
40
|
|
|
* @manyToOne |
|
41
|
|
|
* @joinColumn("className"=>"Ubiquity\\security\\acl\\models\\Permission","name"=>"permissionName","nullable"=>false) |
|
42
|
|
|
*/ |
|
43
|
|
|
#[\Ubiquity\attributes\items\ManyToOne()] |
|
44
|
|
|
#[\Ubiquity\attributes\items\JoinColumn(className:"Ubiquity\\security\\acl\\models\\Permission",name: "permissionName", nullable: false)] |
|
45
|
|
|
protected $permission; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* |
|
49
|
|
|
* @var \Ubiquity\security\acl\models\Resource |
|
50
|
|
|
* @manyToOne |
|
51
|
|
|
* @joinColumn("className"=>"Ubiquity\\security\\acl\\models\\Resource","name"=>"resourceName","nullable"=>false) |
|
52
|
|
|
*/ |
|
53
|
|
|
#[\Ubiquity\attributes\items\ManyToOne()] |
|
54
|
|
|
#[\Ubiquity\attributes\items\JoinColumn(className:"Ubiquity\\security\\acl\\models\\Resource",name: "resourceName", nullable: false)] |
|
55
|
|
|
protected $resource; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var string |
|
59
|
|
|
* @transient |
|
60
|
|
|
*/ |
|
61
|
|
|
#[Transient] |
|
62
|
|
|
protected $type; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* |
|
66
|
|
|
* @return Role |
|
67
|
|
|
* |
|
68
|
|
|
*/ |
|
69
|
16 |
|
public function getRole() { |
|
70
|
16 |
|
return $this->role; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* |
|
75
|
|
|
* @return Permission |
|
76
|
|
|
*/ |
|
77
|
15 |
|
public function getPermission() { |
|
78
|
15 |
|
return $this->permission; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* |
|
83
|
|
|
* @return \Ubiquity\security\acl\models\Resource |
|
84
|
|
|
*/ |
|
85
|
16 |
|
public function getResource() { |
|
86
|
16 |
|
return $this->resource; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
6 |
|
public function fromArray($aclArray) { |
|
90
|
6 |
|
$role = new Role(); |
|
91
|
6 |
|
$role->fromArray($aclArray['role']); |
|
92
|
6 |
|
$resource = new Resource(); |
|
93
|
6 |
|
$resource->fromArray($aclArray['resource']); |
|
94
|
6 |
|
$permission = new Permission(); |
|
95
|
6 |
|
$permission->fromArray($aclArray['permission']); |
|
96
|
6 |
|
$this->role = $role; |
|
97
|
6 |
|
$this->permission = $permission; |
|
98
|
6 |
|
$this->resource = $resource; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
4 |
|
public function toArray(): array { |
|
102
|
4 |
|
return [ |
|
103
|
4 |
|
'resource' => $this->resource->toArray(), |
|
104
|
4 |
|
'role' => $this->role->toArray(), |
|
105
|
4 |
|
'permission' => $this->permission->toArray() |
|
106
|
4 |
|
]; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
13 |
|
public function allow(Role $role, Resource $resource, Permission $permission) { |
|
110
|
13 |
|
$this->role = $role; |
|
111
|
13 |
|
$this->resource = $resource; |
|
112
|
13 |
|
$this->permission = $permission; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* |
|
117
|
|
|
* @return mixed |
|
118
|
|
|
*/ |
|
119
|
1 |
|
public function getId() { |
|
120
|
1 |
|
return $this->id; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* |
|
125
|
|
|
* @param mixed $id |
|
126
|
|
|
*/ |
|
127
|
4 |
|
public function setId($id) { |
|
128
|
4 |
|
$this->id = $id; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* |
|
133
|
|
|
* @param \Ubiquity\security\acl\models\Role $role |
|
134
|
|
|
*/ |
|
135
|
4 |
|
public function setRole($role) { |
|
136
|
4 |
|
$this->role = $role; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* |
|
141
|
|
|
* @param \Ubiquity\security\acl\models\Permission $permission |
|
142
|
|
|
*/ |
|
143
|
4 |
|
public function setPermission($permission) { |
|
144
|
4 |
|
$this->permission = $permission; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* |
|
149
|
|
|
* @param \Ubiquity\security\acl\models\Resource $resource |
|
150
|
|
|
*/ |
|
151
|
4 |
|
public function setResource($resource) { |
|
152
|
4 |
|
$this->resource = $resource; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return string |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getType(): string { |
|
159
|
|
|
return $this->type; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @param string $type |
|
164
|
|
|
*/ |
|
165
|
|
|
public function setType(string $type): void { |
|
166
|
|
|
$this->type = $type; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
6 |
|
public function getId_() { |
|
170
|
6 |
|
$id = ''; |
|
171
|
6 |
|
if (isset($this->role)) { |
|
172
|
6 |
|
$id = $this->role->getName(); |
|
173
|
|
|
} |
|
174
|
6 |
|
if (isset($this->resource)) { |
|
175
|
6 |
|
$id .= $this->resource->getName(); |
|
176
|
|
|
} |
|
177
|
6 |
|
if (isset($this->permission)) { |
|
178
|
6 |
|
$id .= $this->permission->getName(); |
|
179
|
|
|
} |
|
180
|
6 |
|
return \crc32($id) . '.'; |
|
|
|
|
|
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
1 |
|
public function castAs(string $class) { |
|
184
|
1 |
|
return unserialize(sprintf('O:%d:"%s"%s', \strlen($class), $class, \strstr(\strstr(\serialize($this), '"'), ':'))); |
|
185
|
|
|
} |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths