]> BookStack Code Mirror - hacks/commitdiff
Updated autosort tagged books hack
authorDan Brown <redacted>
Fri, 12 Jul 2024 14:01:51 +0000 (15:01 +0100)
committerDan Brown <redacted>
Fri, 12 Jul 2024 14:01:51 +0000 (15:01 +0100)
Upon request via hack update service

content/autosort-tagged-books/functions.php
content/autosort-tagged-books/index.md

index 11375693d930243241a8fbd81a0800a8c9bbc831..df5ec7cb5b729d566c772288d3f4d4341e1f4256 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-use BookStack\Actions\ActivityType;
+use BookStack\Activity\ActivityType;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
@@ -11,7 +11,7 @@ use BookStack\Theming\ThemeEvents;
  * Auto-sort the contents of the given book.
  * This sorts in name order, ascending, with chapters first.
  */
-function autoSortBook(Book $book) {
+function autoSortBook(Book $book): void {
     $chapters = $book->chapters()->orderBy('name', 'asc')->get(['id', 'priority']);
     $pages = $book->pages()->orderBy('name', 'asc')
         ->where('draft', '=', false)
@@ -51,5 +51,4 @@ Theme::listen(ThemeEvents::ACTIVITY_LOGGED, function (string $type, $detail) {
             autoSortBook($detail->book);
         }
     }
-
-});
\ No newline at end of file
+});
index 6feb2da9fd7e654a0c7d19202328d7efb659b6fd..c7d487471842e4a35040f2e416c3933e96607dd1 100644 (file)
@@ -2,11 +2,10 @@
 title = "Autosort Tagged Books"
 author = "@ssddanbrown"
 date = 2023-01-23T20:00:00Z
-updated = 2023-01-23T20:00:00Z
-tested = "v22.11.1"
+updated = 2024-07-12T14:00:00Z
+tested = "v24.05.2"
 +++
 
-
 This is a hack to BookStack to enable auto-sorting of book chapters and pages upon page or chapter create/update. It sorts by name, ascending, with chapters first. By default it will run for any book with an `Autosort` tag assigned.
 
 #### Options