namespace BookStack\Console\Commands;
-use BookStack\Services\PermissionService;
+use BookStack\Auth\Permissions\PermissionService;
use Illuminate\Console\Command;
class RegeneratePermissions extends Command
*
* @var string
*/
- protected $signature = 'bookstack:regenerate-permissions';
+ protected $signature = 'bookstack:regenerate-permissions {--database= : The database connection to use.}';
/**
* The console command description.
/**
* Create a new command instance.
*
- * @param PermissionService $permissionService
+ * @param \BookStack\Auth\\BookStack\Auth\Permissions\PermissionService $permissionService
*/
public function __construct(PermissionService $permissionService)
{
*/
public function handle()
{
+ $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');
}
}