mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 23:55:35 +08:00
Normalization of Context class
This commit is contained in:
@@ -6,6 +6,7 @@ namespace ZM\Event\Swoole;
|
||||
|
||||
use Co;
|
||||
use Doctrine\Common\Annotations\AnnotationException;
|
||||
use Exception;
|
||||
use ReflectionException;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Timer;
|
||||
@@ -14,6 +15,7 @@ use ZM\Annotation\AnnotationParser;
|
||||
use ZM\Annotation\Swoole\OnStart;
|
||||
use ZM\Annotation\Swoole\SwooleEventAfter;
|
||||
use ZM\Connection\ConnectionManager;
|
||||
use ZM\Context\ContextInterface;
|
||||
use ZM\DB\DB;
|
||||
use Framework\Console;
|
||||
use Framework\GlobalConfig;
|
||||
@@ -121,6 +123,7 @@ class WorkerStartEvent implements SwooleEvent
|
||||
/**
|
||||
* @throws AnnotationException
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function loadAllClass() {
|
||||
//加载phar包
|
||||
@@ -149,6 +152,7 @@ class WorkerStartEvent implements SwooleEvent
|
||||
//加载自定义的全局函数
|
||||
if(file_exists(WORKING_DIR."/src/Custom/global_function.php"))
|
||||
require_once WORKING_DIR."/src/Custom/global_function.php";
|
||||
$this->afterCheck();
|
||||
}
|
||||
|
||||
private function setAutosaveTimer($globals) {
|
||||
@@ -157,4 +161,14 @@ class WorkerStartEvent implements SwooleEvent
|
||||
DataProvider::saveBuffer();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function afterCheck() {
|
||||
$context_class = ZMBuf::globals("context_class");
|
||||
if(!is_a($context_class, ContextInterface::class, true)) {
|
||||
throw new Exception("Context class must implemented from ContextInterface!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user