File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed
Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 1111 */
1212class Json
1313{
14+ protected static $ cb = null ;
15+
16+ public static function setResultHandle ($ cb )
17+ {
18+ static ::$ cb = $ cb ;
19+ }
20+
21+
1422 /**
1523 * json encode
1624 * @param $data
@@ -42,7 +50,15 @@ public static function render($data)
4250 */
4351 public static function renderWithTrue ($ data = null , $ code = '0 ' )
4452 {
45- return static ::render (array ('status ' => true , 'data ' => $ data , 'code ' => (string )$ code ));
53+
54+ if (static ::$ cb ) {
55+ return static ::render (call_user_func_array (static ::$ cb , array (true , $ data , (string )$ code )));
56+
57+ } else {
58+ return static ::render (array ('status ' => true , 'data ' => $ data , 'code ' => (string )$ code ));
59+ }
60+
61+ return static ::render ($ arr );
4662 }
4763
4864 /**
@@ -53,6 +69,10 @@ public static function renderWithTrue($data = null, $code = '0')
5369 */
5470 public static function renderWithFalse ($ data = null , $ code = '-1 ' )
5571 {
56- return static ::render (array ('status ' => false , 'data ' => $ data , 'code ' => (string )$ code ));
72+ if (static ::$ cb ) {
73+ return static ::render (call_user_func_array (static ::$ cb , array (false , $ data , (string )$ code )));
74+ } else {
75+ return static ::render (array ('status ' => false , 'data ' => $ data , 'code ' => (string )$ code ));
76+ }
5777 }
58- }
78+ }
You can’t perform that action at this time.
0 commit comments