Completed
Pull Request — Gutenberg/master (#354)
by
unknown
37:23 queued 24:04
created
core/domain/entities/editor/blocks/CoreBlocksAssetRegister.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@
 block discarded – undo
22 22
 class CoreBlocksAssetRegister extends BlockAssetRegister
23 23
 {
24 24
 
25
-    /**
26
-     * CoreBlocksAssetRegister constructor.
27
-     *
28
-     * @param DomainInterface $domain
29
-     * @param Registry        $registry
30
-     * @throws InvalidDataTypeException
31
-     */
32
-    public function __construct(DomainInterface $domain, Registry $registry) {
33
-        parent::__construct(
34
-            'core-blocks',
35
-            array(),
36
-            'core-blocks',
37
-            array(),
38
-            $domain,
39
-            $registry
40
-        );
41
-    }
25
+	/**
26
+	 * CoreBlocksAssetRegister constructor.
27
+	 *
28
+	 * @param DomainInterface $domain
29
+	 * @param Registry        $registry
30
+	 * @throws InvalidDataTypeException
31
+	 */
32
+	public function __construct(DomainInterface $domain, Registry $registry) {
33
+		parent::__construct(
34
+			'core-blocks',
35
+			array(),
36
+			'core-blocks',
37
+			array(),
38
+			$domain,
39
+			$registry
40
+		);
41
+	}
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +920 added lines, -920 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10 10
 if (! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -25,925 +25,925 @@  discard block
 block discarded – undo
25 25
 class EE_Dependency_Map
26 26
 {
27 27
 
28
-    /**
29
-     * This means that the requested class dependency is not present in the dependency map
30
-     */
31
-    const not_registered = 0;
32
-
33
-    /**
34
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
-     */
36
-    const load_new_object = 1;
37
-
38
-    /**
39
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
-     */
42
-    const load_from_cache = 2;
43
-
44
-    /**
45
-     * When registering a dependency,
46
-     * this indicates to keep any existing dependencies that already exist,
47
-     * and simply discard any new dependencies declared in the incoming data
48
-     */
49
-    const KEEP_EXISTING_DEPENDENCIES = 0;
50
-
51
-    /**
52
-     * When registering a dependency,
53
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
-     */
55
-    const OVERWRITE_DEPENDENCIES = 1;
56
-
57
-
58
-
59
-    /**
60
-     * @type EE_Dependency_Map $_instance
61
-     */
62
-    protected static $_instance;
63
-
64
-    /**
65
-     * @type RequestInterface $request
66
-     */
67
-    protected $request;
68
-
69
-    /**
70
-     * @type LegacyRequestInterface $legacy_request
71
-     */
72
-    protected $legacy_request;
73
-
74
-    /**
75
-     * @type ResponseInterface $response
76
-     */
77
-    protected $response;
78
-
79
-    /**
80
-     * @type LoaderInterface $loader
81
-     */
82
-    protected $loader;
83
-
84
-    /**
85
-     * @type array $_dependency_map
86
-     */
87
-    protected $_dependency_map = array();
88
-
89
-    /**
90
-     * @type array $_class_loaders
91
-     */
92
-    protected $_class_loaders = array();
93
-
94
-    /**
95
-     * @type array $_aliases
96
-     */
97
-    protected $_aliases = array();
98
-
99
-
100
-
101
-    /**
102
-     * EE_Dependency_Map constructor.
103
-     */
104
-    protected function __construct()
105
-    {
106
-        // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
-        do_action('EE_Dependency_Map____construct');
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidArgumentException
116
-     */
117
-    public function initialize()
118
-    {
119
-        $this->_register_core_dependencies();
120
-        $this->_register_core_class_loaders();
121
-        $this->_register_core_aliases();
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @singleton method used to instantiate class object
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance() {
131
-        // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
-            self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
-        }
135
-        return self::$_instance;
136
-    }
137
-
138
-
139
-    /**
140
-     * @param RequestInterface $request
141
-     */
142
-    public function setRequest(RequestInterface $request)
143
-    {
144
-        $this->request = $request;
145
-    }
146
-
147
-
148
-    /**
149
-     * @param LegacyRequestInterface $legacy_request
150
-     */
151
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
-    {
153
-        $this->legacy_request = $legacy_request;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param ResponseInterface $response
159
-     */
160
-    public function setResponse(ResponseInterface $response)
161
-    {
162
-        $this->response = $response;
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * @param LoaderInterface $loader
169
-     */
170
-    public function setLoader(LoaderInterface $loader)
171
-    {
172
-        $this->loader = $loader;
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * @param string $class
179
-     * @param array  $dependencies
180
-     * @param int    $overwrite
181
-     * @return bool
182
-     */
183
-    public static function register_dependencies(
184
-        $class,
185
-        array $dependencies,
186
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
-    ) {
188
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Assigns an array of class names and corresponding load sources (new or cached)
195
-     * to the class specified by the first parameter.
196
-     * IMPORTANT !!!
197
-     * The order of elements in the incoming $dependencies array MUST match
198
-     * the order of the constructor parameters for the class in question.
199
-     * This is especially important when overriding any existing dependencies that are registered.
200
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
-     *
202
-     * @param string $class
203
-     * @param array  $dependencies
204
-     * @param int    $overwrite
205
-     * @return bool
206
-     */
207
-    public function registerDependencies(
208
-        $class,
209
-        array $dependencies,
210
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
-    ) {
212
-        $class = trim($class, '\\');
213
-        $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
216
-        }
217
-        // we need to make sure that any aliases used when registering a dependency
218
-        // get resolved to the correct class name
219
-        foreach ($dependencies as $dependency => $load_source) {
220
-            $alias = self::$_instance->get_alias($dependency);
221
-            if (
222
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
-            ) {
225
-                unset($dependencies[$dependency]);
226
-                $dependencies[$alias] = $load_source;
227
-                $registered = true;
228
-            }
229
-        }
230
-        // now add our two lists of dependencies together.
231
-        // using Union (+=) favours the arrays in precedence from left to right,
232
-        // so $dependencies is NOT overwritten because it is listed first
233
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
-        // Union is way faster than array_merge() but should be used with caution...
235
-        // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
237
-        // now we need to ensure that the resulting dependencies
238
-        // array only has the entries that are required for the class
239
-        // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
-        // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
243
-            // then truncate the  final array to match that count
244
-            ? array_slice($dependencies, 0, $dependency_count)
245
-            // otherwise just take the incoming array because nothing previously existed
246
-            : $dependencies;
247
-        return $registered;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @param string $class_name
254
-     * @param string $loader
255
-     * @return bool
256
-     * @throws DomainException
257
-     */
258
-    public static function register_class_loader($class_name, $loader = 'load_core')
259
-    {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
-            throw new DomainException(
262
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
-            );
264
-        }
265
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
266
-        if (
267
-            ! is_callable($loader)
268
-            && (
269
-                strpos($loader, 'load_') !== 0
270
-                || ! method_exists('EE_Registry', $loader)
271
-            )
272
-        ) {
273
-            throw new DomainException(
274
-                sprintf(
275
-                    esc_html__(
276
-                        '"%1$s" is not a valid loader method on EE_Registry.',
277
-                        'event_espresso'
278
-                    ),
279
-                    $loader
280
-                )
281
-            );
282
-        }
283
-        $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
-            self::$_instance->_class_loaders[$class_name] = $loader;
286
-            return true;
287
-        }
288
-        return false;
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * @return array
295
-     */
296
-    public function dependency_map()
297
-    {
298
-        return $this->_dependency_map;
299
-    }
300
-
301
-
302
-
303
-    /**
304
-     * returns TRUE if dependency map contains a listing for the provided class name
305
-     *
306
-     * @param string $class_name
307
-     * @return boolean
308
-     */
309
-    public function has($class_name = '')
310
-    {
311
-        // all legacy models have the same dependencies
312
-        if (strpos($class_name, 'EEM_') === 0) {
313
-            $class_name = 'LEGACY_MODELS';
314
-        }
315
-        return isset($this->_dependency_map[$class_name]) ? true : false;
316
-    }
317
-
318
-
319
-
320
-    /**
321
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
-     *
323
-     * @param string $class_name
324
-     * @param string $dependency
325
-     * @return bool
326
-     */
327
-    public function has_dependency_for_class($class_name = '', $dependency = '')
328
-    {
329
-        // all legacy models have the same dependencies
330
-        if (strpos($class_name, 'EEM_') === 0) {
331
-            $class_name = 'LEGACY_MODELS';
332
-        }
333
-        $dependency = $this->get_alias($dependency);
334
-        return isset($this->_dependency_map[$class_name][$dependency])
335
-            ? true
336
-            : false;
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
-     *
344
-     * @param string $class_name
345
-     * @param string $dependency
346
-     * @return int
347
-     */
348
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
-    {
350
-        // all legacy models have the same dependencies
351
-        if (strpos($class_name, 'EEM_') === 0) {
352
-            $class_name = 'LEGACY_MODELS';
353
-        }
354
-        $dependency = $this->get_alias($dependency);
355
-        return $this->has_dependency_for_class($class_name, $dependency)
356
-            ? $this->_dependency_map[$class_name][$dependency]
357
-            : EE_Dependency_Map::not_registered;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * @param string $class_name
364
-     * @return string | Closure
365
-     */
366
-    public function class_loader($class_name)
367
-    {
368
-        // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
370
-            return 'load_model';
371
-        }
372
-        $class_name = $this->get_alias($class_name);
373
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
-    }
375
-
376
-
377
-
378
-    /**
379
-     * @return array
380
-     */
381
-    public function class_loaders()
382
-    {
383
-        return $this->_class_loaders;
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * adds an alias for a classname
390
-     *
391
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
392
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
-     */
395
-    public function add_alias($class_name, $alias, $for_class = '')
396
-    {
397
-        if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
399
-                $this->_aliases[$for_class] = array();
400
-            }
401
-            $this->_aliases[$for_class][$class_name] = $alias;
402
-        }
403
-        $this->_aliases[$class_name] = $alias;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * returns TRUE if the provided class name has an alias
410
-     *
411
-     * @param string $class_name
412
-     * @param string $for_class
413
-     * @return bool
414
-     */
415
-    public function has_alias($class_name = '', $for_class = '')
416
-    {
417
-        return isset($this->_aliases[$for_class][$class_name])
418
-               || (
419
-                   isset($this->_aliases[$class_name])
420
-                   && ! is_array($this->_aliases[$class_name])
421
-               );
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * returns alias for class name if one exists, otherwise returns the original classname
428
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
429
-     *  for example:
430
-     *      if the following two entries were added to the _aliases array:
431
-     *          array(
432
-     *              'interface_alias'           => 'some\namespace\interface'
433
-     *              'some\namespace\interface'  => 'some\namespace\classname'
434
-     *          )
435
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
-     *      to load an instance of 'some\namespace\classname'
437
-     *
438
-     * @param string $class_name
439
-     * @param string $for_class
440
-     * @return string
441
-     */
442
-    public function get_alias($class_name = '', $for_class = '')
443
-    {
444
-        if (! $this->has_alias($class_name, $for_class)) {
445
-            return $class_name;
446
-        }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
-        }
450
-        return $this->get_alias($this->_aliases[$class_name]);
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
-     * This is done by using the following class constants:
459
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
461
-     */
462
-    protected function _register_core_dependencies()
463
-    {
464
-        $this->_dependency_map = array(
465
-            'EE_Request_Handler'                                                                                          => array(
466
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
467
-            ),
468
-            'EE_System'                                                                                                   => array(
469
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
-            ),
474
-            'EE_Session'                                                                                                  => array(
475
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Cart'                                                                                                     => array(
481
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
482
-            ),
483
-            'EE_Front_Controller'                                                                                         => array(
484
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
-            ),
488
-            'EE_Messenger_Collection_Loader'                                                                              => array(
489
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
-            ),
491
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
492
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
-            ),
494
-            'EE_Message_Resource_Manager'                                                                                 => array(
495
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
-            ),
499
-            'EE_Message_Factory'                                                                                          => array(
500
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EE_messages'                                                                                                 => array(
503
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
-            ),
505
-            'EE_Messages_Generator'                                                                                       => array(
506
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
-            ),
511
-            'EE_Messages_Processor'                                                                                       => array(
512
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EE_Messages_Queue'                                                                                           => array(
515
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
-            ),
517
-            'EE_Messages_Template_Defaults'                                                                               => array(
518
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
522
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
-            ),
528
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
-            ),
532
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
-            ),
535
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
-            ),
569
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
-            ),
572
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-            ),
581
-            'EE_Data_Migration_Class_Base'                                                                                => array(
582
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
-            ),
585
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
586
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
-            ),
589
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
590
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
-            ),
593
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
594
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
-            ),
597
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
598
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
-            ),
601
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
602
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
-            ),
605
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
606
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
-            ),
609
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
610
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
614
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
-            ),
617
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
618
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
-            ),
621
-            'EventEspresso\core\services\assets\I18nRegistry' => array(
622
-                array(),
623
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
624
-            ),
625
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
626
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
627
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
628
-                'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
629
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
638
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
641
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
644
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
647
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
648
-            ),
649
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
650
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
651
-            ),
652
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
653
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
654
-            ),
655
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
656
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
659
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
660
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
661
-            ),
662
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
663
-                null,
664
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
665
-            ),
666
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
667
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
668
-            ),
669
-            'LEGACY_MODELS'                                                   => array(
670
-                null,
671
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EE_Module_Request_Router'                                               => array(
674
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
675
-            ),
676
-            'EE_Registration_Processor'                                              => array(
677
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
678
-            ),
679
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
680
-                null,
681
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
682
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
683
-            ),
684
-            'EE_Admin_Transactions_List_Table' => array(
685
-                null,
686
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
687
-            ),
688
-            'EventEspresso\core\services\licensing\LicenseService' => array(
689
-                'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
690
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
691
-            ),
692
-            'EventEspresso\core\domain\services\pue\Stats' => array(
693
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
694
-                'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
695
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
696
-            ),
697
-            'EventEspresso\core\domain\services\pue\Config' => array(
698
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
699
-                'EE_Config' => EE_Dependency_Map::load_from_cache
700
-            ),
701
-            'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
702
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
703
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
704
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
705
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
706
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
707
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
708
-                'EE_Config' => EE_Dependency_Map::load_from_cache
709
-            ),
710
-            'EventEspresso\core\domain\services\admin\ExitModal' => array(
711
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
712
-            ),
713
-            'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
714
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
715
-            ),
716
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
717
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
718
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
719
-            ),
720
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
721
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
722
-            ),
723
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
724
-                'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
725
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
726
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
727
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
728
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
729
-            ),
730
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
731
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
732
-            ),
733
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array(
734
-                'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
735
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
736
-            ),
737
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'   => array(
738
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
739
-            ),
740
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'   => array(
741
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
742
-            ),
743
-            'EE_CPT_Strategy'   => array(
744
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
745
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
746
-            ),
747
-            'EventEspresso\core\services\editor\BlockRegistrationManager'      => array(
748
-                'EventEspresso\core\services\assets\AssetRegisterCollection'      => EE_Dependency_Map::load_from_cache,
749
-                'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache,
750
-                'EventEspresso\core\services\request\Request'                     => EE_Dependency_Map::load_from_cache,
751
-                'EventEspresso\core\domain\Domain'                                => EE_Dependency_Map::load_from_cache,
752
-                'EventEspresso\core\services\assets\Registry'                     => EE_Dependency_Map::load_from_cache
753
-            ),
754
-            'EventEspresso\core\domain\entities\editor\blocks\widgets\EventAttendees' => array(
755
-                'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetRegister' => EE_Dependency_Map::load_from_cache
756
-            ),
757
-            'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetRegister' => array(
758
-                'EventEspresso\core\domain\Domain'            => EE_Dependency_Map::load_from_cache,
759
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
760
-            ),
761
-        );
762
-    }
763
-
764
-
765
-
766
-    /**
767
-     * Registers how core classes are loaded.
768
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
769
-     *        'EE_Request_Handler' => 'load_core'
770
-     *        'EE_Messages_Queue'  => 'load_lib'
771
-     *        'EEH_Debug_Tools'    => 'load_helper'
772
-     * or, if greater control is required, by providing a custom closure. For example:
773
-     *        'Some_Class' => function () {
774
-     *            return new Some_Class();
775
-     *        },
776
-     * This is required for instantiating dependencies
777
-     * where an interface has been type hinted in a class constructor. For example:
778
-     *        'Required_Interface' => function () {
779
-     *            return new A_Class_That_Implements_Required_Interface();
780
-     *        },
781
-     *
782
-     * @throws InvalidInterfaceException
783
-     * @throws InvalidDataTypeException
784
-     * @throws InvalidArgumentException
785
-     */
786
-    protected function _register_core_class_loaders()
787
-    {
788
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
789
-        //be used in a closure.
790
-        $request = &$this->request;
791
-        $response = &$this->response;
792
-        $legacy_request = &$this->legacy_request;
793
-        // $loader = &$this->loader;
794
-        $this->_class_loaders = array(
795
-            //load_core
796
-            'EE_Capabilities'          => 'load_core',
797
-            'EE_Encryption'            => 'load_core',
798
-            'EE_Front_Controller'      => 'load_core',
799
-            'EE_Module_Request_Router' => 'load_core',
800
-            'EE_Registry'              => 'load_core',
801
-            'EE_Request'               => function () use (&$legacy_request) {
802
-                return $legacy_request;
803
-            },
804
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
805
-                return $request;
806
-            },
807
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
808
-                return $response;
809
-            },
810
-            'EE_Request_Handler'       => 'load_core',
811
-            'EE_Session'               => 'load_core',
812
-            'EE_Cron_Tasks'            => 'load_core',
813
-            'EE_System'                => 'load_core',
814
-            'EE_Maintenance_Mode'      => 'load_core',
815
-            'EE_Register_CPTs'         => 'load_core',
816
-            'EE_Admin'                 => 'load_core',
817
-            'EE_CPT_Strategy'          => 'load_core',
818
-            //load_lib
819
-            'EE_Message_Resource_Manager'          => 'load_lib',
820
-            'EE_Message_Type_Collection'           => 'load_lib',
821
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
822
-            'EE_Messenger_Collection'              => 'load_lib',
823
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
824
-            'EE_Messages_Processor'                => 'load_lib',
825
-            'EE_Message_Repository'                => 'load_lib',
826
-            'EE_Messages_Queue'                    => 'load_lib',
827
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
828
-            'EE_Message_Template_Group_Collection' => 'load_lib',
829
-            'EE_Payment_Method_Manager'            => 'load_lib',
830
-            'EE_Messages_Generator'                => function () {
831
-                return EE_Registry::instance()->load_lib(
832
-                    'Messages_Generator',
833
-                    array(),
834
-                    false,
835
-                    false
836
-                );
837
-            },
838
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
839
-                return EE_Registry::instance()->load_lib(
840
-                    'Messages_Template_Defaults',
841
-                    $arguments,
842
-                    false,
843
-                    false
844
-                );
845
-            },
846
-            //load_helper
847
-            'EEH_Parse_Shortcodes'                 => function () {
848
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
849
-                    return new EEH_Parse_Shortcodes();
850
-                }
851
-                return null;
852
-            },
853
-            'EE_Template_Config'                   => function () {
854
-                return EE_Config::instance()->template_settings;
855
-            },
856
-            'EE_Currency_Config'                   => function () {
857
-                return EE_Config::instance()->currency;
858
-            },
859
-            'EE_Registration_Config'                   => function () {
860
-                return EE_Config::instance()->registration;
861
-            },
862
-            'EE_Core_Config'                   => function () {
863
-                return EE_Config::instance()->core;
864
-            },
865
-            'EventEspresso\core\services\loaders\Loader' => function () {
866
-                return LoaderFactory::getLoader();
867
-            },
868
-            'EE_Network_Config' => function() {
869
-                return EE_Network_Config::instance();
870
-            },
871
-            'EE_Config' => function () {
872
-                return EE_Config::instance();
873
-            }
874
-        );
875
-    }
876
-
877
-
878
-
879
-    /**
880
-     * can be used for supplying alternate names for classes,
881
-     * or for connecting interface names to instantiable classes
882
-     */
883
-    protected function _register_core_aliases()
884
-    {
885
-        $this->_aliases = array(
886
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
887
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
888
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
889
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
890
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
891
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
892
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
893
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
894
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
895
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
896
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
897
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
898
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
899
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
900
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
901
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
902
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
903
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
904
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
905
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
906
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
907
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
908
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
909
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
910
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
911
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
912
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
913
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
914
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
915
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
916
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
917
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
918
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
919
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
920
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
921
-            'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
922
-            'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
923
-            'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
924
-            'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
925
-            'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
926
-        );
927
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
928
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
929
-        }
930
-    }
931
-
932
-
933
-
934
-    /**
935
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
936
-     * request Primarily used by unit tests.
937
-     *
938
-     * @throws InvalidDataTypeException
939
-     * @throws InvalidInterfaceException
940
-     * @throws InvalidArgumentException
941
-     */
942
-    public function reset()
943
-    {
944
-        $this->_register_core_class_loaders();
945
-        $this->_register_core_dependencies();
946
-    }
28
+	/**
29
+	 * This means that the requested class dependency is not present in the dependency map
30
+	 */
31
+	const not_registered = 0;
32
+
33
+	/**
34
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
+	 */
36
+	const load_new_object = 1;
37
+
38
+	/**
39
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
+	 */
42
+	const load_from_cache = 2;
43
+
44
+	/**
45
+	 * When registering a dependency,
46
+	 * this indicates to keep any existing dependencies that already exist,
47
+	 * and simply discard any new dependencies declared in the incoming data
48
+	 */
49
+	const KEEP_EXISTING_DEPENDENCIES = 0;
50
+
51
+	/**
52
+	 * When registering a dependency,
53
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
+	 */
55
+	const OVERWRITE_DEPENDENCIES = 1;
56
+
57
+
58
+
59
+	/**
60
+	 * @type EE_Dependency_Map $_instance
61
+	 */
62
+	protected static $_instance;
63
+
64
+	/**
65
+	 * @type RequestInterface $request
66
+	 */
67
+	protected $request;
68
+
69
+	/**
70
+	 * @type LegacyRequestInterface $legacy_request
71
+	 */
72
+	protected $legacy_request;
73
+
74
+	/**
75
+	 * @type ResponseInterface $response
76
+	 */
77
+	protected $response;
78
+
79
+	/**
80
+	 * @type LoaderInterface $loader
81
+	 */
82
+	protected $loader;
83
+
84
+	/**
85
+	 * @type array $_dependency_map
86
+	 */
87
+	protected $_dependency_map = array();
88
+
89
+	/**
90
+	 * @type array $_class_loaders
91
+	 */
92
+	protected $_class_loaders = array();
93
+
94
+	/**
95
+	 * @type array $_aliases
96
+	 */
97
+	protected $_aliases = array();
98
+
99
+
100
+
101
+	/**
102
+	 * EE_Dependency_Map constructor.
103
+	 */
104
+	protected function __construct()
105
+	{
106
+		// add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
+		do_action('EE_Dependency_Map____construct');
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidArgumentException
116
+	 */
117
+	public function initialize()
118
+	{
119
+		$this->_register_core_dependencies();
120
+		$this->_register_core_class_loaders();
121
+		$this->_register_core_aliases();
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @singleton method used to instantiate class object
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance() {
131
+		// check if class object is instantiated, and instantiated properly
132
+		if (! self::$_instance instanceof EE_Dependency_Map) {
133
+			self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
+		}
135
+		return self::$_instance;
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param RequestInterface $request
141
+	 */
142
+	public function setRequest(RequestInterface $request)
143
+	{
144
+		$this->request = $request;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param LegacyRequestInterface $legacy_request
150
+	 */
151
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
+	{
153
+		$this->legacy_request = $legacy_request;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param ResponseInterface $response
159
+	 */
160
+	public function setResponse(ResponseInterface $response)
161
+	{
162
+		$this->response = $response;
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * @param LoaderInterface $loader
169
+	 */
170
+	public function setLoader(LoaderInterface $loader)
171
+	{
172
+		$this->loader = $loader;
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * @param string $class
179
+	 * @param array  $dependencies
180
+	 * @param int    $overwrite
181
+	 * @return bool
182
+	 */
183
+	public static function register_dependencies(
184
+		$class,
185
+		array $dependencies,
186
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
+	) {
188
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Assigns an array of class names and corresponding load sources (new or cached)
195
+	 * to the class specified by the first parameter.
196
+	 * IMPORTANT !!!
197
+	 * The order of elements in the incoming $dependencies array MUST match
198
+	 * the order of the constructor parameters for the class in question.
199
+	 * This is especially important when overriding any existing dependencies that are registered.
200
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
+	 *
202
+	 * @param string $class
203
+	 * @param array  $dependencies
204
+	 * @param int    $overwrite
205
+	 * @return bool
206
+	 */
207
+	public function registerDependencies(
208
+		$class,
209
+		array $dependencies,
210
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
+	) {
212
+		$class = trim($class, '\\');
213
+		$registered = false;
214
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
215
+			self::$_instance->_dependency_map[ $class ] = array();
216
+		}
217
+		// we need to make sure that any aliases used when registering a dependency
218
+		// get resolved to the correct class name
219
+		foreach ($dependencies as $dependency => $load_source) {
220
+			$alias = self::$_instance->get_alias($dependency);
221
+			if (
222
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
+			) {
225
+				unset($dependencies[$dependency]);
226
+				$dependencies[$alias] = $load_source;
227
+				$registered = true;
228
+			}
229
+		}
230
+		// now add our two lists of dependencies together.
231
+		// using Union (+=) favours the arrays in precedence from left to right,
232
+		// so $dependencies is NOT overwritten because it is listed first
233
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
+		// Union is way faster than array_merge() but should be used with caution...
235
+		// especially with numerically indexed arrays
236
+		$dependencies += self::$_instance->_dependency_map[ $class ];
237
+		// now we need to ensure that the resulting dependencies
238
+		// array only has the entries that are required for the class
239
+		// so first count how many dependencies were originally registered for the class
240
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
+		// if that count is non-zero (meaning dependencies were already registered)
242
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
243
+			// then truncate the  final array to match that count
244
+			? array_slice($dependencies, 0, $dependency_count)
245
+			// otherwise just take the incoming array because nothing previously existed
246
+			: $dependencies;
247
+		return $registered;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @param string $class_name
254
+	 * @param string $loader
255
+	 * @return bool
256
+	 * @throws DomainException
257
+	 */
258
+	public static function register_class_loader($class_name, $loader = 'load_core')
259
+	{
260
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
+			throw new DomainException(
262
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
+			);
264
+		}
265
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
266
+		if (
267
+			! is_callable($loader)
268
+			&& (
269
+				strpos($loader, 'load_') !== 0
270
+				|| ! method_exists('EE_Registry', $loader)
271
+			)
272
+		) {
273
+			throw new DomainException(
274
+				sprintf(
275
+					esc_html__(
276
+						'"%1$s" is not a valid loader method on EE_Registry.',
277
+						'event_espresso'
278
+					),
279
+					$loader
280
+				)
281
+			);
282
+		}
283
+		$class_name = self::$_instance->get_alias($class_name);
284
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
+			self::$_instance->_class_loaders[$class_name] = $loader;
286
+			return true;
287
+		}
288
+		return false;
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * @return array
295
+	 */
296
+	public function dependency_map()
297
+	{
298
+		return $this->_dependency_map;
299
+	}
300
+
301
+
302
+
303
+	/**
304
+	 * returns TRUE if dependency map contains a listing for the provided class name
305
+	 *
306
+	 * @param string $class_name
307
+	 * @return boolean
308
+	 */
309
+	public function has($class_name = '')
310
+	{
311
+		// all legacy models have the same dependencies
312
+		if (strpos($class_name, 'EEM_') === 0) {
313
+			$class_name = 'LEGACY_MODELS';
314
+		}
315
+		return isset($this->_dependency_map[$class_name]) ? true : false;
316
+	}
317
+
318
+
319
+
320
+	/**
321
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
+	 *
323
+	 * @param string $class_name
324
+	 * @param string $dependency
325
+	 * @return bool
326
+	 */
327
+	public function has_dependency_for_class($class_name = '', $dependency = '')
328
+	{
329
+		// all legacy models have the same dependencies
330
+		if (strpos($class_name, 'EEM_') === 0) {
331
+			$class_name = 'LEGACY_MODELS';
332
+		}
333
+		$dependency = $this->get_alias($dependency);
334
+		return isset($this->_dependency_map[$class_name][$dependency])
335
+			? true
336
+			: false;
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
+	 *
344
+	 * @param string $class_name
345
+	 * @param string $dependency
346
+	 * @return int
347
+	 */
348
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
+	{
350
+		// all legacy models have the same dependencies
351
+		if (strpos($class_name, 'EEM_') === 0) {
352
+			$class_name = 'LEGACY_MODELS';
353
+		}
354
+		$dependency = $this->get_alias($dependency);
355
+		return $this->has_dependency_for_class($class_name, $dependency)
356
+			? $this->_dependency_map[$class_name][$dependency]
357
+			: EE_Dependency_Map::not_registered;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * @param string $class_name
364
+	 * @return string | Closure
365
+	 */
366
+	public function class_loader($class_name)
367
+	{
368
+		// all legacy models use load_model()
369
+		if(strpos($class_name, 'EEM_') === 0){
370
+			return 'load_model';
371
+		}
372
+		$class_name = $this->get_alias($class_name);
373
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
+	}
375
+
376
+
377
+
378
+	/**
379
+	 * @return array
380
+	 */
381
+	public function class_loaders()
382
+	{
383
+		return $this->_class_loaders;
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * adds an alias for a classname
390
+	 *
391
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
392
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
+	 */
395
+	public function add_alias($class_name, $alias, $for_class = '')
396
+	{
397
+		if ($for_class !== '') {
398
+			if (! isset($this->_aliases[$for_class])) {
399
+				$this->_aliases[$for_class] = array();
400
+			}
401
+			$this->_aliases[$for_class][$class_name] = $alias;
402
+		}
403
+		$this->_aliases[$class_name] = $alias;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * returns TRUE if the provided class name has an alias
410
+	 *
411
+	 * @param string $class_name
412
+	 * @param string $for_class
413
+	 * @return bool
414
+	 */
415
+	public function has_alias($class_name = '', $for_class = '')
416
+	{
417
+		return isset($this->_aliases[$for_class][$class_name])
418
+			   || (
419
+				   isset($this->_aliases[$class_name])
420
+				   && ! is_array($this->_aliases[$class_name])
421
+			   );
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * returns alias for class name if one exists, otherwise returns the original classname
428
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
429
+	 *  for example:
430
+	 *      if the following two entries were added to the _aliases array:
431
+	 *          array(
432
+	 *              'interface_alias'           => 'some\namespace\interface'
433
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
434
+	 *          )
435
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
+	 *      to load an instance of 'some\namespace\classname'
437
+	 *
438
+	 * @param string $class_name
439
+	 * @param string $for_class
440
+	 * @return string
441
+	 */
442
+	public function get_alias($class_name = '', $for_class = '')
443
+	{
444
+		if (! $this->has_alias($class_name, $for_class)) {
445
+			return $class_name;
446
+		}
447
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
+		}
450
+		return $this->get_alias($this->_aliases[$class_name]);
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
+	 * This is done by using the following class constants:
459
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
461
+	 */
462
+	protected function _register_core_dependencies()
463
+	{
464
+		$this->_dependency_map = array(
465
+			'EE_Request_Handler'                                                                                          => array(
466
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
467
+			),
468
+			'EE_System'                                                                                                   => array(
469
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
+			),
474
+			'EE_Session'                                                                                                  => array(
475
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Cart'                                                                                                     => array(
481
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
482
+			),
483
+			'EE_Front_Controller'                                                                                         => array(
484
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
+			),
488
+			'EE_Messenger_Collection_Loader'                                                                              => array(
489
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
+			),
491
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
492
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
+			),
494
+			'EE_Message_Resource_Manager'                                                                                 => array(
495
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
+			),
499
+			'EE_Message_Factory'                                                                                          => array(
500
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EE_messages'                                                                                                 => array(
503
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
+			),
505
+			'EE_Messages_Generator'                                                                                       => array(
506
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
+			),
511
+			'EE_Messages_Processor'                                                                                       => array(
512
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EE_Messages_Queue'                                                                                           => array(
515
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
+			),
517
+			'EE_Messages_Template_Defaults'                                                                               => array(
518
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
522
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
+			),
528
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
+			),
532
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
+			),
535
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
+			),
569
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
+			),
572
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+			),
581
+			'EE_Data_Migration_Class_Base'                                                                                => array(
582
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
+			),
585
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
586
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
+			),
589
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
590
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
+			),
593
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
594
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
+			),
597
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
598
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
+			),
601
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
602
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
+			),
605
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
606
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
+			),
609
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
610
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
614
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
+			),
617
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
618
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
+			),
621
+			'EventEspresso\core\services\assets\I18nRegistry' => array(
622
+				array(),
623
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
624
+			),
625
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
626
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
627
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
628
+				'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
629
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
638
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
641
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
644
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
647
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
648
+			),
649
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
650
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
651
+			),
652
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
653
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
654
+			),
655
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
656
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
659
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
660
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
661
+			),
662
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
663
+				null,
664
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
665
+			),
666
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
667
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
668
+			),
669
+			'LEGACY_MODELS'                                                   => array(
670
+				null,
671
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EE_Module_Request_Router'                                               => array(
674
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
675
+			),
676
+			'EE_Registration_Processor'                                              => array(
677
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
678
+			),
679
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
680
+				null,
681
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
682
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
683
+			),
684
+			'EE_Admin_Transactions_List_Table' => array(
685
+				null,
686
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
687
+			),
688
+			'EventEspresso\core\services\licensing\LicenseService' => array(
689
+				'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
690
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
691
+			),
692
+			'EventEspresso\core\domain\services\pue\Stats' => array(
693
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
694
+				'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
695
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
696
+			),
697
+			'EventEspresso\core\domain\services\pue\Config' => array(
698
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
699
+				'EE_Config' => EE_Dependency_Map::load_from_cache
700
+			),
701
+			'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
702
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
703
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
704
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
705
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
706
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
707
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
708
+				'EE_Config' => EE_Dependency_Map::load_from_cache
709
+			),
710
+			'EventEspresso\core\domain\services\admin\ExitModal' => array(
711
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
712
+			),
713
+			'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
714
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
715
+			),
716
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
717
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
718
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
719
+			),
720
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
721
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
722
+			),
723
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
724
+				'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
725
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
726
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
727
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
728
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
729
+			),
730
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
731
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
732
+			),
733
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array(
734
+				'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
735
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
736
+			),
737
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'   => array(
738
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
739
+			),
740
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'   => array(
741
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
742
+			),
743
+			'EE_CPT_Strategy'   => array(
744
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
745
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
746
+			),
747
+			'EventEspresso\core\services\editor\BlockRegistrationManager'      => array(
748
+				'EventEspresso\core\services\assets\AssetRegisterCollection'      => EE_Dependency_Map::load_from_cache,
749
+				'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache,
750
+				'EventEspresso\core\services\request\Request'                     => EE_Dependency_Map::load_from_cache,
751
+				'EventEspresso\core\domain\Domain'                                => EE_Dependency_Map::load_from_cache,
752
+				'EventEspresso\core\services\assets\Registry'                     => EE_Dependency_Map::load_from_cache
753
+			),
754
+			'EventEspresso\core\domain\entities\editor\blocks\widgets\EventAttendees' => array(
755
+				'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetRegister' => EE_Dependency_Map::load_from_cache
756
+			),
757
+			'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetRegister' => array(
758
+				'EventEspresso\core\domain\Domain'            => EE_Dependency_Map::load_from_cache,
759
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
760
+			),
761
+		);
762
+	}
763
+
764
+
765
+
766
+	/**
767
+	 * Registers how core classes are loaded.
768
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
769
+	 *        'EE_Request_Handler' => 'load_core'
770
+	 *        'EE_Messages_Queue'  => 'load_lib'
771
+	 *        'EEH_Debug_Tools'    => 'load_helper'
772
+	 * or, if greater control is required, by providing a custom closure. For example:
773
+	 *        'Some_Class' => function () {
774
+	 *            return new Some_Class();
775
+	 *        },
776
+	 * This is required for instantiating dependencies
777
+	 * where an interface has been type hinted in a class constructor. For example:
778
+	 *        'Required_Interface' => function () {
779
+	 *            return new A_Class_That_Implements_Required_Interface();
780
+	 *        },
781
+	 *
782
+	 * @throws InvalidInterfaceException
783
+	 * @throws InvalidDataTypeException
784
+	 * @throws InvalidArgumentException
785
+	 */
786
+	protected function _register_core_class_loaders()
787
+	{
788
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
789
+		//be used in a closure.
790
+		$request = &$this->request;
791
+		$response = &$this->response;
792
+		$legacy_request = &$this->legacy_request;
793
+		// $loader = &$this->loader;
794
+		$this->_class_loaders = array(
795
+			//load_core
796
+			'EE_Capabilities'          => 'load_core',
797
+			'EE_Encryption'            => 'load_core',
798
+			'EE_Front_Controller'      => 'load_core',
799
+			'EE_Module_Request_Router' => 'load_core',
800
+			'EE_Registry'              => 'load_core',
801
+			'EE_Request'               => function () use (&$legacy_request) {
802
+				return $legacy_request;
803
+			},
804
+			'EventEspresso\core\services\request\Request' => function () use (&$request) {
805
+				return $request;
806
+			},
807
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
808
+				return $response;
809
+			},
810
+			'EE_Request_Handler'       => 'load_core',
811
+			'EE_Session'               => 'load_core',
812
+			'EE_Cron_Tasks'            => 'load_core',
813
+			'EE_System'                => 'load_core',
814
+			'EE_Maintenance_Mode'      => 'load_core',
815
+			'EE_Register_CPTs'         => 'load_core',
816
+			'EE_Admin'                 => 'load_core',
817
+			'EE_CPT_Strategy'          => 'load_core',
818
+			//load_lib
819
+			'EE_Message_Resource_Manager'          => 'load_lib',
820
+			'EE_Message_Type_Collection'           => 'load_lib',
821
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
822
+			'EE_Messenger_Collection'              => 'load_lib',
823
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
824
+			'EE_Messages_Processor'                => 'load_lib',
825
+			'EE_Message_Repository'                => 'load_lib',
826
+			'EE_Messages_Queue'                    => 'load_lib',
827
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
828
+			'EE_Message_Template_Group_Collection' => 'load_lib',
829
+			'EE_Payment_Method_Manager'            => 'load_lib',
830
+			'EE_Messages_Generator'                => function () {
831
+				return EE_Registry::instance()->load_lib(
832
+					'Messages_Generator',
833
+					array(),
834
+					false,
835
+					false
836
+				);
837
+			},
838
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
839
+				return EE_Registry::instance()->load_lib(
840
+					'Messages_Template_Defaults',
841
+					$arguments,
842
+					false,
843
+					false
844
+				);
845
+			},
846
+			//load_helper
847
+			'EEH_Parse_Shortcodes'                 => function () {
848
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
849
+					return new EEH_Parse_Shortcodes();
850
+				}
851
+				return null;
852
+			},
853
+			'EE_Template_Config'                   => function () {
854
+				return EE_Config::instance()->template_settings;
855
+			},
856
+			'EE_Currency_Config'                   => function () {
857
+				return EE_Config::instance()->currency;
858
+			},
859
+			'EE_Registration_Config'                   => function () {
860
+				return EE_Config::instance()->registration;
861
+			},
862
+			'EE_Core_Config'                   => function () {
863
+				return EE_Config::instance()->core;
864
+			},
865
+			'EventEspresso\core\services\loaders\Loader' => function () {
866
+				return LoaderFactory::getLoader();
867
+			},
868
+			'EE_Network_Config' => function() {
869
+				return EE_Network_Config::instance();
870
+			},
871
+			'EE_Config' => function () {
872
+				return EE_Config::instance();
873
+			}
874
+		);
875
+	}
876
+
877
+
878
+
879
+	/**
880
+	 * can be used for supplying alternate names for classes,
881
+	 * or for connecting interface names to instantiable classes
882
+	 */
883
+	protected function _register_core_aliases()
884
+	{
885
+		$this->_aliases = array(
886
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
887
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
888
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
889
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
890
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
891
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
892
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
893
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
894
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
895
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
896
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
897
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
898
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
899
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
900
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
901
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
902
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
903
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
904
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
905
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
906
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
907
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
908
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
909
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
910
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
911
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
912
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
913
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
914
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
915
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
916
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
917
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
918
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
919
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
920
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
921
+			'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
922
+			'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
923
+			'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
924
+			'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
925
+			'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
926
+		);
927
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
928
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
929
+		}
930
+	}
931
+
932
+
933
+
934
+	/**
935
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
936
+	 * request Primarily used by unit tests.
937
+	 *
938
+	 * @throws InvalidDataTypeException
939
+	 * @throws InvalidInterfaceException
940
+	 * @throws InvalidArgumentException
941
+	 */
942
+	public function reset()
943
+	{
944
+		$this->_register_core_class_loaders();
945
+		$this->_register_core_dependencies();
946
+	}
947 947
 
