This commit is contained in:
aozhiwei 2024-07-31 19:06:53 +08:00
parent 658603e0a0
commit 559c18cd98
2 changed files with 6 additions and 7 deletions

View File

@ -276,14 +276,14 @@ class BaseController {
return $channel == "0000";
}
public function callService($serviceName, $funcName)
public function _callServiceStatic($serviceName, $funcName, ...$args)
{
if (!array_key_exists($serviceName, $this->serviceHash)) {
require_once('services/' . $serviceName . '.php');
$this->serviceHash[$serviceName] = $this->_getNowTime();
}
$method = new ReflectionMethod($serviceName . 'Service', $funcName);
$ret = $method->invoke(null);
$method = new ReflectionMethod('services\\' . $serviceName, $funcName);
$ret = $method->invoke(null, ...$args);
return $ret;
}

View File

@ -1,7 +1,5 @@
<?php
require_once('services/NoticeService.php');
class UnitTestController extends BaseAuthedController {
public function _handlePre()
@ -35,10 +33,11 @@ class UnitTestController extends BaseAuthedController {
return;
}
services\NoticeService::send($content, $loop, $interval);
myself()->_callServiceStatic('NoticeService', 'send', $content, $loop, $interval);
//services\NoticeService::send($content, $loop, $interval);
} catch (Exception $e){
error_log($e);
}
}
}