This commit is contained in:
2021-08-13 15:19:07 +08:00
parent 3198d66753
commit 62145acb8c
11 changed files with 13 additions and 14 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ use Kiri\Events\EventProvider;
public function execute(mixed $class, mixed $method = null): bool public function execute(mixed $class, mixed $method = null): bool
{ {
$pro = di(EventProvider::class); $pro = di(EventProvider::class);
$pro->on($this->name, [$class, $method]); $pro->on($this->name, [di($class), $method]);
return true; return true;
} }
+1
View File
@@ -74,6 +74,7 @@ use Kiri\Kiri;
* @param $class * @param $class
* @param $method * @param $method
* @return ReflectionProperty|bool * @return ReflectionProperty|bool
* @throws ReflectionException
*/ */
private function getProperty($class, $method): ReflectionProperty|bool private function getProperty($class, $method): ReflectionProperty|bool
{ {
+1 -2
View File
@@ -45,11 +45,10 @@ use Server\Events\OnWorkerExit;
*/ */
public function execute(mixed $class, mixed $method = null): bool public function execute(mixed $class, mixed $method = null): bool
{ {
$class = ['class' => $class::class]; $class = ['class' => $class];
if (!empty($this->args)) { if (!empty($this->args)) {
$class = array_merge($class, $this->args); $class = array_merge($class, $this->args);
} }
Kiri::set($this->service, $class); Kiri::set($this->service, $class);
return true; // TODO: Change the autogenerated stub return true; // TODO: Change the autogenerated stub
} }
+1 -1
View File
@@ -35,7 +35,7 @@ use Kiri\Kiri;
public function execute(mixed $class, mixed $method = null): bool public function execute(mixed $class, mixed $method = null): bool
{ {
$annotation = Kiri::getAnnotation(); $annotation = Kiri::getAnnotation();
$annotation->addGets($class::class, $this->name, $method); $annotation->addGets($class, $this->name, $method);
return true; return true;
} }
+1 -1
View File
@@ -37,7 +37,7 @@ use Kiri\Kiri;
public function execute(mixed $class, mixed $method = null): bool public function execute(mixed $class, mixed $method = null): bool
{ {
$annotation = Kiri::getAnnotation(); $annotation = Kiri::getAnnotation();
$annotation->addRelate($class::class, $this->name, $method); $annotation->addRelate($class, $this->name, $method);
return true; return true;
} }
+1 -1
View File
@@ -31,7 +31,7 @@ use Kiri\Kiri;
public function execute(mixed $class, mixed $method = null): bool public function execute(mixed $class, mixed $method = null): bool
{ {
$annotation = Kiri::getAnnotation(); $annotation = Kiri::getAnnotation();
$annotation->addSets($class::class, $this->name, $method); $annotation->addSets($class, $this->name, $method);
return true; return true;
} }
+1 -1
View File
@@ -37,7 +37,7 @@ use Kiri\Kiri;
{ {
// TODO: Implement setHandler() method. // TODO: Implement setHandler() method.
$router = Kiri::app()->getRouter(); $router = Kiri::app()->getRouter();
$router->addRoute($this->uri, [$class, $method], $this->method); $router->addRoute($this->uri, [di($class::class), $method], $this->method);
return $router; return $router;
} }
+1 -1
View File
@@ -44,7 +44,7 @@ use Kiri\Kiri;
$path = $this->event . '::' . (is_null($this->uri) ? 'event' : $this->uri); $path = $this->event . '::' . (is_null($this->uri) ? 'event' : $this->uri);
$router->addRoute($path, [$class, $method], 'sw::socket'); $router->addRoute($path, [di($class), $method], 'sw::socket');
return $router; return $router;
} }
+1 -1
View File
@@ -27,7 +27,7 @@ class KafkaProvider extends BaseObject
if (isset($this->_topics[$topic])) { if (isset($this->_topics[$topic])) {
return; return;
} }
$this->_topics[$topic] = $handler::class; $this->_topics[$topic] = $handler;
} }
+2 -3
View File
@@ -71,9 +71,8 @@ class OnServerWorker extends \Server\Abstracts\Server
$fileLists = $annotation->runtime(APP_PATH . 'app'); $fileLists = $annotation->runtime(APP_PATH . 'app');
$di = Kiri::getDi(); $di = Kiri::getDi();
foreach ($fileLists as $class) { foreach ($fileLists as $class) {
$instance = $di->get($class);
foreach ($di->getTargetNote($class) as $value) { foreach ($di->getTargetNote($class) as $value) {
$value->execute($instance); $value->execute($class);
} }
$methods = $di->getMethodAttribute($class); $methods = $di->getMethodAttribute($class);
foreach ($methods as $method => $attribute) { foreach ($methods as $method => $attribute) {
@@ -81,7 +80,7 @@ class OnServerWorker extends \Server\Abstracts\Server
continue; continue;
} }
foreach ($attribute as $item) { foreach ($attribute as $item) {
$item->execute($instance, $method); $item->execute($class, $method);
} }
} }
} }
+2 -2
View File
@@ -24,9 +24,9 @@ class Async extends Component
/** /**
* @param string $name * @param string $name
* @param TaskExecute $handler * @param TaskExecute|string $handler
*/ */
public function addAsync(string $name, TaskExecute $handler) public function addAsync(string $name, TaskExecute|string $handler)
{ {
static::$_absences[$name] = $handler::class; static::$_absences[$name] = $handler::class;
} }