+ }
+
+ // Loop through contents of provided map and update entities accordingly
+ foreach ($sortMap as $bookChild) {
+ $priority = $bookChild->sort;
+ $id = intval($bookChild->id);
+ $isPage = $bookChild->type == 'page';
+ $bookId = $defaultBookId;
+ $targetBook = $this->entityRepo->getById('book', $bookChild->book);
+
+ $chapterId = ($isPage && $bookChild->parentChapter === false) ? 0 : intval($bookChild->parentChapter);
+ $model = $this->entityRepo->getById($isPage?'page':'chapter', $id);