1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Added clone of entity permissions on chapter/book promotion

This commit is contained in:
Dan Brown
2022-06-14 15:55:44 +01:00
parent d676e1e824
commit 90ec40691a
2 changed files with 14 additions and 9 deletions

View File

@@ -16,19 +16,13 @@ class HierarchyTransformer
protected Cloner $cloner;
protected TrashCan $trashCan;
// TODO - Test setting book cover image from API
// Ensure we can update without resetting image accidentally
// Ensure api docs correct.
// TODO - As above but for shelves.
public function transformChapterToBook(Chapter $chapter): Book
{
// TODO - Check permissions before call
// Permissions: edit-chapter, delete-chapter, create-book
$inputData = $this->cloner->entityToInputData($chapter);
$book = $this->bookRepo->create($inputData);
// TODO - Copy permissions
$this->cloner->copyEntityPermissions($chapter, $book);
/** @var Page $page */
foreach ($chapter->pages as $page) {
@@ -48,8 +42,7 @@ class HierarchyTransformer
// Permissions: edit-book, delete-book, create-shelf
$inputData = $this->cloner->entityToInputData($book);
$shelf = $this->shelfRepo->create($inputData, []);
// TODO - Copy permissions?
$this->cloner->copyEntityPermissions($book, $shelf);
$shelfBookSyncData = [];