|
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
|
|
|
namespace WPEmerge; |
|
11
|
|
|
|
|
12
|
|
|
use WPEmerge\Facades\Response; |
|
13
|
|
|
use WPEmerge\Facades\View; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @codeCoverageIgnore |
|
17
|
|
|
* @see \WPEmerge\Responses\ResponseService::response() |
|
18
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
19
|
|
|
*/ |
|
20
|
|
|
function response() { |
|
21
|
|
|
return call_user_func_array( [Response::class, 'response'], func_get_args() ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @codeCoverageIgnore |
|
26
|
|
|
* @see \WPEmerge\Responses\ResponseService::output() |
|
27
|
|
|
* @param string $output |
|
28
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
29
|
|
|
*/ |
|
30
|
|
|
function output( $output ) { |
|
31
|
|
|
return call_user_func_array( [Response::class, 'output'], func_get_args() ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @codeCoverageIgnore |
|
36
|
|
|
* @see \WPEmerge\Responses\ResponseService::json() |
|
37
|
|
|
* @param mixed $data |
|
38
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
39
|
|
|
*/ |
|
40
|
|
|
function json( $data ) { |
|
41
|
|
|
return call_user_func_array( [Response::class, 'json'], func_get_args() ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @codeCoverageIgnore |
|
46
|
|
|
* @see \WPEmerge\Responses\ResponseService::redirect() |
|
47
|
|
|
* @return \WPEmerge\Responses\RedirectResponse |
|
48
|
|
|
*/ |
|
49
|
|
|
function redirect() { |
|
50
|
|
|
return call_user_func_array( [Response::class, 'redirect'], func_get_args() ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @codeCoverageIgnore |
|
55
|
|
|
* @see \WPEmerge\Responses\ResponseService::view() |
|
56
|
|
|
* @param string|array<string> $views |
|
57
|
|
|
* @return \WPEmerge\View\ViewInterface |
|
58
|
|
|
*/ |
|
59
|
|
|
function view( $views ) { |
|
60
|
|
|
return call_user_func_array( [Response::class, 'view'], func_get_args() ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @codeCoverageIgnore |
|
65
|
|
|
* @see \WPEmerge\Responses\ResponseService::error() |
|
66
|
|
|
* @param integer $status |
|
67
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
68
|
|
|
*/ |
|
69
|
|
|
function error( $status ) { |
|
70
|
|
|
return call_user_func_array( [Response::class, 'error'], func_get_args() ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @codeCoverageIgnore |
|
75
|
|
|
* @see \WPEmerge\View\ViewService::make() |
|
76
|
|
|
* @see \WPEmerge\View\ViewInterface::toString() |
|
77
|
|
|
* @param string|array<string> $views |
|
78
|
|
|
* @param array<string, mixed> $context |
|
79
|
|
|
* @return void |
|
80
|
|
|
*/ |
|
81
|
|
|
function render( $views, $context = [] ) { |
|
82
|
|
|
$view = view( $views )->with( $context ); |
|
83
|
|
|
View::triggerPartialHooks( $view->getName() ); |
|
84
|
|
|
echo $view->toString(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @codeCoverageIgnore |
|
89
|
|
|
* @see \WPEmerge\View\PhpView::getLayoutContent() |
|
90
|
|
|
* @return void |
|
91
|
|
|
*/ |
|
92
|
|
|
function layout_content() { |
|
93
|
|
|
echo \WPEmerge\View\PhpView::getLayoutContent(); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @codeCoverageIgnore |
|
98
|
|
|
* @see \WPEmerge\Kernels\HttpKernel::run() |
|
99
|
|
|
* @param \WPEmerge\Requests\RequestInterface $request |
|
100
|
|
|
* @param array<string> $middleware |
|
101
|
|
|
* @param string|\Closure $handler |
|
102
|
|
|
* @param array $arguments |
|
103
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
104
|
|
|
*/ |
|
105
|
|
|
function run( \WPEmerge\Requests\RequestInterface $request, $middleware, $handler, $arguments = [] ) { |
|
106
|
|
|
$kernel = \WPEmerge\Facades\Application::resolve( WPEMERGE_WORDPRESS_HTTP_KERNEL_KEY ); |
|
107
|
|
|
return call_user_func_array( [$kernel, 'run'], func_get_args() ); |
|
108
|
|
|
} |
|
109
|
|
|
|