增加app_dispatch钩子

This commit is contained in:
thinkphp
2017-11-08 21:41:29 +08:00
parent 35e763c8ff
commit 75ddca152a

View File

@@ -108,6 +108,9 @@ class App
// 获取应用调度信息 // 获取应用调度信息
$dispatch = self::$dispatch; $dispatch = self::$dispatch;
// 监听 app_dispatch
Hook::listen('app_dispatch', $dispatch);
// 未设置调度信息则进行 URL 路由检测 // 未设置调度信息则进行 URL 路由检测
if (empty($dispatch)) { if (empty($dispatch)) {
$dispatch = self::routeCheck($request, $config); $dispatch = self::routeCheck($request, $config);
@@ -169,7 +172,9 @@ class App
public static function initCommon() public static function initCommon()
{ {
if (empty(self::$init)) { if (empty(self::$init)) {
if (defined('APP_NAMESPACE')) self::$namespace = APP_NAMESPACE; if (defined('APP_NAMESPACE')) {
self::$namespace = APP_NAMESPACE;
}
Loader::addNamespace(self::$namespace, APP_PATH); Loader::addNamespace(self::$namespace, APP_PATH);
@@ -184,11 +189,16 @@ class App
ini_set('display_errors', 'Off'); ini_set('display_errors', 'Off');
} elseif (!IS_CLI) { } elseif (!IS_CLI) {
// 重新申请一块比较大的 buffer // 重新申请一块比较大的 buffer
if (ob_get_level() > 0) $output = ob_get_clean(); if (ob_get_level() > 0) {
$output = ob_get_clean();
}
ob_start(); ob_start();
if (!empty($output)) echo $output; if (!empty($output)) {
echo $output;
}
} }
if (!empty($config['root_namespace'])) { if (!empty($config['root_namespace'])) {
@@ -483,7 +493,9 @@ class App
*/ */
public static function module($result, $config, $convert = null) public static function module($result, $config, $convert = null)
{ {
if (is_string($result)) $result = explode('/', $result); if (is_string($result)) {
$result = explode('/', $result);
}
$request = Request::instance(); $request = Request::instance();