Completed
Branch FET/337/reserved-instance-inte... (25ad8f)
by
unknown
28:05 queued 15:02
created
core/EE_Dependency_Map.core.php 2 patches
Indentation   +946 added lines, -946 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 use EventEspresso\core\services\request\ResponseInterface;
10 10
 
11 11
 if (! defined('EVENT_ESPRESSO_VERSION')) {
12
-    exit('No direct script access allowed');
12
+	exit('No direct script access allowed');
13 13
 }
14 14
 
15 15
 
@@ -26,952 +26,952 @@  discard block
 block discarded – undo
26 26
 class EE_Dependency_Map
27 27
 {
28 28
 
29
-    /**
30
-     * This means that the requested class dependency is not present in the dependency map
31
-     */
32
-    const not_registered = 0;
33
-
34
-    /**
35
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
36
-     */
37
-    const load_new_object = 1;
38
-
39
-    /**
40
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
41
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
42
-     */
43
-    const load_from_cache = 2;
44
-
45
-    /**
46
-     * When registering a dependency,
47
-     * this indicates to keep any existing dependencies that already exist,
48
-     * and simply discard any new dependencies declared in the incoming data
49
-     */
50
-    const KEEP_EXISTING_DEPENDENCIES = 0;
51
-
52
-    /**
53
-     * When registering a dependency,
54
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
55
-     */
56
-    const OVERWRITE_DEPENDENCIES = 1;
57
-
58
-
59
-
60
-    /**
61
-     * @type EE_Dependency_Map $_instance
62
-     */
63
-    protected static $_instance;
64
-
65
-    /**
66
-     * @var ClassInterfaceCache $class_cache
67
-     */
68
-    private $class_cache;
69
-
70
-    /**
71
-     * @type RequestInterface $request
72
-     */
73
-    protected $request;
74
-
75
-    /**
76
-     * @type LegacyRequestInterface $legacy_request
77
-     */
78
-    protected $legacy_request;
79
-
80
-    /**
81
-     * @type ResponseInterface $response
82
-     */
83
-    protected $response;
84
-
85
-    /**
86
-     * @type LoaderInterface $loader
87
-     */
88
-    protected $loader;
89
-
90
-    /**
91
-     * @type array $_dependency_map
92
-     */
93
-    protected $_dependency_map = array();
94
-
95
-    /**
96
-     * @type array $_class_loaders
97
-     */
98
-    protected $_class_loaders = array();
99
-
100
-
101
-    /**
102
-     * EE_Dependency_Map constructor.
103
-     *
104
-     * @param ClassInterfaceCache $class_cache
105
-     */
106
-    protected function __construct(ClassInterfaceCache $class_cache)
107
-    {
108
-        $this->class_cache = $class_cache;
109
-        do_action('EE_Dependency_Map____construct', $this);
110
-    }
111
-
112
-
113
-    /**
114
-     * @return void
115
-     */
116
-    public function initialize()
117
-    {
118
-        $this->_register_core_dependencies();
119
-        $this->_register_core_class_loaders();
120
-        $this->_register_core_aliases();
121
-    }
122
-
123
-
124
-    /**
125
-     * @singleton method used to instantiate class object
126
-     * @param ClassInterfaceCache|null $class_cache
127
-     * @return EE_Dependency_Map
128
-     */
129
-    public static function instance(ClassInterfaceCache $class_cache = null) {
130
-        // check if class object is instantiated, and instantiated properly
131
-        if (
132
-            ! self::$_instance instanceof EE_Dependency_Map
133
-            && $class_cache instanceof ClassInterfaceCache
134
-        ) {
135
-            self::$_instance = new EE_Dependency_Map($class_cache);
136
-        }
137
-        return self::$_instance;
138
-    }
139
-
140
-
141
-    /**
142
-     * @param RequestInterface $request
143
-     */
144
-    public function setRequest(RequestInterface $request)
145
-    {
146
-        $this->request = $request;
147
-    }
148
-
149
-
150
-    /**
151
-     * @param LegacyRequestInterface $legacy_request
152
-     */
153
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
154
-    {
155
-        $this->legacy_request = $legacy_request;
156
-    }
157
-
158
-
159
-    /**
160
-     * @param ResponseInterface $response
161
-     */
162
-    public function setResponse(ResponseInterface $response)
163
-    {
164
-        $this->response = $response;
165
-    }
166
-
167
-
168
-
169
-    /**
170
-     * @param LoaderInterface $loader
171
-     */
172
-    public function setLoader(LoaderInterface $loader)
173
-    {
174
-        $this->loader = $loader;
175
-    }
176
-
177
-
178
-
179
-    /**
180
-     * @param string $class
181
-     * @param array  $dependencies
182
-     * @param int    $overwrite
183
-     * @return bool
184
-     */
185
-    public static function register_dependencies(
186
-        $class,
187
-        array $dependencies,
188
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
189
-    ) {
190
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
191
-    }
192
-
193
-
194
-
195
-    /**
196
-     * Assigns an array of class names and corresponding load sources (new or cached)
197
-     * to the class specified by the first parameter.
198
-     * IMPORTANT !!!
199
-     * The order of elements in the incoming $dependencies array MUST match
200
-     * the order of the constructor parameters for the class in question.
201
-     * This is especially important when overriding any existing dependencies that are registered.
202
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
203
-     *
204
-     * @param string $class
205
-     * @param array  $dependencies
206
-     * @param int    $overwrite
207
-     * @return bool
208
-     */
209
-    public function registerDependencies(
210
-        $class,
211
-        array $dependencies,
212
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
213
-    ) {
214
-        $class = trim($class, '\\');
215
-        $registered = false;
216
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
217
-            self::$_instance->_dependency_map[ $class ] = array();
218
-        }
219
-        // we need to make sure that any aliases used when registering a dependency
220
-        // get resolved to the correct class name
221
-        foreach ($dependencies as $dependency => $load_source) {
222
-            $alias = self::$_instance->getFqnForAlias($dependency);
223
-            if (
224
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
225
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
226
-            ) {
227
-                unset($dependencies[$dependency]);
228
-                $dependencies[$alias] = $load_source;
229
-                $registered = true;
230
-            }
231
-        }
232
-        // now add our two lists of dependencies together.
233
-        // using Union (+=) favours the arrays in precedence from left to right,
234
-        // so $dependencies is NOT overwritten because it is listed first
235
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
236
-        // Union is way faster than array_merge() but should be used with caution...
237
-        // especially with numerically indexed arrays
238
-        $dependencies += self::$_instance->_dependency_map[ $class ];
239
-        // now we need to ensure that the resulting dependencies
240
-        // array only has the entries that are required for the class
241
-        // so first count how many dependencies were originally registered for the class
242
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
243
-        // if that count is non-zero (meaning dependencies were already registered)
244
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
245
-            // then truncate the  final array to match that count
246
-            ? array_slice($dependencies, 0, $dependency_count)
247
-            // otherwise just take the incoming array because nothing previously existed
248
-            : $dependencies;
249
-        return $registered;
250
-    }
251
-
252
-
253
-
254
-    /**
255
-     * @param string $class_name
256
-     * @param string $loader
257
-     * @return bool
258
-     * @throws DomainException
259
-     */
260
-    public static function register_class_loader($class_name, $loader = 'load_core')
261
-    {
262
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
263
-            throw new DomainException(
264
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
265
-            );
266
-        }
267
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
268
-        if (
269
-            ! is_callable($loader)
270
-            && (
271
-                strpos($loader, 'load_') !== 0
272
-                || ! method_exists('EE_Registry', $loader)
273
-            )
274
-        ) {
275
-            throw new DomainException(
276
-                sprintf(
277
-                    esc_html__(
278
-                        '"%1$s" is not a valid loader method on EE_Registry.',
279
-                        'event_espresso'
280
-                    ),
281
-                    $loader
282
-                )
283
-            );
284
-        }
285
-        $class_name = self::$_instance->getFqnForAlias($class_name);
286
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
287
-            self::$_instance->_class_loaders[$class_name] = $loader;
288
-            return true;
289
-        }
290
-        return false;
291
-    }
292
-
293
-
294
-
295
-    /**
296
-     * @return array
297
-     */
298
-    public function dependency_map()
299
-    {
300
-        return $this->_dependency_map;
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     * returns TRUE if dependency map contains a listing for the provided class name
307
-     *
308
-     * @param string $class_name
309
-     * @return boolean
310
-     */
311
-    public function has($class_name = '')
312
-    {
313
-        // all legacy models have the same dependencies
314
-        if (strpos($class_name, 'EEM_') === 0) {
315
-            $class_name = 'LEGACY_MODELS';
316
-        }
317
-        return isset($this->_dependency_map[$class_name]) ? true : false;
318
-    }
319
-
320
-
321
-
322
-    /**
323
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
324
-     *
325
-     * @param string $class_name
326
-     * @param string $dependency
327
-     * @return bool
328
-     */
329
-    public function has_dependency_for_class($class_name = '', $dependency = '')
330
-    {
331
-        // all legacy models have the same dependencies
332
-        if (strpos($class_name, 'EEM_') === 0) {
333
-            $class_name = 'LEGACY_MODELS';
334
-        }
335
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
336
-        return isset($this->_dependency_map[$class_name][$dependency])
337
-            ? true
338
-            : false;
339
-    }
340
-
341
-
342
-
343
-    /**
344
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
345
-     *
346
-     * @param string $class_name
347
-     * @param string $dependency
348
-     * @return int
349
-     */
350
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
351
-    {
352
-        // all legacy models have the same dependencies
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            $class_name = 'LEGACY_MODELS';
355
-        }
356
-        $dependency = $this->getFqnForAlias($dependency);
357
-        return $this->has_dependency_for_class($class_name, $dependency)
358
-            ? $this->_dependency_map[$class_name][$dependency]
359
-            : EE_Dependency_Map::not_registered;
360
-    }
361
-
362
-
363
-
364
-    /**
365
-     * @param string $class_name
366
-     * @return string | Closure
367
-     */
368
-    public function class_loader($class_name)
369
-    {
370
-        // all legacy models use load_model()
371
-        if(strpos($class_name, 'EEM_') === 0){
372
-            return 'load_model';
373
-        }
374
-        $class_name = $this->getFqnForAlias($class_name);
375
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
376
-    }
377
-
378
-
379
-
380
-    /**
381
-     * @return array
382
-     */
383
-    public function class_loaders()
384
-    {
385
-        return $this->_class_loaders;
386
-    }
387
-
388
-
389
-
390
-    /**
391
-     * adds an alias for a classname
392
-     *
393
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
394
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
395
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
396
-     */
397
-    public function add_alias($fqcn, $alias, $for_class = '')
398
-    {
399
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
400
-    }
401
-
402
-
403
-
404
-    /**
405
-     * Returns TRUE if the provided fully qualified name IS an alias
406
-     * WHY?
407
-     * Because if a class is type hinting for a concretion,
408
-     * then why would we need to find another class to supply it?
409
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
410
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
411
-     * Don't go looking for some substitute.
412
-     * Whereas if a class is type hinting for an interface...
413
-     * then we need to find an actual class to use.
414
-     * So the interface IS the alias for some other FQN,
415
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
416
-     * represents some other class.
417
-     *
418
-     * @param string $fqn
419
-     * @param string $for_class
420
-     * @return bool
421
-     */
422
-    public function isAlias($fqn = '', $for_class = '')
423
-    {
424
-        return $this->class_cache->isAlias($fqn, $for_class);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
431
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
432
-     *  for example:
433
-     *      if the following two entries were added to the _aliases array:
434
-     *          array(
435
-     *              'interface_alias'           => 'some\namespace\interface'
436
-     *              'some\namespace\interface'  => 'some\namespace\classname'
437
-     *          )
438
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
439
-     *      to load an instance of 'some\namespace\classname'
440
-     *
441
-     * @param string $alias
442
-     * @param string $for_class
443
-     * @return string
444
-     */
445
-    public function getFqnForAlias($alias = '', $for_class = '')
446
-    {
447
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
448
-    }
449
-
450
-
451
-
452
-    /**
453
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
454
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
455
-     * This is done by using the following class constants:
456
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
457
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
458
-     */
459
-    protected function _register_core_dependencies()
460
-    {
461
-        $this->_dependency_map = array(
462
-            'EE_Request_Handler'                                                                                          => array(
463
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
464
-            ),
465
-            'EE_System'                                                                                                   => array(
466
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
467
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
468
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
469
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
470
-            ),
471
-            'EE_Session'                                                                                                  => array(
472
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
473
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
474
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
475
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
476
-            ),
477
-            'EE_Cart'                                                                                                     => array(
478
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Front_Controller'                                                                                         => array(
481
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
482
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
483
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
484
-            ),
485
-            'EE_Messenger_Collection_Loader'                                                                              => array(
486
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
487
-            ),
488
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
489
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
490
-            ),
491
-            'EE_Message_Resource_Manager'                                                                                 => array(
492
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
493
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
494
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
495
-            ),
496
-            'EE_Message_Factory'                                                                                          => array(
497
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
498
-            ),
499
-            'EE_messages'                                                                                                 => array(
500
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EE_Messages_Generator'                                                                                       => array(
503
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
504
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
505
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
506
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
507
-            ),
508
-            'EE_Messages_Processor'                                                                                       => array(
509
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
510
-            ),
511
-            'EE_Messages_Queue'                                                                                           => array(
512
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
513
-            ),
514
-            'EE_Messages_Template_Defaults'                                                                               => array(
515
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
516
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
517
-            ),
518
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
519
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
520
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
521
-            ),
522
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
523
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
526
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
527
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
528
-            ),
529
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
530
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
531
-            ),
532
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
533
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
534
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
537
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
540
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
543
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
546
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
549
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
552
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
555
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
558
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
561
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
564
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
567
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
-            ),
569
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
570
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
-            ),
572
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
573
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EE_Data_Migration_Class_Base'                                                                                => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
-            ),
582
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
583
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
-            ),
586
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
587
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
-            ),
590
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
591
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
-            ),
594
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
595
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
596
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
597
-            ),
598
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
599
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
600
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
601
-            ),
602
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
603
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
604
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
605
-            ),
606
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
607
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
608
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
609
-            ),
610
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
611
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
612
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
613
-            ),
614
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
615
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
616
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
617
-            ),
618
-            'EventEspresso\core\services\assets\I18nRegistry' => array(
619
-                array(),
620
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
621
-            ),
622
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
623
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
624
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
625
-                'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
626
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
638
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
641
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
644
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
647
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
648
-            ),
649
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
650
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
651
-            ),
652
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
653
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
654
-            ),
655
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
656
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
657
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
658
-            ),
659
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
660
-                null,
661
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
662
-            ),
663
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
664
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
665
-            ),
666
-            'LEGACY_MODELS'                                                   => array(
667
-                null,
668
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
669
-            ),
670
-            'EE_Module_Request_Router' => array(
671
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EE_Registration_Processor' => array(
674
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
675
-            ),
676
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
677
-                null,
678
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
679
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
680
-            ),
681
-            'EventEspresso\core\services\licensing\LicenseService' => array(
682
-                'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
683
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
684
-            ),
29
+	/**
30
+	 * This means that the requested class dependency is not present in the dependency map
31
+	 */
32
+	const not_registered = 0;
33
+
34
+	/**
35
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
36
+	 */
37
+	const load_new_object = 1;
38
+
39
+	/**
40
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
41
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
42
+	 */
43
+	const load_from_cache = 2;
44
+
45
+	/**
46
+	 * When registering a dependency,
47
+	 * this indicates to keep any existing dependencies that already exist,
48
+	 * and simply discard any new dependencies declared in the incoming data
49
+	 */
50
+	const KEEP_EXISTING_DEPENDENCIES = 0;
51
+
52
+	/**
53
+	 * When registering a dependency,
54
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
55
+	 */
56
+	const OVERWRITE_DEPENDENCIES = 1;
57
+
58
+
59
+
60
+	/**
61
+	 * @type EE_Dependency_Map $_instance
62
+	 */
63
+	protected static $_instance;
64
+
65
+	/**
66
+	 * @var ClassInterfaceCache $class_cache
67
+	 */
68
+	private $class_cache;
69
+
70
+	/**
71
+	 * @type RequestInterface $request
72
+	 */
73
+	protected $request;
74
+
75
+	/**
76
+	 * @type LegacyRequestInterface $legacy_request
77
+	 */
78
+	protected $legacy_request;
79
+
80
+	/**
81
+	 * @type ResponseInterface $response
82
+	 */
83
+	protected $response;
84
+
85
+	/**
86
+	 * @type LoaderInterface $loader
87
+	 */
88
+	protected $loader;
89
+
90
+	/**
91
+	 * @type array $_dependency_map
92
+	 */
93
+	protected $_dependency_map = array();
94
+
95
+	/**
96
+	 * @type array $_class_loaders
97
+	 */
98
+	protected $_class_loaders = array();
99
+
100
+
101
+	/**
102
+	 * EE_Dependency_Map constructor.
103
+	 *
104
+	 * @param ClassInterfaceCache $class_cache
105
+	 */
106
+	protected function __construct(ClassInterfaceCache $class_cache)
107
+	{
108
+		$this->class_cache = $class_cache;
109
+		do_action('EE_Dependency_Map____construct', $this);
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return void
115
+	 */
116
+	public function initialize()
117
+	{
118
+		$this->_register_core_dependencies();
119
+		$this->_register_core_class_loaders();
120
+		$this->_register_core_aliases();
121
+	}
122
+
123
+
124
+	/**
125
+	 * @singleton method used to instantiate class object
126
+	 * @param ClassInterfaceCache|null $class_cache
127
+	 * @return EE_Dependency_Map
128
+	 */
129
+	public static function instance(ClassInterfaceCache $class_cache = null) {
130
+		// check if class object is instantiated, and instantiated properly
131
+		if (
132
+			! self::$_instance instanceof EE_Dependency_Map
133
+			&& $class_cache instanceof ClassInterfaceCache
134
+		) {
135
+			self::$_instance = new EE_Dependency_Map($class_cache);
136
+		}
137
+		return self::$_instance;
138
+	}
139
+
140
+
141
+	/**
142
+	 * @param RequestInterface $request
143
+	 */
144
+	public function setRequest(RequestInterface $request)
145
+	{
146
+		$this->request = $request;
147
+	}
148
+
149
+
150
+	/**
151
+	 * @param LegacyRequestInterface $legacy_request
152
+	 */
153
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
154
+	{
155
+		$this->legacy_request = $legacy_request;
156
+	}
157
+
158
+
159
+	/**
160
+	 * @param ResponseInterface $response
161
+	 */
162
+	public function setResponse(ResponseInterface $response)
163
+	{
164
+		$this->response = $response;
165
+	}
166
+
167
+
168
+
169
+	/**
170
+	 * @param LoaderInterface $loader
171
+	 */
172
+	public function setLoader(LoaderInterface $loader)
173
+	{
174
+		$this->loader = $loader;
175
+	}
176
+
177
+
178
+
179
+	/**
180
+	 * @param string $class
181
+	 * @param array  $dependencies
182
+	 * @param int    $overwrite
183
+	 * @return bool
184
+	 */
185
+	public static function register_dependencies(
186
+		$class,
187
+		array $dependencies,
188
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
189
+	) {
190
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
191
+	}
192
+
193
+
194
+
195
+	/**
196
+	 * Assigns an array of class names and corresponding load sources (new or cached)
197
+	 * to the class specified by the first parameter.
198
+	 * IMPORTANT !!!
199
+	 * The order of elements in the incoming $dependencies array MUST match
200
+	 * the order of the constructor parameters for the class in question.
201
+	 * This is especially important when overriding any existing dependencies that are registered.
202
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
203
+	 *
204
+	 * @param string $class
205
+	 * @param array  $dependencies
206
+	 * @param int    $overwrite
207
+	 * @return bool
208
+	 */
209
+	public function registerDependencies(
210
+		$class,
211
+		array $dependencies,
212
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
213
+	) {
214
+		$class = trim($class, '\\');
215
+		$registered = false;
216
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
217
+			self::$_instance->_dependency_map[ $class ] = array();
218
+		}
219
+		// we need to make sure that any aliases used when registering a dependency
220
+		// get resolved to the correct class name
221
+		foreach ($dependencies as $dependency => $load_source) {
222
+			$alias = self::$_instance->getFqnForAlias($dependency);
223
+			if (
224
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
225
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
226
+			) {
227
+				unset($dependencies[$dependency]);
228
+				$dependencies[$alias] = $load_source;
229
+				$registered = true;
230
+			}
231
+		}
232
+		// now add our two lists of dependencies together.
233
+		// using Union (+=) favours the arrays in precedence from left to right,
234
+		// so $dependencies is NOT overwritten because it is listed first
235
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
236
+		// Union is way faster than array_merge() but should be used with caution...
237
+		// especially with numerically indexed arrays
238
+		$dependencies += self::$_instance->_dependency_map[ $class ];
239
+		// now we need to ensure that the resulting dependencies
240
+		// array only has the entries that are required for the class
241
+		// so first count how many dependencies were originally registered for the class
242
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
243
+		// if that count is non-zero (meaning dependencies were already registered)
244
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
245
+			// then truncate the  final array to match that count
246
+			? array_slice($dependencies, 0, $dependency_count)
247
+			// otherwise just take the incoming array because nothing previously existed
248
+			: $dependencies;
249
+		return $registered;
250
+	}
251
+
252
+
253
+
254
+	/**
255
+	 * @param string $class_name
256
+	 * @param string $loader
257
+	 * @return bool
258
+	 * @throws DomainException
259
+	 */
260
+	public static function register_class_loader($class_name, $loader = 'load_core')
261
+	{
262
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
263
+			throw new DomainException(
264
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
265
+			);
266
+		}
267
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
268
+		if (
269
+			! is_callable($loader)
270
+			&& (
271
+				strpos($loader, 'load_') !== 0
272
+				|| ! method_exists('EE_Registry', $loader)
273
+			)
274
+		) {
275
+			throw new DomainException(
276
+				sprintf(
277
+					esc_html__(
278
+						'"%1$s" is not a valid loader method on EE_Registry.',
279
+						'event_espresso'
280
+					),
281
+					$loader
282
+				)
283
+			);
284
+		}
285
+		$class_name = self::$_instance->getFqnForAlias($class_name);
286
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
287
+			self::$_instance->_class_loaders[$class_name] = $loader;
288
+			return true;
289
+		}
290
+		return false;
291
+	}
292
+
293
+
294
+
295
+	/**
296
+	 * @return array
297
+	 */
298
+	public function dependency_map()
299
+	{
300
+		return $this->_dependency_map;
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 * returns TRUE if dependency map contains a listing for the provided class name
307
+	 *
308
+	 * @param string $class_name
309
+	 * @return boolean
310
+	 */
311
+	public function has($class_name = '')
312
+	{
313
+		// all legacy models have the same dependencies
314
+		if (strpos($class_name, 'EEM_') === 0) {
315
+			$class_name = 'LEGACY_MODELS';
316
+		}
317
+		return isset($this->_dependency_map[$class_name]) ? true : false;
318
+	}
319
+
320
+
321
+
322
+	/**
323
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
324
+	 *
325
+	 * @param string $class_name
326
+	 * @param string $dependency
327
+	 * @return bool
328
+	 */
329
+	public function has_dependency_for_class($class_name = '', $dependency = '')
330
+	{
331
+		// all legacy models have the same dependencies
332
+		if (strpos($class_name, 'EEM_') === 0) {
333
+			$class_name = 'LEGACY_MODELS';
334
+		}
335
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
336
+		return isset($this->_dependency_map[$class_name][$dependency])
337
+			? true
338
+			: false;
339
+	}
340
+
341
+
342
+
343
+	/**
344
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
345
+	 *
346
+	 * @param string $class_name
347
+	 * @param string $dependency
348
+	 * @return int
349
+	 */
350
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
351
+	{
352
+		// all legacy models have the same dependencies
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			$class_name = 'LEGACY_MODELS';
355
+		}
356
+		$dependency = $this->getFqnForAlias($dependency);
357
+		return $this->has_dependency_for_class($class_name, $dependency)
358
+			? $this->_dependency_map[$class_name][$dependency]
359
+			: EE_Dependency_Map::not_registered;
360
+	}
361
+
362
+
363
+
364
+	/**
365
+	 * @param string $class_name
366
+	 * @return string | Closure
367
+	 */
368
+	public function class_loader($class_name)
369
+	{
370
+		// all legacy models use load_model()
371
+		if(strpos($class_name, 'EEM_') === 0){
372
+			return 'load_model';
373
+		}
374
+		$class_name = $this->getFqnForAlias($class_name);
375
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
376
+	}
377
+
378
+
379
+
380
+	/**
381
+	 * @return array
382
+	 */
383
+	public function class_loaders()
384
+	{
385
+		return $this->_class_loaders;
386
+	}
387
+
388
+
389
+
390
+	/**
391
+	 * adds an alias for a classname
392
+	 *
393
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
394
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
395
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
396
+	 */
397
+	public function add_alias($fqcn, $alias, $for_class = '')
398
+	{
399
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
400
+	}
401
+
402
+
403
+
404
+	/**
405
+	 * Returns TRUE if the provided fully qualified name IS an alias
406
+	 * WHY?
407
+	 * Because if a class is type hinting for a concretion,
408
+	 * then why would we need to find another class to supply it?
409
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
410
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
411
+	 * Don't go looking for some substitute.
412
+	 * Whereas if a class is type hinting for an interface...
413
+	 * then we need to find an actual class to use.
414
+	 * So the interface IS the alias for some other FQN,
415
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
416
+	 * represents some other class.
417
+	 *
418
+	 * @param string $fqn
419
+	 * @param string $for_class
420
+	 * @return bool
421
+	 */
422
+	public function isAlias($fqn = '', $for_class = '')
423
+	{
424
+		return $this->class_cache->isAlias($fqn, $for_class);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
431
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
432
+	 *  for example:
433
+	 *      if the following two entries were added to the _aliases array:
434
+	 *          array(
435
+	 *              'interface_alias'           => 'some\namespace\interface'
436
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
437
+	 *          )
438
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
439
+	 *      to load an instance of 'some\namespace\classname'
440
+	 *
441
+	 * @param string $alias
442
+	 * @param string $for_class
443
+	 * @return string
444
+	 */
445
+	public function getFqnForAlias($alias = '', $for_class = '')
446
+	{
447
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
448
+	}
449
+
450
+
451
+
452
+	/**
453
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
454
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
455
+	 * This is done by using the following class constants:
456
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
457
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
458
+	 */
459
+	protected function _register_core_dependencies()
460
+	{
461
+		$this->_dependency_map = array(
462
+			'EE_Request_Handler'                                                                                          => array(
463
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
464
+			),
465
+			'EE_System'                                                                                                   => array(
466
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
467
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
468
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
469
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
470
+			),
471
+			'EE_Session'                                                                                                  => array(
472
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
473
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
474
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
475
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
476
+			),
477
+			'EE_Cart'                                                                                                     => array(
478
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Front_Controller'                                                                                         => array(
481
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
482
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
483
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
484
+			),
485
+			'EE_Messenger_Collection_Loader'                                                                              => array(
486
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
487
+			),
488
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
489
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
490
+			),
491
+			'EE_Message_Resource_Manager'                                                                                 => array(
492
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
493
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
494
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
495
+			),
496
+			'EE_Message_Factory'                                                                                          => array(
497
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
498
+			),
499
+			'EE_messages'                                                                                                 => array(
500
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EE_Messages_Generator'                                                                                       => array(
503
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
504
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
505
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
506
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
507
+			),
508
+			'EE_Messages_Processor'                                                                                       => array(
509
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
510
+			),
511
+			'EE_Messages_Queue'                                                                                           => array(
512
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
513
+			),
514
+			'EE_Messages_Template_Defaults'                                                                               => array(
515
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
516
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
517
+			),
518
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
519
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
520
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
521
+			),
522
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
523
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
526
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
527
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
528
+			),
529
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
530
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
531
+			),
532
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
533
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
534
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
537
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
540
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
543
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
546
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
549
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
552
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
555
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
558
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
561
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
564
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
567
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
+			),
569
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
570
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
+			),
572
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
573
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EE_Data_Migration_Class_Base'                                                                                => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
+			),
582
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
583
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
+			),
586
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
587
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
+			),
590
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
591
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
+			),
594
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
595
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
596
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
597
+			),
598
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
599
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
600
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
601
+			),
602
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
603
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
604
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
605
+			),
606
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
607
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
608
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
609
+			),
610
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
611
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
612
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
613
+			),
614
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
615
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
616
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
617
+			),
618
+			'EventEspresso\core\services\assets\I18nRegistry' => array(
619
+				array(),
620
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
621
+			),
622
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
623
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
624
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
625
+				'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
626
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
638
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
641
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
644
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
647
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
648
+			),
649
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
650
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
651
+			),
652
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
653
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
654
+			),
655
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
656
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
657
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
658
+			),
659
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
660
+				null,
661
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
662
+			),
663
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
664
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
665
+			),
666
+			'LEGACY_MODELS'                                                   => array(
667
+				null,
668
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
669
+			),
670
+			'EE_Module_Request_Router' => array(
671
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EE_Registration_Processor' => array(
674
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
675
+			),
676
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
677
+				null,
678
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
679
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
680
+			),
681
+			'EventEspresso\core\services\licensing\LicenseService' => array(
682
+				'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
683
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
684
+			),
685 685
 			'EE_Admin_Transactions_List_Table' => array(
686
-                null,
687
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
688
-			),
689
-            'EventEspresso\core\domain\services\pue\Stats' => array(
690
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
691
-                'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
692
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
693
-            ),
694
-            'EventEspresso\core\domain\services\pue\Config' => array(
695
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
696
-                'EE_Config' => EE_Dependency_Map::load_from_cache
697
-            ),
698
-            'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
699
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
700
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
701
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
702
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
703
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
704
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
705
-                'EE_Config' => EE_Dependency_Map::load_from_cache
706
-            ),
707
-            'EventEspresso\core\domain\services\admin\ExitModal' => array(
708
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
709
-            ),
710
-            'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
711
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
712
-            ),
713
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
714
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
715
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
716
-            ),
717
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
718
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
719
-            ),
720
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
721
-                'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
722
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
723
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
724
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
725
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
726
-            ),
727
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
728
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
729
-            ),
730
-            'EventEspresso\core\services\loaders\ObjectIdentifier' => array(
731
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
732
-            ),
733
-        );
734
-    }
735
-
736
-
737
-    /**
738
-     * Registers how core classes are loaded.
739
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
740
-     *        'EE_Request_Handler' => 'load_core'
741
-     *        'EE_Messages_Queue'  => 'load_lib'
742
-     *        'EEH_Debug_Tools'    => 'load_helper'
743
-     * or, if greater control is required, by providing a custom closure. For example:
744
-     *        'Some_Class' => function () {
745
-     *            return new Some_Class();
746
-     *        },
747
-     * This is required for instantiating dependencies
748
-     * where an interface has been type hinted in a class constructor. For example:
749
-     *        'Required_Interface' => function () {
750
-     *            return new A_Class_That_Implements_Required_Interface();
751
-     *        },
752
-     *
753
-     */
754
-    protected function _register_core_class_loaders()
755
-    {
756
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
757
-        //be used in a closure.
758
-        $request = &$this->request;
759
-        $response = &$this->response;
760
-        $legacy_request = &$this->legacy_request;
761
-        // $loader = &$this->loader;
762
-        $this->_class_loaders = array(
763
-            //load_core
764
-            'EE_Capabilities'          => 'load_core',
765
-            'EE_Encryption'            => 'load_core',
766
-            'EE_Front_Controller'      => 'load_core',
767
-            'EE_Module_Request_Router' => 'load_core',
768
-            'EE_Registry'              => 'load_core',
769
-            'EE_Request'               => function () use (&$legacy_request) {
770
-                return $legacy_request;
771
-            },
772
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
773
-                return $request;
774
-            },
775
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
776
-                return $response;
777
-            },
778
-            'EE_Base'             => 'load_core',
779
-            'EE_Request_Handler'  => 'load_core',
780
-            'EE_Session'          => 'load_core',
781
-            'EE_Cron_Tasks'       => 'load_core',
782
-            'EE_System'           => 'load_core',
783
-            'EE_Maintenance_Mode' => 'load_core',
784
-            'EE_Register_CPTs'    => 'load_core',
785
-            'EE_Admin'            => 'load_core',
786
-            //load_lib
787
-            'EE_Message_Resource_Manager'          => 'load_lib',
788
-            'EE_Message_Type_Collection'           => 'load_lib',
789
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
790
-            'EE_Messenger_Collection'              => 'load_lib',
791
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
792
-            'EE_Messages_Processor'                => 'load_lib',
793
-            'EE_Message_Repository'                => 'load_lib',
794
-            'EE_Messages_Queue'                    => 'load_lib',
795
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
796
-            'EE_Message_Template_Group_Collection' => 'load_lib',
797
-            'EE_Payment_Method_Manager'            => 'load_lib',
798
-            'EE_Messages_Generator'                => function () {
799
-                return EE_Registry::instance()->load_lib(
800
-                    'Messages_Generator',
801
-                    array(),
802
-                    false,
803
-                    false
804
-                );
805
-            },
806
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
807
-                return EE_Registry::instance()->load_lib(
808
-                    'Messages_Template_Defaults',
809
-                    $arguments,
810
-                    false,
811
-                    false
812
-                );
813
-            },
814
-            //load_helper
815
-            'EEH_Parse_Shortcodes'                 => function () {
816
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
817
-                    return new EEH_Parse_Shortcodes();
818
-                }
819
-                return null;
820
-            },
821
-            'EE_Template_Config'                   => function () {
822
-                return EE_Config::instance()->template_settings;
823
-            },
824
-            'EE_Currency_Config'                   => function () {
825
-                return EE_Config::instance()->currency;
826
-            },
827
-            'EE_Registration_Config'                   => function () {
828
-                return EE_Config::instance()->registration;
829
-            },
830
-            'EE_Core_Config'                   => function () {
831
-                return EE_Config::instance()->core;
832
-            },
833
-            'EventEspresso\core\services\loaders\Loader' => function () {
834
-                return LoaderFactory::getLoader();
835
-            },
836
-            'EE_Network_Config' => function() {
837
-                return EE_Network_Config::instance();
838
-            },
839
-            'EE_Config' => function () {
840
-                return EE_Config::instance();
841
-            },
842
-            'EventEspresso\core\domain\Domain' => function () {
843
-                return DomainFactory::getEventEspressoCoreDomain();
844
-            },
845
-        );
846
-    }
847
-
848
-
849
-
850
-
851
-    /**
852
-     * can be used for supplying alternate names for classes,
853
-     * or for connecting interface names to instantiable classes
854
-     */
855
-    protected function _register_core_aliases()
856
-    {
857
-        $aliases = array(
858
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
859
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
860
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
861
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
862
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
863
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
864
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
865
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
866
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
867
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
868
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
869
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
870
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
871
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
872
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
873
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
874
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
875
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
876
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
877
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
878
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
879
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
880
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
881
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
882
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
883
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
884
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
885
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
886
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
887
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
888
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
889
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
890
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
891
-            'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
892
-            'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
893
-            'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
894
-            'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
895
-            'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
896
-        );
897
-        foreach ($aliases as $alias => $fqn) {
898
-            if(is_array($fqn)) {
899
-                foreach ($fqn as $class => $for_class) {
900
-                    $this->class_cache->addAlias($class, $alias, $for_class);
901
-                }
902
-                continue;
903
-            }
904
-            $this->class_cache->addAlias($fqn, $alias);
905
-        }
906
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
907
-            $this->class_cache->addAlias(
908
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
909
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
910
-            );
911
-        }
912
-    }
913
-
914
-
915
-
916
-    /**
917
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
918
-     * request Primarily used by unit tests.
919
-     */
920
-    public function reset()
921
-    {
922
-        $this->_register_core_class_loaders();
923
-        $this->_register_core_dependencies();
924
-    }
925
-
926
-
927
-    /**
928
-     * PLZ NOTE: a better name for this method would be is_alias()
929
-     * because it returns TRUE if the provided fully qualified name IS an alias
930
-     * WHY?
931
-     * Because if a class is type hinting for a concretion,
932
-     * then why would we need to find another class to supply it?
933
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
934
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
935
-     * Don't go looking for some substitute.
936
-     * Whereas if a class is type hinting for an interface...
937
-     * then we need to find an actual class to use.
938
-     * So the interface IS the alias for some other FQN,
939
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
940
-     * represents some other class.
941
-     *
942
-     * @deprecated $VID:$
943
-     * @param string $fqn
944
-     * @param string $for_class
945
-     * @return bool
946
-     */
947
-    public function has_alias($fqn = '', $for_class = '')
948
-    {
949
-        return $this->isAlias($fqn, $for_class);
950
-    }
951
-
952
-
953
-    /**
954
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
955
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
956
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
957
-     *  for example:
958
-     *      if the following two entries were added to the _aliases array:
959
-     *          array(
960
-     *              'interface_alias'           => 'some\namespace\interface'
961
-     *              'some\namespace\interface'  => 'some\namespace\classname'
962
-     *          )
963
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
964
-     *      to load an instance of 'some\namespace\classname'
965
-     *
966
-     * @deprecated $VID:$
967
-     * @param string $alias
968
-     * @param string $for_class
969
-     * @return string
970
-     */
971
-    public function get_alias($alias = '', $for_class = '')
972
-    {
973
-        return $this->getFqnForAlias($alias, $for_class);
974
-    }
686
+				null,
687
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
688
+			),
689
+			'EventEspresso\core\domain\services\pue\Stats' => array(
690
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
691
+				'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
692
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
693
+			),
694
+			'EventEspresso\core\domain\services\pue\Config' => array(
695
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
696
+				'EE_Config' => EE_Dependency_Map::load_from_cache
697
+			),
698
+			'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
699
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
700
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
701
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
702
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
703
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
704
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
705
+				'EE_Config' => EE_Dependency_Map::load_from_cache
706
+			),
707
+			'EventEspresso\core\domain\services\admin\ExitModal' => array(
708
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
709
+			),
710
+			'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
711
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
712
+			),
713
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
714
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
715
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
716
+			),
717
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
718
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
719
+			),
720
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
721
+				'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
722
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
723
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
724
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
725
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
726
+			),
727
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
728
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
729
+			),
730
+			'EventEspresso\core\services\loaders\ObjectIdentifier' => array(
731
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
732
+			),
733
+		);
734
+	}
735
+
736
+
737
+	/**
738
+	 * Registers how core classes are loaded.
739
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
740
+	 *        'EE_Request_Handler' => 'load_core'
741
+	 *        'EE_Messages_Queue'  => 'load_lib'
742
+	 *        'EEH_Debug_Tools'    => 'load_helper'
743
+	 * or, if greater control is required, by providing a custom closure. For example:
744
+	 *        'Some_Class' => function () {
745
+	 *            return new Some_Class();
746
+	 *        },
747
+	 * This is required for instantiating dependencies
748
+	 * where an interface has been type hinted in a class constructor. For example:
749
+	 *        'Required_Interface' => function () {
750
+	 *            return new A_Class_That_Implements_Required_Interface();
751
+	 *        },
752
+	 *
753
+	 */
754
+	protected function _register_core_class_loaders()
755
+	{
756
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
757
+		//be used in a closure.
758
+		$request = &$this->request;
759
+		$response = &$this->response;
760
+		$legacy_request = &$this->legacy_request;
761
+		// $loader = &$this->loader;
762
+		$this->_class_loaders = array(
763
+			//load_core
764
+			'EE_Capabilities'          => 'load_core',
765
+			'EE_Encryption'            => 'load_core',
766
+			'EE_Front_Controller'      => 'load_core',
767
+			'EE_Module_Request_Router' => 'load_core',
768
+			'EE_Registry'              => 'load_core',
769
+			'EE_Request'               => function () use (&$legacy_request) {
770
+				return $legacy_request;
771
+			},
772
+			'EventEspresso\core\services\request\Request' => function () use (&$request) {
773
+				return $request;
774
+			},
775
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
776
+				return $response;
777
+			},
778
+			'EE_Base'             => 'load_core',
779
+			'EE_Request_Handler'  => 'load_core',
780
+			'EE_Session'          => 'load_core',
781
+			'EE_Cron_Tasks'       => 'load_core',
782
+			'EE_System'           => 'load_core',
783
+			'EE_Maintenance_Mode' => 'load_core',
784
+			'EE_Register_CPTs'    => 'load_core',
785
+			'EE_Admin'            => 'load_core',
786
+			//load_lib
787
+			'EE_Message_Resource_Manager'          => 'load_lib',
788
+			'EE_Message_Type_Collection'           => 'load_lib',
789
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
790
+			'EE_Messenger_Collection'              => 'load_lib',
791
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
792
+			'EE_Messages_Processor'                => 'load_lib',
793
+			'EE_Message_Repository'                => 'load_lib',
794
+			'EE_Messages_Queue'                    => 'load_lib',
795
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
796
+			'EE_Message_Template_Group_Collection' => 'load_lib',
797
+			'EE_Payment_Method_Manager'            => 'load_lib',
798
+			'EE_Messages_Generator'                => function () {
799
+				return EE_Registry::instance()->load_lib(
800
+					'Messages_Generator',
801
+					array(),
802
+					false,
803
+					false
804
+				);
805
+			},
806
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
807
+				return EE_Registry::instance()->load_lib(
808
+					'Messages_Template_Defaults',
809
+					$arguments,
810
+					false,
811
+					false
812
+				);
813
+			},
814
+			//load_helper
815
+			'EEH_Parse_Shortcodes'                 => function () {
816
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
817
+					return new EEH_Parse_Shortcodes();
818
+				}
819
+				return null;
820
+			},
821
+			'EE_Template_Config'                   => function () {
822
+				return EE_Config::instance()->template_settings;
823
+			},
824
+			'EE_Currency_Config'                   => function () {
825
+				return EE_Config::instance()->currency;
826
+			},
827
+			'EE_Registration_Config'                   => function () {
828
+				return EE_Config::instance()->registration;
829
+			},
830
+			'EE_Core_Config'                   => function () {
831
+				return EE_Config::instance()->core;
832
+			},
833
+			'EventEspresso\core\services\loaders\Loader' => function () {
834
+				return LoaderFactory::getLoader();
835
+			},
836
+			'EE_Network_Config' => function() {
837
+				return EE_Network_Config::instance();
838
+			},
839
+			'EE_Config' => function () {
840
+				return EE_Config::instance();
841
+			},
842
+			'EventEspresso\core\domain\Domain' => function () {
843
+				return DomainFactory::getEventEspressoCoreDomain();
844
+			},
845
+		);
846
+	}
847
+
848
+
849
+
850
+
851
+	/**
852
+	 * can be used for supplying alternate names for classes,
853
+	 * or for connecting interface names to instantiable classes
854
+	 */
855
+	protected function _register_core_aliases()
856
+	{
857
+		$aliases = array(
858
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
859
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
860
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
861
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
862
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
863
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
864
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
865
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
866
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
867
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
868
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
869
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
870
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
871
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
872
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
873
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
874
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
875
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
876
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
877
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
878
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
879
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
880
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
881
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
882
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
883
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
884
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
885
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
886
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
887
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
888
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
889
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
890
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
891
+			'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
892
+			'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
893
+			'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
894
+			'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
895
+			'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
896
+		);
897
+		foreach ($aliases as $alias => $fqn) {
898
+			if(is_array($fqn)) {
899
+				foreach ($fqn as $class => $for_class) {
900
+					$this->class_cache->addAlias($class, $alias, $for_class);
901
+				}
902
+				continue;
903
+			}
904
+			$this->class_cache->addAlias($fqn, $alias);
905
+		}
906
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
907
+			$this->class_cache->addAlias(
908
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
909
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
910
+			);
911
+		}
912
+	}
913
+
914
+
915
+
916
+	/**
917
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
918
+	 * request Primarily used by unit tests.
919
+	 */
920
+	public function reset()
921
+	{
922
+		$this->_register_core_class_loaders();
923
+		$this->_register_core_dependencies();
924
+	}
925
+
926
+
927
+	/**
928
+	 * PLZ NOTE: a better name for this method would be is_alias()
929
+	 * because it returns TRUE if the provided fully qualified name IS an alias
930
+	 * WHY?
931
+	 * Because if a class is type hinting for a concretion,
932
+	 * then why would we need to find another class to supply it?
933
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
934
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
935
+	 * Don't go looking for some substitute.
936
+	 * Whereas if a class is type hinting for an interface...
937
+	 * then we need to find an actual class to use.
938
+	 * So the interface IS the alias for some other FQN,
939
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
940
+	 * represents some other class.
941
+	 *
942
+	 * @deprecated $VID:$
943
+	 * @param string $fqn
944
+	 * @param string $for_class
945
+	 * @return bool
946
+	 */
947
+	public function has_alias($fqn = '', $for_class = '')
948
+	{
949
+		return $this->isAlias($fqn, $for_class);
950
+	}
951
+
952
+
953
+	/**
954
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
955
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
956
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
957
+	 *  for example:
958
+	 *      if the following two entries were added to the _aliases array:
959
+	 *          array(
960
+	 *              'interface_alias'           => 'some\namespace\interface'
961
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
962
+	 *          )
963
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
964
+	 *      to load an instance of 'some\namespace\classname'
965
+	 *
966
+	 * @deprecated $VID:$
967
+	 * @param string $alias
968
+	 * @param string $for_class
969
+	 * @return string
970
+	 */
971
+	public function get_alias($alias = '', $for_class = '')
972
+	{
973
+		return $this->getFqnForAlias($alias, $for_class);
974
+	}
975 975
 }
