From 63d829b7b44aa72c4bd78b3771800051fa65e556 Mon Sep 17 00:00:00 2001 From: Yurun Date: Fri, 15 Nov 2019 08:28:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Server/Http/Middleware/ActionMiddleware.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Server/Http/Middleware/ActionMiddleware.php b/src/Server/Http/Middleware/ActionMiddleware.php index 7d4853e7a2..93b759bd5a 100644 --- a/src/Server/Http/Middleware/ActionMiddleware.php +++ b/src/Server/Http/Middleware/ActionMiddleware.php @@ -63,12 +63,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface } // 执行动作 $actionResult = ($result->callable)(...$this->prepareActionParams($request, $result)); - $response = $context['response']; - if($useObjectRequestAndResponse) - { - // 获得控制器中的Response - $response = $result->callable[0]->response; - } // 视图 if($actionResult instanceof \Imi\Server\View\Annotation\View) { @@ -100,6 +94,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if(isset($viewAnnotation)) { + if($useObjectRequestAndResponse) + { + // 获得控制器中的Response + $response = $result->callable[0]->response; + } + else + { + $response = $context['response']; + } // 视图渲染 $options = $viewAnnotation->toArray(); $response = $this->view->render($viewAnnotation->renderType, $viewAnnotation->data, $options, $response);