Skip to content

Instantly share code, notes, and snippets.

@alisha
Created July 18, 2018 23:54
Show Gist options
  • Save alisha/b93dce06b8d6c444035e774f0057ffe4 to your computer and use it in GitHub Desktop.
Save alisha/b93dce06b8d6c444035e774f0057ffe4 to your computer and use it in GitHub Desktop.
<?hh
function workspace_prefs_to_db_rows(workspace_t $workspace, array<string, mixed> $prefs): array<db_workspaces_prefs_row_t> {
$pref_rows = [];
foreach ($prefs as $pref_name => $pref_value){
$new_pref = shape(
'workspace_id' => $workspace['id'],
'pref_name' => $pref_name,
'pref_value' => json_encode($pref_value),
);
$pref_rows[] = $new_pref;
}
return $pref_rows;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment