Merge remote-tracking branch 'origin/master'

Conflicts:
	composer.json
This commit is contained in:
yunwuxin
2015-12-15 23:40:27 +08:00

View File

@@ -75,15 +75,15 @@ class App
// 安全检测 // 安全检测
throw new Exception('illegal controller name:' . CONTROLLER_NAME, 10000); throw new Exception('illegal controller name:' . CONTROLLER_NAME, 10000);
} }
if ($config['action_bind_class']) { if (Config::get('action_bind_class')) {
$class = self::bindActionClass($config['empty_controller']); $class = self::bindActionClass(Config::get('empty_controller'));
$instance = new $class; $instance = new $class;
// 操作绑定到类后 固定执行run入口 // 操作绑定到类后 固定执行run入口
$action = 'run'; $action = 'run';
} else { } else {
$instance = Loader::controller(CONTROLLER_NAME, '', $config['empty_controller']); $instance = Loader::controller(CONTROLLER_NAME, '', Config::get('empty_controller'));
// 获取当前操作名 // 获取当前操作名
$action = ACTION_NAME . $config['action_suffix']; $action = ACTION_NAME . Config::get('action_suffix');
} }
if (!$instance) { if (!$instance) {
@@ -101,9 +101,9 @@ class App
$method = new \ReflectionMethod($instance, $action); $method = new \ReflectionMethod($instance, $action);
if ($method->isPublic()) { if ($method->isPublic()) {
// URL参数绑定检测 // URL参数绑定检测
if ($config['url_params_bind'] && $method->getNumberOfParameters() > 0) { if (Config::get('url_params_bind') && $method->getNumberOfParameters() > 0) {
// 获取绑定参数 // 获取绑定参数
$args = self::getBindParams($method, $config['url_parmas_bind_type']); $args = self::getBindParams($method, Config::get('url_parmas_bind_type'));
// 全局过滤 // 全局过滤
array_walk_recursive($args, 'think\\Input::filterExp'); array_walk_recursive($args, 'think\\Input::filterExp');
$data = $method->invokeArgs($instance, $args); $data = $method->invokeArgs($instance, $args);
@@ -113,7 +113,7 @@ class App
// 操作方法执行完成监听 // 操作方法执行完成监听
APP_HOOK && Hook::listen('action_end', $data); APP_HOOK && Hook::listen('action_end', $data);
// 返回数据 // 返回数据
Response::returnData($data, $config['default_return_type'], $config['response_exit']); Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit'));
} else { } else {
// 操作方法不是Public 抛出异常 // 操作方法不是Public 抛出异常
throw new \ReflectionException(); throw new \ReflectionException();
@@ -124,7 +124,7 @@ class App
$method = new \ReflectionMethod($instance, '_empty'); $method = new \ReflectionMethod($instance, '_empty');
$data = $method->invokeArgs($instance, [$action, '']); $data = $method->invokeArgs($instance, [$action, '']);
// 返回数据 // 返回数据
Response::returnData($data, $config['default_return_type'], $config['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);
} }
@@ -170,7 +170,7 @@ class App
$name = $param->getName(); $name = $param->getName();
if (1 == $paramsBindType && !empty($vars)) { if (1 == $paramsBindType && !empty($vars)) {
$args[] = array_shift($vars); $args[] = array_shift($vars);
}if (0 == $paramsBindType && isset($vars[$name])) { } elseif (0 == $paramsBindType && isset($vars[$name])) {
$args[] = $vars[$name]; $args[] = $vars[$name];
} elseif ($param->isDefaultValueAvailable()) { } elseif ($param->isDefaultValueAvailable()) {
$args[] = $param->getDefaultValue(); $args[] = $param->getDefaultValue();
@@ -182,7 +182,7 @@ class App
} }
// 初始化模块 // 初始化模块
private static function initModule($module, &$config) private static function initModule($module, $config)
{ {
// 定位模块目录 // 定位模块目录
$module = COMMON_MODULE == $module ? '' : $module . DS; $module = COMMON_MODULE == $module ? '' : $module . DS;
@@ -193,11 +193,11 @@ class App
} else { } else {
$path = APP_PATH . $module; $path = APP_PATH . $module;
// 加载模块配置 // 加载模块配置
$config = Config::load($module . 'config'); Config::load($module . 'config');
// 加载应用状态配置 // 加载应用状态配置
if ($config['app_status']) { if ($config['app_status']) {
$config = Config::load($module . $config['app_status']); Config::load($module . $config['app_status']);
} }
// 加载别名文件 // 加载别名文件
@@ -225,7 +225,7 @@ class App
* *
* @throws Exception * @throws Exception
*/ */
public static function dispatch(&$config) public static function dispatch($config)
{ {
if (isset($_GET[$config['var_pathinfo']])) { if (isset($_GET[$config['var_pathinfo']])) {
// 判断URL里面是否有兼容模式参数 // 判断URL里面是否有兼容模式参数
@@ -333,11 +333,11 @@ class App
} }
// 获取控制器名 // 获取控制器名
$controller = strip_tags(strtolower($result[1] ?: $config['default_controller'])); $controller = strip_tags(strtolower($result[1] ?: Config::get('default_controller')));
define('CONTROLLER_NAME', defined('BIND_CONTROLLER') ? BIND_CONTROLLER : $controller); define('CONTROLLER_NAME', defined('BIND_CONTROLLER') ? BIND_CONTROLLER : $controller);
// 获取操作名 // 获取操作名
$action = strip_tags(strtolower($result[2] ?: $config['default_action'])); $action = strip_tags(strtolower($result[2] ?: Config::get('default_action')));
define('ACTION_NAME', defined('BIND_ACTION') ? BIND_ACTION : $action); define('ACTION_NAME', defined('BIND_ACTION') ? BIND_ACTION : $action);
} }
} }