976 976
 // End of file EE_Dependency_Map.core.php
977 977
 // Location: /EE_Dependency_Map.core.php
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use EventEspresso\core\services\request\RequestInterface;
9 9
 use EventEspresso\core\services\request\ResponseInterface;
10 10
 
11
-if (! defined('EVENT_ESPRESSO_VERSION')) {
11
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
12 12
     exit('No direct script access allowed');
13 13
 }
14 14
 
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
     ) {
214 214
         $class = trim($class, '\\');
215 215
         $registered = false;
216
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
217
-            self::$_instance->_dependency_map[ $class ] = array();
216
+        if (empty(self::$_instance->_dependency_map[$class])) {
217
+            self::$_instance->_dependency_map[$class] = array();
218 218
         }
219 219
         // we need to make sure that any aliases used when registering a dependency
220 220
         // get resolved to the correct class name
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
             $alias = self::$_instance->getFqnForAlias($dependency);
223 223
             if (
224 224
                 $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
225
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
225
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
226 226
             ) {
227 227
                 unset($dependencies[$dependency]);
228 228
                 $dependencies[$alias] = $load_source;
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
236 236
         // Union is way faster than array_merge() but should be used with caution...
237 237
         // especially with numerically indexed arrays
238
-        $dependencies += self::$_instance->_dependency_map[ $class ];
238
+        $dependencies += self::$_instance->_dependency_map[$class];
239 239
         // now we need to ensure that the resulting dependencies
240 240
         // array only has the entries that are required for the class
241 241
         // so first count how many dependencies were originally registered for the class
242
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
242
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
243 243
         // if that count is non-zero (meaning dependencies were already registered)
244
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
244
+        self::$_instance->_dependency_map[$class] = $dependency_count
245 245
             // then truncate the  final array to match that count
246 246
             ? array_slice($dependencies, 0, $dependency_count)
247 247
             // otherwise just take the incoming array because nothing previously existed
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public static function register_class_loader($class_name, $loader = 'load_core')
261 261
     {
262
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
262
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
263 263
             throw new DomainException(
264 264
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
265 265
             );
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             );
284 284
         }
285 285
         $class_name = self::$_instance->getFqnForAlias($class_name);
286
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
286
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
287 287
             self::$_instance->_class_loaders[$class_name] = $loader;
288 288
             return true;
289 289
         }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     public function class_loader($class_name)
