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