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"; return $channel == "0000";
} }
public function callService($serviceName, $funcName) public function _callServiceStatic($serviceName, $funcName, ...$args)
{ {
if (!array_key_exists($serviceName, $this->serviceHash)) { if (!array_key_exists($serviceName, $this->serviceHash)) {
require_once('services/' . $serviceName . '.php'); require_once('services/' . $serviceName . '.php');
$this->serviceHash[$serviceName] = $this->_getNowTime(); $this->serviceHash[$serviceName] = $this->_getNowTime();
} }
$method = new ReflectionMethod($serviceName . 'Service', $funcName); $method = new ReflectionMethod('services\\' . $serviceName, $funcName);
$ret = $method->invoke(null); $ret = $method->invoke(null, ...$args);
return $ret; return $ret;
} }

View File

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