Skip to content

Commit 70dfbc6

Browse files
committed
close #12
1 parent 577f0e0 commit 70dfbc6

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use GuzzleHttp\Handler\MockHandler;
1717
use Workbunny\WebmanNacos\Exception\NacosException;
18+
use Workbunny\WebmanNacos\Exception\PluginDisableException;
1819
use Workbunny\WebmanNacos\Provider\ConfigProvider;
1920
use Workbunny\WebmanNacos\Provider\InstanceProvider;
2021
use Workbunny\WebmanNacos\Provider\OperatorProvider;
@@ -69,6 +70,10 @@ class Client
6970
*/
7071
public static function channel(string $name = 'default'): Client
7172
{
73+
// 如果插件关闭,则抛出一个特定异常
74+
if (!config('plugin.workbunny.webman-nacos.app.enable', true)) {
75+
throw new PluginDisableException();
76+
}
7277
$channel = config('plugin.workbunny.webman-nacos.channel', []);
7378
if(empty($config = $channel[$name] ?? [])){
7479
throw new NacosException("Channel config $name is invalid.");
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* This file is part of workbunny.
4+
*
5+
* Redistributions of files must retain the above copyright notice.
6+
*
7+
* @author chaz6chez<chaz6chez1993@outlook.com>
8+
* @copyright chaz6chez<chaz6chez1993@outlook.com>
9+
* @link https://github.com/workbunny/webman-nacos
10+
* @license https://github.com/workbunny/webman-nacos/blob/main/LICENSE
11+
*/
12+
declare(strict_types=1);
13+
14+
namespace Workbunny\WebmanNacos\Exception;
15+
16+
class PluginDisableException extends \RuntimeException
17+
{
18+
}

0 commit comments

Comments
 (0)