This commit is contained in:
2021-08-31 19:12:57 +08:00
parent 302247866b
commit 7851259003
4 changed files with 127 additions and 16 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace Kiri\Rpc\Annotation;
use Annotation\Attribute;
use Kiri\Kiri;
use Kiri\Rpc\RpcManager;
use ReflectionException;
/**
*
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class RpcProduct extends Attribute
{
/**
* @param string $cmd
* @param string $protocol
*/
public function __construct(public string $cmd, public string $protocol)
{
}
/**
* @param mixed $class
* @param mixed|string $method
* @return mixed
* @throws ReflectionException
*/
public function execute(mixed $class, mixed $method = ''): mixed
{
$class = Kiri::getDi()->get($class);
RpcManager::addCmdHandler($this->cmd, [$class, $method], $this->protocol);
return parent::execute($class, $method); // TODO: Change the autogenerated stub
}
}