Skip to content

Commit

Permalink
Rewritten visitor to conform to REST standards
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Apr 9, 2024
1 parent 3ac6a87 commit 166c702
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,27 @@ protected function buildPermissionNode(
return;
}

$generator->startHashElement('permissions');
$generator->startList('permissions');

foreach ($permissionRestrictions as $function => $restrictions) {
$generator->startHashElement($function);
$generator->startHashElement('function');
$generator->attribute('name', $function);
foreach ($restrictions as $restrictionKey => $restrictionValue) {
if (is_array($restrictionValue)) {
$generator->startHashElement($restrictionKey . 'List');
$generator->startList($restrictionKey);
foreach ($restrictionValue as $value) {
$generator->valueElement($restrictionKey, $value);
$generator->valueElement('value', $value);
}
$generator->endList($restrictionKey);
} else {
$generator->valueElement($restrictionKey, $restrictionValue);
$generator->endHashElement($restrictionKey . 'List');
} elseif (is_bool($restrictionValue)) {
$generator->valueElement($restrictionKey, $generator->serializeBool($restrictionValue));
}
}
$generator->endHashElement($function);
$generator->endHashElement('function');
}

$generator->endHashElement('permissions');
$generator->endList('permissions');
}
}

0 comments on commit 166c702

Please sign in to comment.