mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 08:35:35 +08:00
fix container and coroutine
This commit is contained in:
@@ -90,9 +90,9 @@ class ContainerServicesProvider
|
||||
{
|
||||
// $context = Context::$context[zm_cid()];
|
||||
$container->instance(HttpRequestEvent::class, $event);
|
||||
$container->alias('http.request.event', HttpRequestEvent::class);
|
||||
$container->alias(HttpRequestEvent::class, 'http.request.event');
|
||||
$container->instance(ServerRequestInterface::class, $event->getRequest());
|
||||
$container->alias('http.request', ServerRequestInterface::class);
|
||||
$container->alias(ServerRequestInterface::class, 'http.request');
|
||||
// $container->instance(Request::class, $context['request']);
|
||||
// $container->instance(Response::class, $context['response']);
|
||||
$container->bind(ContextInterface::class, Context::class);
|
||||
|
||||
@@ -32,6 +32,7 @@ class HttpEventListener
|
||||
{
|
||||
// 注册容器
|
||||
resolve(ContainerServicesProvider::class)->registerServices('request', $event);
|
||||
// TODO: 这里有个bug,如果是用的Workerman+Fiber协程的话,有个前置协程挂起,这里获取到的Event是被挂起的Event对象,触发两次事件才能归正
|
||||
// 跑一遍 BindEvent 绑定了 HttpRequestEvent 的注解
|
||||
$handler = new AnnotationHandler(BindEvent::class);
|
||||
$handler->setRuleCallback(function (BindEvent $anno) {
|
||||
|
||||
@@ -8,9 +8,10 @@ class ZMUtil
|
||||
{
|
||||
/**
|
||||
* 获取 composer.json 并转为数组进行读取使用
|
||||
* @param null|string $path 路径
|
||||
*/
|
||||
public static function getComposerMetadata(): ?array
|
||||
public static function getComposerMetadata(?string $path = null): ?array
|
||||
{
|
||||
return json_decode(file_get_contents(SOURCE_ROOT_DIR . '/composer.json'), true);
|
||||
return json_decode(file_get_contents(($path ?? SOURCE_ROOT_DIR) . '/composer.json'), true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user