Skip to content

Commit

Permalink
Export Tableset Ksorted (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
dergel authored Sep 7, 2024
1 parent a83ec7a commit b29f954
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion plugins/manager/lib/yform/manager/table/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,28 @@ public static function importTablesets(string $tableset_content): bool
*/
public static function exportTablesets(array $table_names)
{
$recursiveKsort = static function (&$array) use (&$recursiveKsort) {
foreach ($array as &$value) {
if (is_array($value)) {
$recursiveKsort($value);
}
}
ksort($array);
};

$export = [];
foreach ($table_names as $table_name) {
$export_table = rex_yform_manager_table::get($table_name);
$export_fields = [];
foreach ($export_table->getFields() as $field) {
$export_fields[] = array_diff_key($field->toArray(), ['id' => 0]);
}
$export[$export_table['table_name']] = [
$exportFields = [
'table' => array_diff_key($export_table->toArray(), ['id' => 0, 'prio' => 0]),
'fields' => $export_fields,
];
$recursiveKsort($exportFields);
$export[$export_table['table_name']] = $exportFields;
}

return json_encode($export, JSON_PRETTY_PRINT);
Expand Down

0 comments on commit b29f954

Please sign in to comment.