From 911c2a3422249c7c48514510d3147f920f82ca2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 21 Oct 2020 11:11:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Route/Node.php | 49 +++++++++++---------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 006f3812..095cb331 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -53,19 +53,19 @@ class Node extends Application */ public function bindHandler($handler) { -// if ($handler instanceof Closure) { -// $this->handler = $handler; -// } else if (is_string($handler) && strpos($handler, '@') !== false) { -// list($controller, $action) = explode('@', $handler); -// if (!empty($this->namespace)) { -// $controller = implode('\\', $this->namespace) . '\\' . $controller; -// } -// $this->handler = $this->getReflect($controller, $action); -// } else if ($handler != null && !is_callable($handler, true)) { -// $this->_error = 'Controller is con\'t exec.'; -// } else { -// } - $this->handler = $handler; + if ($handler instanceof Closure) { + $this->handler = $handler; + } else if (is_string($handler) && strpos($handler, '@') !== false) { + list($controller, $action) = explode('@', $handler); + if (!empty($this->namespace)) { + $controller = implode('\\', $this->namespace) . '\\' . $controller; + } + $this->handler = $this->getReflect($controller, $action); + } else if ($handler != null && !is_callable($handler, true)) { + $this->_error = 'Controller is con\'t exec.'; + } else { + $this->handler = $handler; + } return $this; } @@ -395,11 +395,9 @@ class Node extends Application */ private function restructure() { - $this->resolveHandler(); if (empty($this->handler)) { return $this; } - /** @var Middleware $made */ $made = Snowflake::createObject(Middleware::class); $made->setMiddleWares($this->middleware); $made->getGenerate($this); @@ -407,27 +405,6 @@ class Node extends Application } - /** - * @throws Exception - * 解析回调函数 - */ - private function resolveHandler() - { - if ($this->handler instanceof \Closure) { - return; - } - if (is_string($this->handler) && strpos($this->handler, '@') !== false) { - list($controller, $action) = explode('@', $this->handler); - if (!empty($this->namespace)) { - $controller = implode('\\', $this->namespace) . '\\' . $controller; - } - $this->handler = $this->getReflect($controller, $action); - } else if ($this->handler != null && !is_callable($this->handler, true)) { - $this->_error = 'Controller is con\'t exec.'; - } - } - - /** * @return mixed * @throws Exception