|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package WPEmerge |
|
4
|
|
|
* @author Atanas Angelov <[email protected]> |
|
5
|
|
|
* @copyright 2018 Atanas Angelov |
|
6
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0 |
|
7
|
|
|
* @link https://wpemerge.com/ |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
use WPEmerge\Facades\Response; |
|
11
|
|
|
use WPEmerge\Facades\View; |
|
12
|
|
|
|
|
13
|
|
|
if ( ! function_exists( 'app_response' ) ) { |
|
14
|
|
|
/** |
|
15
|
|
|
* @codeCoverageIgnore |
|
16
|
|
|
* @see \WPEmerge\Responses\ResponseService::response() |
|
17
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
18
|
|
|
*/ |
|
19
|
|
|
function app_response() { |
|
20
|
|
|
return call_user_func_array( [Response::class, 'response'], func_get_args() ); |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
if ( ! function_exists( 'app_output' ) ) { |
|
25
|
|
|
/** |
|
26
|
|
|
* @codeCoverageIgnore |
|
27
|
|
|
* @see \WPEmerge\Responses\ResponseService::output() |
|
28
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
29
|
|
|
*/ |
|
30
|
|
|
function app_output( $output ) { |
|
31
|
|
|
return call_user_func_array( [Response::class, 'output'], func_get_args() ); |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
if ( ! function_exists( 'app_json' ) ) { |
|
36
|
|
|
/** |
|
37
|
|
|
* @codeCoverageIgnore |
|
38
|
|
|
* @see \WPEmerge\Responses\ResponseService::json() |
|
39
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
40
|
|
|
*/ |
|
41
|
|
|
function app_json( $data ) { |
|
42
|
|
|
return call_user_func_array( [Response::class, 'json'], func_get_args() ); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if ( ! function_exists( 'app_redirect' ) ) { |
|
47
|
|
|
/** |
|
48
|
|
|
* @codeCoverageIgnore |
|
49
|
|
|
* @see \WPEmerge\Responses\ResponseService::redirect() |
|
50
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
51
|
|
|
*/ |
|
52
|
|
|
function app_redirect() { |
|
53
|
|
|
return call_user_func_array( [Response::class, 'redirect'], func_get_args() ); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if ( ! function_exists( 'app_view' ) ) { |
|
58
|
|
|
/** |
|
59
|
|
|
* @codeCoverageIgnore |
|
60
|
|
|
* @see \WPEmerge\Responses\ResponseService::view() |
|
61
|
|
|
* @return \WPEmerge\View\ViewInterface |
|
62
|
|
|
*/ |
|
63
|
|
|
function app_view( $views ) { |
|
64
|
|
|
return call_user_func_array( [Response::class, 'view'], func_get_args() ); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
if ( ! function_exists( 'app_error' ) ) { |
|
69
|
|
|
/** |
|
70
|
|
|
* @codeCoverageIgnore |
|
71
|
|
|
* @see \WPEmerge\Responses\ResponseService::error() |
|
72
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
73
|
|
|
*/ |
|
74
|
|
|
function app_error( $code ) { |
|
75
|
|
|
return call_user_func_array( [Response::class, 'error'], func_get_args() ); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
if ( ! function_exists( 'app_render' ) ) { |
|
80
|
|
|
/** |
|
81
|
|
|
* @codeCoverageIgnore |
|
82
|
|
|
* @see \WPEmerge\View\ViewService::make() |
|
83
|
|
|
* @see \WPEmerge\View\ViewInterface::toString() |
|
84
|
|
|
* @return void |
|
85
|
|
|
*/ |
|
86
|
|
|
function app_render( $views, $context = [] ) { |
|
87
|
|
|
$view = app_view( $views )->with( $context ); |
|
88
|
|
|
View::triggerPartialHooks( $view->getName() ); |
|
89
|
|
|
echo $view->toString(); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
if ( ! function_exists( 'app_layout_content' ) ) { |
|
94
|
|
|
/** |
|
95
|
|
|
* @codeCoverageIgnore |
|
96
|
|
|
* @see \WPEmerge\View\PhpView::getLayoutContent() |
|
97
|
|
|
* @return void |
|
98
|
|
|
*/ |
|
99
|
|
|
function app_layout_content() { |
|
100
|
|
|
echo \WPEmerge\View\PhpView::getLayoutContent(); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
if ( ! function_exists( 'app_pipeline' ) ) { |
|
105
|
|
|
/** |
|
106
|
|
|
* @codeCoverageIgnore |
|
107
|
|
|
* @see \WPEmerge\Kernels\HttpKernel::run() |
|
108
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
109
|
|
|
*/ |
|
110
|
|
|
function app_pipeline() { |
|
111
|
|
|
$kernel = \WPEmerge\Facades\Application::resolve( WPEMERGE_WORDPRESS_HTTP_KERNEL_KEY ); |
|
112
|
|
|
return call_user_func_array( [$kernel, 'run'], func_get_args() ); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|