]> BookStack Code Mirror - bookstack/commitdiff
Tweaked custom command registration, Added StyleCI fixes
authorDan Brown <redacted>
Mon, 22 Nov 2021 22:22:31 +0000 (22:22 +0000)
committerDan Brown <redacted>
Mon, 22 Nov 2021 22:22:31 +0000 (22:22 +0000)
Old command registration method was interfering with default commands,
causing only a limited subset of commands to show overall.
This change follows the method the frameworks uses when loading in from a
directory to prevent issues with run/load order.

app/Auth/Access/ExternalBaseUserProvider.php
app/Entities/Models/Entity.php
app/Interfaces/Deletable.php
app/Theming/ThemeService.php
tests/ThemeTest.php

index dc765ddc53a587dd399f70f7cf27ac12eae386c7..122425c1157f33618049b550ca51169a9c9eef98 100644 (file)
@@ -64,7 +64,7 @@ class ExternalBaseUserProvider implements UserProvider
      * Update the "remember me" token for the given user in storage.
      *
      * @param Authenticatable $user
-     * @param string                                     $token
+     * @param string          $token
      *
      * @return void
      */
@@ -94,7 +94,7 @@ class ExternalBaseUserProvider implements UserProvider
      * Validate a user against the given credentials.
      *
      * @param Authenticatable $user
-     * @param array                                      $credentials
+     * @param array           $credentials
      *
      * @return bool
      */
index eccec40b592e829f0573756c7de06cff50e2dbc1..2b6f85d24ceff1f9b5b05954bbbe52c820bf8590 100644 (file)
@@ -211,6 +211,7 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable
     /**
      * Check if this instance or class is a certain type of entity.
      * Examples of $type are 'page', 'book', 'chapter'.
+     *
      * @deprecated Use instanceof instead.
      */
     public static function isA(string $type): bool
index ca59e04f355473b218f2108ad6550556a6c500b5..be9b4ac418fc715d2ae57d8e9d913df77900145a 100644 (file)
@@ -11,4 +11,4 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
 interface Deletable
 {
     public function deletions(): MorphMany;
-}
\ No newline at end of file
+}
index f0f8f033c4d9c4542259906835cb1bf98d4651a3..7bc12c5d1561f5e1463b8ff52dea935b7b78e0e4 100644 (file)
@@ -3,6 +3,8 @@
 namespace BookStack\Theming;
 
 use BookStack\Auth\Access\SocialAuthService;
+use Illuminate\Console\Application;
+use Illuminate\Console\Application as Artisan;
 use Illuminate\Contracts\Console\Kernel;
 use Symfony\Component\Console\Command\Command;
 
@@ -50,9 +52,9 @@ class ThemeService
      */
     public function registerCommand(Command $command)
     {
-        /** @var \Illuminate\Foundation\Console\Kernel $consoleKernel */
-        $consoleKernel = app()->make(Kernel::class);
-        $consoleKernel->registerCommand($command);
+        Artisan::starting(function(Application $application) use ($command) {
+            $application->addCommands([$command]);
+        });
     }
 
     /**
index f04250bff57a2719e2cfa6d51df6b182f9ba8f15..364bf6900517e65a7e727bb80613fb7e0b61d3ad 100644 (file)
@@ -210,7 +210,7 @@ class ThemeTest extends TestCase
 
     public function test_register_command_allows_provided_command_to_be_usable_via_artisan()
     {
-        Theme::registerCommand(new MyCustomCommand);
+        Theme::registerCommand(new MyCustomCommand());
 
         Artisan::call('bookstack:test-custom-command', []);
         $output = Artisan::output();
@@ -233,9 +233,12 @@ class ThemeTest extends TestCase
     }
 }
 
-class MyCustomCommand extends Command {
+class MyCustomCommand extends Command
+{
     protected $signature = 'bookstack:test-custom-command';
-    public function handle() {
+
+    public function handle()
+    {
         $this->line('Command ran!');
     }
-}
\ No newline at end of file
+}