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