Skip to content

Commit

Permalink
Update api.php
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w committed Jun 21, 2024
1 parent 0b70aa2 commit 1f176c5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions plugins/manager/lib/yform/manager/table/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ public static function importTablesets(string $tableset_content): bool
*/
public static function exportTablesets(array $table_names)
{
$recursiveKsort = 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);
Expand All @@ -130,17 +137,8 @@ public static function exportTablesets(array $table_names)
];
}

return json_encode(self::recursive_ksort($export), JSON_PRETTY_PRINT);
}
/**
* @param array $array
* @return array
*/
public static function recursive_ksort(&$array) {
foreach ($array as &$value) {
if (is_array($value)) recursive_ksort($value);
}
return ksort($array);
$recursiveKsort($export);
return json_encode($export, JSON_PRETTY_PRINT);
}

/**
Expand Down

0 comments on commit 1f176c5

Please sign in to comment.