I have 10 roles 1->2->3->4->etc every inherits previous
public function getAcl()
{
$config = require PH_APP_PATH . '/config/acl.php';
$roles = [];
$acl = new AclList();
$acl->setDefaultAction(Acl::DENY);
/* @var UsersRoles[] $users_roles */
$users_roles = UsersRoles::query()->orderBy('id')->execute();
foreach ($users_roles as $users_role) {
$roles[$users_role->role] = new Role($users_role->role);
if (!empty($users_role->parent)) {
$acl->addRole($users_role->role, $users_role->parent);
} else {
$acl->addRole($users_role->role);
}
}
foreach ($roles as $role) {
foreach ($config[$role->getName()] as $resource => $action) {
$acl->addResource(new Resource($resource), $action);
$acl->allow($role->getName(), $resource, $action);
}
}
return $acl;
}