1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\entities\routing\handlers\shared; |
4
|
|
|
|
5
|
|
|
use EE_Dependency_Map; |
6
|
|
|
use EventEspresso\core\domain\entities\routing\handlers\Route; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class GQLRequests |
10
|
|
|
* loads for any type of request where GraphQL requests may occur |
11
|
|
|
* |
12
|
|
|
* @package EventEspresso\core\domain\entities\routing\handlers\shared |
13
|
|
|
* @author Brent Christensen |
14
|
|
|
* @since \$VID:$ |
15
|
|
|
*/ |
16
|
|
|
class GQLRequests extends Route |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* returns true if the current request matches this route |
21
|
|
|
* |
22
|
|
|
* @return bool |
23
|
|
|
* @since $VID:$ |
24
|
|
|
*/ |
25
|
|
|
public function matchesCurrentRequest() |
26
|
|
|
{ |
27
|
|
|
return PHP_VERSION_ID > 70000 |
28
|
|
|
&& ( |
29
|
|
|
$this->request->isGQL() |
30
|
|
|
|| $this->request->isUnitTesting() |
31
|
|
|
|| ( |
32
|
|
|
$this->request->isAdmin() |
33
|
|
|
&& $this->request->getRequestParam('page') === 'espresso_events' |
34
|
|
|
&& ( |
35
|
|
|
$this->request->getRequestParam('action') === 'create_new' |
36
|
|
|
|| $this->request->getRequestParam('action') === 'edit' |
37
|
|
|
) |
38
|
|
|
) |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @since $VID:$ |
45
|
|
|
*/ |
46
|
|
|
protected function registerDependencies() |
47
|
|
|
{ |
48
|
|
|
$this->dependency_map->registerDependencies( |
49
|
|
|
'EventEspresso\core\services\graphql\GraphQLManager', |
50
|
|
|
[ |
51
|
|
|
'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache, |
52
|
|
|
'EventEspresso\core\services\graphql\DataLoaderManager' => EE_Dependency_Map::load_from_cache, |
53
|
|
|
'EventEspresso\core\services\graphql\EnumsManager' => EE_Dependency_Map::load_from_cache, |
54
|
|
|
'EventEspresso\core\services\graphql\InputsManager' => EE_Dependency_Map::load_from_cache, |
55
|
|
|
'EventEspresso\core\services\graphql\TypesManager' => EE_Dependency_Map::load_from_cache, |
56
|
|
|
] |
57
|
|
|
); |
58
|
|
|
$this->dependency_map->registerDependencies( |
59
|
|
|
'EventEspresso\core\services\graphql\TypesManager', |
60
|
|
|
[ |
61
|
|
|
'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache, |
62
|
|
|
] |
63
|
|
|
); |
64
|
|
|
$this->dependency_map->registerDependencies( |
65
|
|
|
'EventEspresso\core\services\graphql\InputsManager', |
66
|
|
|
[ |
67
|
|
|
'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache, |
68
|
|
|
] |
69
|
|
|
); |
70
|
|
|
$this->dependency_map->registerDependencies( |
71
|
|
|
'EventEspresso\core\services\graphql\EnumsManager', |
72
|
|
|
[ |
73
|
|
|
'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache, |
74
|
|
|
] |
75
|
|
|
); |
76
|
|
|
$this->dependency_map->registerDependencies( |
77
|
|
|
'EventEspresso\core\services\graphql\ConnectionsManager', |
78
|
|
|
[ |
79
|
|
|
'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache, |
80
|
|
|
] |
81
|
|
|
); |
82
|
|
|
$this->dependency_map->registerDependencies( |
83
|
|
|
'EventEspresso\core\services\graphql\DataLoaderManager', |
84
|
|
|
[ |
85
|
|
|
'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache, |
86
|
|
|
] |
87
|
|
|
); |
88
|
|
|
$this->dependency_map->registerDependencies( |
89
|
|
|
'EventEspresso\core\domain\services\graphql\types\Datetime', |
90
|
|
|
['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
91
|
|
|
); |
92
|
|
|
$this->dependency_map->registerDependencies( |
93
|
|
|
'EventEspresso\core\domain\services\graphql\types\Attendee', |
94
|
|
|
['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
95
|
|
|
); |
96
|
|
|
$this->dependency_map->registerDependencies( |
97
|
|
|
'EventEspresso\core\domain\services\graphql\types\Event', |
98
|
|
|
['EEM_Event' => EE_Dependency_Map::load_from_cache] |
99
|
|
|
); |
100
|
|
|
$this->dependency_map->registerDependencies( |
101
|
|
|
'EventEspresso\core\domain\services\graphql\types\Ticket', |
102
|
|
|
['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
103
|
|
|
); |
104
|
|
|
$this->dependency_map->registerDependencies( |
105
|
|
|
'EventEspresso\core\domain\services\graphql\types\Price', |
106
|
|
|
['EEM_Price' => EE_Dependency_Map::load_from_cache] |
107
|
|
|
); |
108
|
|
|
$this->dependency_map->registerDependencies( |
109
|
|
|
'EventEspresso\core\domain\services\graphql\types\PriceType', |
110
|
|
|
['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
111
|
|
|
); |
112
|
|
|
$this->dependency_map->registerDependencies( |
113
|
|
|
'EventEspresso\core\domain\services\graphql\types\Venue', |
114
|
|
|
['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
115
|
|
|
); |
116
|
|
|
$this->dependency_map->registerDependencies( |
117
|
|
|
'EventEspresso\core\domain\services\graphql\types\State', |
118
|
|
|
['EEM_State' => EE_Dependency_Map::load_from_cache] |
119
|
|
|
); |
120
|
|
|
$this->dependency_map->registerDependencies( |
121
|
|
|
'EventEspresso\core\domain\services\graphql\types\Country', |
122
|
|
|
['EEM_Country' => EE_Dependency_Map::load_from_cache] |
123
|
|
|
); |
124
|
|
|
$this->dependency_map->registerDependencies( |
125
|
|
|
'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection', |
126
|
|
|
['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
127
|
|
|
); |
128
|
|
|
$this->dependency_map->registerDependencies( |
129
|
|
|
'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection', |
130
|
|
|
['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
131
|
|
|
); |
132
|
|
|
$this->dependency_map->registerDependencies( |
133
|
|
|
'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection', |
134
|
|
|
['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
135
|
|
|
); |
136
|
|
|
$this->dependency_map->registerDependencies( |
137
|
|
|
'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection', |
138
|
|
|
['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
139
|
|
|
); |
140
|
|
|
$this->dependency_map->registerDependencies( |
141
|
|
|
'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection', |
142
|
|
|
['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
143
|
|
|
); |
144
|
|
|
$this->dependency_map->registerDependencies( |
145
|
|
|
'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection', |
146
|
|
|
['EEM_Price' => EE_Dependency_Map::load_from_cache] |
147
|
|
|
); |
148
|
|
|
$this->dependency_map->registerDependencies( |
149
|
|
|
'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection', |
150
|
|
|
['EEM_Price' => EE_Dependency_Map::load_from_cache] |
151
|
|
|
); |
152
|
|
|
$this->dependency_map->registerDependencies( |
153
|
|
|
'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection', |
154
|
|
|
['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
155
|
|
|
); |
156
|
|
|
$this->dependency_map->registerDependencies( |
157
|
|
|
'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection', |
158
|
|
|
['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
159
|
|
|
); |
160
|
|
|
$this->dependency_map->registerDependencies( |
161
|
|
|
'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection', |
162
|
|
|
['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
163
|
|
|
); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* implements logic required to run during request |
169
|
|
|
* |
170
|
|
|
* @return bool |
171
|
|
|
* @since $VID:$ |
172
|
|
|
*/ |
173
|
|
|
protected function requestHandler() |
174
|
|
|
{ |
175
|
|
|
|
176
|
|
|
if (! class_exists('WPGraphQL')) { |
177
|
|
|
require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
178
|
|
|
} |
179
|
|
|
// load handler for EE GraphQL requests |
180
|
|
|
$graphQL_manager = $this->loader->getShared( |
181
|
|
|
'EventEspresso\core\services\graphql\GraphQLManager' |
182
|
|
|
); |
183
|
|
|
$graphQL_manager->init(); |
184
|
|
|
return true; |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|