Allow to enable or disable a plugin via CLI
This commit is contained in:
parent
aa635c16af
commit
c281a444f0
33
app/Console/Commands/DisablePlugin.php
Normal file
33
app/Console/Commands/DisablePlugin.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Services\PluginManager;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class DisablePlugin extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'plugin:disable {name}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Disable a plugin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(PluginManager $plugins)
|
||||||
|
{
|
||||||
|
$plugins->disable($this->argument('name'));
|
||||||
|
}
|
||||||
|
}
|
33
app/Console/Commands/EnablePlugin.php
Normal file
33
app/Console/Commands/EnablePlugin.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Services\PluginManager;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class EnablePlugin extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'plugin:enable {name}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Enable a plugin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(PluginManager $plugins)
|
||||||
|
{
|
||||||
|
$plugins->enable($this->argument('name'));
|
||||||
|
}
|
||||||
|
}
|
@ -19,5 +19,7 @@ class Kernel extends ConsoleKernel
|
|||||||
Commands\MigrateCloset::class,
|
Commands\MigrateCloset::class,
|
||||||
Commands\ExecuteInstallation::class,
|
Commands\ExecuteInstallation::class,
|
||||||
Commands\RegressLikesField::class,
|
Commands\RegressLikesField::class,
|
||||||
|
Commands\EnablePlugin::class,
|
||||||
|
Commands\DisablePlugin::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
## Added
|
## Added
|
||||||
|
|
||||||
- Plugin system: `config.blade.php` as default config file name.
|
- 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
|
## Tweaked
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
## 新增
|
## 新增
|
||||||
|
|
||||||
- 插件系统:`config.blade.php` 为默认情况下配置视图文件名
|
- 插件系统:`config.blade.php` 为默认情况下配置视图文件名
|
||||||
|
- 支持以 `php artisan plugin:enable {name}` 的方式开启插件
|
||||||
|
- 支持以 `php artisan plugin:disable {name}` 的方式关闭插件
|
||||||
|
|
||||||
## 调整
|
## 调整
|
||||||
|
|
||||||
|
16
tests/CommandsTest/DisablePluginTest.php
Normal file
16
tests/CommandsTest/DisablePluginTest.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use App\Services\PluginManager;
|
||||||
|
|
||||||
|
class DisablePluginTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testDisablePlugin()
|
||||||
|
{
|
||||||
|
$this->mock(PluginManager::class, function ($mock) {
|
||||||
|
$mock->shouldReceive('disable')->with('my-plugin')->once();
|
||||||
|
});
|
||||||
|
$this->artisan('plugin:disable my-plugin');
|
||||||
|
}
|
||||||
|
}
|
16
tests/CommandsTest/EnablePluginTest.php
Normal file
16
tests/CommandsTest/EnablePluginTest.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use App\Services\PluginManager;
|
||||||
|
|
||||||
|
class EnablePluginTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testEnablePlugin()
|
||||||
|
{
|
||||||
|
$this->mock(PluginManager::class, function ($mock) {
|
||||||
|
$mock->shouldReceive('enable')->with('my-plugin')->once();
|
||||||
|
});
|
||||||
|
$this->artisan('plugin:enable my-plugin');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user