X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ada7c83e96f35a6b484869d6d27939555e1942f7..refs/pull/261/head:/app/Console/Commands/RegeneratePermissions.php diff --git a/app/Console/Commands/RegeneratePermissions.php b/app/Console/Commands/RegeneratePermissions.php index bd221c138..9cd577a17 100644 --- a/app/Console/Commands/RegeneratePermissions.php +++ b/app/Console/Commands/RegeneratePermissions.php @@ -2,7 +2,7 @@ namespace BookStack\Console\Commands; -use BookStack\Services\RestrictionService; +use BookStack\Services\PermissionService; use Illuminate\Console\Command; class RegeneratePermissions extends Command @@ -12,7 +12,7 @@ class RegeneratePermissions extends Command * * @var string */ - protected $signature = 'permissions:regen'; + protected $signature = 'bookstack:regenerate-permissions {--database= : The database connection to use.}'; /** * The console command description. @@ -24,18 +24,18 @@ class RegeneratePermissions extends Command /** * The service to handle the permission system. * - * @var RestrictionService + * @var PermissionService */ - protected $restrictionService; + protected $permissionService; /** * Create a new command instance. * - * @param RestrictionService $restrictionService + * @param PermissionService $permissionService */ - public function __construct(RestrictionService $restrictionService) + public function __construct(PermissionService $permissionService) { - $this->restrictionService = $restrictionService; + $this->permissionService = $permissionService; parent::__construct(); } @@ -46,6 +46,15 @@ class RegeneratePermissions extends Command */ public function handle() { - $this->restrictionService->buildEntityPermissions(); + $connection = \DB::getDefaultConnection(); + if ($this->option('database') !== null) { + \DB::setDefaultConnection($this->option('database')); + $this->permissionService->setConnection(\DB::connection($this->option('database'))); + } + + $this->permissionService->buildJointPermissions(); + + \DB::setDefaultConnection($connection); + $this->comment('Permissions regenerated'); } }