948 948
 
949 949
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 1 patch
Indentation   +1302 added lines, -1302 removed lines patch added patch discarded remove patch
@@ -32,1308 +32,1308 @@
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
37
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
38
-     */
39
-    const req_type_normal = 0;
40
-
41
-    /**
42
-     * Indicates this is a brand new installation of EE so we should install
43
-     * tables and default data etc
44
-     */
45
-    const req_type_new_activation = 1;
46
-
47
-    /**
48
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
49
-     * and we just exited maintenance mode). We MUST check the database is setup properly
50
-     * and that default data is setup too
51
-     */
52
-    const req_type_reactivation = 2;
53
-
54
-    /**
55
-     * indicates that EE has been upgraded since its previous request.
56
-     * We may have data migration scripts to call and will want to trigger maintenance mode
57
-     */
58
-    const req_type_upgrade = 3;
59
-
60
-    /**
61
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
62
-     */
63
-    const req_type_downgrade = 4;
64
-
65
-    /**
66
-     * @deprecated since version 4.6.0.dev.006
67
-     * Now whenever a new_activation is detected the request type is still just
68
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
69
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
70
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
71
-     * (Specifically, when the migration manager indicates migrations are finished
72
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
73
-     */
74
-    const req_type_activation_but_not_installed = 5;
75
-
76
-    /**
77
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
78
-     */
79
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
80
-
81
-
82
-    /**
83
-     * @var EE_System $_instance
84
-     */
85
-    private static $_instance;
86
-
87
-    /**
88
-     * @var EE_Registry $registry
89
-     */
90
-    private $registry;
91
-
92
-    /**
93
-     * @var LoaderInterface $loader
94
-     */
95
-    private $loader;
96
-
97
-    /**
98
-     * @var EE_Capabilities $capabilities
99
-     */
100
-    private $capabilities;
101
-
102
-    /**
103
-     * @var RequestInterface $request
104
-     */
105
-    private $request;
106
-
107
-    /**
108
-     * @var EE_Maintenance_Mode $maintenance_mode
109
-     */
110
-    private $maintenance_mode;
111
-
112
-    /**
113
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
114
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
115
-     *
116
-     * @var int $_req_type
117
-     */
118
-    private $_req_type;
119
-
120
-    /**
121
-     * Whether or not there was a non-micro version change in EE core version during this request
122
-     *
123
-     * @var boolean $_major_version_change
124
-     */
125
-    private $_major_version_change = false;
126
-
127
-    /**
128
-     * A Context DTO dedicated solely to identifying the current request type.
129
-     *
130
-     * @var RequestTypeContextCheckerInterface $request_type
131
-     */
132
-    private $request_type;
133
-
134
-
135
-
136
-    /**
137
-     * @singleton method used to instantiate class object
138
-     * @param EE_Registry|null         $registry
139
-     * @param LoaderInterface|null     $loader
140
-     * @param RequestInterface|null          $request
141
-     * @param EE_Maintenance_Mode|null $maintenance_mode
142
-     * @return EE_System
143
-     */
144
-    public static function instance(
145
-        EE_Registry $registry = null,
146
-        LoaderInterface $loader = null,
147
-        RequestInterface $request = null,
148
-        EE_Maintenance_Mode $maintenance_mode = null
149
-    ) {
150
-        // check if class object is instantiated
151
-        if (! self::$_instance instanceof EE_System) {
152
-            self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
153
-        }
154
-        return self::$_instance;
155
-    }
156
-
157
-
158
-
159
-    /**
160
-     * resets the instance and returns it
161
-     *
162
-     * @return EE_System
163
-     */
164
-    public static function reset()
165
-    {
166
-        self::$_instance->_req_type = null;
167
-        //make sure none of the old hooks are left hanging around
168
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
169
-        //we need to reset the migration manager in order for it to detect DMSs properly
170
-        EE_Data_Migration_Manager::reset();
171
-        self::instance()->detect_activations_or_upgrades();
172
-        self::instance()->perform_activations_upgrades_and_migrations();
173
-        return self::instance();
174
-    }
175
-
176
-
177
-
178
-    /**
179
-     * sets hooks for running rest of system
180
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
181
-     * starting EE Addons from any other point may lead to problems
182
-     *
183
-     * @param EE_Registry         $registry
184
-     * @param LoaderInterface     $loader
185
-     * @param RequestInterface          $request
186
-     * @param EE_Maintenance_Mode $maintenance_mode
187
-     */
188
-    private function __construct(
189
-        EE_Registry $registry,
190
-        LoaderInterface $loader,
191
-        RequestInterface $request,
192
-        EE_Maintenance_Mode $maintenance_mode
193
-    ) {
194
-        $this->registry         = $registry;
195
-        $this->loader           = $loader;
196
-        $this->request          = $request;
197
-        $this->maintenance_mode = $maintenance_mode;
198
-        do_action('AHEE__EE_System__construct__begin', $this);
199
-        add_action(
200
-            'AHEE__EE_Bootstrap__load_espresso_addons',
201
-            array($this, 'loadCapabilities'),
202
-            5
203
-        );
204
-        add_action(
205
-            'AHEE__EE_Bootstrap__load_espresso_addons',
206
-            array($this, 'loadCommandBus'),
207
-            7
208
-        );
209
-        add_action(
210
-            'AHEE__EE_Bootstrap__load_espresso_addons',
211
-            array($this, 'loadPluginApi'),
212
-            9
213
-        );
214
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
215
-        add_action(
216
-            'AHEE__EE_Bootstrap__load_espresso_addons',
217
-            array($this, 'load_espresso_addons')
218
-        );
219
-        // when an ee addon is activated, we want to call the core hook(s) again
220
-        // because the newly-activated addon didn't get a chance to run at all
221
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
222
-        // detect whether install or upgrade
223
-        add_action(
224
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
225
-            array($this, 'detect_activations_or_upgrades'),
226
-            3
227
-        );
228
-        // load EE_Config, EE_Textdomain, etc
229
-        add_action(
230
-            'AHEE__EE_Bootstrap__load_core_configuration',
231
-            array($this, 'load_core_configuration'),
232
-            5
233
-        );
234
-        // load EE_Config, EE_Textdomain, etc
235
-        add_action(
236
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
237
-            array($this, 'register_shortcodes_modules_and_widgets'),
238
-            7
239
-        );
240
-        // you wanna get going? I wanna get going... let's get going!
241
-        add_action(
242
-            'AHEE__EE_Bootstrap__brew_espresso',
243
-            array($this, 'brew_espresso'),
244
-            9
245
-        );
246
-        //other housekeeping
247
-        //exclude EE critical pages from wp_list_pages
248
-        add_filter(
249
-            'wp_list_pages_excludes',
250
-            array($this, 'remove_pages_from_wp_list_pages'),
251
-            10
252
-        );
253
-        // ALL EE Addons should use the following hook point to attach their initial setup too
254
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
255
-        do_action('AHEE__EE_System__construct__complete', $this);
256
-    }
257
-
258
-
259
-    /**
260
-     * load and setup EE_Capabilities
261
-     *
262
-     * @return void
263
-     * @throws EE_Error
264
-     */
265
-    public function loadCapabilities()
266
-    {
267
-        $this->capabilities = $this->loader->getShared('EE_Capabilities');
268
-        add_action(
269
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
270
-            function ()
271
-            {
272
-                LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
273
-            }
274
-        );
275
-    }
276
-
277
-
278
-
279
-    /**
280
-     * create and cache the CommandBus, and also add middleware
281
-     * The CapChecker middleware requires the use of EE_Capabilities
282
-     * which is why we need to load the CommandBus after Caps are set up
283
-     *
284
-     * @return void
285
-     * @throws EE_Error
286
-     */
287
-    public function loadCommandBus()
288
-    {
289
-        $this->loader->getShared(
290
-            'CommandBusInterface',
291
-            array(
292
-                null,
293
-                apply_filters(
294
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
295
-                    array(
296
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
297
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
298
-                    )
299
-                ),
300
-            )
301
-        );
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * @return void
308
-     * @throws EE_Error
309
-     */
310
-    public function loadPluginApi()
311
-    {
312
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
313
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
314
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
315
-        $this->loader->getShared('EE_Request_Handler');
316
-    }
317
-
318
-
319
-    /**
320
-     * @param string $addon_name
321
-     * @param string $version_constant
322
-     * @param string $min_version_required
323
-     * @param string $load_callback
324
-     * @param string $plugin_file_constant
325
-     * @return void
326
-     */
327
-    private function deactivateIncompatibleAddon(
328
-        $addon_name,
329
-        $version_constant,
330
-        $min_version_required,
331
-        $load_callback,
332
-        $plugin_file_constant
333
-    ) {
334
-        if (! defined($version_constant)) {
335
-            return;
336
-        }
337
-        $addon_version = constant($version_constant);
338
-        if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
339
-            remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
340
-            if (! function_exists('deactivate_plugins')) {
341
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
342
-            }
343
-            deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
344
-            unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
345
-            EE_Error::add_error(
346
-                sprintf(
347
-                    esc_html__(
348
-                        'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
349
-                        'event_espresso'
350
-                    ),
351
-                    $addon_name,
352
-                    $min_version_required
353
-                ),
354
-                __FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
355
-            );
356
-            EE_Error::get_notices(false, true);
357
-        }
358
-    }
359
-
360
-
361
-    /**
362
-     * load_espresso_addons
363
-     * allow addons to load first so that they can set hooks for running DMS's, etc
364
-     * this is hooked into both:
365
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
366
-     *        which runs during the WP 'plugins_loaded' action at priority 5
367
-     *    and the WP 'activate_plugin' hook point
368
-     *
369
-     * @access public
370
-     * @return void
371
-     */
372
-    public function load_espresso_addons()
373
-    {
374
-        $this->deactivateIncompatibleAddon(
375
-            'Wait Lists',
376
-            'EE_WAIT_LISTS_VERSION',
377
-            '1.0.0.beta.074',
378
-            'load_espresso_wait_lists',
379
-            'EE_WAIT_LISTS_PLUGIN_FILE'
380
-        );
381
-        $this->deactivateIncompatibleAddon(
382
-            'Automated Upcoming Event Notifications',
383
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
384
-            '1.0.0.beta.091',
385
-            'load_espresso_automated_upcoming_event_notification',
386
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
387
-        );
388
-        do_action('AHEE__EE_System__load_espresso_addons');
389
-        //if the WP API basic auth plugin isn't already loaded, load it now.
390
-        //We want it for mobile apps. Just include the entire plugin
391
-        //also, don't load the basic auth when a plugin is getting activated, because
392
-        //it could be the basic auth plugin, and it doesn't check if its methods are already defined
393
-        //and causes a fatal error
394
-        if (
395
-            $this->request->getRequestParam('activate') !== 'true'
396
-            && ! function_exists('json_basic_auth_handler')
397
-            && ! function_exists('json_basic_auth_error')
398
-            && ! in_array(
399
-                $this->request->getRequestParam('action'),
400
-                array('activate', 'activate-selected'),
401
-                true
402
-            )
403
-        ) {
404
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
405
-        }
406
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
407
-    }
408
-
409
-
410
-
411
-    /**
412
-     * detect_activations_or_upgrades
413
-     * Checks for activation or upgrade of core first;
414
-     * then also checks if any registered addons have been activated or upgraded
415
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
416
-     * which runs during the WP 'plugins_loaded' action at priority 3
417
-     *
418
-     * @access public
419
-     * @return void
420
-     */
421
-    public function detect_activations_or_upgrades()
422
-    {
423
-        //first off: let's make sure to handle core
424
-        $this->detect_if_activation_or_upgrade();
425
-        foreach ($this->registry->addons as $addon) {
426
-            if ($addon instanceof EE_Addon) {
427
-                //detect teh request type for that addon
428
-                $addon->detect_activation_or_upgrade();
429
-            }
430
-        }
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * detect_if_activation_or_upgrade
437
-     * Takes care of detecting whether this is a brand new install or code upgrade,
438
-     * and either setting up the DB or setting up maintenance mode etc.
439
-     *
440
-     * @access public
441
-     * @return void
442
-     */
443
-    public function detect_if_activation_or_upgrade()
444
-    {
445
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
446
-        // check if db has been updated, or if its a brand-new installation
447
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
448
-        $request_type       = $this->detect_req_type($espresso_db_update);
449
-        //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
450
-        switch ($request_type) {
451
-            case EE_System::req_type_new_activation:
452
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
453
-                $this->_handle_core_version_change($espresso_db_update);
454
-                break;
455
-            case EE_System::req_type_reactivation:
456
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
457
-                $this->_handle_core_version_change($espresso_db_update);
458
-                break;
459
-            case EE_System::req_type_upgrade:
460
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
461
-                //migrations may be required now that we've upgraded
462
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
463
-                $this->_handle_core_version_change($espresso_db_update);
464
-                //				echo "done upgrade";die;
465
-                break;
466
-            case EE_System::req_type_downgrade:
467
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
468
-                //its possible migrations are no longer required
469
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
470
-                $this->_handle_core_version_change($espresso_db_update);
471
-                break;
472
-            case EE_System::req_type_normal:
473
-            default:
474
-                break;
475
-        }
476
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
477
-    }
478
-
479
-
480
-
481
-    /**
482
-     * Updates the list of installed versions and sets hooks for
483
-     * initializing the database later during the request
484
-     *
485
-     * @param array $espresso_db_update
486
-     */
487
-    private function _handle_core_version_change($espresso_db_update)
488
-    {
489
-        $this->update_list_of_installed_versions($espresso_db_update);
490
-        //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
491
-        add_action(
492
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
493
-            array($this, 'initialize_db_if_no_migrations_required')
494
-        );
495
-    }
496
-
497
-
498
-
499
-    /**
500
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
501
-     * information about what versions of EE have been installed and activated,
502
-     * NOT necessarily the state of the database
503
-     *
504
-     * @param mixed $espresso_db_update           the value of the WordPress option.
505
-     *                                            If not supplied, fetches it from the options table
506
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
507
-     */
508
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
509
-    {
510
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
511
-        if (! $espresso_db_update) {
512
-            $espresso_db_update = get_option('espresso_db_update');
513
-        }
514
-        // check that option is an array
515
-        if (! is_array($espresso_db_update)) {
516
-            // if option is FALSE, then it never existed
517
-            if ($espresso_db_update === false) {
518
-                // make $espresso_db_update an array and save option with autoload OFF
519
-                $espresso_db_update = array();
520
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
521
-            } else {
522
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
523
-                $espresso_db_update = array($espresso_db_update => array());
524
-                update_option('espresso_db_update', $espresso_db_update);
525
-            }
526
-        } else {
527
-            $corrected_db_update = array();
528
-            //if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
529
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
530
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
531
-                    //the key is an int, and the value IS NOT an array
532
-                    //so it must be numerically-indexed, where values are versions installed...
533
-                    //fix it!
534
-                    $version_string                         = $should_be_array;
535
-                    $corrected_db_update[ $version_string ] = array('unknown-date');
536
-                } else {
537
-                    //ok it checks out
538
-                    $corrected_db_update[ $should_be_version_string ] = $should_be_array;
539
-                }
540
-            }
541
-            $espresso_db_update = $corrected_db_update;
542
-            update_option('espresso_db_update', $espresso_db_update);
543
-        }
544
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
545
-        return $espresso_db_update;
546
-    }
547
-
548
-
549
-
550
-    /**
551
-     * Does the traditional work of setting up the plugin's database and adding default data.
552
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
553
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
554
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
555
-     * so that it will be done when migrations are finished
556
-     *
557
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
558
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
559
-     *                                       This is a resource-intensive job
560
-     *                                       so we prefer to only do it when necessary
561
-     * @return void
562
-     * @throws EE_Error
563
-     */
564
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
565
-    {
566
-        $request_type = $this->detect_req_type();
567
-        //only initialize system if we're not in maintenance mode.
568
-        if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
569
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
570
-            $rewrite_rules = $this->loader->getShared(
571
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
572
-            );
573
-            $rewrite_rules->flush();
574
-            if ($verify_schema) {
575
-                EEH_Activation::initialize_db_and_folders();
576
-            }
577
-            EEH_Activation::initialize_db_content();
578
-            EEH_Activation::system_initialization();
579
-            if ($initialize_addons_too) {
580
-                $this->initialize_addons();
581
-            }
582
-        } else {
583
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
584
-        }
585
-        if ($request_type === EE_System::req_type_new_activation
586
-            || $request_type === EE_System::req_type_reactivation
587
-            || (
588
-                $request_type === EE_System::req_type_upgrade
589
-                && $this->is_major_version_change()
590
-            )
591
-        ) {
592
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
593
-        }
594
-    }
595
-
596
-
597
-
598
-    /**
599
-     * Initializes the db for all registered addons
600
-     *
601
-     * @throws EE_Error
602
-     */
603
-    public function initialize_addons()
604
-    {
605
-        //foreach registered addon, make sure its db is up-to-date too
606
-        foreach ($this->registry->addons as $addon) {
607
-            if ($addon instanceof EE_Addon) {
608
-                $addon->initialize_db_if_no_migrations_required();
609
-            }
610
-        }
611
-    }
612
-
613
-
614
-
615
-    /**
616
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
617
-     *
618
-     * @param    array  $version_history
619
-     * @param    string $current_version_to_add version to be added to the version history
620
-     * @return    boolean success as to whether or not this option was changed
621
-     */
622
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
623
-    {
624
-        if (! $version_history) {
625
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
626
-        }
627
-        if ($current_version_to_add === null) {
628
-            $current_version_to_add = espresso_version();
629
-        }
630
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
631
-        // re-save
632
-        return update_option('espresso_db_update', $version_history);
633
-    }
634
-
635
-
636
-
637
-    /**
638
-     * Detects if the current version indicated in the has existed in the list of
639
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
640
-     *
641
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
642
-     *                                  If not supplied, fetches it from the options table.
643
-     *                                  Also, caches its result so later parts of the code can also know whether
644
-     *                                  there's been an update or not. This way we can add the current version to
645
-     *                                  espresso_db_update, but still know if this is a new install or not
646
-     * @return int one of the constants on EE_System::req_type_
647
-     */
648
-    public function detect_req_type($espresso_db_update = null)
649
-    {
650
-        if ($this->_req_type === null) {
651
-            $espresso_db_update          = ! empty($espresso_db_update)
652
-                ? $espresso_db_update
653
-                : $this->fix_espresso_db_upgrade_option();
654
-            $this->_req_type             = EE_System::detect_req_type_given_activation_history(
655
-                $espresso_db_update,
656
-                'ee_espresso_activation', espresso_version()
657
-            );
658
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
659
-            $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
660
-        }
661
-        return $this->_req_type;
662
-    }
663
-
664
-
665
-
666
-    /**
667
-     * Returns whether or not there was a non-micro version change (ie, change in either
668
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
669
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
670
-     *
671
-     * @param $activation_history
672
-     * @return bool
673
-     */
674
-    private function _detect_major_version_change($activation_history)
675
-    {
676
-        $previous_version       = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
677
-        $previous_version_parts = explode('.', $previous_version);
678
-        $current_version_parts  = explode('.', espresso_version());
679
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
680
-               && ($previous_version_parts[0] !== $current_version_parts[0]
681
-                   || $previous_version_parts[1] !== $current_version_parts[1]
682
-               );
683
-    }
684
-
685
-
686
-
687
-    /**
688
-     * Returns true if either the major or minor version of EE changed during this request.
689
-     * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
690
-     *
691
-     * @return bool
692
-     */
693
-    public function is_major_version_change()
694
-    {
695
-        return $this->_major_version_change;
696
-    }
697
-
698
-
699
-
700
-    /**
701
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
702
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
703
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
704
-     * just activated to (for core that will always be espresso_version())
705
-     *
706
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
707
-     *                                                 ee plugin. for core that's 'espresso_db_update'
708
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
709
-     *                                                 indicate that this plugin was just activated
710
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
711
-     *                                                 espresso_version())
712
-     * @return int one of the constants on EE_System::req_type_*
713
-     */
714
-    public static function detect_req_type_given_activation_history(
715
-        $activation_history_for_addon,
716
-        $activation_indicator_option_name,
717
-        $version_to_upgrade_to
718
-    ) {
719
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
720
-        if ($activation_history_for_addon) {
721
-            //it exists, so this isn't a completely new install
722
-            //check if this version already in that list of previously installed versions
723
-            if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
724
-                //it a version we haven't seen before
725
-                if ($version_is_higher === 1) {
726
-                    $req_type = EE_System::req_type_upgrade;
727
-                } else {
728
-                    $req_type = EE_System::req_type_downgrade;
729
-                }
730
-                delete_option($activation_indicator_option_name);
731
-            } else {
732
-                // its not an update. maybe a reactivation?
733
-                if (get_option($activation_indicator_option_name, false)) {
734
-                    if ($version_is_higher === -1) {
735
-                        $req_type = EE_System::req_type_downgrade;
736
-                    } elseif ($version_is_higher === 0) {
737
-                        //we've seen this version before, but it's an activation. must be a reactivation
738
-                        $req_type = EE_System::req_type_reactivation;
739
-                    } else {//$version_is_higher === 1
740
-                        $req_type = EE_System::req_type_upgrade;
741
-                    }
742
-                    delete_option($activation_indicator_option_name);
743
-                } else {
744
-                    //we've seen this version before and the activation indicate doesn't show it was just activated
745
-                    if ($version_is_higher === -1) {
746
-                        $req_type = EE_System::req_type_downgrade;
747
-                    } elseif ($version_is_higher === 0) {
748
-                        //we've seen this version before and it's not an activation. its normal request
749
-                        $req_type = EE_System::req_type_normal;
750
-                    } else {//$version_is_higher === 1
751
-                        $req_type = EE_System::req_type_upgrade;
752
-                    }
753
-                }
754
-            }
755
-        } else {
756
-            //brand new install
757
-            $req_type = EE_System::req_type_new_activation;
758
-            delete_option($activation_indicator_option_name);
759
-        }
760
-        return $req_type;
761
-    }
762
-
763
-
764
-
765
-    /**
766
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
767
-     * the $activation_history_for_addon
768
-     *
769
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
770
-     *                                             sometimes containing 'unknown-date'
771
-     * @param string $version_to_upgrade_to        (current version)
772
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
773
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
774
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
775
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
776
-     */
777
-    private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
778
-    {
779
-        //find the most recently-activated version
780
-        $most_recently_active_version =
781
-            EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
782
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
783
-    }
784
-
785
-
786
-
787
-    /**
788
-     * Gets the most recently active version listed in the activation history,
789
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
790
-     *
791
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
792
-     *                                   sometimes containing 'unknown-date'
793
-     * @return string
794
-     */
795
-    private static function _get_most_recently_active_version_from_activation_history($activation_history)
796
-    {
797
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
798
-        $most_recently_active_version            = '0.0.0.dev.000';
799
-        if (is_array($activation_history)) {
800
-            foreach ($activation_history as $version => $times_activated) {
801
-                //check there is a record of when this version was activated. Otherwise,
802
-                //mark it as unknown
803
-                if (! $times_activated) {
804
-                    $times_activated = array('unknown-date');
805
-                }
806
-                if (is_string($times_activated)) {
807
-                    $times_activated = array($times_activated);
808
-                }
809
-                foreach ($times_activated as $an_activation) {
810
-                    if ($an_activation !== 'unknown-date'
811
-                        && $an_activation
812
-                           > $most_recently_active_version_activation) {
813
-                        $most_recently_active_version            = $version;
814
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
815
-                            ? '1970-01-01 00:00:00'
816
-                            : $an_activation;
817
-                    }
818
-                }
819
-            }
820
-        }
821
-        return $most_recently_active_version;
822
-    }
823
-
824
-
825
-
826
-    /**
827
-     * This redirects to the about EE page after activation
828
-     *
829
-     * @return void
830
-     */
831
-    public function redirect_to_about_ee()
832
-    {
833
-        $notices = EE_Error::get_notices(false);
834
-        //if current user is an admin and it's not an ajax or rest request
835
-        if (
836
-            ! isset($notices['errors'])
837
-            && $this->request->isAdmin()
838
-            && apply_filters(
839
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
840
-                $this->capabilities->current_user_can('manage_options', 'espresso_about_default')
841
-            )
842
-        ) {
843
-            $query_params = array('page' => 'espresso_about');
844
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
845
-                $query_params['new_activation'] = true;
846
-            }
847
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
848
-                $query_params['reactivation'] = true;
849
-            }
850
-            $url = add_query_arg($query_params, admin_url('admin.php'));
851
-            wp_safe_redirect($url);
852
-            exit();
853
-        }
854
-    }
855
-
856
-
857
-
858
-    /**
859
-     * load_core_configuration
860
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
861
-     * which runs during the WP 'plugins_loaded' action at priority 5
862
-     *
863
-     * @return void
864
-     * @throws ReflectionException
865
-     */
866
-    public function load_core_configuration()
867
-    {
868
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
869
-        $this->loader->getShared('EE_Load_Textdomain');
870
-        //load textdomain
871
-        EE_Load_Textdomain::load_textdomain();
872
-        // load and setup EE_Config and EE_Network_Config
873
-        $config = $this->loader->getShared('EE_Config');
874
-        $this->loader->getShared('EE_Network_Config');
875
-        // setup autoloaders
876
-        // enable logging?
877
-        if ($config->admin->use_full_logging) {
878
-            $this->loader->getShared('EE_Log');
879
-        }
880
-        // check for activation errors
881
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
882
-        if ($activation_errors) {
883
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
884
-            update_option('ee_plugin_activation_errors', false);
885
-        }
886
-        // get model names
887
-        $this->_parse_model_names();
888
-        //load caf stuff a chance to play during the activation process too.
889
-        $this->_maybe_brew_regular();
890
-        // configure custom post type definitions
891
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
892
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
893
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
894
-    }
895
-
896
-
897
-
898
-    /**
899
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
900
-     *
901
-     * @return void
902
-     * @throws ReflectionException
903
-     */
904
-    private function _parse_model_names()
905
-    {
906
-        //get all the files in the EE_MODELS folder that end in .model.php
907
-        $models                 = glob(EE_MODELS . '*.model.php');
908
-        $model_names            = array();
909
-        $non_abstract_db_models = array();
910
-        foreach ($models as $model) {
911
-            // get model classname
912
-            $classname       = EEH_File::get_classname_from_filepath_with_standard_filename($model);
913
-            $short_name      = str_replace('EEM_', '', $classname);
914
-            $reflectionClass = new ReflectionClass($classname);
915
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
916
-                $non_abstract_db_models[ $short_name ] = $classname;
917
-            }
918
-            $model_names[ $short_name ] = $classname;
919
-        }
920
-        $this->registry->models                 = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
921
-        $this->registry->non_abstract_db_models = apply_filters(
922
-            'FHEE__EE_System__parse_implemented_model_names',
923
-            $non_abstract_db_models
924
-        );
925
-    }
926
-
927
-
928
-    /**
929
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
930
-     * that need to be setup before our EE_System launches.
931
-     *
932
-     * @return void
933
-     * @throws DomainException
934
-     * @throws InvalidArgumentException
935
-     * @throws InvalidDataTypeException
936
-     * @throws InvalidInterfaceException
937
-     * @throws InvalidClassException
938
-     * @throws InvalidFilePathException
939
-     */
940
-    private function _maybe_brew_regular()
941
-    {
942
-        /** @var Domain $domain */
943
-        $domain = DomainFactory::getShared(
944
-            new FullyQualifiedName(
945
-                'EventEspresso\core\domain\Domain'
946
-            ),
947
-            array(
948
-                new FilePath(EVENT_ESPRESSO_MAIN_FILE),
949
-                Version::fromString(espresso_version())
950
-            )
951
-        );
952
-        if ($domain->isCaffeinated()) {
953
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
954
-        }
955
-    }
956
-
957
-
958
-
959
-    /**
960
-     * register_shortcodes_modules_and_widgets
961
-     * generate lists of shortcodes and modules, then verify paths and classes
962
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
963
-     * which runs during the WP 'plugins_loaded' action at priority 7
964
-     *
965
-     * @access public
966
-     * @return void
967
-     * @throws Exception
968
-     */
969
-    public function register_shortcodes_modules_and_widgets()
970
-    {
971
-        try {
972
-            // load, register, and add shortcodes the new way
973
-            if ($this->request->isFrontend() || $this->request->isIframe()) {
974
-                $this->loader->getShared(
975
-                    'EventEspresso\core\services\shortcodes\ShortcodesManager',
976
-                    array(
977
-                        // and the old way, but we'll put it under control of the new system
978
-                        EE_Config::getLegacyShortcodesManager(),
979
-                    )
980
-                );
981
-            }
982
-            if (function_exists('register_block_type')) {
983
-                // or the even newer newer new way
984
-                if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAdmin()) {
985
-                    $this->loader->getShared(
986
-                        'EventEspresso\core\services\editor\BlockRegistrationManager'
987
-                    );
988
-                }
989
-            }
990
-        } catch (Exception $exception) {
991
-            new ExceptionStackTraceDisplay($exception);
992
-        }
993
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
994
-        // check for addons using old hook point
995
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
996
-            $this->_incompatible_addon_error();
997
-        }
998
-    }
999
-
1000
-
1001
-
1002
-    /**
1003
-     * _incompatible_addon_error
1004
-     *
1005
-     * @access public
1006
-     * @return void
1007
-     */
1008
-    private function _incompatible_addon_error()
1009
-    {
1010
-        // get array of classes hooking into here
1011
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
1012
-            'AHEE__EE_System__register_shortcodes_modules_and_addons'
1013
-        );
1014
-        if (! empty($class_names)) {
1015
-            $msg = __(
1016
-                'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
1017
-                'event_espresso'
1018
-            );
1019
-            $msg .= '<ul>';
1020
-            foreach ($class_names as $class_name) {
1021
-                $msg .= '<li><b>Event Espresso - ' . str_replace(
1022
-                        array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
1023
-                        $class_name
1024
-                    ) . '</b></li>';
1025
-            }
1026
-            $msg .= '</ul>';
1027
-            $msg .= __(
1028
-                'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1029
-                'event_espresso'
1030
-            );
1031
-            // save list of incompatible addons to wp-options for later use
1032
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
1033
-            if (is_admin()) {
1034
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1035
-            }
1036
-        }
1037
-    }
1038
-
1039
-
1040
-
1041
-    /**
1042
-     * brew_espresso
1043
-     * begins the process of setting hooks for initializing EE in the correct order
1044
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1045
-     * which runs during the WP 'plugins_loaded' action at priority 9
1046
-     *
1047
-     * @return void
1048
-     */
1049
-    public function brew_espresso()
1050
-    {
1051
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
1052
-        // load some final core systems
1053
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
1054
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1055
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
1056
-        add_action('init', array($this, 'load_controllers'), 7);
1057
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
1058
-        add_action('init', array($this, 'initialize'), 10);
1059
-        add_action('init', array($this, 'initialize_last'), 100);
1060
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1061
-            // pew pew pew
1062
-            $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1063
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1064
-        }
1065
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
1066
-    }
1067
-
1068
-
1069
-
1070
-    /**
1071
-     *    set_hooks_for_core
1072
-     *
1073
-     * @access public
1074
-     * @return    void
1075
-     * @throws EE_Error
1076
-     */
1077
-    public function set_hooks_for_core()
1078
-    {
1079
-        $this->_deactivate_incompatible_addons();
1080
-        do_action('AHEE__EE_System__set_hooks_for_core');
1081
-        $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1082
-        //caps need to be initialized on every request so that capability maps are set.
1083
-        //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1084
-        $this->registry->CAP->init_caps();
1085
-    }
1086
-
1087
-
1088
-
1089
-    /**
1090
-     * Using the information gathered in EE_System::_incompatible_addon_error,
1091
-     * deactivates any addons considered incompatible with the current version of EE
1092
-     */
1093
-    private function _deactivate_incompatible_addons()
1094
-    {
1095
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
1096
-        if (! empty($incompatible_addons)) {
1097
-            $active_plugins = get_option('active_plugins', array());
1098
-            foreach ($active_plugins as $active_plugin) {
1099
-                foreach ($incompatible_addons as $incompatible_addon) {
1100
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
1101
-                        unset($_GET['activate']);
1102
-                        espresso_deactivate_plugin($active_plugin);
1103
-                    }
1104
-                }
1105
-            }
1106
-        }
1107
-    }
1108
-
1109
-
1110
-
1111
-    /**
1112
-     *    perform_activations_upgrades_and_migrations
1113
-     *
1114
-     * @access public
1115
-     * @return    void
1116
-     */
1117
-    public function perform_activations_upgrades_and_migrations()
1118
-    {
1119
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1120
-    }
1121
-
1122
-
1123
-    /**
1124
-     * @return void
1125
-     * @throws DomainException
1126
-     */
1127
-    public function load_CPTs_and_session()
1128
-    {
1129
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
1130
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1131
-        $register_custom_taxonomies = $this->loader->getShared(
1132
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1133
-        );
1134
-        $register_custom_taxonomies->registerCustomTaxonomies();
1135
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1136
-        $register_custom_post_types = $this->loader->getShared(
1137
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1138
-        );
1139
-        $register_custom_post_types->registerCustomPostTypes();
1140
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1141
-        $register_custom_taxonomy_terms = $this->loader->getShared(
1142
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1143
-        );
1144
-        $register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1145
-        // load legacy Custom Post Types and Taxonomies
1146
-        $this->loader->getShared('EE_Register_CPTs');
1147
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1148
-    }
1149
-
1150
-
1151
-
1152
-    /**
1153
-     * load_controllers
1154
-     * this is the best place to load any additional controllers that needs access to EE core.
1155
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1156
-     * time
1157
-     *
1158
-     * @access public
1159
-     * @return void
1160
-     */
1161
-    public function load_controllers()
1162
-    {
1163
-        do_action('AHEE__EE_System__load_controllers__start');
1164
-        // let's get it started
1165
-        if (
1166
-            ! $this->maintenance_mode->level()
1167
-            && ($this->request->isFrontend() || $this->request->isFrontAjax())
1168
-        ) {
1169
-            do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1170
-            $this->loader->getShared('EE_Front_Controller');
1171
-        } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1172
-            do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1173
-            $this->loader->getShared('EE_Admin');
1174
-        }
1175
-        do_action('AHEE__EE_System__load_controllers__complete');
1176
-    }
1177
-
1178
-
1179
-
1180
-    /**
1181
-     * core_loaded_and_ready
1182
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1183
-     *
1184
-     * @access public
1185
-     * @return void
1186
-     */
1187
-    public function core_loaded_and_ready()
1188
-    {
1189
-        if (
1190
-            $this->request->isAdmin()
1191
-            || $this->request->isEeAjax()
1192
-            || $this->request->isFrontend()
1193
-        ) {
1194
-            $this->loader->getShared('EE_Session');
1195
-        }
1196
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1197
-        // load_espresso_template_tags
1198
-        if (
1199
-            is_readable(EE_PUBLIC . 'template_tags.php')
1200
-            && (
1201
-                $this->request->isFrontend()
1202
-                || $this->request->isAdmin()
1203
-                || $this->request->isIframe()
1204
-                || $this->request->isFeed()
1205
-            )
1206
-        ) {
1207
-            require_once EE_PUBLIC . 'template_tags.php';
1208
-        }
1209
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1210
-        if ($this->request->isAdmin() || $this->request->isFrontend() || $this->request->isIframe()) {
1211
-            $this->loader->getShared('EventEspresso\core\services\assets\Registry');
1212
-        }
1213
-    }
1214
-
1215
-
1216
-
1217
-    /**
1218
-     * initialize
1219
-     * this is the best place to begin initializing client code
1220
-     *
1221
-     * @access public
1222
-     * @return void
1223
-     */
1224
-    public function initialize()
1225
-    {
1226
-        do_action('AHEE__EE_System__initialize');
1227
-    }
1228
-
1229
-
1230
-
1231
-    /**
1232
-     * initialize_last
1233
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1234
-     * initialize has done so
1235
-     *
1236
-     * @access public
1237
-     * @return void
1238
-     */
1239
-    public function initialize_last()
1240
-    {
1241
-        do_action('AHEE__EE_System__initialize_last');
1242
-        /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1243
-        $rewrite_rules = $this->loader->getShared(
1244
-            'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1245
-        );
1246
-        $rewrite_rules->flushRewriteRules();
1247
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1248
-    }
1249
-
1250
-
1251
-
1252
-    /**
1253
-     * @return void
1254
-     * @throws EE_Error
1255
-     */
1256
-    public function addEspressoToolbar()
1257
-    {
1258
-        $this->loader->getShared(
1259
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1260
-            array($this->registry->CAP)
1261
-        );
1262
-    }
1263
-
1264
-
1265
-
1266
-    /**
1267
-     * do_not_cache
1268
-     * sets no cache headers and defines no cache constants for WP plugins
1269
-     *
1270
-     * @access public
1271
-     * @return void
1272
-     */
1273
-    public static function do_not_cache()
1274
-    {
1275
-        // set no cache constants
1276
-        if (! defined('DONOTCACHEPAGE')) {
1277
-            define('DONOTCACHEPAGE', true);
1278
-        }
1279
-        if (! defined('DONOTCACHCEOBJECT')) {
1280
-            define('DONOTCACHCEOBJECT', true);
1281
-        }
1282
-        if (! defined('DONOTCACHEDB')) {
1283
-            define('DONOTCACHEDB', true);
1284
-        }
1285
-        // add no cache headers
1286
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1287
-        // plus a little extra for nginx and Google Chrome
1288
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1289
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1290
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1291
-    }
1292
-
1293
-
1294
-
1295
-    /**
1296
-     *    extra_nocache_headers
1297
-     *
1298
-     * @access    public
1299
-     * @param $headers
1300
-     * @return    array
1301
-     */
1302
-    public static function extra_nocache_headers($headers)
1303
-    {
1304
-        // for NGINX
1305
-        $headers['X-Accel-Expires'] = 0;
1306
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1307
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1308
-        return $headers;
1309
-    }
1310
-
1311
-
1312
-
1313
-    /**
1314
-     *    nocache_headers
1315
-     *
1316
-     * @access    public
1317
-     * @return    void
1318
-     */
1319
-    public static function nocache_headers()
1320
-    {
1321
-        nocache_headers();
1322
-    }
1323
-
1324
-
1325
-
1326
-    /**
1327
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1328
-     * never returned with the function.
1329
-     *
1330
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1331
-     * @return array
1332
-     */
1333
-    public function remove_pages_from_wp_list_pages($exclude_array)
1334
-    {
1335
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1336
-    }
35
+	/**
36
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
37
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
38
+	 */
39
+	const req_type_normal = 0;
40
+
41
+	/**
42
+	 * Indicates this is a brand new installation of EE so we should install
43
+	 * tables and default data etc
44
+	 */
45
+	const req_type_new_activation = 1;
46
+
47
+	/**
48
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
49
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
50
+	 * and that default data is setup too
51
+	 */
52
+	const req_type_reactivation = 2;
53
+
54
+	/**
55
+	 * indicates that EE has been upgraded since its previous request.
56
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
57
+	 */
58
+	const req_type_upgrade = 3;
59
+
60
+	/**
61
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
62
+	 */
63
+	const req_type_downgrade = 4;
64
+
65
+	/**
66
+	 * @deprecated since version 4.6.0.dev.006
67
+	 * Now whenever a new_activation is detected the request type is still just
68
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
69
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
70
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
71
+	 * (Specifically, when the migration manager indicates migrations are finished
72
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
73
+	 */
74
+	const req_type_activation_but_not_installed = 5;
75
+
76
+	/**
77
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
78
+	 */
79
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
80
+
81
+
82
+	/**
83
+	 * @var EE_System $_instance
84
+	 */
85
+	private static $_instance;
86
+
87
+	/**
88
+	 * @var EE_Registry $registry
89
+	 */
90
+	private $registry;
91
+
92
+	/**
93
+	 * @var LoaderInterface $loader
94
+	 */
95
+	private $loader;
96
+
97
+	/**
98
+	 * @var EE_Capabilities $capabilities
99
+	 */
100
+	private $capabilities;
101
+
102
+	/**
103
+	 * @var RequestInterface $request
104
+	 */
105
+	private $request;
106
+
107
+	/**
108
+	 * @var EE_Maintenance_Mode $maintenance_mode
109
+	 */
110
+	private $maintenance_mode;
111
+
112
+	/**
113
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
114
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
115
+	 *
116
+	 * @var int $_req_type
117
+	 */
118
+	private $_req_type;
119
+
120
+	/**
121
+	 * Whether or not there was a non-micro version change in EE core version during this request
122
+	 *
123
+	 * @var boolean $_major_version_change
124
+	 */
125
+	private $_major_version_change = false;
126
+
127
+	/**
128
+	 * A Context DTO dedicated solely to identifying the current request type.
129
+	 *
130
+	 * @var RequestTypeContextCheckerInterface $request_type
131
+	 */
132
+	private $request_type;
133
+
134
+
135
+
136
+	/**
137
+	 * @singleton method used to instantiate class object
138
+	 * @param EE_Registry|null         $registry
139
+	 * @param LoaderInterface|null     $loader
140
+	 * @param RequestInterface|null          $request
141
+	 * @param EE_Maintenance_Mode|null $maintenance_mode
142
+	 * @return EE_System
143
+	 */
144
+	public static function instance(
145
+		EE_Registry $registry = null,
146
+		LoaderInterface $loader = null,
147
+		RequestInterface $request = null,
148
+		EE_Maintenance_Mode $maintenance_mode = null
149
+	) {
150
+		// check if class object is instantiated
151
+		if (! self::$_instance instanceof EE_System) {
152
+			self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
153
+		}
154
+		return self::$_instance;
155
+	}
156
+
157
+
158
+
159
+	/**
160
+	 * resets the instance and returns it
161
+	 *
162
+	 * @return EE_System
163
+	 */
164
+	public static function reset()
165
+	{
166
+		self::$_instance->_req_type = null;
167
+		//make sure none of the old hooks are left hanging around
168
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
169
+		//we need to reset the migration manager in order for it to detect DMSs properly
170
+		EE_Data_Migration_Manager::reset();
171
+		self::instance()->detect_activations_or_upgrades();
172
+		self::instance()->perform_activations_upgrades_and_migrations();
173
+		return self::instance();
174
+	}
175
+
176
+
177
+
178
+	/**
179
+	 * sets hooks for running rest of system
180
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
181
+	 * starting EE Addons from any other point may lead to problems
182
+	 *
183
+	 * @param EE_Registry         $registry
184
+	 * @param LoaderInterface     $loader
185
+	 * @param RequestInterface          $request
186
+	 * @param EE_Maintenance_Mode $maintenance_mode
187
+	 */
188
+	private function __construct(
189
+		EE_Registry $registry,
190
+		LoaderInterface $loader,
191
+		RequestInterface $request,
192
+		EE_Maintenance_Mode $maintenance_mode
193
+	) {
194
+		$this->registry         = $registry;
195
+		$this->loader           = $loader;
196
+		$this->request          = $request;
197
+		$this->maintenance_mode = $maintenance_mode;
198
+		do_action('AHEE__EE_System__construct__begin', $this);
199
+		add_action(
200
+			'AHEE__EE_Bootstrap__load_espresso_addons',
201
+			array($this, 'loadCapabilities'),
202
+			5
203
+		);
204
+		add_action(
205
+			'AHEE__EE_Bootstrap__load_espresso_addons',
206
+			array($this, 'loadCommandBus'),
207
+			7
208
+		);
209
+		add_action(
210
+			'AHEE__EE_Bootstrap__load_espresso_addons',
211
+			array($this, 'loadPluginApi'),
212
+			9
213
+		);
214
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
215
+		add_action(
216
+			'AHEE__EE_Bootstrap__load_espresso_addons',
217
+			array($this, 'load_espresso_addons')
218
+		);
219
+		// when an ee addon is activated, we want to call the core hook(s) again
220
+		// because the newly-activated addon didn't get a chance to run at all
221
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
222
+		// detect whether install or upgrade
223
+		add_action(
224
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
225
+			array($this, 'detect_activations_or_upgrades'),
226
+			3
227
+		);
228
+		// load EE_Config, EE_Textdomain, etc
229
+		add_action(
230
+			'AHEE__EE_Bootstrap__load_core_configuration',
231
+			array($this, 'load_core_configuration'),
232
+			5
233
+		);
234
+		// load EE_Config, EE_Textdomain, etc
235
+		add_action(
236
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
237
+			array($this, 'register_shortcodes_modules_and_widgets'),
238
+			7
239
+		);
240
+		// you wanna get going? I wanna get going... let's get going!
241
+		add_action(
242
+			'AHEE__EE_Bootstrap__brew_espresso',
243
+			array($this, 'brew_espresso'),
244
+			9
245
+		);
246
+		//other housekeeping
247
+		//exclude EE critical pages from wp_list_pages
248
+		add_filter(
249
+			'wp_list_pages_excludes',
250
+			array($this, 'remove_pages_from_wp_list_pages'),
251
+			10
252
+		);
253
+		// ALL EE Addons should use the following hook point to attach their initial setup too
254
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
255
+		do_action('AHEE__EE_System__construct__complete', $this);
256
+	}
257
+
258
+
259
+	/**
260
+	 * load and setup EE_Capabilities
261
+	 *
262
+	 * @return void
263
+	 * @throws EE_Error
264
+	 */
265
+	public function loadCapabilities()
266
+	{
267
+		$this->capabilities = $this->loader->getShared('EE_Capabilities');
268
+		add_action(
269
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
270
+			function ()
271
+			{
272
+				LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
273
+			}
274
+		);
275
+	}
276
+
277
+
278
+
279
+	/**
280
+	 * create and cache the CommandBus, and also add middleware
281
+	 * The CapChecker middleware requires the use of EE_Capabilities
282
+	 * which is why we need to load the CommandBus after Caps are set up
283
+	 *
284
+	 * @return void
285
+	 * @throws EE_Error
286
+	 */
287
+	public function loadCommandBus()
288
+	{
289
+		$this->loader->getShared(
290
+			'CommandBusInterface',
291
+			array(
292
+				null,
293
+				apply_filters(
294
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
295
+					array(
296
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
297
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
298
+					)
299
+				),
300
+			)
301
+		);
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * @return void
308
+	 * @throws EE_Error
309
+	 */
310
+	public function loadPluginApi()
311
+	{
312
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
313
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
314
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
315
+		$this->loader->getShared('EE_Request_Handler');
316
+	}
317
+
318
+
319
+	/**
320
+	 * @param string $addon_name
321
+	 * @param string $version_constant
322
+	 * @param string $min_version_required
323
+	 * @param string $load_callback
324
+	 * @param string $plugin_file_constant
325
+	 * @return void
326
+	 */
327
+	private function deactivateIncompatibleAddon(
328
+		$addon_name,
329
+		$version_constant,
330
+		$min_version_required,
331
+		$load_callback,
332
+		$plugin_file_constant
333
+	) {
334
+		if (! defined($version_constant)) {
335
+			return;
336
+		}
337
+		$addon_version = constant($version_constant);
338
+		if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
339
+			remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
340
+			if (! function_exists('deactivate_plugins')) {
341
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
342
+			}
343
+			deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
344
+			unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
345
+			EE_Error::add_error(
346
+				sprintf(
347
+					esc_html__(
348
+						'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
349
+						'event_espresso'
350
+					),
351
+					$addon_name,
352
+					$min_version_required
353
+				),
354
+				__FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
355
+			);
356
+			EE_Error::get_notices(false, true);
357
+		}
358
+	}
359
+
360
+
361
+	/**
362
+	 * load_espresso_addons
363
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
364
+	 * this is hooked into both:
365
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
366
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
367
+	 *    and the WP 'activate_plugin' hook point
368
+	 *
369
+	 * @access public
370
+	 * @return void
371
+	 */
372
+	public function load_espresso_addons()
373
+	{
374
+		$this->deactivateIncompatibleAddon(
375
+			'Wait Lists',
376
+			'EE_WAIT_LISTS_VERSION',
377
+			'1.0.0.beta.074',
378
+			'load_espresso_wait_lists',
379
+			'EE_WAIT_LISTS_PLUGIN_FILE'
380
+		);
381
+		$this->deactivateIncompatibleAddon(
382
+			'Automated Upcoming Event Notifications',
383
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
384
+			'1.0.0.beta.091',
385
+			'load_espresso_automated_upcoming_event_notification',
386
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
387
+		);
388
+		do_action('AHEE__EE_System__load_espresso_addons');
389
+		//if the WP API basic auth plugin isn't already loaded, load it now.
390
+		//We want it for mobile apps. Just include the entire plugin
391
+		//also, don't load the basic auth when a plugin is getting activated, because
392
+		//it could be the basic auth plugin, and it doesn't check if its methods are already defined
393
+		//and causes a fatal error
394
+		if (
395
+			$this->request->getRequestParam('activate') !== 'true'
396
+			&& ! function_exists('json_basic_auth_handler')
397
+			&& ! function_exists('json_basic_auth_error')
398
+			&& ! in_array(
399
+				$this->request->getRequestParam('action'),
400
+				array('activate', 'activate-selected'),
401
+				true
402
+			)
403
+		) {
404
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
405
+		}
406
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
407
+	}
408
+
409
+
410
+
411
+	/**
412
+	 * detect_activations_or_upgrades
413
+	 * Checks for activation or upgrade of core first;
414
+	 * then also checks if any registered addons have been activated or upgraded
415
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
416
+	 * which runs during the WP 'plugins_loaded' action at priority 3
417
+	 *
418
+	 * @access public
419
+	 * @return void
420
+	 */
421
+	public function detect_activations_or_upgrades()
422
+	{
423
+		//first off: let's make sure to handle core
424
+		$this->detect_if_activation_or_upgrade();
425
+		foreach ($this->registry->addons as $addon) {
426
+			if ($addon instanceof EE_Addon) {
427
+				//detect teh request type for that addon
428
+				$addon->detect_activation_or_upgrade();
429
+			}
430
+		}
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * detect_if_activation_or_upgrade
437
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
438
+	 * and either setting up the DB or setting up maintenance mode etc.
439
+	 *
440
+	 * @access public
441
+	 * @return void
442
+	 */
443
+	public function detect_if_activation_or_upgrade()
444
+	{
445
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
446
+		// check if db has been updated, or if its a brand-new installation
447
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
448
+		$request_type       = $this->detect_req_type($espresso_db_update);
449
+		//EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
450
+		switch ($request_type) {
451
+			case EE_System::req_type_new_activation:
452
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
453
+				$this->_handle_core_version_change($espresso_db_update);
454
+				break;
455
+			case EE_System::req_type_reactivation:
456
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
457
+				$this->_handle_core_version_change($espresso_db_update);
458
+				break;
459
+			case EE_System::req_type_upgrade:
460
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
461
+				//migrations may be required now that we've upgraded
462
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
463
+				$this->_handle_core_version_change($espresso_db_update);
464
+				//				echo "done upgrade";die;
465
+				break;
466
+			case EE_System::req_type_downgrade:
467
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
468
+				//its possible migrations are no longer required
469
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
470
+				$this->_handle_core_version_change($espresso_db_update);
471
+				break;
472
+			case EE_System::req_type_normal:
473
+			default:
474
+				break;
475
+		}
476
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
477
+	}
478
+
479
+
480
+
481
+	/**
482
+	 * Updates the list of installed versions and sets hooks for
483
+	 * initializing the database later during the request
484
+	 *
485
+	 * @param array $espresso_db_update
486
+	 */
487
+	private function _handle_core_version_change($espresso_db_update)
488
+	{
489
+		$this->update_list_of_installed_versions($espresso_db_update);
490
+		//get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
491
+		add_action(
492
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
493
+			array($this, 'initialize_db_if_no_migrations_required')
494
+		);
495
+	}
496
+
497
+
498
+
499
+	/**
500
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
501
+	 * information about what versions of EE have been installed and activated,
502
+	 * NOT necessarily the state of the database
503
+	 *
504
+	 * @param mixed $espresso_db_update           the value of the WordPress option.
505
+	 *                                            If not supplied, fetches it from the options table
506
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
507
+	 */
508
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
509
+	{
510
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
511
+		if (! $espresso_db_update) {
512
+			$espresso_db_update = get_option('espresso_db_update');
513
+		}
514
+		// check that option is an array
515
+		if (! is_array($espresso_db_update)) {
516
+			// if option is FALSE, then it never existed
517
+			if ($espresso_db_update === false) {
518
+				// make $espresso_db_update an array and save option with autoload OFF
519
+				$espresso_db_update = array();
520
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
521
+			} else {
522
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
523
+				$espresso_db_update = array($espresso_db_update => array());
524
+				update_option('espresso_db_update', $espresso_db_update);
525
+			}
526
+		} else {
527
+			$corrected_db_update = array();
528
+			//if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
529
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
530
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
531
+					//the key is an int, and the value IS NOT an array
532
+					//so it must be numerically-indexed, where values are versions installed...
533
+					//fix it!
534
+					$version_string                         = $should_be_array;
535
+					$corrected_db_update[ $version_string ] = array('unknown-date');
536
+				} else {
537
+					//ok it checks out
538
+					$corrected_db_update[ $should_be_version_string ] = $should_be_array;
539
+				}
540
+			}
541
+			$espresso_db_update = $corrected_db_update;
542
+			update_option('espresso_db_update', $espresso_db_update);
543
+		}
544
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
545
+		return $espresso_db_update;
546
+	}
547
+
548
+
549
+
550
+	/**
551
+	 * Does the traditional work of setting up the plugin's database and adding default data.
552
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
553
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
554
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
555
+	 * so that it will be done when migrations are finished
556
+	 *
557
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
558
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
559
+	 *                                       This is a resource-intensive job
560
+	 *                                       so we prefer to only do it when necessary
561
+	 * @return void
562
+	 * @throws EE_Error
563
+	 */
564
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
565
+	{
566
+		$request_type = $this->detect_req_type();
567
+		//only initialize system if we're not in maintenance mode.
568
+		if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
569
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
570
+			$rewrite_rules = $this->loader->getShared(
571
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
572
+			);
573
+			$rewrite_rules->flush();
574
+			if ($verify_schema) {
575
+				EEH_Activation::initialize_db_and_folders();
576
+			}
577
+			EEH_Activation::initialize_db_content();
578
+			EEH_Activation::system_initialization();
579
+			if ($initialize_addons_too) {
580
+				$this->initialize_addons();
581
+			}
582
+		} else {
583
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
584
+		}
585
+		if ($request_type === EE_System::req_type_new_activation
586
+			|| $request_type === EE_System::req_type_reactivation
587
+			|| (
588
+				$request_type === EE_System::req_type_upgrade
589
+				&& $this->is_major_version_change()
590
+			)
591
+		) {
592
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
593
+		}
594
+	}
595
+
596
+
597
+
598
+	/**
599
+	 * Initializes the db for all registered addons
600
+	 *
601
+	 * @throws EE_Error
602
+	 */
603
+	public function initialize_addons()
604
+	{
605
+		//foreach registered addon, make sure its db is up-to-date too
606
+		foreach ($this->registry->addons as $addon) {
607
+			if ($addon instanceof EE_Addon) {
608
+				$addon->initialize_db_if_no_migrations_required();
609
+			}
610
+		}
611
+	}
612
+
613
+
614
+
615
+	/**
616
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
617
+	 *
618
+	 * @param    array  $version_history
619
+	 * @param    string $current_version_to_add version to be added to the version history
620
+	 * @return    boolean success as to whether or not this option was changed
621
+	 */
622
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
623
+	{
624
+		if (! $version_history) {
625
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
626
+		}
627
+		if ($current_version_to_add === null) {
628
+			$current_version_to_add = espresso_version();
629
+		}
630
+		$version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
631
+		// re-save
632
+		return update_option('espresso_db_update', $version_history);
633
+	}
634
+
635
+
636
+
637
+	/**
638
+	 * Detects if the current version indicated in the has existed in the list of
639
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
640
+	 *
641
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
642
+	 *                                  If not supplied, fetches it from the options table.
643
+	 *                                  Also, caches its result so later parts of the code can also know whether
644
+	 *                                  there's been an update or not. This way we can add the current version to
645
+	 *                                  espresso_db_update, but still know if this is a new install or not
646
+	 * @return int one of the constants on EE_System::req_type_
647
+	 */
648
+	public function detect_req_type($espresso_db_update = null)
649
+	{
650
+		if ($this->_req_type === null) {
651
+			$espresso_db_update          = ! empty($espresso_db_update)
652
+				? $espresso_db_update
653
+				: $this->fix_espresso_db_upgrade_option();
654
+			$this->_req_type             = EE_System::detect_req_type_given_activation_history(
655
+				$espresso_db_update,
656
+				'ee_espresso_activation', espresso_version()
657
+			);
658
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
659
+			$this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
660
+		}
661
+		return $this->_req_type;
662
+	}
663
+
664
+
665
+
666
+	/**
667
+	 * Returns whether or not there was a non-micro version change (ie, change in either
668
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
669
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
670
+	 *
671
+	 * @param $activation_history
672
+	 * @return bool
673
+	 */
674
+	private function _detect_major_version_change($activation_history)
675
+	{
676
+		$previous_version       = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
677
+		$previous_version_parts = explode('.', $previous_version);
678
+		$current_version_parts  = explode('.', espresso_version());
679
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
680
+			   && ($previous_version_parts[0] !== $current_version_parts[0]
681
+				   || $previous_version_parts[1] !== $current_version_parts[1]
682
+			   );
683
+	}
684
+
685
+
686
+
687
+	/**
688
+	 * Returns true if either the major or minor version of EE changed during this request.
689
+	 * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
690
+	 *
691
+	 * @return bool
692
+	 */
693
+	public function is_major_version_change()
694
+	{
695
+		return $this->_major_version_change;
696
+	}
697
+
698
+
699
+
700
+	/**
701
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
702
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
703
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
704
+	 * just activated to (for core that will always be espresso_version())
705
+	 *
706
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
707
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
708
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
709
+	 *                                                 indicate that this plugin was just activated
710
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
711
+	 *                                                 espresso_version())
712
+	 * @return int one of the constants on EE_System::req_type_*
713
+	 */
714
+	public static function detect_req_type_given_activation_history(
715
+		$activation_history_for_addon,
716
+		$activation_indicator_option_name,
717
+		$version_to_upgrade_to
718
+	) {
719
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
720
+		if ($activation_history_for_addon) {
721
+			//it exists, so this isn't a completely new install
722
+			//check if this version already in that list of previously installed versions
723
+			if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
724
+				//it a version we haven't seen before
725
+				if ($version_is_higher === 1) {
726
+					$req_type = EE_System::req_type_upgrade;
727
+				} else {
728
+					$req_type = EE_System::req_type_downgrade;
729
+				}
730
+				delete_option($activation_indicator_option_name);
731
+			} else {
732
+				// its not an update. maybe a reactivation?
733
+				if (get_option($activation_indicator_option_name, false)) {
734
+					if ($version_is_higher === -1) {
735
+						$req_type = EE_System::req_type_downgrade;
736
+					} elseif ($version_is_higher === 0) {
737
+						//we've seen this version before, but it's an activation. must be a reactivation
738
+						$req_type = EE_System::req_type_reactivation;
739
+					} else {//$version_is_higher === 1
740
+						$req_type = EE_System::req_type_upgrade;
741
+					}
742
+					delete_option($activation_indicator_option_name);
743
+				} else {
744
+					//we've seen this version before and the activation indicate doesn't show it was just activated
745
+					if ($version_is_higher === -1) {
746
+						$req_type = EE_System::req_type_downgrade;
747
+					} elseif ($version_is_higher === 0) {
748
+						//we've seen this version before and it's not an activation. its normal request
749
+						$req_type = EE_System::req_type_normal;
750
+					} else {//$version_is_higher === 1
751
+						$req_type = EE_System::req_type_upgrade;
752
+					}
753
+				}
754
+			}
755
+		} else {
756
+			//brand new install
757
+			$req_type = EE_System::req_type_new_activation;
758
+			delete_option($activation_indicator_option_name);
759
+		}
760
+		return $req_type;
761
+	}
762
+
763
+
764
+
765
+	/**
766
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
767
+	 * the $activation_history_for_addon
768
+	 *
769
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
770
+	 *                                             sometimes containing 'unknown-date'
771
+	 * @param string $version_to_upgrade_to        (current version)
772
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
773
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
774
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
775
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
776
+	 */
777
+	private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
778
+	{
779
+		//find the most recently-activated version
780
+		$most_recently_active_version =
781
+			EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
782
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
783
+	}
784
+
785
+
786
+
787
+	/**
788
+	 * Gets the most recently active version listed in the activation history,
789
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
790
+	 *
791
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
792
+	 *                                   sometimes containing 'unknown-date'
793
+	 * @return string
794
+	 */
795
+	private static function _get_most_recently_active_version_from_activation_history($activation_history)
796
+	{
797
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
798
+		$most_recently_active_version            = '0.0.0.dev.000';
799
+		if (is_array($activation_history)) {
800
+			foreach ($activation_history as $version => $times_activated) {
801
+				//check there is a record of when this version was activated. Otherwise,
802
+				//mark it as unknown
803
+				if (! $times_activated) {
804
+					$times_activated = array('unknown-date');
805
+				}
806
+				if (is_string($times_activated)) {
807
+					$times_activated = array($times_activated);
808
+				}
809
+				foreach ($times_activated as $an_activation) {
810
+					if ($an_activation !== 'unknown-date'
811
+						&& $an_activation
812
+						   > $most_recently_active_version_activation) {
813
+						$most_recently_active_version            = $version;
814
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
815
+							? '1970-01-01 00:00:00'
816
+							: $an_activation;
817
+					}
818
+				}
819
+			}
820
+		}
821
+		return $most_recently_active_version;
822
+	}
823
+
824
+
825
+
826
+	/**
827
+	 * This redirects to the about EE page after activation
828
+	 *
829
+	 * @return void
830
+	 */
831
+	public function redirect_to_about_ee()
832
+	{
833
+		$notices = EE_Error::get_notices(false);
834
+		//if current user is an admin and it's not an ajax or rest request
835
+		if (
836
+			! isset($notices['errors'])
837
+			&& $this->request->isAdmin()
838
+			&& apply_filters(
839
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
840
+				$this->capabilities->current_user_can('manage_options', 'espresso_about_default')
841
+			)
842
+		) {
843
+			$query_params = array('page' => 'espresso_about');
844
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
845
+				$query_params['new_activation'] = true;
846
+			}
847
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
848
+				$query_params['reactivation'] = true;
849
+			}
850
+			$url = add_query_arg($query_params, admin_url('admin.php'));
851
+			wp_safe_redirect($url);
852
+			exit();
853
+		}
854
+	}
855
+
856
+
857
+
858
+	/**
859
+	 * load_core_configuration
860
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
861
+	 * which runs during the WP 'plugins_loaded' action at priority 5
862
+	 *
863
+	 * @return void
864
+	 * @throws ReflectionException
865
+	 */
866
+	public function load_core_configuration()
867
+	{
868
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
869
+		$this->loader->getShared('EE_Load_Textdomain');
870
+		//load textdomain
871
+		EE_Load_Textdomain::load_textdomain();
872
+		// load and setup EE_Config and EE_Network_Config
873
+		$config = $this->loader->getShared('EE_Config');
874
+		$this->loader->getShared('EE_Network_Config');
875
+		// setup autoloaders
876
+		// enable logging?
877
+		if ($config->admin->use_full_logging) {
878
+			$this->loader->getShared('EE_Log');
879
+		}
880
+		// check for activation errors
881
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
882
+		if ($activation_errors) {
883
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
884
+			update_option('ee_plugin_activation_errors', false);
885
+		}
886
+		// get model names
887
+		$this->_parse_model_names();
888
+		//load caf stuff a chance to play during the activation process too.
889
+		$this->_maybe_brew_regular();
890
+		// configure custom post type definitions
891
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
892
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
893
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
894
+	}
895
+
896
+
897
+
898
+	/**
899
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
900
+	 *
901
+	 * @return void
902
+	 * @throws ReflectionException
903
+	 */
904
+	private function _parse_model_names()
905
+	{
906
+		//get all the files in the EE_MODELS folder that end in .model.php
907
+		$models                 = glob(EE_MODELS . '*.model.php');
908
+		$model_names            = array();
909
+		$non_abstract_db_models = array();
910
+		foreach ($models as $model) {
911
+			// get model classname
912
+			$classname       = EEH_File::get_classname_from_filepath_with_standard_filename($model);
913
+			$short_name      = str_replace('EEM_', '', $classname);
914
+			$reflectionClass = new ReflectionClass($classname);
915
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
916
+				$non_abstract_db_models[ $short_name ] = $classname;
917
+			}
918
+			$model_names[ $short_name ] = $classname;
919
+		}
920
+		$this->registry->models                 = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
921
+		$this->registry->non_abstract_db_models = apply_filters(
922
+			'FHEE__EE_System__parse_implemented_model_names',
923
+			$non_abstract_db_models
924
+		);
925
+	}
926
+
927
+
928
+	/**
929
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
930
+	 * that need to be setup before our EE_System launches.
931
+	 *
932
+	 * @return void
933
+	 * @throws DomainException
934
+	 * @throws InvalidArgumentException
935
+	 * @throws InvalidDataTypeException
936
+	 * @throws InvalidInterfaceException
937
+	 * @throws InvalidClassException
938
+	 * @throws InvalidFilePathException
939
+	 */
940
+	private function _maybe_brew_regular()
941
+	{
942
+		/** @var Domain $domain */
943
+		$domain = DomainFactory::getShared(
944
+			new FullyQualifiedName(
945
+				'EventEspresso\core\domain\Domain'
946
+			),
947
+			array(
948
+				new FilePath(EVENT_ESPRESSO_MAIN_FILE),
949
+				Version::fromString(espresso_version())
950
+			)
951
+		);
952
+		if ($domain->isCaffeinated()) {
953
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
954
+		}
955
+	}
956
+
957
+
958
+
959
+	/**
960
+	 * register_shortcodes_modules_and_widgets
961
+	 * generate lists of shortcodes and modules, then verify paths and classes
962
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
963
+	 * which runs during the WP 'plugins_loaded' action at priority 7
964
+	 *
965
+	 * @access public
966
+	 * @return void
967
+	 * @throws Exception
968
+	 */
969
+	public function register_shortcodes_modules_and_widgets()
970
+	{
971
+		try {
972
+			// load, register, and add shortcodes the new way
973
+			if ($this->request->isFrontend() || $this->request->isIframe()) {
974
+				$this->loader->getShared(
975
+					'EventEspresso\core\services\shortcodes\ShortcodesManager',
976
+					array(
977
+						// and the old way, but we'll put it under control of the new system
978
+						EE_Config::getLegacyShortcodesManager(),
979
+					)
980
+				);
981
+			}
982
+			if (function_exists('register_block_type')) {
983
+				// or the even newer newer new way
984
+				if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAdmin()) {
985
+					$this->loader->getShared(
986
+						'EventEspresso\core\services\editor\BlockRegistrationManager'
987
+					);
988
+				}
989
+			}
990
+		} catch (Exception $exception) {
991
+			new ExceptionStackTraceDisplay($exception);
992
+		}
993
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
994
+		// check for addons using old hook point
995
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
996
+			$this->_incompatible_addon_error();
997
+		}
998
+	}
999
+
1000
+
1001
+
1002
+	/**
1003
+	 * _incompatible_addon_error
1004
+	 *
1005
+	 * @access public
1006
+	 * @return void
1007
+	 */
1008
+	private function _incompatible_addon_error()
1009
+	{
1010
+		// get array of classes hooking into here
1011
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
1012
+			'AHEE__EE_System__register_shortcodes_modules_and_addons'
1013
+		);
1014
+		if (! empty($class_names)) {
1015
+			$msg = __(
1016
+				'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
1017
+				'event_espresso'
1018
+			);
1019
+			$msg .= '<ul>';
1020
+			foreach ($class_names as $class_name) {
1021
+				$msg .= '<li><b>Event Espresso - ' . str_replace(
1022
+						array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
1023
+						$class_name
1024
+					) . '</b></li>';
1025
+			}
1026
+			$msg .= '</ul>';
1027
+			$msg .= __(
1028
+				'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1029
+				'event_espresso'
1030
+			);
1031
+			// save list of incompatible addons to wp-options for later use
1032
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
1033
+			if (is_admin()) {
1034
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1035
+			}
1036
+		}
1037
+	}
1038
+
1039
+
1040
+
1041
+	/**
1042
+	 * brew_espresso
1043
+	 * begins the process of setting hooks for initializing EE in the correct order
1044
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1045
+	 * which runs during the WP 'plugins_loaded' action at priority 9
1046
+	 *
1047
+	 * @return void
1048
+	 */
1049
+	public function brew_espresso()
1050
+	{
1051
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
1052
+		// load some final core systems
1053
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
1054
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1055
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
1056
+		add_action('init', array($this, 'load_controllers'), 7);
1057
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
1058
+		add_action('init', array($this, 'initialize'), 10);
1059
+		add_action('init', array($this, 'initialize_last'), 100);
1060
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1061
+			// pew pew pew
1062
+			$this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1063
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1064
+		}
1065
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
1066
+	}
1067
+
1068
+
1069
+
1070
+	/**
1071
+	 *    set_hooks_for_core
1072
+	 *
1073
+	 * @access public
1074
+	 * @return    void
1075
+	 * @throws EE_Error
1076
+	 */
1077
+	public function set_hooks_for_core()
1078
+	{
1079
+		$this->_deactivate_incompatible_addons();
1080
+		do_action('AHEE__EE_System__set_hooks_for_core');
1081
+		$this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1082
+		//caps need to be initialized on every request so that capability maps are set.
1083
+		//@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1084
+		$this->registry->CAP->init_caps();
1085
+	}
1086
+
1087
+
1088
+
1089
+	/**
1090
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
1091
+	 * deactivates any addons considered incompatible with the current version of EE
1092
+	 */
1093
+	private function _deactivate_incompatible_addons()
1094
+	{
1095
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
1096
+		if (! empty($incompatible_addons)) {
1097
+			$active_plugins = get_option('active_plugins', array());
1098
+			foreach ($active_plugins as $active_plugin) {
1099
+				foreach ($incompatible_addons as $incompatible_addon) {
1100
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
1101
+						unset($_GET['activate']);
1102
+						espresso_deactivate_plugin($active_plugin);
1103
+					}
1104
+				}
1105
+			}
1106
+		}
1107
+	}
1108
+
1109
+
1110
+
1111
+	/**
1112
+	 *    perform_activations_upgrades_and_migrations
1113
+	 *
1114
+	 * @access public
1115
+	 * @return    void
1116
+	 */
1117
+	public function perform_activations_upgrades_and_migrations()
1118
+	{
1119
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1120
+	}
1121
+
1122
+
1123
+	/**
1124
+	 * @return void
1125
+	 * @throws DomainException
1126
+	 */
1127
+	public function load_CPTs_and_session()
1128
+	{
1129
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
1130
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1131
+		$register_custom_taxonomies = $this->loader->getShared(
1132
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1133
+		);
1134
+		$register_custom_taxonomies->registerCustomTaxonomies();
1135
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1136
+		$register_custom_post_types = $this->loader->getShared(
1137
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1138
+		);
1139
+		$register_custom_post_types->registerCustomPostTypes();
1140
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1141
+		$register_custom_taxonomy_terms = $this->loader->getShared(
1142
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1143
+		);
1144
+		$register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1145
+		// load legacy Custom Post Types and Taxonomies
1146
+		$this->loader->getShared('EE_Register_CPTs');
1147
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1148
+	}
1149
+
1150
+
1151
+
1152
+	/**
1153
+	 * load_controllers
1154
+	 * this is the best place to load any additional controllers that needs access to EE core.
1155
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1156
+	 * time
1157
+	 *
1158
+	 * @access public
1159
+	 * @return void
1160
+	 */
1161
+	public function load_controllers()
1162
+	{
1163
+		do_action('AHEE__EE_System__load_controllers__start');
1164
+		// let's get it started
1165
+		if (
1166
+			! $this->maintenance_mode->level()
1167
+			&& ($this->request->isFrontend() || $this->request->isFrontAjax())
1168
+		) {
1169
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1170
+			$this->loader->getShared('EE_Front_Controller');
1171
+		} elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1172
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1173
+			$this->loader->getShared('EE_Admin');
1174
+		}
1175
+		do_action('AHEE__EE_System__load_controllers__complete');
1176
+	}
1177
+
1178
+
1179
+
1180
+	/**
1181
+	 * core_loaded_and_ready
1182
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1183
+	 *
1184
+	 * @access public
1185
+	 * @return void
1186
+	 */
1187
+	public function core_loaded_and_ready()
1188
+	{
1189
+		if (
1190
+			$this->request->isAdmin()
1191
+			|| $this->request->isEeAjax()
1192
+			|| $this->request->isFrontend()
1193
+		) {
1194
+			$this->loader->getShared('EE_Session');
1195
+		}
1196
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1197
+		// load_espresso_template_tags
1198
+		if (
1199
+			is_readable(EE_PUBLIC . 'template_tags.php')
1200
+			&& (
1201
+				$this->request->isFrontend()
1202
+				|| $this->request->isAdmin()
1203
+				|| $this->request->isIframe()
1204
+				|| $this->request->isFeed()
1205
+			)
1206
+		) {
1207
+			require_once EE_PUBLIC . 'template_tags.php';
1208
+		}
1209
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1210
+		if ($this->request->isAdmin() || $this->request->isFrontend() || $this->request->isIframe()) {
1211
+			$this->loader->getShared('EventEspresso\core\services\assets\Registry');
1212
+		}
1213
+	}
1214
+
1215
+
1216
+
1217
+	/**
1218
+	 * initialize
1219
+	 * this is the best place to begin initializing client code
1220
+	 *
1221
+	 * @access public
1222
+	 * @return void
1223
+	 */
1224
+	public function initialize()
1225
+	{
1226
+		do_action('AHEE__EE_System__initialize');
1227
+	}
1228
+
1229
+
1230
+
1231
+	/**
1232
+	 * initialize_last
1233
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1234
+	 * initialize has done so
1235
+	 *
1236
+	 * @access public
1237
+	 * @return void
1238
+	 */
1239
+	public function initialize_last()
1240
+	{
1241
+		do_action('AHEE__EE_System__initialize_last');
1242
+		/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1243
+		$rewrite_rules = $this->loader->getShared(
1244
+			'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1245
+		);
1246
+		$rewrite_rules->flushRewriteRules();
1247
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1248
+	}
1249
+
1250
+
1251
+
1252
+	/**
1253
+	 * @return void
1254
+	 * @throws EE_Error
1255
+	 */
1256
+	public function addEspressoToolbar()
1257
+	{
1258
+		$this->loader->getShared(
1259
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1260
+			array($this->registry->CAP)
1261
+		);
1262
+	}
1263
+
1264
+
1265
+
1266
+	/**
1267
+	 * do_not_cache
1268
+	 * sets no cache headers and defines no cache constants for WP plugins
1269
+	 *
1270
+	 * @access public
1271
+	 * @return void
1272
+	 */
1273
+	public static function do_not_cache()
1274
+	{
1275
+		// set no cache constants
1276
+		if (! defined('DONOTCACHEPAGE')) {
1277
+			define('DONOTCACHEPAGE', true);
1278
+		}
1279
+		if (! defined('DONOTCACHCEOBJECT')) {
1280
+			define('DONOTCACHCEOBJECT', true);
1281
+		}
1282
+		if (! defined('DONOTCACHEDB')) {
1283
+			define('DONOTCACHEDB', true);
1284
+		}
1285
+		// add no cache headers
1286
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1287
+		// plus a little extra for nginx and Google Chrome
1288
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1289
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1290
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1291
+	}
1292
+
1293
+
1294
+
1295
+	/**
1296
+	 *    extra_nocache_headers
1297
+	 *
1298
+	 * @access    public
1299
+	 * @param $headers
1300
+	 * @return    array
1301
+	 */
1302
+	public static function extra_nocache_headers($headers)
1303
+	{
1304
+		// for NGINX
1305
+		$headers['X-Accel-Expires'] = 0;
1306
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1307
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1308
+		return $headers;
1309
+	}
1310
+
1311
+
1312
+
1313
+	/**
1314
+	 *    nocache_headers
1315
+	 *
1316
+	 * @access    public
1317
+	 * @return    void
1318
+	 */
1319
+	public static function nocache_headers()
1320
+	{
1321
+		nocache_headers();
1322
+	}
1323
+
1324
+
1325
+
1326
+	/**
1327
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1328
+	 * never returned with the function.
1329
+	 *
1330
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1331
+	 * @return array
1332
+	 */
1333
+	public function remove_pages_from_wp_list_pages($exclude_array)
1334
+	{
1335
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1336
+	}
1337 1337
 
