0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-05 08:40:11 +00:00

Tweaked custom command registration, Added StyleCI fixes

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.
This commit is contained in:
Dan Brown 2021-11-22 22:22:31 +00:00
parent c6e196989e
commit 1bf59f434b
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
5 changed files with 16 additions and 10 deletions

View file

@ -64,7 +64,7 @@ class ExternalBaseUserProvider implements UserProvider
* Update the "remember me" token for the given user in storage. * Update the "remember me" token for the given user in storage.
* *
* @param Authenticatable $user * @param Authenticatable $user
* @param string $token * @param string $token
* *
* @return void * @return void
*/ */
@ -94,7 +94,7 @@ class ExternalBaseUserProvider implements UserProvider
* Validate a user against the given credentials. * Validate a user against the given credentials.
* *
* @param Authenticatable $user * @param Authenticatable $user
* @param array $credentials * @param array $credentials
* *
* @return bool * @return bool
*/ */

View 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. * Check if this instance or class is a certain type of entity.
* Examples of $type are 'page', 'book', 'chapter'. * Examples of $type are 'page', 'book', 'chapter'.
*
* @deprecated Use instanceof instead. * @deprecated Use instanceof instead.
*/ */
public static function isA(string $type): bool public static function isA(string $type): bool

View file

@ -11,4 +11,4 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
interface Deletable interface Deletable
{ {
public function deletions(): MorphMany; public function deletions(): MorphMany;
} }

View file

@ -3,6 +3,8 @@
namespace BookStack\Theming; namespace BookStack\Theming;
use BookStack\Auth\Access\SocialAuthService; use BookStack\Auth\Access\SocialAuthService;
use Illuminate\Console\Application;
use Illuminate\Console\Application as Artisan;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
@ -50,9 +52,9 @@ class ThemeService
*/ */
public function registerCommand(Command $command) public function registerCommand(Command $command)
{ {
/** @var \Illuminate\Foundation\Console\Kernel $consoleKernel */ Artisan::starting(function(Application $application) use ($command) {
$consoleKernel = app()->make(Kernel::class); $application->addCommands([$command]);
$consoleKernel->registerCommand($command); });
} }
/** /**

View file

@ -210,7 +210,7 @@ class ThemeTest extends TestCase
public function test_register_command_allows_provided_command_to_be_usable_via_artisan() 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', []); Artisan::call('bookstack:test-custom-command', []);
$output = Artisan::output(); $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'; protected $signature = 'bookstack:test-custom-command';
public function handle() {
public function handle()
{
$this->line('Command ran!'); $this->line('Command ran!');
} }
} }