1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\bootstrap; |
4
|
|
|
|
5
|
|
|
use EE_Dependency_Map; |
6
|
|
|
use EE_Error; |
7
|
|
|
use EE_Request; |
8
|
|
|
use EventEspresso\core\services\loaders\LoaderInterface; |
9
|
|
|
use EventEspresso\core\services\request\LegacyRequestInterface; |
10
|
|
|
use EventEspresso\core\services\request\Request; |
11
|
|
|
use EventEspresso\core\services\request\RequestInterface; |
12
|
|
|
use EventEspresso\core\services\request\Response; |
13
|
|
|
use EventEspresso\core\services\request\ResponseInterface; |
14
|
|
|
use InvalidArgumentException; |
15
|
|
|
|
16
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class BootstrapRequestResponseObjects |
22
|
|
|
* Sets up the Request and Response objects |
23
|
|
|
* as well as backwards compatibility for the Legacy EE_Request object |
24
|
|
|
* |
25
|
|
|
* @package EventEspresso\core\services\bootstrap |
26
|
|
|
* @author Brent Christensen |
27
|
|
|
* @since 4.9.53 |
28
|
|
|
*/ |
29
|
|
|
class BootstrapRequestResponseObjects |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @type LegacyRequestInterface $legacy_request |
34
|
|
|
*/ |
35
|
|
|
protected $legacy_request; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @type LoaderInterface $loader |
39
|
|
|
*/ |
40
|
|
|
protected $loader; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var RequestInterface $request |
44
|
|
|
*/ |
45
|
|
|
protected $request; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var ResponseInterface $response |
49
|
|
|
*/ |
50
|
|
|
protected $response; |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* BootstrapRequestResponseObjects constructor. |
55
|
|
|
* |
56
|
|
|
* @param LoaderInterface $loader |
57
|
|
|
*/ |
58
|
|
|
public function __construct(LoaderInterface $loader) |
59
|
|
|
{ |
60
|
|
|
$this->loader = $loader; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
public function buildRequestResponse() |
68
|
|
|
{ |
69
|
|
|
// load our Request and Response objects |
70
|
|
|
$this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER); |
71
|
|
|
$this->response = new Response(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return void |
77
|
|
|
* @throws InvalidArgumentException |
78
|
|
|
*/ |
79
|
|
|
public function shareRequestResponse() |
80
|
|
|
{ |
81
|
|
|
$this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
82
|
|
|
$this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
83
|
|
|
EE_Dependency_Map::instance()->setRequest($this->request); |
84
|
|
|
EE_Dependency_Map::instance()->setResponse($this->response); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return void |
90
|
|
|
* @throws InvalidArgumentException |
91
|
|
|
* @throws EE_Error |
92
|
|
|
*/ |
93
|
|
|
public function setupLegacyRequest() |
94
|
|
|
{ |
95
|
|
|
espresso_load_required( |
96
|
|
|
'EE_Request', |
97
|
|
|
EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
98
|
|
|
); |
99
|
|
|
$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
|
|
|
100
|
|
|
$this->legacy_request->setRequest($this->request); |
101
|
|
|
$this->legacy_request->admin = $this->request->isAdmin(); |
102
|
|
|
$this->legacy_request->ajax = $this->request->isAjax(); |
103
|
|
|
$this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
104
|
|
|
EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
105
|
|
|
$this->loader->share('EE_Request', $this->legacy_request); |
106
|
|
|
$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.