mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 11:48:08 +08:00
Merge branch 'master' of github.com:hyperf-cloud/hyperf
This commit is contained in:
commit
5c67767027
@ -12,6 +12,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Hyperf\JsonRpc;
|
||||
|
||||
use Hyperf\JsonRpc\Listener\RegisterProtocolListener;
|
||||
use Hyperf\JsonRpc\Listener\RegisterServiceListener;
|
||||
use Hyperf\ServiceGovernance\ServiceManager;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
public function __invoke(): array
|
||||
@ -23,6 +27,15 @@ class ConfigProvider
|
||||
],
|
||||
'commands' => [
|
||||
],
|
||||
'listeners' => [
|
||||
RegisterProtocolListener::class,
|
||||
value(function () {
|
||||
if (class_exists(ServiceManager::class)) {
|
||||
return RegisterServiceListener::class;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
],
|
||||
'scan' => [
|
||||
'paths' => [
|
||||
__DIR__,
|
||||
|
@ -12,10 +12,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Hyperf\JsonRpc\Listener;
|
||||
|
||||
use Hyperf\Event\Annotation\Listener;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\Framework\Event\BeforeServerStart;
|
||||
use Hyperf\Framework\Event\BeforeWorkerStart;
|
||||
use Hyperf\Framework\Event\BootApplication;
|
||||
use Hyperf\JsonRpc\DataFormatter;
|
||||
use Hyperf\JsonRpc\JsonRpcHttpTransporter;
|
||||
use Hyperf\JsonRpc\JsonRpcTransporter;
|
||||
@ -23,9 +22,6 @@ use Hyperf\JsonRpc\PathGenerator;
|
||||
use Hyperf\Rpc\ProtocolManager;
|
||||
use Hyperf\Utils\Packer\JsonPacker;
|
||||
|
||||
/**
|
||||
* @Listener
|
||||
*/
|
||||
class RegisterProtocolListener implements ListenerInterface
|
||||
{
|
||||
/**
|
||||
@ -41,7 +37,7 @@ class RegisterProtocolListener implements ListenerInterface
|
||||
public function listen(): array
|
||||
{
|
||||
return [
|
||||
BeforeServerStart::class,
|
||||
BootApplication::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Hyperf\JsonRpc\Listener;
|
||||
|
||||
use Hyperf\Event\Annotation\Listener;
|
||||
use Hyperf\Event\Contract\ListenerInterface;
|
||||
use Hyperf\RpcServer\Event\AfterPathRegister;
|
||||
use Hyperf\ServiceGovernance\ServiceManager;
|
||||
|
||||
/**
|
||||
* @Listener
|
||||
*/
|
||||
class RegisterServiceListener implements ListenerInterface
|
||||
{
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class ProtocolManager
|
||||
{
|
||||
$result = $this->config->get('protocols.' . Str::lower($name) . '.' . Str::lower($target));
|
||||
if (! is_string($result)) {
|
||||
throw new InvalidArgumentException(sprintf('Data Formatter %s is not exists.', Str::studly($target, ' ')));
|
||||
throw new InvalidArgumentException(sprintf('%s is not exists.', Str::studly($target, ' ')));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user