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