111
This commit is contained in:
+12
-13
@@ -24,15 +24,8 @@ use Server\Events\OnWorkerExit;
|
||||
* @param bool $async_reload
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(public string $service, public ?array $args = [], public bool $async_reload = true)
|
||||
public function __construct(string $service, ?array $args = [], bool $async_reload = true)
|
||||
{
|
||||
if ($this->async_reload !== true) {
|
||||
return;
|
||||
}
|
||||
$pro = di(EventProvider::class);
|
||||
$pro->on(OnWorkerExit::class, function () {
|
||||
di(\Kiri\Di\LocalService::class)->remove($this->service);
|
||||
},0);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +35,20 @@ use Server\Events\OnWorkerExit;
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): bool
|
||||
public static function execute(mixed $params, mixed $class, mixed $method = null): bool
|
||||
{
|
||||
$class = ['class' => $class];
|
||||
if (!empty($this->args)) {
|
||||
$class = array_merge($class, $this->args);
|
||||
if (!empty($params->args)) {
|
||||
$class = array_merge($class, $params->args);
|
||||
}
|
||||
Kiri::set($this->service, $class);
|
||||
return true; // TODO: Change the autogenerated stub
|
||||
if ($params->async_reload !== true) {
|
||||
$pro = di(EventProvider::class);
|
||||
$pro->on(OnWorkerExit::class, function () use ($params) {
|
||||
di(\Kiri\Di\LocalService::class)->remove($params->service);
|
||||
},0);
|
||||
}
|
||||
Kiri::set($params->service, $class);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user