|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\request; |
|
4
|
|
|
|
|
5
|
|
|
use EE_Error; |
|
6
|
|
|
use EventEspresso\core\exceptions\InvalidClassException; |
|
7
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
8
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
9
|
|
|
use EventEspresso\core\services\loaders\LoaderFactory; |
|
10
|
|
|
use InvalidArgumentException; |
|
11
|
|
|
|
|
12
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class RequestStackCoreApp |
|
18
|
|
|
* This is the core application loader class at the center of the Middleware Request Stack. |
|
19
|
|
|
* Although not an instance of Middleware, it DOES implement the RequestDecoratorInterface, allowing it to communicate |
|
20
|
|
|
* with the other Middleware classes. |
|
21
|
|
|
* Performs all of the basic class loading that used to be in the EE_System constructor. |
|
22
|
|
|
* |
|
23
|
|
|
* @package EventEspresso\core\services\request |
|
24
|
|
|
* @author Brent Christensen |
|
25
|
|
|
* @since $VID:$ |
|
26
|
|
|
*/ |
|
27
|
|
|
class RequestStackCoreApp implements RequestDecoratorInterface, RequestStackCoreAppInterface |
|
28
|
|
|
{ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var RequestInterface $request |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $request; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var ResponseInterface $response |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $response; |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* handle |
|
45
|
|
|
* sets hooks for running rest of system |
|
46
|
|
|
* provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
47
|
|
|
* starting EE Addons from any other point may lead to problems |
|
48
|
|
|
* |
|
49
|
|
|
* @param RequestInterface $request |
|
50
|
|
|
* @param ResponseInterface $response |
|
51
|
|
|
* @return ResponseInterface |
|
52
|
|
|
* @throws InvalidClassException |
|
53
|
|
|
* @throws EE_Error |
|
54
|
|
|
* @throws InvalidDataTypeException |
|
55
|
|
|
* @throws InvalidInterfaceException |
|
56
|
|
|
* @throws InvalidArgumentException |
|
57
|
|
|
*/ |
|
58
|
|
|
public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->request = $request; |
|
61
|
|
|
$this->response = $response; |
|
62
|
|
|
espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
63
|
|
|
espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
64
|
|
|
// workarounds for PHP < 5.3 |
|
65
|
|
|
espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
66
|
|
|
do_action( |
|
67
|
|
|
'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading' |
|
68
|
|
|
); |
|
69
|
|
|
// legacy action for backwards compatibility |
|
70
|
|
|
do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
71
|
|
|
$this->setupFramework(); |
|
72
|
|
|
$loader = LoaderFactory::getLoader(); |
|
73
|
|
|
$loader->getShared( |
|
74
|
|
|
'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
75
|
|
|
); |
|
76
|
|
|
// WP cron jobs |
|
77
|
|
|
$loader->getShared('EE_Cron_Tasks'); |
|
78
|
|
|
$loader->getShared('EE_System'); |
|
79
|
|
|
return $this->response; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* set framework for the rest of EE to hook into when loading |
|
85
|
|
|
* |
|
86
|
|
|
* @throws EE_Error |
|
87
|
|
|
*/ |
|
88
|
|
|
private function setupFramework() |
|
89
|
|
|
{ |
|
90
|
|
|
espresso_load_required( |
|
91
|
|
|
'EE_Bootstrap', |
|
92
|
|
|
EE_CORE . 'EE_Bootstrap.core.php' |
|
93
|
|
|
); |
|
94
|
|
|
add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
95
|
|
|
add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
96
|
|
|
add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
97
|
|
|
add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
98
|
|
|
add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* called after the request stack has been fully processed |
|
104
|
|
|
* if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
105
|
|
|
* |
|
106
|
|
|
* @param RequestInterface $request |
|
107
|
|
|
* @param ResponseInterface $response |
|
108
|
|
|
*/ |
|
109
|
|
|
public function handleResponse(RequestInterface $request, ResponseInterface $response) |
|
110
|
|
|
{ |
|
111
|
|
|
if ($response->pluginDeactivated()) { |
|
112
|
|
|
espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
// Location: RequestStackCoreApp.php |
|
118
|
|
|
|