From 8d29e575af8313385ad55210da432c71f3b93377 Mon Sep 17 00:00:00 2001 From: Jan Kristinus Date: Sat, 7 Sep 2024 14:24:35 +0200 Subject: [PATCH] Export Tableset Ksorted --- plugins/manager/lib/yform/manager/table/api.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/manager/lib/yform/manager/table/api.php b/plugins/manager/lib/yform/manager/table/api.php index 26c27fe2..472c3990 100644 --- a/plugins/manager/lib/yform/manager/table/api.php +++ b/plugins/manager/lib/yform/manager/table/api.php @@ -117,6 +117,15 @@ 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); @@ -124,10 +133,12 @@ public static function exportTablesets(array $table_names) 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);