/** * @param \Reflector $element * * @return bool */ protected function checkRoles(\Reflector $element) { // Check if element has @Secured\Role annotation if ($element->hasAnnotation('Secured\\Role')) { $roles = (array) $element->getAnnotation('Secured\\Role'); foreach ($roles as $role) { if ($this->user->isInRole($role)) { return TRUE; } } return FALSE; } return TRUE; }
/** * @param \Reflector * @throws JedenWeb\UnexpectedValueException */ private function checkPermission(\Reflector $element, $message = NULL) { if ($element->hasAnnotation($annotation = 'allowed') || $element->hasAnnotation($annotation = 'Allowed')) { $permission = (array) $element->getAnnotation($annotation); if (isset($permission['message'])) { $message = $permission['message']; unset($permission['message']); } $resource = array_shift($permission) ?: IAuthorizator::ALL; $privilege = array_shift($permission) ?: IAuthorizator::ALL; $this->needAllowed($resource, $privilege, $message); } }