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