1338 1338
 
1339 1339
 
Please login to merge, or discard this patch.
core/services/assets/AssetRegisterCollection.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,55 +20,55 @@
 block discarded – undo
20 20
 class AssetRegisterCollection extends Collection
21 21
 {
22 22
 
23
-    /**
24
-     * Collection constructor
25
-     *
26
-     * @throws InvalidInterfaceException
27
-     */
28
-    public function __construct()
29
-    {
30
-        parent::__construct('EventEspresso\core\services\assets\AssetRegisterInterface');
31
-    }
23
+	/**
24
+	 * Collection constructor
25
+	 *
26
+	 * @throws InvalidInterfaceException
27
+	 */
28
+	public function __construct()
29
+	{
30
+		parent::__construct('EventEspresso\core\services\assets\AssetRegisterInterface');
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * @return  void
36
-     */
37
-    public function registerManifestFile()
38
-    {
39
-        $this->rewind();
40
-        while ($this->valid()) {
41
-            $this->current()->registerManifestFile();
42
-            $this->next();
43
-        }
44
-        $this->rewind();
45
-    }
34
+	/**
35
+	 * @return  void
36
+	 */
37
+	public function registerManifestFile()
38
+	{
39
+		$this->rewind();
40
+		while ($this->valid()) {
41
+			$this->current()->registerManifestFile();
42
+			$this->next();
43
+		}
44
+		$this->rewind();
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * @return  void
50
-     */
51
-    public function registerScripts()
52
-    {
53
-        $this->rewind();
54
-        while ($this->valid()) {
55
-            $this->current()->registerScripts();
56
-            $this->next();
57
-        }
58
-        $this->rewind();
59
-    }
48
+	/**
49
+	 * @return  void
50
+	 */
51
+	public function registerScripts()
52
+	{
53
+		$this->rewind();
54
+		while ($this->valid()) {
55
+			$this->current()->registerScripts();
56
+			$this->next();
57
+		}
58
+		$this->rewind();
59
+	}
60 60
 
61 61
 
62
-    /**
63
-     * @return void
64
-     */
65
-    public function registerStyles()
66
-    {
67
-        $this->rewind();
68
-        while ($this->valid()) {
69
-            $this->current()->registerStyles();
70
-            $this->next();
71
-        }
72
-        $this->rewind();
73
-    }
62
+	/**
63
+	 * @return void
64
+	 */
65
+	public function registerStyles()
66
+	{
67
+		$this->rewind();
68
+		while ($this->valid()) {
69
+			$this->current()->registerStyles();
70
+			$this->next();
71
+		}
72
+		$this->rewind();
73
+	}
74 74
 }
75 75
\ No newline at end of file
Please login to merge, or discard this patch.