1 | <?php |
||
23 | 1 | class Role implements IRole |
|
24 | { |
||
25 | /** |
||
26 | * Implement nette smart magic |
||
27 | */ |
||
28 | 1 | use Nette\SmartObject; |
|
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $id; |
||
34 | |||
35 | /** |
||
36 | * @var IRole|NULL |
||
37 | */ |
||
38 | protected $parent; |
||
39 | |||
40 | /** |
||
41 | * @var \SplObjectStorage |
||
42 | */ |
||
43 | protected $children; |
||
44 | |||
45 | /** |
||
46 | * @var string|NULL |
||
47 | */ |
||
48 | protected $name; |
||
49 | |||
50 | /** |
||
51 | * @var string|NULL |
||
52 | */ |
||
53 | protected $comment; |
||
54 | |||
55 | /** |
||
56 | * @var \SplObjectStorage |
||
57 | */ |
||
58 | protected $permissions; |
||
59 | |||
60 | /** |
||
61 | * @param string $id |
||
62 | * @param string|NULL $name |
||
63 | * @param string|NULL $comment |
||
64 | */ |
||
65 | public function __construct(string $id, ?string $name = NULL, ?string $comment = NULL) |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | public function setParent(IRole $parent = NULL) : void |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | public function getParent() : ?IRole |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | public function setChildren(array $roles) : void |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | public function addChild(IRole $role) : void |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function getChildren() : array |
||
143 | |||
144 | /** |
||
145 | * {@inheritdoc} |
||
146 | */ |
||
147 | public function getRoleId() : string |
||
151 | |||
152 | /** |
||
153 | * {@inheritdoc} |
||
154 | */ |
||
155 | public function setName(string $name) : void |
||
159 | |||
160 | /** |
||
161 | * {@inheritdoc} |
||
162 | */ |
||
163 | public function getName() : ?string |
||
167 | |||
168 | /** |
||
169 | * {@inheritdoc} |
||
170 | */ |
||
171 | public function setComment(?string $comment) : void |
||
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | public function getComment() : ?string |
||
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | public function setPermissions(array $permissions) : void |
||
197 | |||
198 | /** |
||
199 | * {@inheritdoc} |
||
200 | */ |
||
201 | public function addPermission(IPermission $permission) : void |
||
207 | |||
208 | /** |
||
209 | * {@inheritdoc} |
||
210 | */ |
||
211 | public function getPermissions() : array |
||
225 | |||
226 | /** |
||
227 | * {@inheritdoc} |
||
228 | */ |
||
229 | public function hasPermission(IPermission $permission) : bool |
||
233 | |||
234 | /** |
||
235 | * {@inheritdoc} |
||
236 | */ |
||
237 | public function removePermission(IPermission $permission) : void |
||
245 | |||
246 | /** |
||
247 | * {@inheritdoc} |
||
248 | */ |
||
249 | public function clearPermissions() : void |
||
253 | |||
254 | /** |
||
255 | * {@inheritdoc} |
||
256 | */ |
||
257 | public function isLocked() : bool |
||
261 | |||
262 | /** |
||
263 | * {@inheritdoc} |
||
264 | */ |
||
265 | public function isAnonymous() : bool |
||
269 | |||
270 | /** |
||
271 | * {@inheritdoc} |
||
272 | */ |
||
273 | public function isAuthenticated() : bool |
||
277 | |||
278 | /** |
||
279 | * {@inheritdoc} |
||
280 | */ |
||
281 | public function isAdministrator() : bool |
||
285 | |||
286 | /** |
||
287 | * Convert role object to string |
||
288 | * |
||
289 | * @return string |
||
290 | */ |
||
291 | public function __toString() |
||
295 | } |
||
296 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: