From b57401eb1e8ceb481c865010be9baecd61282e8a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 1 Aug 2016 23:17:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index ead06c95..5d13fd2d 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -355,6 +355,7 @@ class Route self::$rules['*'][$name]['pattern'] = $pattern; } } else { + $item = []; foreach ($routes as $key => $val) { if (is_numeric($key)) { $key = array_shift($val); @@ -380,18 +381,16 @@ class Route } } + } elseif ($routes instanceof \Closure) { + // 闭包注册 + $currentOption = self::getGroup('option'); + $currentPattern = self::getGroup('pattern'); + self::setGroup('', $option, $pattern); + call_user_func_array($routes, []); + self::setGroup($currentGroup, $currentOption, $currentPattern); } else { - if ($routes instanceof \Closure) { - // 闭包注册 - $currentOption = self::getGroup('option'); - $currentPattern = self::getGroup('pattern'); - self::setGroup('', $option, $pattern); - call_user_func_array($routes, []); - self::setGroup($currentGroup, $currentOption, $currentPattern); - } else { - // 批量注册路由 - self::rule($routes, '', '*', $option, $pattern); - } + // 批量注册路由 + self::rule($routes, '', '*', $option, $pattern); } }