]> BookStack Code Mirror - bookstack/blobdiff - app/Console/Commands/RegeneratePermissions.php
Move logFailedAccess into Activity
[bookstack] / app / Console / Commands / RegeneratePermissions.php
index 966ee4a820841429148a19c3724003492909742b..430b8fcb05fdad572a4f587548d271a230ea8394 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace BookStack\Console\Commands;
 
-use BookStack\Services\PermissionService;
+use BookStack\Auth\Permissions\PermissionService;
 use Illuminate\Console\Command;
 
 class RegeneratePermissions extends Command
@@ -12,7 +12,7 @@ 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.
@@ -31,7 +31,7 @@ class RegeneratePermissions extends Command
     /**
      * Create a new command instance.
      *
-     * @param PermissionService $permissionService
+     * @param \BookStack\Auth\\BookStack\Auth\Permissions\PermissionService $permissionService
      */
     public function __construct(PermissionService $permissionService)
     {
@@ -46,7 +46,15 @@ class RegeneratePermissions extends Command
      */
     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');
     }
 }