Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AclElement.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\security\acl\models
;
4
5
use
Ubiquity\attributes\items\Transient
;
6
16
class
AclElement
{
17
23
#[\Ubiquity\attributes\items\Id()]
24
#[\Ubiquity\attributes\items\Column(name:'id',nullable:false,dbType:'int(11)')]
25
protected
$id
;
26
33
#[\Ubiquity\attributes\items\ManyToOne()]
34
#[\Ubiquity\attributes\items\JoinColumn(className:"Ubiquity\\security\\acl\\models\\Role",name: "roleName", nullable: false)]
35
protected
$role
;
36
43
#[\Ubiquity\attributes\items\ManyToOne()]
44
#[\Ubiquity\attributes\items\JoinColumn(className:"Ubiquity\\security\\acl\\models\\Permission",name: "permissionName", nullable: false)]
45
protected
$permission
;
46
53
#[\Ubiquity\attributes\items\ManyToOne()]
54
#[\Ubiquity\attributes\items\JoinColumn(className:"Ubiquity\\security\\acl\\models\\Resource",name: "resourceName", nullable: false)]
55
protected
$resource
;
56
61
#[Transient]
62
protected
$type
=
''
;
63
69
public
function
getRole
() {
70
return
$this->role
;
71
}
72
77
public
function
getPermission
() {
78
return
$this->permission
;
79
}
80
85
public
function
getResource
() {
86
return
$this->resource
;
87
}
88
89
public
function
fromArray
($aclArray) {
90
$role
=
new
Role
();
91
$role
->fromArray($aclArray[
'role'
]);
92
$resource
=
new
Resource
();
93
$resource
->fromArray($aclArray[
'resource'
]);
94
$permission
=
new
Permission
();
95
$permission
->fromArray($aclArray[
'permission'
]);
96
$this->role =
$role
;
97
$this->permission =
$permission
;
98
$this->resource =
$resource
;
99
}
100
101
public
function
toArray
(): array {
102
return [
103
'resource'
=> $this->resource->
toArray
(),
104
'role'
=> $this->role->
toArray
(),
105
'permission'
=> $this->permission->
toArray
()
106
];
107
}
108
109
public
function
allow
(
Role
$role,
Resource
$resource,
Permission
$permission) {
110
$this->role = $role;
111
$this->resource = $resource;
112
$this->permission = $permission;
113
}
114
119
public
function
getId
() {
120
return
$this->id;
121
}
122
127
public
function
setId
($id) {
128
$this->
id
= $id;
129
}
130
135
public
function
setRole
($role) {
136
$this->role = $role;
137
}
138
143
public
function
setPermission
($permission) {
144
$this->permission = $permission;
145
}
146
151
public
function
setResource
($resource) {
152
$this->resource = $resource;
153
}
154
158
public
function
getType
(): string {
159
return $this->type;
160
}
161
165
public
function
setType
(?
string
$type): void {
166
$this->type = $type;
167
}
168
169
public
function
getId_
() {
170
$id =
''
;
171
if
(isset($this->role)) {
172
$id = $this->role->getName();
173
}
174
if
(isset($this->resource)) {
175
$id .= $this->resource->getName();
176
}
177
if
(isset($this->permission)) {
178
$id .= $this->permission->getName();
179
}
180
return \crc32($id) .
'.'
;
181
}
182
183
public
function
castAs
(
string
$class) {
184
return
unserialize(sprintf(
'O:%d:"%s"%s'
, \strlen($class), $class, \strstr(\strstr(\serialize($this),
'"'
),
':'
)));
185
}
186
}
187
Ubiquity\attributes\items\Transient
Annotation Transient.
Definition
Transient.php:16
Ubiquity\security\acl\models\AclElement
Ubiquity\security\acl\models$AclElement This class is part of Ubiquity.
Definition
AclElement.php:16
Ubiquity\security\acl\models\AclElement\getRole
getRole()
Definition
AclElement.php:69
Ubiquity\security\acl\models\AclElement\getId
getId()
Definition
AclElement.php:119
Ubiquity\security\acl\models\AclElement\$role
$role
Definition
AclElement.php:35
Ubiquity\security\acl\models\AclElement\setType
setType(?string $type)
Definition
AclElement.php:165
Ubiquity\security\acl\models\AclElement\allow
allow(Role $role, Resource $resource, Permission $permission)
Definition
AclElement.php:109
Ubiquity\security\acl\models\AclElement\getPermission
getPermission()
Definition
AclElement.php:77
Ubiquity\security\acl\models\AclElement\toArray
toArray()
Definition
AclElement.php:101
Ubiquity\security\acl\models\AclElement\fromArray
fromArray($aclArray)
Definition
AclElement.php:89
Ubiquity\security\acl\models\AclElement\setPermission
setPermission($permission)
Definition
AclElement.php:143
Ubiquity\security\acl\models\AclElement\getType
getType()
Definition
AclElement.php:158
Ubiquity\security\acl\models\AclElement\setResource
setResource($resource)
Definition
AclElement.php:151
Ubiquity\security\acl\models\AclElement\setId
setId($id)
Definition
AclElement.php:127
Ubiquity\security\acl\models\AclElement\getResource
getResource()
Definition
AclElement.php:85
Ubiquity\security\acl\models\AclElement\castAs
castAs(string $class)
Definition
AclElement.php:183
Ubiquity\security\acl\models\AclElement\$type
$type
Definition
AclElement.php:62
Ubiquity\security\acl\models\AclElement\setRole
setRole($role)
Definition
AclElement.php:135
Ubiquity\security\acl\models\AclElement\$permission
$permission
Definition
AclElement.php:45
Ubiquity\security\acl\models\AclElement\$resource
$resource
Definition
AclElement.php:55
Ubiquity\security\acl\models\AclElement\getId_
getId_()
Definition
AclElement.php:169
Ubiquity\security\acl\models\AclElement\$id
$id
@id @column("name"=>"id","nullable"=>false,"dbType"=>"int(11)")
Definition
AclElement.php:25
Ubiquity\security\acl\models\Permission
Ubiquity\security\acl\models$Permission This class is part of Ubiquity.
Definition
Permission.php:12
Ubiquity\security\acl\models\Resource
Ubiquity\security\acl\models$Resource This class is part of Ubiquity.
Definition
Resource.php:12
Ubiquity\security\acl\models\Role
Ubiquity\security\acl\models$Role This class is part of Ubiquity.
Definition
Role.php:12
Ubiquity\security\acl\models
Definition
AbstractAclPart.php:3
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity-acl
src
Ubiquity
security
acl
models
AclElement.php
Generated on Sun Dec 10 2023 15:04:01 for
Ubiquity
by
doxygen
1.9.8