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