1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\entities\routing\handlers\shared; |
4
|
|
|
|
5
|
|
|
use EE_Dependency_Map; |
6
|
|
|
use EventEspresso\core\services\routing\Route; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class RoutingRequests |
10
|
|
|
* registers dependencies for all other Routes as long as this is not an activation request |
11
|
|
|
* |
12
|
|
|
* @package EventEspresso\core\domain\entities\routing\handlers\shared |
13
|
|
|
* @author Brent Christensen |
14
|
|
|
* @since $VID:$ |
15
|
|
|
*/ |
16
|
|
|
class RoutingRequests extends Route |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* called just before matchesCurrentRequest() |
21
|
|
|
* and allows Route to perform any setup required such as calling setSpecification() |
22
|
|
|
* |
23
|
|
|
* @since $VID:$ |
24
|
|
|
*/ |
25
|
|
|
public function initialize() |
26
|
|
|
{ |
27
|
|
|
$basic_nodes = [ |
28
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\Api', |
29
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser', |
30
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings', |
31
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale', |
32
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls', |
33
|
|
|
]; |
34
|
|
|
foreach ($basic_nodes as $basic_node) { |
35
|
|
|
$this->dependency_map->registerDependencies( |
36
|
|
|
$basic_node, |
37
|
|
|
['EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache] |
38
|
|
|
); |
39
|
|
|
} |
40
|
|
|
$this->dependency_map->registerDependencies( |
41
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData', |
42
|
|
|
[ |
43
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\Api' => EE_Dependency_Map::load_from_cache, |
44
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\Config' => EE_Dependency_Map::load_from_cache, |
45
|
|
|
'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
46
|
|
|
'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
47
|
|
|
] |
48
|
|
|
); |
49
|
|
|
$this->dependency_map->registerDependencies( |
50
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\Config', |
51
|
|
|
[ |
52
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser' => EE_Dependency_Map::load_from_cache, |
53
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain' => EE_Dependency_Map::load_from_cache, |
54
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings' => EE_Dependency_Map::load_from_cache, |
55
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale' => EE_Dependency_Map::load_from_cache, |
56
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency' => EE_Dependency_Map::load_from_cache, |
57
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls' => EE_Dependency_Map::load_from_cache, |
58
|
|
|
'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
59
|
|
|
] |
60
|
|
|
); |
61
|
|
|
$this->dependency_map->registerDependencies( |
62
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain', |
63
|
|
|
[ |
64
|
|
|
'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
65
|
|
|
'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
66
|
|
|
] |
67
|
|
|
); |
68
|
|
|
$this->dependency_map->registerDependencies( |
69
|
|
|
'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency', |
70
|
|
|
[ |
71
|
|
|
'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
72
|
|
|
'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
73
|
|
|
] |
74
|
|
|
); |
75
|
|
|
$this->setDataNode( |
76
|
|
|
$this->loader->getShared('EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData') |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* returns true if the current request matches this route |
83
|
|
|
* |
84
|
|
|
* @return bool |
85
|
|
|
* @since $VID:$ |
86
|
|
|
*/ |
87
|
|
|
public function matchesCurrentRequest() |
88
|
|
|
{ |
89
|
|
|
return ! $this->request->isActivation() || $this->request->isUnitTesting(); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @since $VID:$ |
95
|
|
|
*/ |
96
|
|
|
protected function registerDependencies() |
97
|
|
|
{ |
98
|
|
|
$default = [ |
99
|
|
|
'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
100
|
|
|
'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
101
|
|
|
'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
102
|
|
|
]; |
103
|
|
|
$admin = ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache] + $default; |
104
|
|
|
$public = ['EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache] + $default; |
105
|
|
|
$default_routes = [ |
106
|
|
|
// default dependencies |
107
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests' => $default, |
108
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage' => $default, |
109
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests' => $default, |
110
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests' => $default, |
111
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests' => $default, |
112
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests' => $default, |
113
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests' => $default, |
114
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat' => $default, |
115
|
|
|
// admin dependencies |
116
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute' => $admin, |
117
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin' => $admin, |
118
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor' => $admin, |
119
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin' => $admin, |
120
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor' => $admin, |
121
|
|
|
// public dependencies |
122
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests' => $public, |
123
|
|
|
'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests' => $public, |
124
|
|
|
]; |
125
|
|
|
foreach ($default_routes as $route => $dependencies) { |
126
|
|
|
$this->dependency_map->registerDependencies($route, $dependencies); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* implements logic required to run during request |
133
|
|
|
* |
134
|
|
|
* @return bool |
135
|
|
|
* @since $VID:$ |
136
|
|
|
*/ |
137
|
|
|
protected function requestHandler() |
138
|
|
|
{ |
139
|
|
|
return true; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|