-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacl.php
47 lines (41 loc) · 1.45 KB
/
acl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
use Antares\Acl\RoleActionList;
use Antares\Model\Role;
use Antares\Acl\Action;
$actions = [
'Index Action' => 'Default index preview action. Very first page from main menu.',
'Sample crud' => [
'Add Action' => 'Allows user to add action.',
'Update Action' => 'Allows user to update action.',
'Delete Action' => 'Allows user to delete action.'
],
'Items' => [
'Items List' => 'Allows user to preview items list.',
'Item Add' => 'Allows user to add item.',
'Item Update' => 'Allows user to update item.',
'Item Delete' => 'Allows user to delete item.',
]
];
$imports = [];
$descriptions = [];
$categories = [];
foreach ($actions as $index => $action) {
$import = null;
if (is_numeric($index)) {
$imports[] = new Action('', $action);
} elseif (is_string($index) && is_array($action)) {
foreach ($action as $name => $description) {
$imports[] = new Action('', $name);
$descriptions[str_slug($name)] = $description;
$categories[str_slug($name)] = $index;
}
} else {
$imports[] = new Action('', $index);
$descriptions[str_slug($index)] = $action;
}
}
$permissions = new RoleActionList;
$permissions->add(Role::admin()->name, $imports);
$permissions->addDescriptions($descriptions);
$permissions->addCategories($categories);
return $permissions;