369 369
     {
370 370
         // all legacy models use load_model()
371
-        if(strpos($class_name, 'EEM_') === 0){
371
+        if (strpos($class_name, 'EEM_') === 0) {
372 372
             return 'load_model';
373 373
         }
374 374
         $class_name = $this->getFqnForAlias($class_name);
@@ -766,13 +766,13 @@  discard block
 block discarded – undo
766 766
             'EE_Front_Controller'      => 'load_core',
767 767
             'EE_Module_Request_Router' => 'load_core',
768 768
             'EE_Registry'              => 'load_core',
769
-            'EE_Request'               => function () use (&$legacy_request) {
769
+            'EE_Request'               => function() use (&$legacy_request) {
770 770
                 return $legacy_request;
771 771
             },
772
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
772
+            'EventEspresso\core\services\request\Request' => function() use (&$request) {
773 773
                 return $request;
774 774
             },
775
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
775
+            'EventEspresso\core\services\request\Response' => function() use (&$response) {
776 776
                 return $response;
777 777
             },
778 778
             'EE_Base'             => 'load_core',
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
796 796
             'EE_Message_Template_Group_Collection' => 'load_lib',
797 797
             'EE_Payment_Method_Manager'            => 'load_lib',
798
-            'EE_Messages_Generator'                => function () {
798
+            'EE_Messages_Generator'                => function() {
799 799
                 return EE_Registry::instance()->load_lib(
800 800
                     'Messages_Generator',
801 801
                     array(),
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
                     false
804 804
                 );
805 805
             },
806
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
806
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
807 807
                 return EE_Registry::instance()->load_lib(
808 808
                     'Messages_Template_Defaults',
809 809
                     $arguments,
@@ -812,34 +812,34 @@  discard block
 block discarded – undo
812 812
                 );
813 813
             },
814 814
             //load_helper
815
-            'EEH_Parse_Shortcodes'                 => function () {
815
+            'EEH_Parse_Shortcodes'                 => function() {
816 816
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
817 817
                     return new EEH_Parse_Shortcodes();
818 818
                 }
819 819
                 return null;
820 820
             },
821
-            'EE_Template_Config'                   => function () {
821
+            'EE_Template_Config'                   => function() {
822 822
                 return EE_Config::instance()->template_settings;
823 823
             },
824
-            'EE_Currency_Config'                   => function () {
824
+            'EE_Currency_Config'                   => function() {
825 825
                 return EE_Config::instance()->currency;
826 826
             },
827
-            'EE_Registration_Config'                   => function () {
827
+            'EE_Registration_Config'                   => function() {
828 828
                 return EE_Config::instance()->registration;
829 829
             },
830
-            'EE_Core_Config'                   => function () {
830
+            'EE_Core_Config'                   => function() {
831 831
                 return EE_Config::instance()->core;
832 832
             },
833
-            'EventEspresso\core\services\loaders\Loader' => function () {
833
+            'EventEspresso\core\services\loaders\Loader' => function() {
834 834
                 return LoaderFactory::getLoader();
835 835
             },
836 836
             'EE_Network_Config' => function() {
837 837
                 return EE_Network_Config::instance();
838 838
             },
839
-            'EE_Config' => function () {
839
+            'EE_Config' => function() {
840 840
                 return EE_Config::instance();
841 841
             },
842
-            'EventEspresso\core\domain\Domain' => function () {
842
+            'EventEspresso\core\domain\Domain' => function() {
843 843
                 return DomainFactory::getEventEspressoCoreDomain();
844 844
             },
845 845
         );
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
             'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
896 896
         );
897 897
         foreach ($aliases as $alias => $fqn) {
898
-            if(is_array($fqn)) {
898
+            if (is_array($fqn)) {
899 899
                 foreach ($fqn as $class => $for_class) {
900 900
                     $this->class_cache->addAlias($class, $alias, $for_class);
901 901
                 }
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
             }
904 904
             $this->class_cache->addAlias($fqn, $alias);
905 905
         }
906
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
906
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
907 907
             $this->class_cache->addAlias(
908 908
                 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
909 909
                 'EventEspresso\core\services\notices\NoticeConverterInterface'
Please login to merge, or discard this patch.
core/services/loaders/CachingLoader.php 1 patch
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -21,158 +21,158 @@
 block discarded – undo
21 21
 class CachingLoader extends CachingLoaderDecorator
22 22
 {
23 23
 
24
-    /**
25
-     * @var string $identifier
26
-     */
27
-    protected $identifier;
28
-
29
-    /**
30
-     * @var CollectionInterface $cache
31
-     */
32
-    protected $cache;
33
-
34
-    /**
35
-     * @var ObjectIdentifier
36
-     */
37
-    private $object_identifier;
38
-
39
-
40
-    /**
41
-     * CachingLoader constructor.
42
-     *
43
-     * @param LoaderDecoratorInterface $loader
44
-     * @param CollectionInterface      $cache
45
-     * @param ObjectIdentifier         $object_identifier
46
-     * @param string                   $identifier
47
-     * @throws InvalidDataTypeException
48
-     */
49
-    public function __construct(
50
-        LoaderDecoratorInterface $loader,
51
-        CollectionInterface $cache,
52
-        ObjectIdentifier $object_identifier,
53
-        $identifier = ''
54
-    ) {
55
-        parent::__construct($loader);
56
-        $this->cache       = $cache;
57
-        $this->object_identifier = $object_identifier;
58
-        $this->setIdentifier($identifier);
59
-        if ($this->identifier !== '') {
60
-            // to only clear this cache, and assuming an identifier has been set, simply do the following:
61
-            // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__IDENTIFIER');
62
-            // where "IDENTIFIER" = the string that was set during construction
63
-            add_action(
64
-                "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}",
65
-                array($this, 'reset')
66
-            );
67
-        }
68
-        // to clear ALL caches, simply do the following:
69
-        // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache');
70
-        add_action(
71
-            'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache',
72
-            array($this, 'reset')
73
-        );
74
-    }
75
-
76
-
77
-    /**
78
-     * @return string
79
-     */
80
-    public function identifier()
81
-    {
82
-        return $this->identifier;
83
-    }
84
-
85
-
86
-    /**
87
-     * @param string $identifier
88
-     * @throws InvalidDataTypeException
89
-     */
90
-    private function setIdentifier($identifier)
91
-    {
92
-        if (! is_string($identifier)) {
93
-            throw new InvalidDataTypeException('$identifier', $identifier, 'string');
94
-        }
95
-        $this->identifier = $identifier;
96
-    }
97
-
98
-
99
-    /**
100
-     * @param FullyQualifiedName|string $fqcn
101
-     * @param mixed                     $object
102
-     * @return bool
103
-     * @throws InvalidArgumentException
104
-     */
105
-    public function share($fqcn, $object)
106
-    {
107
-        if ($object instanceof $fqcn) {
108
-            return $this->cache->add($object, md5($fqcn));
109
-        }
110
-        throw new InvalidArgumentException(
111
-            sprintf(
112
-                esc_html__(
113
-                    'The supplied class name "%1$s" must match the class of the supplied object.',
114
-                    'event_espresso'
115
-                ),
116
-                $fqcn
117
-            )
118
-        );
119
-    }
120
-
121
-
122
-    /**
123
-     * @param FullyQualifiedName|string $fqcn
124
-     * @param array                     $arguments
125
-     * @param bool                      $shared
126
-     * @param array                     $interfaces
127
-     * @return mixed
128
-     */
129
-    public function load($fqcn, $arguments = array(), $shared = true, array $interfaces = array())
130
-    {
131
-        $fqcn = ltrim($fqcn, '\\');
132
-        // caching can be turned off via the following code:
133
-        // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true');
134
-        if (
135
-            apply_filters(
136
-                'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache',
137
-                false,
138
-                $this
139
-            )
140
-        ) {
141
-            // even though $shared might be true, caching could be bypassed for whatever reason,
142
-            // so we don't want the core loader to cache anything, therefore caching is turned off
143
-            return $this->loader->load($fqcn, $arguments, false);
144
-        }
145
-        $object_identifier = $this->object_identifier->getIdentifier($fqcn, $arguments);
146
-        if ($this->cache->has($object_identifier)) {
147
-            return $this->cache->get($object_identifier);
148
-        }
149
-        $object = $this->loader->load($fqcn, $arguments, $shared);
150
-        if ($object instanceof $fqcn) {
151
-            $this->cache->add($object, $object_identifier);
152
-        }
153
-        return $object;
154
-    }
155
-
156
-
157
-    /**
158
-     * empties cache and calls reset() on loader if method exists
159
-     */
160
-    public function reset()
161
-    {
162
-        $this->clearCache();
163
-        $this->loader->reset();
164
-    }
165
-
166
-
167
-    /**
168
-     * unsets and detaches ALL objects from the cache
169
-     *
170
-     * @since $VID:$
171
-     */
172
-    public function clearCache()
173
-    {
174
-        $this->cache->trashAndDetachAll();
175
-    }
24
+	/**
25
+	 * @var string $identifier
26
+	 */
27
+	protected $identifier;
28
+
29
+	/**
30
+	 * @var CollectionInterface $cache
31
+	 */
32
+	protected $cache;
33
+
34
+	/**
35
+	 * @var ObjectIdentifier
36
+	 */
37
+	private $object_identifier;
38
+
39
+
40
+	/**
41
+	 * CachingLoader constructor.
42
+	 *
43
+	 * @param LoaderDecoratorInterface $loader
44
+	 * @param CollectionInterface      $cache
45
+	 * @param ObjectIdentifier         $object_identifier
46
+	 * @param string                   $identifier
47
+	 * @throws InvalidDataTypeException
48
+	 */
49
+	public function __construct(
50
+		LoaderDecoratorInterface $loader,
51
+		CollectionInterface $cache,
52
+		ObjectIdentifier $object_identifier,
53
+		$identifier = ''
54
+	) {
55
+		parent::__construct($loader);
56
+		$this->cache       = $cache;
57
+		$this->object_identifier = $object_identifier;
58
+		$this->setIdentifier($identifier);
59
+		if ($this->identifier !== '') {
60
+			// to only clear this cache, and assuming an identifier has been set, simply do the following:
61
+			// do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__IDENTIFIER');
62
+			// where "IDENTIFIER" = the string that was set during construction
63
+			add_action(
64
+				"AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}",
65
+				array($this, 'reset')
66
+			);
67
+		}
68
+		// to clear ALL caches, simply do the following:
69
+		// do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache');
70
+		add_action(
71
+			'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache',
72
+			array($this, 'reset')
73
+		);
74
+	}
75
+
76
+
77
+	/**
78
+	 * @return string
79
+	 */
80
+	public function identifier()
81
+	{
82
+		return $this->identifier;
83
+	}
84
+
85
+
86
+	/**
87
+	 * @param string $identifier
88
+	 * @throws InvalidDataTypeException
89
+	 */
90
+	private function setIdentifier($identifier)
91
+	{
92
+		if (! is_string($identifier)) {
93
+			throw new InvalidDataTypeException('$identifier', $identifier, 'string');
94
+		}
95
+		$this->identifier = $identifier;
96
+	}
97
+
98
+
99
+	/**
100
+	 * @param FullyQualifiedName|string $fqcn
101
+	 * @param mixed                     $object
102
+	 * @return bool
103
+	 * @throws InvalidArgumentException
104
+	 */
105
+	public function share($fqcn, $object)
106
+	{
107
+		if ($object instanceof $fqcn) {
108
+			return $this->cache->add($object, md5($fqcn));
109
+		}
110
+		throw new InvalidArgumentException(
111
+			sprintf(
112
+				esc_html__(
113
+					'The supplied class name "%1$s" must match the class of the supplied object.',
114
+					'event_espresso'
115
+				),
116
+				$fqcn
117
+			)
118
+		);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @param FullyQualifiedName|string $fqcn
124
+	 * @param array                     $arguments
125
+	 * @param bool                      $shared
126
+	 * @param array                     $interfaces
127
+	 * @return mixed
128
+	 */
129
+	public function load($fqcn, $arguments = array(), $shared = true, array $interfaces = array())
130
+	{
131
+		$fqcn = ltrim($fqcn, '\\');
132
+		// caching can be turned off via the following code:
133
+		// add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true');
134
+		if (
135
+			apply_filters(
136
+				'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache',
137
+				false,
138
+				$this
139
+			)
140
+		) {
141
+			// even though $shared might be true, caching could be bypassed for whatever reason,
142
+			// so we don't want the core loader to cache anything, therefore caching is turned off
143
+			return $this->loader->load($fqcn, $arguments, false);
144
+		}
145
+		$object_identifier = $this->object_identifier->getIdentifier($fqcn, $arguments);
146
+		if ($this->cache->has($object_identifier)) {
147
+			return $this->cache->get($object_identifier);
148
+		}
149
+		$object = $this->loader->load($fqcn, $arguments, $shared);
150
+		if ($object instanceof $fqcn) {
151
+			$this->cache->add($object, $object_identifier);
152
+		}
153
+		return $object;
154
+	}
155
+
156
+
157
+	/**
158
+	 * empties cache and calls reset() on loader if method exists
159
+	 */
160
+	public function reset()
161
+	{
162
+		$this->clearCache();
163
+		$this->loader->reset();
164
+	}
165
+
166
+
167
+	/**
168
+	 * unsets and detaches ALL objects from the cache
169
+	 *
170
+	 * @since $VID:$
171
+	 */
172
+	public function clearCache()
173
+	{
174
+		$this->cache->trashAndDetachAll();
175
+	}
176 176
 }
177 177
 // End of file CachingLoader.php
178 178
 // Location: EventEspresso\core\services\loaders/CachingLoader.php
Please login to merge, or discard this patch.