|
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\Kernels; |
|
11
|
|
|
|
|
12
|
|
|
use WPEmerge\Requests\RequestInterface; |
|
13
|
|
|
use WPEmerge\Routing\Router; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Describes how a request is handled. |
|
17
|
|
|
*/ |
|
18
|
|
|
class WordPressHttpKernel implements HttpKernel { |
|
19
|
|
|
/** |
|
20
|
|
|
* Router. |
|
21
|
|
|
* |
|
22
|
|
|
* @var Router|null |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $router = null; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Middleware available to the application. |
|
28
|
|
|
* TODO: implement. |
|
29
|
|
|
* |
|
30
|
|
|
* @var array<string, string> |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $middleware = []; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Middleware groups. |
|
36
|
|
|
* TODO: implement. |
|
37
|
|
|
* |
|
38
|
|
|
* @var array<string, array> |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $middleware_groups = []; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Global middleware that will be applied to all routes. |
|
44
|
|
|
* |
|
45
|
|
|
* @var array |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $global_middleware = []; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Middleware sorted in order of execution. |
|
51
|
|
|
* |
|
52
|
|
|
* @var array<string> |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $middleware_priority = []; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Constructor. |
|
58
|
|
|
* |
|
59
|
|
|
* @codeCoverageIgnore |
|
60
|
|
|
* @param Router $router |
|
61
|
|
|
*/ |
|
62
|
|
|
public function __construct( $router ) { |
|
63
|
|
|
$this->router = $router; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* {@inheritDoc} |
|
68
|
|
|
*/ |
|
69
|
|
|
public function bootstrap() { |
|
70
|
|
|
$this->router->setMiddleware( $this->middleware ); |
|
|
|
|
|
|
71
|
|
|
$this->router->setMiddlewareGroups( $this->middleware_groups ); |
|
72
|
|
|
$this->router->setGlobalMiddleware( $this->global_middleware ); |
|
73
|
|
|
$this->router->setMiddlewarePriority( $this->middleware_priority ); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* {@inheritDoc} |
|
78
|
|
|
* @codeCoverageIgnore |
|
79
|
|
|
*/ |
|
80
|
|
|
public function handle( RequestInterface $request, $view ) { |
|
81
|
|
|
return $this->router->execute( $request, $view ); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.