28 if ($this->roles ===
null)
36 $res = RoleRelationTable::query()
37 ->addSelect(
'ROLE_ID')
40 foreach ($res as $row)
42 $this->roles[] = (int) $row[
'ROLE_ID'];
60 $permissions = $this->getPermissions();
61 if (array_key_exists($permissionId, $permissions))
63 return $permissions[$permissionId];
74 private function getPermissions(): array
76 if (!$this->permissions)
78 $this->permissions = [];
83 return $this->permissions;
86 $query = PermissionTable::query();
89 ->addSelect(
"PERMISSION_ID")
91 ->whereIn(
"ROLE_ID",
$roles)
95 foreach ($res as $row)
97 $permissionId = $row[
"PERMISSION_ID"];
98 $value = (int) $row[
"VALUE"];
99 if (!array_key_exists($permissionId, $this->permissions))
101 $this->permissions[$permissionId] = 0;
103 if ($value > $this->permissions[$permissionId])
105 $this->permissions[$permissionId] = $value;
109 return $this->permissions;