简化两处写法

This commit is contained in:
huangdijia
2015-12-22 15:18:25 +08:00
parent f6acdd1578
commit d28dbf644e

View File

@@ -110,12 +110,10 @@ class App
} }
// 操作方法执行完成监听 // 操作方法执行完成监听
APP_HOOK && Hook::listen('action_end', $data); APP_HOOK && Hook::listen('action_end', $data);
// 返回数据 // 单元测试模式下返回数据
if (IN_UNIT_TEST) { if (IN_UNIT_TEST) { return $data; }
return $data; // 输出数据
} else {
Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit'));
}
} else { } else {
// 操作方法不是Public 抛出异常 // 操作方法不是Public 抛出异常
throw new \ReflectionException(); throw new \ReflectionException();
@@ -127,12 +125,10 @@ class App
$data = $method->invokeArgs($instance, [$action, '']); $data = $method->invokeArgs($instance, [$action, '']);
// 操作方法执行完成监听 // 操作方法执行完成监听
APP_HOOK && Hook::listen('action_end', $data); APP_HOOK && Hook::listen('action_end', $data);
// 返回数据 // 单元测试模式下返回数据
if (IN_UNIT_TEST) { if (IN_UNIT_TEST) { return $data; }
return $data; // 输出数据
} else {
Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit'));
}
} else { } else {
throw new Exception('method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ', 10002); throw new Exception('method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ', 10002);
} }