namespace BookStack\Entities\Tools;
-use BookStack\Actions\ActivityType;
+use BookStack\Activity\ActivityType;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
class HierarchyTransformer
{
- protected BookRepo $bookRepo;
- protected BookshelfRepo $shelfRepo;
- protected Cloner $cloner;
- protected TrashCan $trashCan;
-
- public function __construct(BookRepo $bookRepo, BookshelfRepo $shelfRepo, Cloner $cloner, TrashCan $trashCan)
- {
- $this->bookRepo = $bookRepo;
- $this->shelfRepo = $shelfRepo;
- $this->cloner = $cloner;
- $this->trashCan = $trashCan;
+ public function __construct(
+ protected BookRepo $bookRepo,
+ protected BookshelfRepo $shelfRepo,
+ protected Cloner $cloner,
+ protected TrashCan $trashCan
+ ) {
}
/**
$this->trashCan->destroyEntity($chapter);
Activity::add(ActivityType::BOOK_CREATE_FROM_CHAPTER, $book);
+
return $book;
}
foreach ($book->chapters as $index => $chapter) {
$newBook = $this->transformChapterToBook($chapter);
$shelfBookSyncData[$newBook->id] = ['order' => $index];
- if (!$newBook->restricted) {
+ if (!$newBook->hasPermissions()) {
$this->cloner->copyEntityPermissions($shelf, $newBook);
}
}
$shelf->books()->sync($shelfBookSyncData);
Activity::add(ActivityType::BOOKSHELF_CREATE_FROM_BOOK, $shelf);
+
return $shelf;
}
-}
\ No newline at end of file
+}