X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c157dc3490c39aa236e22714019a649ebeb11f13..refs/pull/2484/head:/app/Http/Controllers/BookController.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 5a42daddb..3d695ba85 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -2,9 +2,10 @@ use Activity; use BookStack\Actions\ActivityType; -use BookStack\Entities\Managers\BookContents; -use BookStack\Entities\Bookshelf; -use BookStack\Entities\Managers\EntityContext; +use BookStack\Entities\Tools\BookContents; +use BookStack\Entities\Models\Bookshelf; +use BookStack\Entities\Tools\PermissionsUpdater; +use BookStack\Entities\Tools\ShelfContext; use BookStack\Entities\Repos\BookRepo; use BookStack\Exceptions\ImageUploadException; use Illuminate\Http\Request; @@ -18,11 +19,10 @@ class BookController extends Controller protected $bookRepo; protected $entityContextManager; - public function __construct(EntityContext $entityContextManager, BookRepo $bookRepo) + public function __construct(ShelfContext $entityContextManager, BookRepo $bookRepo) { $this->bookRepo = $bookRepo; $this->entityContextManager = $entityContextManager; - parent::__construct(); } /** @@ -97,7 +97,7 @@ class BookController extends Controller if ($bookshelf) { $bookshelf->appendBook($book); - Activity::add($bookshelf, ActivityType::BOOKSHELF_UPDATE); + Activity::addForEntity($bookshelf, ActivityType::BOOKSHELF_UPDATE); } return redirect($book->getUrl()); @@ -203,14 +203,12 @@ class BookController extends Controller * Set the restrictions for this book. * @throws Throwable */ - public function permissions(Request $request, string $bookSlug) + public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug) { $book = $this->bookRepo->getBySlug($bookSlug); $this->checkOwnablePermission('restrictions-manage', $book); - $restricted = $request->get('restricted') === 'true'; - $permissions = $request->filled('restrictions') ? collect($request->get('restrictions')) : null; - $this->bookRepo->updatePermissions($book, $restricted, $permissions); + $permissionsUpdater->updateFromPermissionsForm($book, $request); $this->showSuccessNotification(trans('entities.books_permissions_updated')); return redirect($book->getUrl());