@@ -24,34 +24,38 @@ public function execute($addon = null, $controller = null, $action = null)
2424 // 是否自动转换控制器和操作名
2525 $ convert = Config::get ('url_convert ' );
2626 $ filter = $ convert ? 'strtolower ' : 'trim ' ;
27-
27+
2828 $ addon = $ addon ? call_user_func ($ filter , $ addon ) : '' ;
2929 $ controller = $ controller ? call_user_func ($ filter , $ controller ) : 'index ' ;
3030 $ action = $ action ? call_user_func ($ filter , $ action ) : 'index ' ;
3131
32+ Hook::listen ('addon_begin ' , $ request );
33+
3234 if (!empty ($ addon ) && !empty ($ controller ) && !empty ($ action ))
3335 {
3436 $ info = get_addon_info ($ addon );
3537 if (!$ info )
3638 {
37- throw new HttpException (404 , 'addon not exists: ' . $ addon );
39+ throw new HttpException (404 , __ ( 'addon %s not found ' , $ addon) );
3840 }
3941 if (!$ info ['state ' ])
4042 {
41- throw new HttpException (500 , ' the addon is disabled: ' . $ addon );
43+ throw new HttpException (500 , __ ( ' addon %s is disabled ' , $ addon) );
4244 }
4345 // 设置当前请求的控制器、操作
4446 $ request ->controller ($ controller )->action ($ action );
4547
48+ // 监听addon_module_init
49+ Hook::listen ('addon_module_init ' , $ request );
50+ // 兼容旧版本行为,即将移除,不建议使用
51+ Hook::listen ('addons_init ' , $ request );
52+
4653 $ class = get_addon_class ($ addon , 'controller ' , $ controller );
4754 if (!$ class )
4855 {
49- throw new HttpException (404 , ' controller not exists: ' . Loader::parseName ($ controller , 1 ));
56+ throw new HttpException (404 , __ ( ' addon controller %s not found ' , Loader::parseName ($ controller , 1 ) ));
5057 }
5158
52- // 监听addons_init
53- Hook::listen ('addons_init ' , $ request );
54-
5559 $ instance = new $ class ($ request );
5660
5761 $ vars = [];
@@ -69,10 +73,10 @@ public function execute($addon = null, $controller = null, $action = null)
6973 else
7074 {
7175 // 操作不存在
72- throw new HttpException (404 , ' method not exists: ' . get_class ($ instance ) . '-> ' . $ action . '() ' );
76+ throw new HttpException (404 , __ ( ' addon action %s not found ' , get_class ($ instance ) . '-> ' . $ action . '() ' ) );
7377 }
7478
75- Hook::listen ('action_begin ' , $ call );
79+ Hook::listen ('addon_action_begin ' , $ call );
7680
7781 return call_user_func_array ($ call , $ vars );
7882 }
0 commit comments