1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use WPEmerge\Facades\Response; |
4
|
|
|
use WPEmerge\Facades\View; |
5
|
|
|
|
6
|
|
|
if ( ! function_exists( 'app_response' ) ) { |
7
|
|
|
/** |
8
|
|
|
* @codeCoverageIgnore |
9
|
|
|
* @see \WPEmerge\Responses\ResponseService::response() |
10
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
11
|
|
|
*/ |
12
|
|
|
function app_response() { |
13
|
|
|
return call_user_func_array( [Response::class, 'response'], func_get_args() ); |
14
|
|
|
} |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
if ( ! function_exists( 'app_output' ) ) { |
18
|
|
|
/** |
19
|
|
|
* @codeCoverageIgnore |
20
|
|
|
* @see \WPEmerge\Responses\ResponseService::output() |
21
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
22
|
|
|
*/ |
23
|
|
|
function app_output( $output ) { |
|
|
|
|
24
|
|
|
return call_user_func_array( [Response::class, 'output'], func_get_args() ); |
25
|
|
|
} |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
if ( ! function_exists( 'app_json' ) ) { |
29
|
|
|
/** |
30
|
|
|
* @codeCoverageIgnore |
31
|
|
|
* @see \WPEmerge\Responses\ResponseService::json() |
32
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
33
|
|
|
*/ |
34
|
|
|
function app_json( $data ) { |
|
|
|
|
35
|
|
|
return call_user_func_array( [Response::class, 'json'], func_get_args() ); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if ( ! function_exists( 'app_redirect' ) ) { |
40
|
|
|
/** |
41
|
|
|
* @codeCoverageIgnore |
42
|
|
|
* @see \WPEmerge\Responses\ResponseService::redirect() |
43
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
44
|
|
|
*/ |
45
|
|
|
function app_redirect() { |
|
|
|
|
46
|
|
|
return call_user_func_array( [Response::class, 'redirect'], func_get_args() ); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if ( ! function_exists( 'app_view' ) ) { |
51
|
|
|
/** |
52
|
|
|
* @codeCoverageIgnore |
53
|
|
|
* @see \WPEmerge\Responses\ResponseService::view() |
54
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
55
|
|
|
*/ |
56
|
|
|
function app_view( $views, $context = [] ) { |
|
|
|
|
57
|
|
|
return call_user_func_array( [Response::class, 'view'], func_get_args() ); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if ( ! function_exists( 'app_error' ) ) { |
62
|
|
|
/** |
63
|
|
|
* @codeCoverageIgnore |
64
|
|
|
* @see \WPEmerge\Responses\ResponseService::error() |
65
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
66
|
|
|
*/ |
67
|
|
|
function app_error( $code ) { |
|
|
|
|
68
|
|
|
return call_user_func_array( [Response::class, 'error'], func_get_args() ); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
if ( ! function_exists( 'app_partial' ) ) { |
73
|
|
|
/** |
74
|
|
|
* @codeCoverageIgnore |
75
|
|
|
* @see \WPEmerge\View\ViewService::toString() |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
|
|
function app_partial( $views, $context = [] ) { |
|
|
|
|
79
|
|
|
echo call_user_func_array( [View::class, 'toString'], func_get_args() ); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.