/** @var Role|int $role */
if ($role !== null &&
is_numeric($role)) { $role =
$this->modelManager->
find(Role::
class,
$role);
$repository =
$this->modelManager->
getRepository(Rule::
class);
$adminRole =
$repository->
findOneBy([ 'roleId' =>
$role->
getId(),
'resourceId' => null,
'privilegeId' => null,
]);
$resourceAdmins =
$this->
getResourceAdminRules($role->
getId());
// The admin property is temporary used to flag the passed role as admin role
if ($adminRole instanceof Rule &&
$adminRole->
getRoleId()) { $role->
setAdmin(1
);
} else { $role->
setAdmin(0
);
} } foreach ($resources as $resource) { $data[] =
$this->
getResourceNode($resource,
$role,
$resourceAdmins);
}