Skip to content

Commit 5da2c46

Browse files
committed
update extractPermissions
1 parent fde0de3 commit 5da2c46

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/SDK/Language.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,30 @@ public function extractPermissionParts(string $string): array
151151

152152
$result = [];
153153
foreach ($matches as $match) {
154+
$action = $match[1];
155+
$roleString = $match[2];
156+
157+
$role = null;
158+
$id = null;
159+
$innerRole = null;
160+
161+
if (strpos($roleString, ':') !== false) {
162+
$role = explode(':', $roleString, 2)[0];
163+
$idString = explode(':', $roleString, 2)[1];
164+
165+
if (strpos($idString, '/') !== false) {
166+
$id = explode('/', $idString, 2)[0];
167+
$innerRole = explode('/', $idString, 2)[1];
168+
}
169+
} else {
170+
$role = $roleString;
171+
}
172+
154173
$result[] = [
155-
'action' => $match[1],
156-
'role' => $match[2]
174+
'action' => $action,
175+
'role' => $role,
176+
'id' => $id ?? null,
177+
'innerRole' => $innerRole
157178
];
158179
}
159180

0 commit comments

Comments
 (0)