X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d3ca23b195cf2484ac5eaeea0b0e8cb4ca0aad48..refs/pull/3616/head:/app/Entities/Tools/BookContents.php diff --git a/app/Entities/Tools/BookContents.php b/app/Entities/Tools/BookContents.php index 99602de41..6f11e8cbe 100644 --- a/app/Entities/Tools/BookContents.php +++ b/app/Entities/Tools/BookContents.php @@ -119,9 +119,10 @@ class BookContents // Sort our changes from our map to be chapters first // Since they need to be process to ensure book alignment for child page changes. $sortMapItems = $sortMap->all(); - usort($sortMapItems, function(BookSortMapItem $itemA, BookSortMapItem $itemB) { + usort($sortMapItems, function (BookSortMapItem $itemA, BookSortMapItem $itemB) { $aScore = $itemA->type === 'page' ? 2 : 1; $bScore = $itemB->type === 'page' ? 2 : 1; + return $aScore - $bScore; }); @@ -167,9 +168,9 @@ class BookContents return; } - $currentParentKey = 'book:' . $model->book_id; + $currentParentKey = 'book:' . $model->book_id; if ($model instanceof Page && $model->chapter_id) { - $currentParentKey = 'chapter:' . $model->chapter_id; + $currentParentKey = 'chapter:' . $model->chapter_id; } $currentParent = $modelMap[$currentParentKey] ?? null; @@ -265,6 +266,7 @@ class BookContents /** * Load models from the database into the given sort map. + * * @return array */ protected function loadModelsFromSortMap(BookSortMap $sortMap): array @@ -272,8 +274,8 @@ class BookContents $modelMap = []; $ids = [ 'chapter' => [], - 'page' => [], - 'book' => [], + 'page' => [], + 'book' => [], ]; foreach ($sortMap->all() as $sortMapItem) {