1
|
|
|
<?php |
2
|
|
|
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
3
|
|
|
exit( 'No direct script access allowed' ); |
4
|
|
|
} |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class EE_Dependency_Map |
10
|
|
|
* |
11
|
|
|
* info about how to load classes required by other classes |
12
|
|
|
* |
13
|
|
|
* @package Event Espresso |
14
|
|
|
* @subpackage core |
15
|
|
|
* @author Brent Christensen |
16
|
|
|
* @since 4.9.0 |
17
|
|
|
* |
18
|
|
|
*/ |
19
|
|
|
class EE_Dependency_Map { |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* This means that the requested class dependency is not present in the dependency map |
24
|
|
|
*/ |
25
|
|
|
const not_registered = 0; |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
30
|
|
|
*/ |
31
|
|
|
const load_new_object = 1; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* This instructs class loaders to return a previously instantiated and cached object for the requested class. |
35
|
|
|
* IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
36
|
|
|
*/ |
37
|
|
|
const load_from_cache = 2; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @type EE_Dependency_Map $_instance |
41
|
|
|
*/ |
42
|
|
|
protected static $_instance; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @type EE_Request $request |
46
|
|
|
*/ |
47
|
|
|
protected $_request; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @type EE_Response $response |
51
|
|
|
*/ |
52
|
|
|
protected $_response; |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @type array $_dependency_map |
57
|
|
|
*/ |
58
|
|
|
protected $_dependency_map = array(); |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @type array $_class_loaders |
62
|
|
|
*/ |
63
|
|
|
protected $_class_loaders = array(); |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @type array $_aliases |
67
|
|
|
*/ |
68
|
|
|
protected $_aliases = array(); |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* EE_Dependency_Map constructor. |
74
|
|
|
* |
75
|
|
|
* @param \EE_Request $request |
76
|
|
|
* @param \EE_Response $response |
77
|
|
|
*/ |
78
|
|
|
protected function __construct( EE_Request $request, EE_Response $response ) { |
79
|
|
|
$this->_request = $request; |
80
|
|
|
$this->_response = $response; |
81
|
|
|
add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
82
|
|
|
do_action( 'EE_Dependency_Map____construct' ); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
*/ |
89
|
|
|
public function initialize() { |
90
|
|
|
$this->_register_core_dependencies(); |
91
|
|
|
$this->_register_core_class_loaders(); |
92
|
|
|
$this->_register_core_aliases(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @singleton method used to instantiate class object |
99
|
|
|
* @access public |
100
|
|
|
* @param \EE_Request $request |
101
|
|
|
* @param \EE_Response $response |
102
|
|
|
* @return \EE_Dependency_Map instance |
103
|
|
|
*/ |
104
|
|
|
public static function instance( EE_Request $request = null, EE_Response $response = null ) { |
105
|
|
|
// check if class object is instantiated, and instantiated properly |
106
|
|
|
if ( ! self::$_instance instanceof EE_Dependency_Map ) { |
107
|
|
|
self::$_instance = new EE_Dependency_Map( $request, $response ); |
|
|
|
|
108
|
|
|
} |
109
|
|
|
return self::$_instance; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param string $class |
116
|
|
|
* @param array $dependencies |
117
|
|
|
* @return boolean |
118
|
|
|
*/ |
119
|
|
|
public static function register_dependencies( $class, $dependencies ) { |
120
|
|
|
if ( ! isset( self::$_instance->_dependency_map[ $class ] ) ) { |
121
|
|
|
// we need to make sure that any aliases used when registering a dependency |
122
|
|
|
// get resolved to the correct class name |
123
|
|
|
foreach ( (array) $dependencies as $dependency => $load_source ) { |
124
|
|
|
$alias = self::$_instance->get_alias( $dependency ); |
125
|
|
|
unset( $dependencies[ $dependency ] ); |
126
|
|
|
$dependencies[ $alias ] = $load_source; |
127
|
|
|
} |
128
|
|
|
self::$_instance->_dependency_map[ $class ] = (array) $dependencies; |
129
|
|
|
return true; |
130
|
|
|
} |
131
|
|
|
return false; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param string $class_name |
138
|
|
|
* @param string $loader |
139
|
|
|
* @return bool |
140
|
|
|
* @throws \EE_Error |
141
|
|
|
*/ |
142
|
|
|
public static function register_class_loader( $class_name, $loader = 'load_core' ) { |
143
|
|
|
// check that loader method starts with "load_" and exists in EE_Registry |
144
|
|
|
if ( |
145
|
|
|
! is_callable($loader) |
146
|
|
|
&& (strpos( $loader, 'load_' ) !== 0 || ! method_exists( 'EE_Registry', $loader )) |
147
|
|
|
) { |
148
|
|
|
throw new EE_Error( |
149
|
|
|
sprintf( |
150
|
|
|
__( '"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso' ), |
151
|
|
|
$loader |
152
|
|
|
) |
153
|
|
|
); |
154
|
|
|
} |
155
|
|
|
$class_name = self::$_instance->get_alias( $class_name ); |
156
|
|
|
if ( ! isset( self::$_instance->_class_loaders[ $class_name ] ) ) { |
157
|
|
|
self::$_instance->_class_loaders[ $class_name ] = $loader; |
158
|
|
|
return true; |
159
|
|
|
} |
160
|
|
|
return false; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
|
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @return array |
167
|
|
|
*/ |
168
|
|
|
public function dependency_map() { |
169
|
|
|
return $this->_dependency_map; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
|
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* returns TRUE if dependency map contains a listing for the provided class name |
176
|
|
|
* |
177
|
|
|
* @param string $class_name |
178
|
|
|
* @return boolean |
179
|
|
|
*/ |
180
|
|
|
public function has( $class_name = '' ) { |
181
|
|
|
return isset( $this->_dependency_map[ $class_name ] ) ? true : false; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
|
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* returns TRUE if dependency map contains a listing for the provided class name AND dependency |
188
|
|
|
* |
189
|
|
|
* @param string $class_name |
190
|
|
|
* @param string $dependency |
191
|
|
|
* @return bool |
192
|
|
|
*/ |
193
|
|
|
public function has_dependency_for_class( $class_name = '', $dependency = '' ) { |
194
|
|
|
$dependency = $this->get_alias( $dependency ); |
195
|
|
|
return isset( $this->_dependency_map[ $class_name ], $this->_dependency_map[ $class_name ][ $dependency ] ) |
196
|
|
|
? true |
197
|
|
|
: false; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
|
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
204
|
|
|
* |
205
|
|
|
* @param string $class_name |
206
|
|
|
* @param string $dependency |
207
|
|
|
* @return int |
208
|
|
|
*/ |
209
|
|
|
public function loading_strategy_for_class_dependency( $class_name = '', $dependency = '' ) { |
210
|
|
|
$dependency = $this->get_alias( $dependency ); |
211
|
|
|
return $this->has_dependency_for_class( $class_name, $dependency ) |
212
|
|
|
? $this->_dependency_map[ $class_name ][ $dependency ] |
213
|
|
|
: EE_Dependency_Map::not_registered; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
|
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @param string $class_name |
220
|
|
|
* @return string | Closure |
221
|
|
|
*/ |
222
|
|
|
public function class_loader( $class_name ) { |
223
|
|
|
$class_name = $this->get_alias( $class_name ); |
224
|
|
|
return isset( $this->_class_loaders[ $class_name ] ) ? $this->_class_loaders[ $class_name ] : ''; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
|
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @return array |
231
|
|
|
*/ |
232
|
|
|
public function class_loaders() { |
233
|
|
|
return $this->_class_loaders; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
|
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* adds an alias for a classname |
240
|
|
|
* |
241
|
|
|
* @param string $class_name the class name that should be used (concrete class to replace interface) |
242
|
|
|
* @param string $alias the class name that would be type hinted for (abstract parent or interface) |
243
|
|
|
* @param string $for_class the class that has the dependency (is type hinting for the interface) |
244
|
|
|
*/ |
245
|
|
|
public function add_alias( $class_name, $alias, $for_class = '' ) { |
246
|
|
|
if ($for_class !== '') { |
247
|
|
|
if ( ! isset($this->_aliases[$for_class])) { |
248
|
|
|
$this->_aliases[$for_class] = array(); |
249
|
|
|
} |
250
|
|
|
$this->_aliases[$for_class][$class_name] = $alias; |
251
|
|
|
} |
252
|
|
|
$this->_aliases[ $class_name ] = $alias; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
|
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* returns TRUE if the provided class name has an alias |
259
|
|
|
* |
260
|
|
|
* @param string $class_name |
261
|
|
|
* @param string $for_class |
262
|
|
|
* @return bool |
263
|
|
|
*/ |
264
|
|
|
public function has_alias( $class_name = '', $for_class = '' ) { |
265
|
|
|
if (isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])) { |
266
|
|
|
return true; |
267
|
|
|
} |
268
|
|
|
return isset( $this->_aliases[ $class_name ] ) && ! is_array( $this->_aliases[ $class_name ] ) ? true : false; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
|
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* returns alias for class name if one exists, otherwise returns the original classname |
275
|
|
|
* functions recursively, so that multiple aliases can be used to drill down to a classname |
276
|
|
|
* for example: |
277
|
|
|
* if the following two entries were added to the _aliases array: |
278
|
|
|
* array( |
279
|
|
|
* 'interface_alias' => 'some\namespace\interface' |
280
|
|
|
* 'some\namespace\interface' => 'some\namespace\classname' |
281
|
|
|
* ) |
282
|
|
|
* then one could use EE_Registry::instance()->create( 'interface_alias' ) |
283
|
|
|
* to load an instance of 'some\namespace\classname' |
284
|
|
|
* |
285
|
|
|
* @param string $class_name |
286
|
|
|
* @param string $for_class |
287
|
|
|
* @return string |
288
|
|
|
*/ |
289
|
|
|
public function get_alias( $class_name = '', $for_class = '' ) { |
290
|
|
|
if(! $this->has_alias($class_name, $for_class)) { |
291
|
|
|
return $class_name; |
292
|
|
|
} |
293
|
|
|
if ($for_class !== '') { |
294
|
|
|
return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
295
|
|
|
} |
296
|
|
|
return $this->get_alias( $this->_aliases[ $class_name ] ); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
302
|
|
|
* if one exists, or whether a new object should be generated every time the requested class is loaded. |
303
|
|
|
* This is done by using the following class constants: |
304
|
|
|
* |
305
|
|
|
* EE_Dependency_Map::load_from_cache - loads previously instantiated object |
306
|
|
|
* EE_Dependency_Map::load_new_object - generates a new object every time |
307
|
|
|
*/ |
308
|
|
|
protected function _register_core_dependencies() { |
309
|
|
|
$this->_dependency_map = array( |
310
|
|
|
'EE_Request_Handler' => array( |
311
|
|
|
'EE_Request' => EE_Dependency_Map::load_from_cache, |
312
|
|
|
), |
313
|
|
|
'EE_System' => array( |
314
|
|
|
'EE_Registry' => EE_Dependency_Map::load_from_cache, |
315
|
|
|
), |
316
|
|
|
'EE_Session' => array( |
317
|
|
|
'EE_Encryption' => EE_Dependency_Map::load_from_cache |
318
|
|
|
), |
319
|
|
|
'EE_Cart' => array( |
320
|
|
|
'EE_Session' => EE_Dependency_Map::load_from_cache, |
321
|
|
|
), |
322
|
|
|
'EE_Front_Controller' => array( |
323
|
|
|
'EE_Registry' => EE_Dependency_Map::load_from_cache, |
324
|
|
|
'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
325
|
|
|
'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
326
|
|
|
), |
327
|
|
|
'EE_Messenger_Collection_Loader' => array( |
328
|
|
|
'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
329
|
|
|
), |
330
|
|
|
'EE_Message_Type_Collection_Loader' => array( |
331
|
|
|
'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
332
|
|
|
), |
333
|
|
|
'EE_Message_Resource_Manager' => array( |
334
|
|
|
'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
335
|
|
|
'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
336
|
|
|
'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
337
|
|
|
), |
338
|
|
|
'EE_Message_Factory' => array( |
339
|
|
|
'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
340
|
|
|
), |
341
|
|
|
'EE_messages' => array( |
342
|
|
|
'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
343
|
|
|
), |
344
|
|
|
'EE_Messages_Generator' => array( |
345
|
|
|
'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
346
|
|
|
'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
347
|
|
|
'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
348
|
|
|
'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
349
|
|
|
), |
350
|
|
|
'EE_Messages_Processor' => array( |
351
|
|
|
'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
352
|
|
|
), |
353
|
|
|
'EE_Messages_Queue' => array( |
354
|
|
|
'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
355
|
|
|
), |
356
|
|
|
'EE_Messages_Template_Defaults' => array( |
357
|
|
|
'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
358
|
|
|
'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
359
|
|
|
), |
360
|
|
|
'EE_Message_To_Generate_From_Request' => array( |
361
|
|
|
'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
362
|
|
|
'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
363
|
|
|
), |
364
|
|
|
'EventEspresso\core\services\commands\CommandBus' => array( |
365
|
|
|
'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
366
|
|
|
), |
367
|
|
|
'EventEspresso\services\commands\CommandHandler' => array( |
368
|
|
|
'EE_Registry' => EE_Dependency_Map::load_from_cache, |
369
|
|
|
'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
370
|
|
|
), |
371
|
|
|
'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
372
|
|
|
'EE_Registry' => EE_Dependency_Map::load_from_cache, |
373
|
|
|
), |
374
|
|
|
'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
375
|
|
|
'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
376
|
|
|
), |
377
|
|
|
'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
378
|
|
|
'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
379
|
|
|
), |
380
|
|
|
'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
381
|
|
|
'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
382
|
|
|
), |
383
|
|
|
'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
384
|
|
|
'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
385
|
|
|
), |
386
|
|
|
'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
387
|
|
|
'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
388
|
|
|
), |
389
|
|
|
'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
390
|
|
|
'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
391
|
|
|
), |
392
|
|
|
'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
393
|
|
|
'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
394
|
|
|
), |
395
|
|
|
'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
396
|
|
|
'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
397
|
|
|
), |
398
|
|
|
'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
399
|
|
|
'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
400
|
|
|
), |
401
|
|
|
'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
402
|
|
|
'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
403
|
|
|
), |
404
|
|
|
'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
405
|
|
|
'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
406
|
|
|
), |
407
|
|
|
'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
408
|
|
|
'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
409
|
|
|
), |
410
|
|
|
'EventEspresso\core\services\database\TableManager' => array( |
411
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
412
|
|
|
), |
413
|
|
|
'EE_Data_Migration_Class_Base' => array( |
414
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
415
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
416
|
|
|
), |
417
|
|
|
'EE_DMS_Core_4_1_0' => array( |
418
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
419
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
420
|
|
|
), |
421
|
|
|
'EE_DMS_Core_4_2_0' => array( |
422
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
423
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
424
|
|
|
), |
425
|
|
|
'EE_DMS_Core_4_3_0' => array( |
426
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
427
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
428
|
|
|
), |
429
|
|
|
'EE_DMS_Core_4_4_0' => array( |
430
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
431
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
432
|
|
|
), |
433
|
|
|
'EE_DMS_Core_4_5_0' => array( |
434
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
435
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
436
|
|
|
), |
437
|
|
|
'EE_DMS_Core_4_6_0' => array( |
438
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
439
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
440
|
|
|
), |
441
|
|
|
'EE_DMS_Core_4_7_0' => array( |
442
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
443
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
444
|
|
|
), |
445
|
|
|
'EE_DMS_Core_4_8_0' => array( |
446
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
447
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
448
|
|
|
), |
449
|
|
|
'EE_DMS_Core_4_9_0' => array( |
450
|
|
|
'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
451
|
|
|
'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
452
|
|
|
), |
453
|
|
|
); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
|
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* Registers how core classes are loaded. |
460
|
|
|
* |
461
|
|
|
* This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
462
|
|
|
* |
463
|
|
|
* 'EE_Request_Handler' => 'load_core' |
464
|
|
|
* 'EE_Messages_Queue' => 'load_lib' |
465
|
|
|
* 'EEH_Debug_Tools' => 'load_helper' |
466
|
|
|
* |
467
|
|
|
* or, if greater control is required, by providing a custom closure. For example: |
468
|
|
|
* |
469
|
|
|
* 'Some_Class' => function () { |
470
|
|
|
* return new Some_Class(); |
471
|
|
|
* }, |
472
|
|
|
* |
473
|
|
|
* This is required for instantiating dependencies |
474
|
|
|
* where an interface has been type hinted in a class constructor. For example: |
475
|
|
|
* |
476
|
|
|
* 'Required_Interface' => function () { |
477
|
|
|
* return new A_Class_That_Implements_Required_Interface(); |
478
|
|
|
* }, |
479
|
|
|
* |
480
|
|
|
*/ |
481
|
|
|
protected function _register_core_class_loaders() { |
482
|
|
|
//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
483
|
|
|
//be used in a closure. |
484
|
|
|
$request = &$this->_request; |
485
|
|
|
$response = &$this->_response; |
486
|
|
|
$this->_class_loaders = array( |
487
|
|
|
//load_core |
488
|
|
|
'EE_Capabilities' => 'load_core', |
489
|
|
|
'EE_Encryption' => 'load_core', |
490
|
|
|
'EE_Front_Controller' => 'load_core', |
491
|
|
|
'EE_Module_Request_Router' => 'load_core', |
492
|
|
|
'EE_Registry' => 'load_core', |
493
|
|
|
'EE_Request' => function() use(&$request) { |
494
|
|
|
return $request; |
495
|
|
|
}, |
496
|
|
|
'EE_Response' => function() use(&$response) { |
497
|
|
|
return $response; |
498
|
|
|
}, |
499
|
|
|
'EE_Request_Handler' => 'load_core', |
500
|
|
|
'EE_Session' => 'load_core', |
501
|
|
|
'EE_System' => 'load_core', |
502
|
|
|
//load_lib |
503
|
|
|
'EE_Message_Resource_Manager' => 'load_lib', |
504
|
|
|
'EE_Message_Type_Collection' => 'load_lib', |
505
|
|
|
'EE_Message_Type_Collection_Loader' => 'load_lib', |
506
|
|
|
'EE_Messenger_Collection' => 'load_lib', |
507
|
|
|
'EE_Messenger_Collection_Loader' => 'load_lib', |
508
|
|
|
'EE_Messages_Processor' => 'load_lib', |
509
|
|
|
'EE_Message_Repository' => 'load_lib', |
510
|
|
|
'EE_Messages_Queue' => 'load_lib', |
511
|
|
|
'EE_Messages_Data_Handler_Collection' => 'load_lib', |
512
|
|
|
'EE_Message_Template_Group_Collection' => 'load_lib', |
513
|
|
|
'EE_Messages_Generator' => function() { |
514
|
|
|
return EE_Registry::instance()->load_lib( 'Messages_Generator', array(), false, false ); |
515
|
|
|
}, |
516
|
|
|
'EE_Messages_Template_Defaults' => function( $arguments = array() ) { |
517
|
|
|
return EE_Registry::instance()->load_lib( 'Messages_Template_Defaults', $arguments, false, false ); |
518
|
|
|
}, |
519
|
|
|
//load_model |
520
|
|
|
'EEM_Attendee' => 'load_model', |
521
|
|
|
'EEM_Message_Template_Group' => 'load_model', |
522
|
|
|
'EEM_Message_Template' => 'load_model', |
523
|
|
|
//load_helper |
524
|
|
|
'EEH_Parse_Shortcodes' => function() { |
525
|
|
|
if ( EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ) ) { |
526
|
|
|
return new EEH_Parse_Shortcodes(); |
527
|
|
|
} |
528
|
|
|
return null; |
529
|
|
|
}, |
530
|
|
|
); |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* can be used for supplying alternate names for classes, |
536
|
|
|
* or for connecting interface names to instantiable classes |
537
|
|
|
*/ |
538
|
|
|
protected function _register_core_aliases() { |
539
|
|
|
$this->_aliases = array( |
540
|
|
|
'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
541
|
|
|
'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
542
|
|
|
'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
543
|
|
|
'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
544
|
|
|
'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
545
|
|
|
'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
546
|
|
|
'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
547
|
|
|
'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
548
|
|
|
'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
549
|
|
|
'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
550
|
|
|
'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
551
|
|
|
'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
552
|
|
|
'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
553
|
|
|
'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
554
|
|
|
'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
555
|
|
|
'TableManager' => 'EventEspresso\core\services\database\TableManager', |
556
|
|
|
'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
557
|
|
|
'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
558
|
|
|
'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
559
|
|
|
); |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
|
563
|
|
|
/** |
564
|
|
|
* This is used to reset the internal map and class_loaders to their original default state at the beginning of the request |
565
|
|
|
* Primarily used by unit tests. |
566
|
|
|
*/ |
567
|
|
|
public function reset() { |
568
|
|
|
$this->_register_core_class_loaders(); |
569
|
|
|
$this->_register_core_dependencies(); |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
|
573
|
|
|
} |
574
|
|
|
// End of file EE_Dependency_Map.core.php |
575
|
|
|
// Location: /EE_Dependency_Map.core.php |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):