src/IPub/Permissions/Access/AnnotationChecker.php 1 location
|
@@ 229-244 (lines=16) @@
|
226 |
|
private function checkRoles($element) : bool |
227 |
|
{ |
228 |
|
// Check if element has @Secured\Role annotation |
229 |
|
if ($element->hasAnnotation('Secured\Role')) { |
230 |
|
$roles = $this->getElementAttribute($element, 'Secured\Role'); |
231 |
|
|
232 |
|
foreach ($roles as $role) { |
233 |
|
// Check if role name is defined |
234 |
|
if ($role === TRUE) { |
235 |
|
continue; |
236 |
|
} |
237 |
|
|
238 |
|
if ($this->user->isInRole($role)) { |
239 |
|
return TRUE; |
240 |
|
} |
241 |
|
} |
242 |
|
|
243 |
|
return FALSE; |
244 |
|
} |
245 |
|
|
246 |
|
return TRUE; |
247 |
|
} |
src/IPub/Permissions/Access/LatteChecker.php 1 location
|
@@ 216-226 (lines=11) @@
|
213 |
|
protected function checkRoles(Utils\ArrayHash $element) : bool |
214 |
|
{ |
215 |
|
// Check if element has role parameter |
216 |
|
if ($element->offsetExists('role')) { |
217 |
|
$roles = (array) $element->offsetGet('role'); |
218 |
|
|
219 |
|
foreach ($roles as $role) { |
220 |
|
if ($this->user->isInRole($role)) { |
221 |
|
return TRUE; |
222 |
|
} |
223 |
|
} |
224 |
|
|
225 |
|
return FALSE; |
226 |
|
} |
227 |
|
|
228 |
|
return TRUE; |
229 |
|
} |