From c281a444f0af37e82a17120f1b8f77671cb54600 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Thu, 8 Aug 2019 23:03:48 +0800 Subject: [PATCH] Allow to enable or disable a plugin via CLI --- app/Console/Commands/DisablePlugin.php | 33 ++++++++++++++++++++++++ app/Console/Commands/EnablePlugin.php | 33 ++++++++++++++++++++++++ app/Console/Kernel.php | 2 ++ resources/misc/changelogs/en/next.md | 2 ++ resources/misc/changelogs/zh_CN/next.md | 2 ++ tests/CommandsTest/DisablePluginTest.php | 16 ++++++++++++ tests/CommandsTest/EnablePluginTest.php | 16 ++++++++++++ 7 files changed, 104 insertions(+) create mode 100644 app/Console/Commands/DisablePlugin.php create mode 100644 app/Console/Commands/EnablePlugin.php create mode 100644 tests/CommandsTest/DisablePluginTest.php create mode 100644 tests/CommandsTest/EnablePluginTest.php diff --git a/app/Console/Commands/DisablePlugin.php b/app/Console/Commands/DisablePlugin.php new file mode 100644 index 00000000..941f6a35 --- /dev/null +++ b/app/Console/Commands/DisablePlugin.php @@ -0,0 +1,33 @@ +disable($this->argument('name')); + } +} diff --git a/app/Console/Commands/EnablePlugin.php b/app/Console/Commands/EnablePlugin.php new file mode 100644 index 00000000..aa7f8c8e --- /dev/null +++ b/app/Console/Commands/EnablePlugin.php @@ -0,0 +1,33 @@ +enable($this->argument('name')); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index cfc6ba4b..a5dbd4f5 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -19,5 +19,7 @@ class Kernel extends ConsoleKernel Commands\MigrateCloset::class, Commands\ExecuteInstallation::class, Commands\RegressLikesField::class, + Commands\EnablePlugin::class, + Commands\DisablePlugin::class, ]; } diff --git a/resources/misc/changelogs/en/next.md b/resources/misc/changelogs/en/next.md index 45c6f9f7..76b6a4a9 100644 --- a/resources/misc/changelogs/en/next.md +++ b/resources/misc/changelogs/en/next.md @@ -1,6 +1,8 @@ ## Added - Plugin system: `config.blade.php` as default config file name. +- Allow to enable a plugin by running `php artisan plugin:enable {name}`. +- Allow to disable a plugin by running `php artisan plugin:disable {name}`. ## Tweaked diff --git a/resources/misc/changelogs/zh_CN/next.md b/resources/misc/changelogs/zh_CN/next.md index 2e5a8f73..3e5042aa 100644 --- a/resources/misc/changelogs/zh_CN/next.md +++ b/resources/misc/changelogs/zh_CN/next.md @@ -1,6 +1,8 @@ ## 新增 - 插件系统:`config.blade.php` 为默认情况下配置视图文件名 +- 支持以 `php artisan plugin:enable {name}` 的方式开启插件 +- 支持以 `php artisan plugin:disable {name}` 的方式关闭插件 ## 调整 diff --git a/tests/CommandsTest/DisablePluginTest.php b/tests/CommandsTest/DisablePluginTest.php new file mode 100644 index 00000000..8883941b --- /dev/null +++ b/tests/CommandsTest/DisablePluginTest.php @@ -0,0 +1,16 @@ +mock(PluginManager::class, function ($mock) { + $mock->shouldReceive('disable')->with('my-plugin')->once(); + }); + $this->artisan('plugin:disable my-plugin'); + } +} diff --git a/tests/CommandsTest/EnablePluginTest.php b/tests/CommandsTest/EnablePluginTest.php new file mode 100644 index 00000000..1423504d --- /dev/null +++ b/tests/CommandsTest/EnablePluginTest.php @@ -0,0 +1,16 @@ +mock(PluginManager::class, function ($mock) { + $mock->shouldReceive('enable')->with('my-plugin')->once(); + }); + $this->artisan('plugin:enable my-plugin'); + } +}