]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/SiblingFetcher.php
fix deprecated syntax
[bookstack] / app / Entities / Tools / SiblingFetcher.php
index 7b8ac37ad8792429038bb9645355488d4dbcf853..156209fd23e78ef641cb7324d477a1e469c54466 100644 (file)
@@ -14,6 +14,7 @@ class SiblingFetcher
 {
     public function __construct(
         protected EntityQueries $queries,
+        protected ShelfContext $shelfContext,
     ) {
     }
 
@@ -38,17 +39,17 @@ class SiblingFetcher
         // Book
         // Gets just the books in a shelf if shelf is in context
         if ($entity instanceof Book) {
-            $contextShelf = (new ShelfContext())->getContextualShelfForBook($entity);
+            $contextShelf = $this->shelfContext->getContextualShelfForBook($entity);
             if ($contextShelf) {
                 $entities = $contextShelf->visibleBooks()->get();
             } else {
-                $entities = $this->queries->books->visibleForList()->get();
+                $entities = $this->queries->books->visibleForList()->orderBy('name', 'asc')->get();
             }
         }
 
         // Shelf
         if ($entity instanceof Bookshelf) {
-            $entities = $this->queries->shelves->visibleForList()->get();
+            $entities = $this->queries->shelves->visibleForList()->orderBy('name', 'asc')->get();
         }
 
         return $entities;