From 63c3031e04c968678ab335df8b36ea00592d483e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Jan 2016 11:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B7=AF=E7=94=B1=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=8C=B9=E9=85=8D=E6=88=90=E5=8A=9F=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E6=89=A7=E8=A1=8C=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E7=94=B1=E8=B7=AF=E7=94=B1=E5=8F=82=E6=95=B0=20after=5Fbehavio?= =?UTF-8?q?r=20=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 580cd894..365a2d4a 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -393,7 +393,7 @@ class Route $pattern = array_merge($pattern, isset($route[2]) ? $route[2] : []); $route = $route[0]; } - $result = self::checkRule($key, $route, $url1, $pattern); + $result = self::checkRule($key, $route, $url1, $pattern, $option1); if (false !== $result) { return $result; } @@ -405,7 +405,7 @@ class Route // 单项路由 $route = !empty($val['route']) ? $val['route'] : ''; // 规则路由 - $result = self::checkRule($rule, $route, $url, $pattern); + $result = self::checkRule($rule, $route, $url, $pattern, $option); if (false !== $result) { return $result; } @@ -471,7 +471,7 @@ class Route /** * 检查规则路由 */ - private static function checkRule($rule, $route, $url, $pattern) + private static function checkRule($rule, $route, $url, $pattern, $option) { // 检查完整规则定义 if (isset($pattern['__url__']) && !preg_match('/^' . $pattern['__url__'] . '/', $url)) { @@ -495,6 +495,11 @@ class Route } $pattern = array_merge(self::$pattern, $pattern); if (false !== $match = self::match($url, $rule, $pattern)) { + // 匹配到路由规则 + // 检测是否定义路由 + if ($option['after_behavior']) { + Hook::exec($option['after_behavior'], $route); + } if ($route instanceof \Closure) { // 执行闭包 return ['type' => 'function', 'function' => $route, 'params' => $match];