Do not mutate the result of Permission->getChildren()

This commit is contained in:
Dylan K. Taylor 2020-11-27 20:28:36 +00:00
parent f0e43a6b22
commit 3849756993
2 changed files with 6 additions and 1 deletions

View File

@ -28,7 +28,7 @@ abstract class DefaultPermissions{
public static function registerPermission(Permission $perm, ?Permission $parent = null) : Permission{
if($parent instanceof Permission){
$parent->getChildren()[$perm->getName()] = true;
$parent->addChild($perm->getName(), true);
}
PermissionManager::getInstance()->addPermission($perm);

View File

@ -116,4 +116,9 @@ class Permission{
$p->recalculatePermissions();
}
}
public function addChild(string $name, bool $value) : void{
$this->children[$name] = $value;
$this->recalculatePermissibles();
}
}