X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/193d7fb3fe71a76a43ebc1ccdb617b4b627d1e09..refs/pull/3918/head:/app/Console/Commands/CopyShelfPermissions.php diff --git a/app/Console/Commands/CopyShelfPermissions.php b/app/Console/Commands/CopyShelfPermissions.php index 32adf0683..ec4c875ff 100644 --- a/app/Console/Commands/CopyShelfPermissions.php +++ b/app/Console/Commands/CopyShelfPermissions.php @@ -3,7 +3,7 @@ namespace BookStack\Console\Commands; use BookStack\Entities\Models\Bookshelf; -use BookStack\Entities\Repos\BookshelfRepo; +use BookStack\Entities\Tools\PermissionsUpdater; use Illuminate\Console\Command; class CopyShelfPermissions extends Command @@ -25,19 +25,16 @@ class CopyShelfPermissions extends Command */ protected $description = 'Copy shelf permissions to all child books'; - /** - * @var BookshelfRepo - */ - protected $bookshelfRepo; + protected PermissionsUpdater $permissionsUpdater; /** * Create a new command instance. * * @return void */ - public function __construct(BookshelfRepo $repo) + public function __construct(PermissionsUpdater $permissionsUpdater) { - $this->bookshelfRepo = $repo; + $this->permissionsUpdater = $permissionsUpdater; parent::__construct(); } @@ -69,18 +66,18 @@ class CopyShelfPermissions extends Command return; } - $shelves = Bookshelf::query()->get(['id', 'restricted']); + $shelves = Bookshelf::query()->get(['id']); } if ($shelfSlug) { - $shelves = Bookshelf::query()->where('slug', '=', $shelfSlug)->get(['id', 'restricted']); + $shelves = Bookshelf::query()->where('slug', '=', $shelfSlug)->get(['id']); if ($shelves->count() === 0) { $this->info('No shelves found with the given slug.'); } } foreach ($shelves as $shelf) { - $this->bookshelfRepo->copyDownPermissions($shelf, false); + $this->permissionsUpdater->updateBookPermissionsFromShelf($shelf, false); $this->info('Copied permissions for shelf [' . $shelf->id . ']'); }