Skip to content

Commit

Permalink
FIX Include default_sort in sortChildren method
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jul 25, 2022
1 parent 3605a40 commit b176a49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions code/GraphQL/Resolvers/FolderTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ public static function sortChildren(array $context): Closure
$classNameField = "(CASE WHEN \"ClassName\"={$className} THEN 1 ELSE 0 END)";
$sortArgs = array_merge([$classNameField => 'DESC'], $sortArgs);

// Handle File::$default_sort when it has default value of "\"Name\""
$defaultSort = File::config()->get('default_sort');
if ($defaultSort === "\"Name\"") {
$sortArgs = array_merge($sortArgs, ['Name' => 'ASC']);
}

$sort = [];
foreach ($sortArgs as $field => $dir) {
if ($field == $classNameField) {
Expand Down

0 comments on commit b176a49

Please sign in to comment.