Completed
Pull Request — master (#296)
by Darren
13:53
created
core/domain/services/admin/ExitModal.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -18,68 +18,68 @@
 block discarded – undo
18 18
 class ExitModal
19 19
 {
20 20
 
21
-    /**
22
-     * @var Registry
23
-     */
24
-    private $assets_registry;
21
+	/**
22
+	 * @var Registry
23
+	 */
24
+	private $assets_registry;
25 25
 
26
-    /**
27
-     * ExitModal constructor.
28
-     *
29
-     * @param Registry $assets_registry
30
-     */
31
-    public function __construct(Registry $assets_registry)
32
-    {
33
-        $this->assets_registry = $assets_registry;
34
-        add_action('in_admin_footer', array($this, 'modalContainer'));
35
-        add_action('admin_enqueue_scripts', array($this, 'enqueues'));
36
-    }
26
+	/**
27
+	 * ExitModal constructor.
28
+	 *
29
+	 * @param Registry $assets_registry
30
+	 */
31
+	public function __construct(Registry $assets_registry)
32
+	{
33
+		$this->assets_registry = $assets_registry;
34
+		add_action('in_admin_footer', array($this, 'modalContainer'));
35
+		add_action('admin_enqueue_scripts', array($this, 'enqueues'));
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Callback on in_admin_footer that is used to output the exit modal container.
41
-     */
42
-    public function modalContainer()
43
-    {
44
-        echo '<div id="ee-exit-survey-modal"></div>';
45
-    }
39
+	/**
40
+	 * Callback on in_admin_footer that is used to output the exit modal container.
41
+	 */
42
+	public function modalContainer()
43
+	{
44
+		echo '<div id="ee-exit-survey-modal"></div>';
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal.
50
-     *
51
-     * @throws InvalidArgumentException
52
-     */
53
-    public function enqueues()
54
-    {
55
-        $current_user = new WP_User(get_current_user_id());
56
-        $this->assets_registry->addData(
57
-            'exitModalInfo',
58
-            array(
59
-                'firstname' => htmlspecialchars($current_user->user_firstname),
60
-                'emailaddress' => htmlspecialchars($current_user->user_email),
61
-                'website' => htmlspecialchars(site_url()),
62
-                'isModalActive' => $this->isModalActive()
63
-            )
64
-        );
48
+	/**
49
+	 * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal.
50
+	 *
51
+	 * @throws InvalidArgumentException
52
+	 */
53
+	public function enqueues()
54
+	{
55
+		$current_user = new WP_User(get_current_user_id());
56
+		$this->assets_registry->addData(
57
+			'exitModalInfo',
58
+			array(
59
+				'firstname' => htmlspecialchars($current_user->user_firstname),
60
+				'emailaddress' => htmlspecialchars($current_user->user_email),
61
+				'website' => htmlspecialchars(site_url()),
62
+				'isModalActive' => $this->isModalActive()
63
+			)
64
+		);
65 65
 
66
-        wp_enqueue_script('ee-wp-plugins-page');
67
-        wp_enqueue_style('ee-wp-plugins-page');
68
-    }
66
+		wp_enqueue_script('ee-wp-plugins-page');
67
+		wp_enqueue_style('ee-wp-plugins-page');
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * Exposes a filter switch for turning off the enqueueing of the modal script.
73
-     * @return bool
74
-     */
75
-    private function isModalActive()
76
-    {
77
-        return filter_var(
78
-            apply_filters(
79
-                'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive',
80
-                true
81
-            ),
82
-            FILTER_VALIDATE_BOOLEAN
83
-        );
84
-    }
71
+	/**
72
+	 * Exposes a filter switch for turning off the enqueueing of the modal script.
73
+	 * @return bool
74
+	 */
75
+	private function isModalActive()
76
+	{
77
+		return filter_var(
78
+			apply_filters(
79
+				'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive',
80
+				true
81
+			),
82
+			FILTER_VALIDATE_BOOLEAN
83
+		);
84
+	}
85 85
 }
86 86
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +889 added lines, -889 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10 10
 if (! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -25,895 +25,895 @@  discard block
 block discarded – undo
25 25
 class EE_Dependency_Map
26 26
 {
27 27
 
28
-    /**
29
-     * This means that the requested class dependency is not present in the dependency map
30
-     */
31
-    const not_registered = 0;
32
-
33
-    /**
34
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
-     */
36
-    const load_new_object = 1;
37
-
38
-    /**
39
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
-     */
42
-    const load_from_cache = 2;
43
-
44
-    /**
45
-     * When registering a dependency,
46
-     * this indicates to keep any existing dependencies that already exist,
47
-     * and simply discard any new dependencies declared in the incoming data
48
-     */
49
-    const KEEP_EXISTING_DEPENDENCIES = 0;
50
-
51
-    /**
52
-     * When registering a dependency,
53
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
-     */
55
-    const OVERWRITE_DEPENDENCIES = 1;
56
-
57
-
58
-
59
-    /**
60
-     * @type EE_Dependency_Map $_instance
61
-     */
62
-    protected static $_instance;
63
-
64
-    /**
65
-     * @type RequestInterface $request
66
-     */
67
-    protected $request;
68
-
69
-    /**
70
-     * @type LegacyRequestInterface $legacy_request
71
-     */
72
-    protected $legacy_request;
73
-
74
-    /**
75
-     * @type ResponseInterface $response
76
-     */
77
-    protected $response;
78
-
79
-    /**
80
-     * @type LoaderInterface $loader
81
-     */
82
-    protected $loader;
83
-
84
-    /**
85
-     * @type array $_dependency_map
86
-     */
87
-    protected $_dependency_map = array();
88
-
89
-    /**
90
-     * @type array $_class_loaders
91
-     */
92
-    protected $_class_loaders = array();
93
-
94
-    /**
95
-     * @type array $_aliases
96
-     */
97
-    protected $_aliases = array();
98
-
99
-
100
-
101
-    /**
102
-     * EE_Dependency_Map constructor.
103
-     */
104
-    protected function __construct()
105
-    {
106
-        // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
-        do_action('EE_Dependency_Map____construct');
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidArgumentException
116
-     */
117
-    public function initialize()
118
-    {
119
-        $this->_register_core_dependencies();
120
-        $this->_register_core_class_loaders();
121
-        $this->_register_core_aliases();
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @singleton method used to instantiate class object
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance() {
131
-        // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
-            self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
-        }
135
-        return self::$_instance;
136
-    }
137
-
138
-
139
-    /**
140
-     * @param RequestInterface $request
141
-     */
142
-    public function setRequest(RequestInterface $request)
143
-    {
144
-        $this->request = $request;
145
-    }
146
-
147
-
148
-    /**
149
-     * @param LegacyRequestInterface $legacy_request
150
-     */
151
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
-    {
153
-        $this->legacy_request = $legacy_request;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param ResponseInterface $response
159
-     */
160
-    public function setResponse(ResponseInterface $response)
161
-    {
162
-        $this->response = $response;
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * @param LoaderInterface $loader
169
-     */
170
-    public function setLoader(LoaderInterface $loader)
171
-    {
172
-        $this->loader = $loader;
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * @param string $class
179
-     * @param array  $dependencies
180
-     * @param int    $overwrite
181
-     * @return bool
182
-     */
183
-    public static function register_dependencies(
184
-        $class,
185
-        array $dependencies,
186
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
-    ) {
188
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Assigns an array of class names and corresponding load sources (new or cached)
195
-     * to the class specified by the first parameter.
196
-     * IMPORTANT !!!
197
-     * The order of elements in the incoming $dependencies array MUST match
198
-     * the order of the constructor parameters for the class in question.
199
-     * This is especially important when overriding any existing dependencies that are registered.
200
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
-     *
202
-     * @param string $class
203
-     * @param array  $dependencies
204
-     * @param int    $overwrite
205
-     * @return bool
206
-     */
207
-    public function registerDependencies(
208
-        $class,
209
-        array $dependencies,
210
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
-    ) {
212
-        $class = trim($class, '\\');
213
-        $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
216
-        }
217
-        // we need to make sure that any aliases used when registering a dependency
218
-        // get resolved to the correct class name
219
-        foreach ($dependencies as $dependency => $load_source) {
220
-            $alias = self::$_instance->get_alias($dependency);
221
-            if (
222
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
-            ) {
225
-                unset($dependencies[$dependency]);
226
-                $dependencies[$alias] = $load_source;
227
-                $registered = true;
228
-            }
229
-        }
230
-        // now add our two lists of dependencies together.
231
-        // using Union (+=) favours the arrays in precedence from left to right,
232
-        // so $dependencies is NOT overwritten because it is listed first
233
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
-        // Union is way faster than array_merge() but should be used with caution...
235
-        // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
237
-        // now we need to ensure that the resulting dependencies
238
-        // array only has the entries that are required for the class
239
-        // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
-        // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
243
-            // then truncate the  final array to match that count
244
-            ? array_slice($dependencies, 0, $dependency_count)
245
-            // otherwise just take the incoming array because nothing previously existed
246
-            : $dependencies;
247
-        return $registered;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @param string $class_name
254
-     * @param string $loader
255
-     * @return bool
256
-     * @throws DomainException
257
-     */
258
-    public static function register_class_loader($class_name, $loader = 'load_core')
259
-    {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
-            throw new DomainException(
262
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
-            );
264
-        }
265
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
266
-        if (
267
-            ! is_callable($loader)
268
-            && (
269
-                strpos($loader, 'load_') !== 0
270
-                || ! method_exists('EE_Registry', $loader)
271
-            )
272
-        ) {
273
-            throw new DomainException(
274
-                sprintf(
275
-                    esc_html__(
276
-                        '"%1$s" is not a valid loader method on EE_Registry.',
277
-                        'event_espresso'
278
-                    ),
279
-                    $loader
280
-                )
281
-            );
282
-        }
283
-        $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
-            self::$_instance->_class_loaders[$class_name] = $loader;
286
-            return true;
287
-        }
288
-        return false;
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * @return array
295
-     */
296
-    public function dependency_map()
297
-    {
298
-        return $this->_dependency_map;
299
-    }
300
-
301
-
302
-
303
-    /**
304
-     * returns TRUE if dependency map contains a listing for the provided class name
305
-     *
306
-     * @param string $class_name
307
-     * @return boolean
308
-     */
309
-    public function has($class_name = '')
310
-    {
311
-        // all legacy models have the same dependencies
312
-        if (strpos($class_name, 'EEM_') === 0) {
313
-            $class_name = 'LEGACY_MODELS';
314
-        }
315
-        return isset($this->_dependency_map[$class_name]) ? true : false;
316
-    }
317
-
318
-
319
-
320
-    /**
321
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
-     *
323
-     * @param string $class_name
324
-     * @param string $dependency
325
-     * @return bool
326
-     */
327
-    public function has_dependency_for_class($class_name = '', $dependency = '')
328
-    {
329
-        // all legacy models have the same dependencies
330
-        if (strpos($class_name, 'EEM_') === 0) {
331
-            $class_name = 'LEGACY_MODELS';
332
-        }
333
-        $dependency = $this->get_alias($dependency);
334
-        return isset($this->_dependency_map[$class_name][$dependency])
335
-            ? true
336
-            : false;
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
-     *
344
-     * @param string $class_name
345
-     * @param string $dependency
346
-     * @return int
347
-     */
348
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
-    {
350
-        // all legacy models have the same dependencies
351
-        if (strpos($class_name, 'EEM_') === 0) {
352
-            $class_name = 'LEGACY_MODELS';
353
-        }
354
-        $dependency = $this->get_alias($dependency);
355
-        return $this->has_dependency_for_class($class_name, $dependency)
356
-            ? $this->_dependency_map[$class_name][$dependency]
357
-            : EE_Dependency_Map::not_registered;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * @param string $class_name
364
-     * @return string | Closure
365
-     */
366
-    public function class_loader($class_name)
367
-    {
368
-        // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
370
-            return 'load_model';
371
-        }
372
-        $class_name = $this->get_alias($class_name);
373
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
-    }
375
-
376
-
377
-
378
-    /**
379
-     * @return array
380
-     */
381
-    public function class_loaders()
382
-    {
383
-        return $this->_class_loaders;
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * adds an alias for a classname
390
-     *
391
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
392
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
-     */
395
-    public function add_alias($class_name, $alias, $for_class = '')
396
-    {
397
-        if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
399
-                $this->_aliases[$for_class] = array();
400
-            }
401
-            $this->_aliases[$for_class][$class_name] = $alias;
402
-        }
403
-        $this->_aliases[$class_name] = $alias;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * returns TRUE if the provided class name has an alias
410
-     *
411
-     * @param string $class_name
412
-     * @param string $for_class
413
-     * @return bool
414
-     */
415
-    public function has_alias($class_name = '', $for_class = '')
416
-    {
417
-        return isset($this->_aliases[$for_class][$class_name])
418
-               || (
419
-                   isset($this->_aliases[$class_name])
420
-                   && ! is_array($this->_aliases[$class_name])
421
-               );
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * returns alias for class name if one exists, otherwise returns the original classname
428
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
429
-     *  for example:
430
-     *      if the following two entries were added to the _aliases array:
431
-     *          array(
432
-     *              'interface_alias'           => 'some\namespace\interface'
433
-     *              'some\namespace\interface'  => 'some\namespace\classname'
434
-     *          )
435
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
-     *      to load an instance of 'some\namespace\classname'
437
-     *
438
-     * @param string $class_name
439
-     * @param string $for_class
440
-     * @return string
441
-     */
442
-    public function get_alias($class_name = '', $for_class = '')
443
-    {
444
-        if (! $this->has_alias($class_name, $for_class)) {
445
-            return $class_name;
446
-        }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
-        }
450
-        return $this->get_alias($this->_aliases[$class_name]);
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
-     * This is done by using the following class constants:
459
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
461
-     */
462
-    protected function _register_core_dependencies()
463
-    {
464
-        $this->_dependency_map = array(
465
-            'EE_Request_Handler'                                                                                          => array(
466
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
467
-            ),
468
-            'EE_System'                                                                                                   => array(
469
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
-            ),
474
-            'EE_Session'                                                                                                  => array(
475
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Cart'                                                                                                     => array(
481
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
482
-            ),
483
-            'EE_Front_Controller'                                                                                         => array(
484
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
-            ),
488
-            'EE_Messenger_Collection_Loader'                                                                              => array(
489
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
-            ),
491
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
492
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
-            ),
494
-            'EE_Message_Resource_Manager'                                                                                 => array(
495
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
-            ),
499
-            'EE_Message_Factory'                                                                                          => array(
500
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EE_messages'                                                                                                 => array(
503
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
-            ),
505
-            'EE_Messages_Generator'                                                                                       => array(
506
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
-            ),
511
-            'EE_Messages_Processor'                                                                                       => array(
512
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EE_Messages_Queue'                                                                                           => array(
515
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
-            ),
517
-            'EE_Messages_Template_Defaults'                                                                               => array(
518
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
522
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
-            ),
528
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
-            ),
532
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
-            ),
535
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
-            ),
569
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
-            ),
572
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-            ),
581
-            'EE_Data_Migration_Class_Base'                                                                                => array(
582
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
-            ),
585
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
586
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
-            ),
589
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
590
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
-            ),
593
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
594
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
-            ),
597
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
598
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
-            ),
601
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
602
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
-            ),
605
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
606
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
-            ),
609
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
610
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
614
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
-            ),
617
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
618
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
-            ),
621
-            'EventEspresso\core\services\assets\I18nRegistry' => array(
622
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
623
-            ),
624
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
625
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
626
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
627
-                'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
628
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
629
-            ),
630
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
631
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
632
-            ),
633
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
634
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
635
-            ),
636
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
637
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
638
-            ),
639
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
640
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
641
-            ),
642
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
643
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
644
-            ),
645
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
646
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
647
-            ),
648
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
649
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
652
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
653
-            ),
654
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
655
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
656
-            ),
657
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
658
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
659
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
660
-            ),
661
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
662
-                null,
663
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
664
-            ),
665
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
666
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
667
-            ),
668
-            'LEGACY_MODELS'                                                   => array(
669
-                null,
670
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
671
-            ),
672
-            'EE_Module_Request_Router' => array(
673
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
674
-            ),
675
-            'EE_Registration_Processor' => array(
676
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
677
-            ),
678
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
679
-                null,
680
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
681
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
682
-            ),
683
-            'EventEspresso\core\services\licensing\LicenseService' => array(
684
-                'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
685
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
686
-            ),
28
+	/**
29
+	 * This means that the requested class dependency is not present in the dependency map
30
+	 */
31
+	const not_registered = 0;
32
+
33
+	/**
34
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
+	 */
36
+	const load_new_object = 1;
37
+
38
+	/**
39
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
+	 */
42
+	const load_from_cache = 2;
43
+
44
+	/**
45
+	 * When registering a dependency,
46
+	 * this indicates to keep any existing dependencies that already exist,
47
+	 * and simply discard any new dependencies declared in the incoming data
48
+	 */
49
+	const KEEP_EXISTING_DEPENDENCIES = 0;
50
+
51
+	/**
52
+	 * When registering a dependency,
53
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
+	 */
55
+	const OVERWRITE_DEPENDENCIES = 1;
56
+
57
+
58
+
59
+	/**
60
+	 * @type EE_Dependency_Map $_instance
61
+	 */
62
+	protected static $_instance;
63
+
64
+	/**
65
+	 * @type RequestInterface $request
66
+	 */
67
+	protected $request;
68
+
69
+	/**
70
+	 * @type LegacyRequestInterface $legacy_request
71
+	 */
72
+	protected $legacy_request;
73
+
74
+	/**
75
+	 * @type ResponseInterface $response
76
+	 */
77
+	protected $response;
78
+
79
+	/**
80
+	 * @type LoaderInterface $loader
81
+	 */
82
+	protected $loader;
83
+
84
+	/**
85
+	 * @type array $_dependency_map
86
+	 */
87
+	protected $_dependency_map = array();
88
+
89
+	/**
90
+	 * @type array $_class_loaders
91
+	 */
92
+	protected $_class_loaders = array();
93
+
94
+	/**
95
+	 * @type array $_aliases
96
+	 */
97
+	protected $_aliases = array();
98
+
99
+
100
+
101
+	/**
102
+	 * EE_Dependency_Map constructor.
103
+	 */
104
+	protected function __construct()
105
+	{
106
+		// add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
+		do_action('EE_Dependency_Map____construct');
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidArgumentException
116
+	 */
117
+	public function initialize()
118
+	{
119
+		$this->_register_core_dependencies();
120
+		$this->_register_core_class_loaders();
121
+		$this->_register_core_aliases();
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @singleton method used to instantiate class object
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance() {
131
+		// check if class object is instantiated, and instantiated properly
132
+		if (! self::$_instance instanceof EE_Dependency_Map) {
133
+			self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
+		}
135
+		return self::$_instance;
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param RequestInterface $request
141
+	 */
142
+	public function setRequest(RequestInterface $request)
143
+	{
144
+		$this->request = $request;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param LegacyRequestInterface $legacy_request
150
+	 */
151
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
+	{
153
+		$this->legacy_request = $legacy_request;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param ResponseInterface $response
159
+	 */
160
+	public function setResponse(ResponseInterface $response)
161
+	{
162
+		$this->response = $response;
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * @param LoaderInterface $loader
169
+	 */
170
+	public function setLoader(LoaderInterface $loader)
171
+	{
172
+		$this->loader = $loader;
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * @param string $class
179
+	 * @param array  $dependencies
180
+	 * @param int    $overwrite
181
+	 * @return bool
182
+	 */
183
+	public static function register_dependencies(
184
+		$class,
185
+		array $dependencies,
186
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
+	) {
188
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Assigns an array of class names and corresponding load sources (new or cached)
195
+	 * to the class specified by the first parameter.
196
+	 * IMPORTANT !!!
197
+	 * The order of elements in the incoming $dependencies array MUST match
198
+	 * the order of the constructor parameters for the class in question.
199
+	 * This is especially important when overriding any existing dependencies that are registered.
200
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
+	 *
202
+	 * @param string $class
203
+	 * @param array  $dependencies
204
+	 * @param int    $overwrite
205
+	 * @return bool
206
+	 */
207
+	public function registerDependencies(
208
+		$class,
209
+		array $dependencies,
210
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
+	) {
212
+		$class = trim($class, '\\');
213
+		$registered = false;
214
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
215
+			self::$_instance->_dependency_map[ $class ] = array();
216
+		}
217
+		// we need to make sure that any aliases used when registering a dependency
218
+		// get resolved to the correct class name
219
+		foreach ($dependencies as $dependency => $load_source) {
220
+			$alias = self::$_instance->get_alias($dependency);
221
+			if (
222
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
+			) {
225
+				unset($dependencies[$dependency]);
226
+				$dependencies[$alias] = $load_source;
227
+				$registered = true;
228
+			}
229
+		}
230
+		// now add our two lists of dependencies together.
231
+		// using Union (+=) favours the arrays in precedence from left to right,
232
+		// so $dependencies is NOT overwritten because it is listed first
233
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
+		// Union is way faster than array_merge() but should be used with caution...
235
+		// especially with numerically indexed arrays
236
+		$dependencies += self::$_instance->_dependency_map[ $class ];
237
+		// now we need to ensure that the resulting dependencies
238
+		// array only has the entries that are required for the class
239
+		// so first count how many dependencies were originally registered for the class
240
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
+		// if that count is non-zero (meaning dependencies were already registered)
242
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
243
+			// then truncate the  final array to match that count
244
+			? array_slice($dependencies, 0, $dependency_count)
245
+			// otherwise just take the incoming array because nothing previously existed
246
+			: $dependencies;
247
+		return $registered;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @param string $class_name
254
+	 * @param string $loader
255
+	 * @return bool
256
+	 * @throws DomainException
257
+	 */
258
+	public static function register_class_loader($class_name, $loader = 'load_core')
259
+	{
260
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
+			throw new DomainException(
262
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
+			);
264
+		}
265
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
266
+		if (
267
+			! is_callable($loader)
268
+			&& (
269
+				strpos($loader, 'load_') !== 0
270
+				|| ! method_exists('EE_Registry', $loader)
271
+			)
272
+		) {
273
+			throw new DomainException(
274
+				sprintf(
275
+					esc_html__(
276
+						'"%1$s" is not a valid loader method on EE_Registry.',
277
+						'event_espresso'
278
+					),
279
+					$loader
280
+				)
281
+			);
282
+		}
283
+		$class_name = self::$_instance->get_alias($class_name);
284
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
+			self::$_instance->_class_loaders[$class_name] = $loader;
286
+			return true;
287
+		}
288
+		return false;
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * @return array
295
+	 */
296
+	public function dependency_map()
297
+	{
298
+		return $this->_dependency_map;
299
+	}
300
+
301
+
302
+
303
+	/**
304
+	 * returns TRUE if dependency map contains a listing for the provided class name
305
+	 *
306
+	 * @param string $class_name
307
+	 * @return boolean
308
+	 */
309
+	public function has($class_name = '')
310
+	{
311
+		// all legacy models have the same dependencies
312
+		if (strpos($class_name, 'EEM_') === 0) {
313
+			$class_name = 'LEGACY_MODELS';
314
+		}
315
+		return isset($this->_dependency_map[$class_name]) ? true : false;
316
+	}
317
+
318
+
319
+
320
+	/**
321
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
+	 *
323
+	 * @param string $class_name
324
+	 * @param string $dependency
325
+	 * @return bool
326
+	 */
327
+	public function has_dependency_for_class($class_name = '', $dependency = '')
328
+	{
329
+		// all legacy models have the same dependencies
330
+		if (strpos($class_name, 'EEM_') === 0) {
331
+			$class_name = 'LEGACY_MODELS';
332
+		}
333
+		$dependency = $this->get_alias($dependency);
334
+		return isset($this->_dependency_map[$class_name][$dependency])
335
+			? true
336
+			: false;
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
+	 *
344
+	 * @param string $class_name
345
+	 * @param string $dependency
346
+	 * @return int
347
+	 */
348
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
+	{
350
+		// all legacy models have the same dependencies
351
+		if (strpos($class_name, 'EEM_') === 0) {
352
+			$class_name = 'LEGACY_MODELS';
353
+		}
354
+		$dependency = $this->get_alias($dependency);
355
+		return $this->has_dependency_for_class($class_name, $dependency)
356
+			? $this->_dependency_map[$class_name][$dependency]
357
+			: EE_Dependency_Map::not_registered;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * @param string $class_name
364
+	 * @return string | Closure
365
+	 */
366
+	public function class_loader($class_name)
367
+	{
368
+		// all legacy models use load_model()
369
+		if(strpos($class_name, 'EEM_') === 0){
370
+			return 'load_model';
371
+		}
372
+		$class_name = $this->get_alias($class_name);
373
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
+	}
375
+
376
+
377
+
378
+	/**
379
+	 * @return array
380
+	 */
381
+	public function class_loaders()
382
+	{
383
+		return $this->_class_loaders;
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * adds an alias for a classname
390
+	 *
391
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
392
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
+	 */
395
+	public function add_alias($class_name, $alias, $for_class = '')
396
+	{
397
+		if ($for_class !== '') {
398
+			if (! isset($this->_aliases[$for_class])) {
399
+				$this->_aliases[$for_class] = array();
400
+			}
401
+			$this->_aliases[$for_class][$class_name] = $alias;
402
+		}
403
+		$this->_aliases[$class_name] = $alias;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * returns TRUE if the provided class name has an alias
410
+	 *
411
+	 * @param string $class_name
412
+	 * @param string $for_class
413
+	 * @return bool
414
+	 */
415
+	public function has_alias($class_name = '', $for_class = '')
416
+	{
417
+		return isset($this->_aliases[$for_class][$class_name])
418
+			   || (
419
+				   isset($this->_aliases[$class_name])
420
+				   && ! is_array($this->_aliases[$class_name])
421
+			   );
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * returns alias for class name if one exists, otherwise returns the original classname
428
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
429
+	 *  for example:
430
+	 *      if the following two entries were added to the _aliases array:
431
+	 *          array(
432
+	 *              'interface_alias'           => 'some\namespace\interface'
433
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
434
+	 *          )
435
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
+	 *      to load an instance of 'some\namespace\classname'
437
+	 *
438
+	 * @param string $class_name
439
+	 * @param string $for_class
440
+	 * @return string
441
+	 */
442
+	public function get_alias($class_name = '', $for_class = '')
443
+	{
444
+		if (! $this->has_alias($class_name, $for_class)) {
445
+			return $class_name;
446
+		}
447
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
+		}
450
+		return $this->get_alias($this->_aliases[$class_name]);
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
+	 * This is done by using the following class constants:
459
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
461
+	 */
462
+	protected function _register_core_dependencies()
463
+	{
464
+		$this->_dependency_map = array(
465
+			'EE_Request_Handler'                                                                                          => array(
466
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
467
+			),
468
+			'EE_System'                                                                                                   => array(
469
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
+			),
474
+			'EE_Session'                                                                                                  => array(
475
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
476
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
477
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
478
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Cart'                                                                                                     => array(
481
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
482
+			),
483
+			'EE_Front_Controller'                                                                                         => array(
484
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
485
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
486
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
487
+			),
488
+			'EE_Messenger_Collection_Loader'                                                                              => array(
489
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
490
+			),
491
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
492
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
493
+			),
494
+			'EE_Message_Resource_Manager'                                                                                 => array(
495
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
496
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
497
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
498
+			),
499
+			'EE_Message_Factory'                                                                                          => array(
500
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EE_messages'                                                                                                 => array(
503
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
+			),
505
+			'EE_Messages_Generator'                                                                                       => array(
506
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
507
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
508
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
509
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
510
+			),
511
+			'EE_Messages_Processor'                                                                                       => array(
512
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EE_Messages_Queue'                                                                                           => array(
515
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
516
+			),
517
+			'EE_Messages_Template_Defaults'                                                                               => array(
518
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
519
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
522
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
523
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
526
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
527
+			),
528
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
529
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
530
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
531
+			),
532
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
533
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
534
+			),
535
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
536
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
537
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
540
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
543
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
546
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
549
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
552
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
555
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
558
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
561
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
564
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
567
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
568
+			),
569
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
570
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
571
+			),
572
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
573
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
576
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+			),
581
+			'EE_Data_Migration_Class_Base'                                                                                => array(
582
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
583
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
584
+			),
585
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
586
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
587
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
588
+			),
589
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
590
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
591
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
592
+			),
593
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
594
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
595
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
596
+			),
597
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
598
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
599
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
600
+			),
601
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
602
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
603
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
604
+			),
605
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
606
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
607
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
608
+			),
609
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
610
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
611
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
614
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
615
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
616
+			),
617
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
618
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
619
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
620
+			),
621
+			'EventEspresso\core\services\assets\I18nRegistry' => array(
622
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
623
+			),
624
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
625
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
626
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
627
+				'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache,
628
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
629
+			),
630
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
631
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
632
+			),
633
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
634
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
635
+			),
636
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
637
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
638
+			),
639
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
640
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
641
+			),
642
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
643
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
644
+			),
645
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
646
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
647
+			),
648
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
649
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
652
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
653
+			),
654
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
655
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
656
+			),
657
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
658
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
659
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
660
+			),
661
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
662
+				null,
663
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
664
+			),
665
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
666
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
667
+			),
668
+			'LEGACY_MODELS'                                                   => array(
669
+				null,
670
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
671
+			),
672
+			'EE_Module_Request_Router' => array(
673
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
674
+			),
675
+			'EE_Registration_Processor' => array(
676
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
677
+			),
678
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
679
+				null,
680
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
681
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
682
+			),
683
+			'EventEspresso\core\services\licensing\LicenseService' => array(
684
+				'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
685
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
686
+			),
687 687
 			'EE_Admin_Transactions_List_Table' => array(
688
-                null,
689
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
690
-			),
691
-            'EventEspresso\core\domain\services\pue\Stats' => array(
692
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
693
-                'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
694
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
695
-            ),
696
-            'EventEspresso\core\domain\services\pue\Config' => array(
697
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
698
-                'EE_Config' => EE_Dependency_Map::load_from_cache
699
-            ),
700
-            'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
701
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
702
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
703
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
704
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
705
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
706
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
707
-                'EE_Config' => EE_Dependency_Map::load_from_cache
708
-            ),
709
-            'EventEspresso\core\domain\services\admin\ExitModal' => array(
710
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
711
-            ),
712
-            'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
713
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
714
-            ),
715
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
716
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
717
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
718
-            ),
719
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
720
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
723
-                'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
724
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
725
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
726
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
727
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
728
-            ),
729
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
730
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
731
-            ),
732
-        );
733
-    }
734
-
735
-
736
-
737
-    /**
738
-     * Registers how core classes are loaded.
739
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
740
-     *        'EE_Request_Handler' => 'load_core'
741
-     *        'EE_Messages_Queue'  => 'load_lib'
742
-     *        'EEH_Debug_Tools'    => 'load_helper'
743
-     * or, if greater control is required, by providing a custom closure. For example:
744
-     *        'Some_Class' => function () {
745
-     *            return new Some_Class();
746
-     *        },
747
-     * This is required for instantiating dependencies
748
-     * where an interface has been type hinted in a class constructor. For example:
749
-     *        'Required_Interface' => function () {
750
-     *            return new A_Class_That_Implements_Required_Interface();
751
-     *        },
752
-     *
753
-     * @throws InvalidInterfaceException
754
-     * @throws InvalidDataTypeException
755
-     * @throws InvalidArgumentException
756
-     */
757
-    protected function _register_core_class_loaders()
758
-    {
759
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
760
-        //be used in a closure.
761
-        $request = &$this->request;
762
-        $response = &$this->response;
763
-        $legacy_request = &$this->legacy_request;
764
-        // $loader = &$this->loader;
765
-        $this->_class_loaders = array(
766
-            //load_core
767
-            'EE_Capabilities'          => 'load_core',
768
-            'EE_Encryption'            => 'load_core',
769
-            'EE_Front_Controller'      => 'load_core',
770
-            'EE_Module_Request_Router' => 'load_core',
771
-            'EE_Registry'              => 'load_core',
772
-            'EE_Request'               => function () use (&$legacy_request) {
773
-                return $legacy_request;
774
-            },
775
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
776
-                return $request;
777
-            },
778
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
779
-                return $response;
780
-            },
781
-            'EE_Request_Handler'       => 'load_core',
782
-            'EE_Session'               => 'load_core',
783
-            'EE_Cron_Tasks'            => 'load_core',
784
-            'EE_System'                => 'load_core',
785
-            'EE_Maintenance_Mode'      => 'load_core',
786
-            'EE_Register_CPTs'         => 'load_core',
787
-            'EE_Admin'                 => 'load_core',
788
-            //load_lib
789
-            'EE_Message_Resource_Manager'          => 'load_lib',
790
-            'EE_Message_Type_Collection'           => 'load_lib',
791
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
792
-            'EE_Messenger_Collection'              => 'load_lib',
793
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
794
-            'EE_Messages_Processor'                => 'load_lib',
795
-            'EE_Message_Repository'                => 'load_lib',
796
-            'EE_Messages_Queue'                    => 'load_lib',
797
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
798
-            'EE_Message_Template_Group_Collection' => 'load_lib',
799
-            'EE_Payment_Method_Manager'            => 'load_lib',
800
-            'EE_Messages_Generator'                => function () {
801
-                return EE_Registry::instance()->load_lib(
802
-                    'Messages_Generator',
803
-                    array(),
804
-                    false,
805
-                    false
806
-                );
807
-            },
808
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
809
-                return EE_Registry::instance()->load_lib(
810
-                    'Messages_Template_Defaults',
811
-                    $arguments,
812
-                    false,
813
-                    false
814
-                );
815
-            },
816
-            //load_helper
817
-            'EEH_Parse_Shortcodes'                 => function () {
818
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
819
-                    return new EEH_Parse_Shortcodes();
820
-                }
821
-                return null;
822
-            },
823
-            'EE_Template_Config'                   => function () {
824
-                return EE_Config::instance()->template_settings;
825
-            },
826
-            'EE_Currency_Config'                   => function () {
827
-                return EE_Config::instance()->currency;
828
-            },
829
-            'EE_Registration_Config'                   => function () {
830
-                return EE_Config::instance()->registration;
831
-            },
832
-            'EE_Core_Config'                   => function () {
833
-                return EE_Config::instance()->core;
834
-            },
835
-            'EventEspresso\core\services\loaders\Loader' => function () {
836
-                return LoaderFactory::getLoader();
837
-            },
838
-            'EE_Network_Config' => function() {
839
-                return EE_Network_Config::instance();
840
-            },
841
-            'EE_Config' => function () {
842
-                return EE_Config::instance();
843
-            }
844
-        );
845
-    }
846
-
847
-
848
-
849
-    /**
850
-     * can be used for supplying alternate names for classes,
851
-     * or for connecting interface names to instantiable classes
852
-     */
853
-    protected function _register_core_aliases()
854
-    {
855
-        $this->_aliases = array(
856
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
857
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
858
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
859
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
860
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
861
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
862
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
863
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
864
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
865
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
866
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
867
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
868
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
869
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
870
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
871
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
872
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
873
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
874
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
875
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
876
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
877
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
878
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
879
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
880
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
881
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
882
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
883
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
884
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
885
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
886
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
887
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
888
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
889
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
890
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
891
-            'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
892
-            'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
893
-            'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
894
-            'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
895
-            'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
896
-        );
897
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
898
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
899
-        }
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
906
-     * request Primarily used by unit tests.
907
-     *
908
-     * @throws InvalidDataTypeException
909
-     * @throws InvalidInterfaceException
910
-     * @throws InvalidArgumentException
911
-     */
912
-    public function reset()
913
-    {
914
-        $this->_register_core_class_loaders();
915
-        $this->_register_core_dependencies();
916
-    }
688
+				null,
689
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
690
+			),
691
+			'EventEspresso\core\domain\services\pue\Stats' => array(
692
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
693
+				'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
694
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
695
+			),
696
+			'EventEspresso\core\domain\services\pue\Config' => array(
697
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
698
+				'EE_Config' => EE_Dependency_Map::load_from_cache
699
+			),
700
+			'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
701
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
702
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
703
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
704
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
705
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
706
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
707
+				'EE_Config' => EE_Dependency_Map::load_from_cache
708
+			),
709
+			'EventEspresso\core\domain\services\admin\ExitModal' => array(
710
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache
711
+			),
712
+			'EventEspresso\core\domain\services\admin\PluginUpsells' => array(
713
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
714
+			),
715
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array(
716
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
717
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
718
+			),
719
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array(
720
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array(
723
+				'EE_Core_Config' => EE_Dependency_Map::load_from_cache,
724
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
725
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
726
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
727
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
728
+			),
729
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array(
730
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
731
+			),
732
+		);
733
+	}
734
+
735
+
736
+
737
+	/**
738
+	 * Registers how core classes are loaded.
739
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
740
+	 *        'EE_Request_Handler' => 'load_core'
741
+	 *        'EE_Messages_Queue'  => 'load_lib'
742
+	 *        'EEH_Debug_Tools'    => 'load_helper'
743
+	 * or, if greater control is required, by providing a custom closure. For example:
744
+	 *        'Some_Class' => function () {
745
+	 *            return new Some_Class();
746
+	 *        },
747
+	 * This is required for instantiating dependencies
748
+	 * where an interface has been type hinted in a class constructor. For example:
749
+	 *        'Required_Interface' => function () {
750
+	 *            return new A_Class_That_Implements_Required_Interface();
751
+	 *        },
752
+	 *
753
+	 * @throws InvalidInterfaceException
754
+	 * @throws InvalidDataTypeException
755
+	 * @throws InvalidArgumentException
756
+	 */
757
+	protected function _register_core_class_loaders()
758
+	{
759
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
760
+		//be used in a closure.
761
+		$request = &$this->request;
762
+		$response = &$this->response;
763
+		$legacy_request = &$this->legacy_request;
764
+		// $loader = &$this->loader;
765
+		$this->_class_loaders = array(
766
+			//load_core
767
+			'EE_Capabilities'          => 'load_core',
768
+			'EE_Encryption'            => 'load_core',
769
+			'EE_Front_Controller'      => 'load_core',
770
+			'EE_Module_Request_Router' => 'load_core',
771
+			'EE_Registry'              => 'load_core',
772
+			'EE_Request'               => function () use (&$legacy_request) {
773
+				return $legacy_request;
774
+			},
775
+			'EventEspresso\core\services\request\Request' => function () use (&$request) {
776
+				return $request;
777
+			},
778
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
779
+				return $response;
780
+			},
781
+			'EE_Request_Handler'       => 'load_core',
782
+			'EE_Session'               => 'load_core',
783
+			'EE_Cron_Tasks'            => 'load_core',
784
+			'EE_System'                => 'load_core',
785
+			'EE_Maintenance_Mode'      => 'load_core',
786
+			'EE_Register_CPTs'         => 'load_core',
787
+			'EE_Admin'                 => 'load_core',
788
+			//load_lib
789
+			'EE_Message_Resource_Manager'          => 'load_lib',
790
+			'EE_Message_Type_Collection'           => 'load_lib',
791
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
792
+			'EE_Messenger_Collection'              => 'load_lib',
793
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
794
+			'EE_Messages_Processor'                => 'load_lib',
795
+			'EE_Message_Repository'                => 'load_lib',
796
+			'EE_Messages_Queue'                    => 'load_lib',
797
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
798
+			'EE_Message_Template_Group_Collection' => 'load_lib',
799
+			'EE_Payment_Method_Manager'            => 'load_lib',
800
+			'EE_Messages_Generator'                => function () {
801
+				return EE_Registry::instance()->load_lib(
802
+					'Messages_Generator',
803
+					array(),
804
+					false,
805
+					false
806
+				);
807
+			},
808
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
809
+				return EE_Registry::instance()->load_lib(
810
+					'Messages_Template_Defaults',
811
+					$arguments,
812
+					false,
813
+					false
814
+				);
815
+			},
816
+			//load_helper
817
+			'EEH_Parse_Shortcodes'                 => function () {
818
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
819
+					return new EEH_Parse_Shortcodes();
820
+				}
821
+				return null;
822
+			},
823
+			'EE_Template_Config'                   => function () {
824
+				return EE_Config::instance()->template_settings;
825
+			},
826
+			'EE_Currency_Config'                   => function () {
827
+				return EE_Config::instance()->currency;
828
+			},
829
+			'EE_Registration_Config'                   => function () {
830
+				return EE_Config::instance()->registration;
831
+			},
832
+			'EE_Core_Config'                   => function () {
833
+				return EE_Config::instance()->core;
834
+			},
835
+			'EventEspresso\core\services\loaders\Loader' => function () {
836
+				return LoaderFactory::getLoader();
837
+			},
838
+			'EE_Network_Config' => function() {
839
+				return EE_Network_Config::instance();
840
+			},
841
+			'EE_Config' => function () {
842
+				return EE_Config::instance();
843
+			}
844
+		);
845
+	}
846
+
847
+
848
+
849
+	/**
850
+	 * can be used for supplying alternate names for classes,
851
+	 * or for connecting interface names to instantiable classes
852
+	 */
853
+	protected function _register_core_aliases()
854
+	{
855
+		$this->_aliases = array(
856
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
857
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
858
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
859
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
860
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
861
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
862
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
863
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
864
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
865
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
866
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
867
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
868
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
869
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
870
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
871
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
872
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
873
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
874
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
875
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
876
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
877
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
878
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
879
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
880
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
881
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
882
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
883
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
884
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
885
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
886
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
887
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
888
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
889
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
890
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
891
+			'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
892
+			'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
893
+			'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
894
+			'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
895
+			'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
896
+		);
897
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
898
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
899
+		}
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
906
+	 * request Primarily used by unit tests.
907
+	 *
908
+	 * @throws InvalidDataTypeException
909
+	 * @throws InvalidInterfaceException
910
+	 * @throws InvalidArgumentException
911
+	 */
912
+	public function reset()
913
+	{
914
+		$this->_register_core_class_loaders();
915
+		$this->_register_core_dependencies();
916
+	}
917 917
 
918 918
 
919 919
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Indentation   +678 added lines, -678 removed lines patch added patch discarded remove patch
@@ -26,686 +26,686 @@
 block discarded – undo
26 26
 class Registry
27 27
 {
28 28
 
29
-    const ASSET_TYPE_CSS = 'css';
30
-    const ASSET_TYPE_JS = 'js';
31
-    const ASSET_NAMESPACE = 'core';
32
-
33
-    /**
34
-     * @var EE_Template_Config $template_config
35
-     */
36
-    protected $template_config;
37
-
38
-    /**
39
-     * @var EE_Currency_Config $currency_config
40
-     */
41
-    protected $currency_config;
42
-
43
-    /**
44
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
45
-     *
46
-     * @var array
47
-     */
48
-    protected $jsdata = array();
49
-
50
-
51
-    /**
52
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
53
-     * page source.
54
-     * @var array
55
-     */
56
-    protected $script_handles_with_data = array();
57
-
58
-
59
-    /**
60
-     * @var DomainInterface
61
-     */
62
-    protected $domain;
63
-
64
-
65
-    /**
66
-     * @var I18nRegistry
67
-     */
68
-    private $i18n_registry;
69
-
70
-
71
-
72
-    /**
73
-     * Holds the manifest data obtained from registered manifest files.
74
-     * Manifests are maps of asset chunk name to actual built asset file names.
75
-     * Shape of this array is:
76
-     *
77
-     * array(
78
-     *  'some_namespace_slug' => array(
79
-     *      'some_chunk_name' => array(
80
-     *          'js' => 'filename.js'
81
-     *          'css' => 'filename.js'
82
-     *      ),
83
-     *      'url_base' => 'https://baseurl.com/to/assets
84
-     *  )
85
-     * )
86
-     *
87
-     * @var array
88
-     */
89
-    private $manifest_data = array();
90
-
91
-
92
-    /**
93
-     * Registry constructor.
94
-     * Hooking into WP actions for script registry.
95
-     *
96
-     * @param EE_Template_Config $template_config
97
-     * @param EE_Currency_Config $currency_config
98
-     * @param I18nRegistry       $i18n_registry
99
-     * @param DomainInterface    $domain
100
-     * @throws InvalidArgumentException
101
-     * @throws InvalidFilePathException
102
-     */
103
-    public function __construct(
104
-        EE_Template_Config $template_config,
105
-        EE_Currency_Config $currency_config,
106
-        I18nRegistry $i18n_registry,
107
-        DomainInterface $domain
108
-    ) {
109
-        $this->template_config = $template_config;
110
-        $this->currency_config = $currency_config;
111
-        $this->domain = $domain;
112
-        $this->i18n_registry = $i18n_registry;
113
-        $this->registerManifestFile(
114
-            self::ASSET_NAMESPACE,
115
-            $this->domain->distributionAssetsUrl(),
116
-            $this->domain->distributionAssetsPath() . 'build-manifest.json'
117
-        );
118
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
119
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
120
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
121
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
122
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
123
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
124
-    }
125
-
126
-
127
-    /**
128
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
129
-     * translation handling.
130
-     *
131
-     * @return I18nRegistry
132
-     */
133
-    public function getI18nRegistry()
134
-    {
135
-        return $this->i18n_registry;
136
-    }
137
-
138
-    /**
139
-     * Callback for the WP script actions.
140
-     * Used to register globally accessible core scripts.
141
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
142
-     *
143
-     */
144
-    public function scripts()
145
-    {
146
-        global $wp_version;
147
-        wp_register_script(
148
-            'ee-manifest',
149
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'manifest'),
150
-            array(),
151
-            null,
152
-            true
153
-        );
154
-        wp_register_script(
155
-            'eejs-core',
156
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'eejs'),
157
-            array('ee-manifest'),
158
-            null,
159
-            true
160
-        );
161
-        wp_register_script(
162
-            'ee-vendor-react',
163
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'reactVendor'),
164
-            array('eejs-core'),
165
-            null,
166
-            true
167
-        );
168
-        //only run this if WordPress 4.4.0 > is in use.
169
-        if (version_compare($wp_version, '4.4.0', '>')) {
170
-            //js.api
171
-            wp_register_script(
172
-                'eejs-api',
173
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
174
-                array('underscore', 'eejs-core'),
175
-                EVENT_ESPRESSO_VERSION,
176
-                true
177
-            );
178
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
179
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
180
-        }
181
-        if (! is_admin()) {
182
-            $this->loadCoreCss();
183
-        }
184
-        $this->registerTranslationsForHandles(array('eejs-core'));
185
-        $this->loadCoreJs();
186
-        $this->loadJqueryValidate();
187
-        $this->loadAccountingJs();
188
-        $this->loadQtipJs();
189
-        $this->registerAdminAssets();
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     * Call back for the script print in frontend and backend.
196
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
197
-     *
198
-     * @since 4.9.31.rc.015
199
-     */
200
-    public function enqueueData()
201
-    {
202
-        $this->removeAlreadyRegisteredDataForScriptHandles();
203
-        wp_localize_script('eejs-core', 'eejsdata', array('data' => $this->jsdata));
204
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
205
-        $this->localizeAccountingJs();
206
-        $this->addRegisteredScriptHandlesWithData('eejs-core');
207
-        $this->addRegisteredScriptHandlesWithData('espresso_core');
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     * Used to add data to eejs.data object.
214
-     * Note:  Overriding existing data is not allowed.
215
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
216
-     * If the data you add is something like this:
217
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
218
-     * It will be exposed in the page source as:
219
-     *  eejs.data.my_plugin_data.foo == gar
220
-     *
221
-     * @param string       $key   Key used to access your data
222
-     * @param string|array $value Value to attach to key
223
-     * @throws InvalidArgumentException
224
-     */
225
-    public function addData($key, $value)
226
-    {
227
-        if ($this->verifyDataNotExisting($key)) {
228
-            $this->jsdata[$key] = $value;
229
-        }
230
-    }
231
-
232
-
233
-
234
-    /**
235
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
236
-     * elements in an array.
237
-     * When you use this method, the value you include will be appended to the end of an array on $key.
238
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
239
-     * object like this, eejs.data.test = [ my_data,
240
-     * ]
241
-     * If there has already been a scalar value attached to the data object given key, then
242
-     * this will throw an exception.
243
-     *
244
-     * @param string       $key   Key to attach data to.
245
-     * @param string|array $value Value being registered.
246
-     * @throws InvalidArgumentException
247
-     */
248
-    public function pushData($key, $value)
249
-    {
250
-        if (isset($this->jsdata[$key])
251
-            && ! is_array($this->jsdata[$key])
252
-        ) {
253
-            throw new invalidArgumentException(
254
-                sprintf(
255
-                    __(
256
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
29
+	const ASSET_TYPE_CSS = 'css';
30
+	const ASSET_TYPE_JS = 'js';
31
+	const ASSET_NAMESPACE = 'core';
32
+
33
+	/**
34
+	 * @var EE_Template_Config $template_config
35
+	 */
36
+	protected $template_config;
37
+
38
+	/**
39
+	 * @var EE_Currency_Config $currency_config
40
+	 */
41
+	protected $currency_config;
42
+
43
+	/**
44
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
45
+	 *
46
+	 * @var array
47
+	 */
48
+	protected $jsdata = array();
49
+
50
+
51
+	/**
52
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
53
+	 * page source.
54
+	 * @var array
55
+	 */
56
+	protected $script_handles_with_data = array();
57
+
58
+
59
+	/**
60
+	 * @var DomainInterface
61
+	 */
62
+	protected $domain;
63
+
64
+
65
+	/**
66
+	 * @var I18nRegistry
67
+	 */
68
+	private $i18n_registry;
69
+
70
+
71
+
72
+	/**
73
+	 * Holds the manifest data obtained from registered manifest files.
74
+	 * Manifests are maps of asset chunk name to actual built asset file names.
75
+	 * Shape of this array is:
76
+	 *
77
+	 * array(
78
+	 *  'some_namespace_slug' => array(
79
+	 *      'some_chunk_name' => array(
80
+	 *          'js' => 'filename.js'
81
+	 *          'css' => 'filename.js'
82
+	 *      ),
83
+	 *      'url_base' => 'https://baseurl.com/to/assets
84
+	 *  )
85
+	 * )
86
+	 *
87
+	 * @var array
88
+	 */
89
+	private $manifest_data = array();
90
+
91
+
92
+	/**
93
+	 * Registry constructor.
94
+	 * Hooking into WP actions for script registry.
95
+	 *
96
+	 * @param EE_Template_Config $template_config
97
+	 * @param EE_Currency_Config $currency_config
98
+	 * @param I18nRegistry       $i18n_registry
99
+	 * @param DomainInterface    $domain
100
+	 * @throws InvalidArgumentException
101
+	 * @throws InvalidFilePathException
102
+	 */
103
+	public function __construct(
104
+		EE_Template_Config $template_config,
105
+		EE_Currency_Config $currency_config,
106
+		I18nRegistry $i18n_registry,
107
+		DomainInterface $domain
108
+	) {
109
+		$this->template_config = $template_config;
110
+		$this->currency_config = $currency_config;
111
+		$this->domain = $domain;
112
+		$this->i18n_registry = $i18n_registry;
113
+		$this->registerManifestFile(
114
+			self::ASSET_NAMESPACE,
115
+			$this->domain->distributionAssetsUrl(),
116
+			$this->domain->distributionAssetsPath() . 'build-manifest.json'
117
+		);
118
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
119
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
120
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
121
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
122
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
123
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
124
+	}
125
+
126
+
127
+	/**
128
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
129
+	 * translation handling.
130
+	 *
131
+	 * @return I18nRegistry
132
+	 */
133
+	public function getI18nRegistry()
134
+	{
135
+		return $this->i18n_registry;
136
+	}
137
+
138
+	/**
139
+	 * Callback for the WP script actions.
140
+	 * Used to register globally accessible core scripts.
141
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
142
+	 *
143
+	 */
144
+	public function scripts()
145
+	{
146
+		global $wp_version;
147
+		wp_register_script(
148
+			'ee-manifest',
149
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'manifest'),
150
+			array(),
151
+			null,
152
+			true
153
+		);
154
+		wp_register_script(
155
+			'eejs-core',
156
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'eejs'),
157
+			array('ee-manifest'),
158
+			null,
159
+			true
160
+		);
161
+		wp_register_script(
162
+			'ee-vendor-react',
163
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'reactVendor'),
164
+			array('eejs-core'),
165
+			null,
166
+			true
167
+		);
168
+		//only run this if WordPress 4.4.0 > is in use.
169
+		if (version_compare($wp_version, '4.4.0', '>')) {
170
+			//js.api
171
+			wp_register_script(
172
+				'eejs-api',
173
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
174
+				array('underscore', 'eejs-core'),
175
+				EVENT_ESPRESSO_VERSION,
176
+				true
177
+			);
178
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
179
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
180
+		}
181
+		if (! is_admin()) {
182
+			$this->loadCoreCss();
183
+		}
184
+		$this->registerTranslationsForHandles(array('eejs-core'));
185
+		$this->loadCoreJs();
186
+		$this->loadJqueryValidate();
187
+		$this->loadAccountingJs();
188
+		$this->loadQtipJs();
189
+		$this->registerAdminAssets();
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 * Call back for the script print in frontend and backend.
196
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
197
+	 *
198
+	 * @since 4.9.31.rc.015
199
+	 */
200
+	public function enqueueData()
201
+	{
202
+		$this->removeAlreadyRegisteredDataForScriptHandles();
203
+		wp_localize_script('eejs-core', 'eejsdata', array('data' => $this->jsdata));
204
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
205
+		$this->localizeAccountingJs();
206
+		$this->addRegisteredScriptHandlesWithData('eejs-core');
207
+		$this->addRegisteredScriptHandlesWithData('espresso_core');
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 * Used to add data to eejs.data object.
214
+	 * Note:  Overriding existing data is not allowed.
215
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
216
+	 * If the data you add is something like this:
217
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
218
+	 * It will be exposed in the page source as:
219
+	 *  eejs.data.my_plugin_data.foo == gar
220
+	 *
221
+	 * @param string       $key   Key used to access your data
222
+	 * @param string|array $value Value to attach to key
223
+	 * @throws InvalidArgumentException
224
+	 */
225
+	public function addData($key, $value)
226
+	{
227
+		if ($this->verifyDataNotExisting($key)) {
228
+			$this->jsdata[$key] = $value;
229
+		}
230
+	}
231
+
232
+
233
+
234
+	/**
235
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
236
+	 * elements in an array.
237
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
238
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
239
+	 * object like this, eejs.data.test = [ my_data,
240
+	 * ]
241
+	 * If there has already been a scalar value attached to the data object given key, then
242
+	 * this will throw an exception.
243
+	 *
244
+	 * @param string       $key   Key to attach data to.
245
+	 * @param string|array $value Value being registered.
246
+	 * @throws InvalidArgumentException
247
+	 */
248
+	public function pushData($key, $value)
249
+	{
250
+		if (isset($this->jsdata[$key])
251
+			&& ! is_array($this->jsdata[$key])
252
+		) {
253
+			throw new invalidArgumentException(
254
+				sprintf(
255
+					__(
256
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
257 257
                          push values to this data element when it is an array.',
258
-                        'event_espresso'
259
-                    ),
260
-                    $key,
261
-                    __METHOD__
262
-                )
263
-            );
264
-        }
265
-        $this->jsdata[$key][] = $value;
266
-    }
267
-
268
-
269
-
270
-    /**
271
-     * Used to set content used by javascript for a template.
272
-     * Note: Overrides of existing registered templates are not allowed.
273
-     *
274
-     * @param string $template_reference
275
-     * @param string $template_content
276
-     * @throws InvalidArgumentException
277
-     */
278
-    public function addTemplate($template_reference, $template_content)
279
-    {
280
-        if (! isset($this->jsdata['templates'])) {
281
-            $this->jsdata['templates'] = array();
282
-        }
283
-        //no overrides allowed.
284
-        if (isset($this->jsdata['templates'][$template_reference])) {
285
-            throw new invalidArgumentException(
286
-                sprintf(
287
-                    __(
288
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
289
-                        'event_espresso'
290
-                    ),
291
-                    $template_reference
292
-                )
293
-            );
294
-        }
295
-        $this->jsdata['templates'][$template_reference] = $template_content;
296
-    }
297
-
298
-
299
-
300
-    /**
301
-     * Retrieve the template content already registered for the given reference.
302
-     *
303
-     * @param string $template_reference
304
-     * @return string
305
-     */
306
-    public function getTemplate($template_reference)
307
-    {
308
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
309
-            ? $this->jsdata['templates'][$template_reference]
310
-            : '';
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * Retrieve registered data.
317
-     *
318
-     * @param string $key Name of key to attach data to.
319
-     * @return mixed                If there is no for the given key, then false is returned.
320
-     */
321
-    public function getData($key)
322
-    {
323
-        return isset($this->jsdata[$key])
324
-            ? $this->jsdata[$key]
325
-            : false;
326
-    }
327
-
328
-
329
-    /**
330
-     * Get the actual asset path for asset manifests.
331
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
332
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
333
-     *                           asset file location.
334
-     * @param string $chunk_name
335
-     * @param string $asset_type
336
-     * @return string
337
-     * @since 4.9.59.p
338
-     */
339
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
340
-    {
341
-        $url = isset(
342
-            $this->manifest_data[$namespace][$chunk_name][$asset_type],
343
-            $this->manifest_data[$namespace]['url_base']
344
-        )
345
-            ? $this->manifest_data[$namespace]['url_base']
346
-              . $this->manifest_data[$namespace][$chunk_name][$asset_type]
347
-            : $chunk_name;
348
-        return apply_filters(
349
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
350
-            $url,
351
-            $namespace,
352
-            $chunk_name,
353
-            $asset_type
354
-        );
355
-    }
356
-
357
-
358
-    /**
359
-     * Return the url to a js file for the given namespace and chunk name.
360
-     *
361
-     * @param string $namespace
362
-     * @param string $chunk_name
363
-     * @return string
364
-     */
365
-    public function getJsUrl($namespace, $chunk_name)
366
-    {
367
-        return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS);
368
-    }
369
-
370
-
371
-    /**
372
-     * Return the url to a css file for the given namespace and chunk name.
373
-     *
374
-     * @param string $namespace
375
-     * @param string $chunk_name
376
-     * @return string
377
-     */
378
-    public function getCssUrl($namespace, $chunk_name)
379
-    {
380
-        return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS);
381
-    }
382
-
383
-
384
-    /**
385
-     * Used to register a js/css manifest file with the registered_manifest_files property.
386
-     *
387
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
388
-     * @param string $url_base      The url base for the manifest file location.
389
-     * @param string $manifest_file The absolute path to the manifest file.
390
-     * @throws InvalidArgumentException
391
-     * @throws InvalidFilePathException
392
-     * @since 4.9.59.p
393
-     */
394
-    public function registerManifestFile($namespace, $url_base, $manifest_file)
395
-    {
396
-        if (isset($this->manifest_data[$namespace])) {
397
-            throw new InvalidArgumentException(
398
-                sprintf(
399
-                    esc_html__(
400
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
401
-                        'event_espresso'
402
-                    ),
403
-                    $namespace
404
-                )
405
-            );
406
-        }
407
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
408
-            if (is_admin()) {
409
-                EE_Error::add_error(
410
-                    sprintf(
411
-                        esc_html__(
412
-                            'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
413
-                            'event_espresso'
414
-                        ),
415
-                        'Event Espresso',
416
-                        $url_base,
417
-                        'plugins_url',
418
-                        'WP_PLUGIN_URL'
419
-                    ),
420
-                    __FILE__,
421
-                    __FUNCTION__,
422
-                    __LINE__
423
-                );
424
-            }
425
-            return;
426
-        }
427
-        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
428
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
429
-            $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
430
-        }
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * Decodes json from the provided manifest file.
437
-     *
438
-     * @since 4.9.59.p
439
-     * @param string $manifest_file Path to manifest file.
440
-     * @return array
441
-     * @throws InvalidFilePathException
442
-     */
443
-    private function decodeManifestFile($manifest_file)
444
-    {
445
-        if (! file_exists($manifest_file)) {
446
-            throw new InvalidFilePathException($manifest_file);
447
-        }
448
-        return json_decode(file_get_contents($manifest_file), true);
449
-    }
450
-
451
-
452
-
453
-    /**
454
-     * Verifies whether the given data exists already on the jsdata array.
455
-     * Overriding data is not allowed.
456
-     *
457
-     * @param string $key Index for data.
458
-     * @return bool        If valid then return true.
459
-     * @throws InvalidArgumentException if data already exists.
460
-     */
461
-    protected function verifyDataNotExisting($key)
462
-    {
463
-        if (isset($this->jsdata[$key])) {
464
-            if (is_array($this->jsdata[$key])) {
465
-                throw new InvalidArgumentException(
466
-                    sprintf(
467
-                        __(
468
-                            'The value for %1$s already exists in the Registry::eejs object.
258
+						'event_espresso'
259
+					),
260
+					$key,
261
+					__METHOD__
262
+				)
263
+			);
264
+		}
265
+		$this->jsdata[$key][] = $value;
266
+	}
267
+
268
+
269
+
270
+	/**
271
+	 * Used to set content used by javascript for a template.
272
+	 * Note: Overrides of existing registered templates are not allowed.
273
+	 *
274
+	 * @param string $template_reference
275
+	 * @param string $template_content
276
+	 * @throws InvalidArgumentException
277
+	 */
278
+	public function addTemplate($template_reference, $template_content)
279
+	{
280
+		if (! isset($this->jsdata['templates'])) {
281
+			$this->jsdata['templates'] = array();
282
+		}
283
+		//no overrides allowed.
284
+		if (isset($this->jsdata['templates'][$template_reference])) {
285
+			throw new invalidArgumentException(
286
+				sprintf(
287
+					__(
288
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
289
+						'event_espresso'
290
+					),
291
+					$template_reference
292
+				)
293
+			);
294
+		}
295
+		$this->jsdata['templates'][$template_reference] = $template_content;
296
+	}
297
+
298
+
299
+
300
+	/**
301
+	 * Retrieve the template content already registered for the given reference.
302
+	 *
303
+	 * @param string $template_reference
304
+	 * @return string
305
+	 */
306
+	public function getTemplate($template_reference)
307
+	{
308
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
309
+			? $this->jsdata['templates'][$template_reference]
310
+			: '';
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * Retrieve registered data.
317
+	 *
318
+	 * @param string $key Name of key to attach data to.
319
+	 * @return mixed                If there is no for the given key, then false is returned.
320
+	 */
321
+	public function getData($key)
322
+	{
323
+		return isset($this->jsdata[$key])
324
+			? $this->jsdata[$key]
325
+			: false;
326
+	}
327
+
328
+
329
+	/**
330
+	 * Get the actual asset path for asset manifests.
331
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
332
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
333
+	 *                           asset file location.
334
+	 * @param string $chunk_name
335
+	 * @param string $asset_type
336
+	 * @return string
337
+	 * @since 4.9.59.p
338
+	 */
339
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
340
+	{
341
+		$url = isset(
342
+			$this->manifest_data[$namespace][$chunk_name][$asset_type],
343
+			$this->manifest_data[$namespace]['url_base']
344
+		)
345
+			? $this->manifest_data[$namespace]['url_base']
346
+			  . $this->manifest_data[$namespace][$chunk_name][$asset_type]
347
+			: $chunk_name;
348
+		return apply_filters(
349
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
350
+			$url,
351
+			$namespace,
352
+			$chunk_name,
353
+			$asset_type
354
+		);
355
+	}
356
+
357
+
358
+	/**
359
+	 * Return the url to a js file for the given namespace and chunk name.
360
+	 *
361
+	 * @param string $namespace
362
+	 * @param string $chunk_name
363
+	 * @return string
364
+	 */
365
+	public function getJsUrl($namespace, $chunk_name)
366
+	{
367
+		return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS);
368
+	}
369
+
370
+
371
+	/**
372
+	 * Return the url to a css file for the given namespace and chunk name.
373
+	 *
374
+	 * @param string $namespace
375
+	 * @param string $chunk_name
376
+	 * @return string
377
+	 */
378
+	public function getCssUrl($namespace, $chunk_name)
379
+	{
380
+		return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS);
381
+	}
382
+
383
+
384
+	/**
385
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
386
+	 *
387
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
388
+	 * @param string $url_base      The url base for the manifest file location.
389
+	 * @param string $manifest_file The absolute path to the manifest file.
390
+	 * @throws InvalidArgumentException
391
+	 * @throws InvalidFilePathException
392
+	 * @since 4.9.59.p
393
+	 */
394
+	public function registerManifestFile($namespace, $url_base, $manifest_file)
395
+	{
396
+		if (isset($this->manifest_data[$namespace])) {
397
+			throw new InvalidArgumentException(
398
+				sprintf(
399
+					esc_html__(
400
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
401
+						'event_espresso'
402
+					),
403
+					$namespace
404
+				)
405
+			);
406
+		}
407
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
408
+			if (is_admin()) {
409
+				EE_Error::add_error(
410
+					sprintf(
411
+						esc_html__(
412
+							'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
413
+							'event_espresso'
414
+						),
415
+						'Event Espresso',
416
+						$url_base,
417
+						'plugins_url',
418
+						'WP_PLUGIN_URL'
419
+					),
420
+					__FILE__,
421
+					__FUNCTION__,
422
+					__LINE__
423
+				);
424
+			}
425
+			return;
426
+		}
427
+		$this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
428
+		if (! isset($this->manifest_data[$namespace]['url_base'])) {
429
+			$this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
430
+		}
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * Decodes json from the provided manifest file.
437
+	 *
438
+	 * @since 4.9.59.p
439
+	 * @param string $manifest_file Path to manifest file.
440
+	 * @return array
441
+	 * @throws InvalidFilePathException
442
+	 */
443
+	private function decodeManifestFile($manifest_file)
444
+	{
445
+		if (! file_exists($manifest_file)) {
446
+			throw new InvalidFilePathException($manifest_file);
447
+		}
448
+		return json_decode(file_get_contents($manifest_file), true);
449
+	}
450
+
451
+
452
+
453
+	/**
454
+	 * Verifies whether the given data exists already on the jsdata array.
455
+	 * Overriding data is not allowed.
456
+	 *
457
+	 * @param string $key Index for data.
458
+	 * @return bool        If valid then return true.
459
+	 * @throws InvalidArgumentException if data already exists.
460
+	 */
461
+	protected function verifyDataNotExisting($key)
462
+	{
463
+		if (isset($this->jsdata[$key])) {
464
+			if (is_array($this->jsdata[$key])) {
465
+				throw new InvalidArgumentException(
466
+					sprintf(
467
+						__(
468
+							'The value for %1$s already exists in the Registry::eejs object.
469 469
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
470 470
                             %2$s method to push your value to the array.',
471
-                            'event_espresso'
472
-                        ),
473
-                        $key,
474
-                        'pushData()'
475
-                    )
476
-                );
477
-            }
478
-            throw new InvalidArgumentException(
479
-                sprintf(
480
-                    __(
481
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
471
+							'event_espresso'
472
+						),
473
+						$key,
474
+						'pushData()'
475
+					)
476
+				);
477
+			}
478
+			throw new InvalidArgumentException(
479
+				sprintf(
480
+					__(
481
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
482 482
                         allowed.  Consider attaching your value to a different key',
483
-                        'event_espresso'
484
-                    ),
485
-                    $key
486
-                )
487
-            );
488
-        }
489
-        return true;
490
-    }
491
-
492
-
493
-
494
-    /**
495
-     * registers core default stylesheets
496
-     */
497
-    private function loadCoreCss()
498
-    {
499
-        if ($this->template_config->enable_default_style) {
500
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
501
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
502
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
503
-            wp_register_style(
504
-                'espresso_default',
505
-                $default_stylesheet_path,
506
-                array('dashicons'),
507
-                EVENT_ESPRESSO_VERSION
508
-            );
509
-            //Load custom style sheet if available
510
-            if ($this->template_config->custom_style_sheet !== null) {
511
-                wp_register_style(
512
-                    'espresso_custom_css',
513
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
514
-                    array('espresso_default'),
515
-                    EVENT_ESPRESSO_VERSION
516
-                );
517
-            }
518
-        }
519
-    }
520
-
521
-
522
-
523
-    /**
524
-     * registers core default javascript
525
-     */
526
-    private function loadCoreJs()
527
-    {
528
-        // load core js
529
-        wp_register_script(
530
-            'espresso_core',
531
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
532
-            array('jquery'),
533
-            EVENT_ESPRESSO_VERSION,
534
-            true
535
-        );
536
-    }
537
-
538
-
539
-
540
-    /**
541
-     * registers jQuery Validate for form validation
542
-     */
543
-    private function loadJqueryValidate()
544
-    {
545
-        // register jQuery Validate and additional methods
546
-        wp_register_script(
547
-            'jquery-validate',
548
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
549
-            array('jquery'),
550
-            '1.15.0',
551
-            true
552
-        );
553
-        wp_register_script(
554
-            'jquery-validate-extra-methods',
555
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
556
-            array('jquery', 'jquery-validate'),
557
-            '1.15.0',
558
-            true
559
-        );
560
-    }
561
-
562
-
563
-
564
-    /**
565
-     * registers accounting.js for performing client-side calculations
566
-     */
567
-    private function loadAccountingJs()
568
-    {
569
-        //accounting.js library
570
-        // @link http://josscrowcroft.github.io/accounting.js/
571
-        wp_register_script(
572
-            'ee-accounting-core',
573
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
574
-            array('underscore'),
575
-            '0.3.2',
576
-            true
577
-        );
578
-        wp_register_script(
579
-            'ee-accounting',
580
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
581
-            array('ee-accounting-core'),
582
-            EVENT_ESPRESSO_VERSION,
583
-            true
584
-        );
585
-    }
586
-
587
-
588
-
589
-    /**
590
-     * registers accounting.js for performing client-side calculations
591
-     */
592
-    private function localizeAccountingJs()
593
-    {
594
-        wp_localize_script(
595
-            'ee-accounting',
596
-            'EE_ACCOUNTING_CFG',
597
-            array(
598
-                'currency' => array(
599
-                    'symbol'    => $this->currency_config->sign,
600
-                    'format'    => array(
601
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
602
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
603
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
604
-                    ),
605
-                    'decimal'   => $this->currency_config->dec_mrk,
606
-                    'thousand'  => $this->currency_config->thsnds,
607
-                    'precision' => $this->currency_config->dec_plc,
608
-                ),
609
-                'number'   => array(
610
-                    'precision' => $this->currency_config->dec_plc,
611
-                    'thousand'  => $this->currency_config->thsnds,
612
-                    'decimal'   => $this->currency_config->dec_mrk,
613
-                ),
614
-            )
615
-        );
616
-        $this->addRegisteredScriptHandlesWithData('ee-accounting');
617
-    }
618
-
619
-
620
-
621
-    /**
622
-     * registers assets for cleaning your ears
623
-     */
624
-    private function loadQtipJs()
625
-    {
626
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
627
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
628
-        if (apply_filters('FHEE_load_qtip', false)) {
629
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
630
-        }
631
-    }
632
-
633
-
634
-    /**
635
-     * This is used to set registered script handles that have data.
636
-     * @param string $script_handle
637
-     */
638
-    private function addRegisteredScriptHandlesWithData($script_handle)
639
-    {
640
-        $this->script_handles_with_data[$script_handle] = $script_handle;
641
-    }
642
-
643
-
644
-    /**
645
-     * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
646
-     * Dependency stored in WP_Scripts if its set.
647
-     */
648
-    private function removeAlreadyRegisteredDataForScriptHandles()
649
-    {
650
-        if (empty($this->script_handles_with_data)) {
651
-            return;
652
-        }
653
-        foreach ($this->script_handles_with_data as $script_handle) {
654
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
655
-        }
656
-    }
657
-
658
-
659
-    /**
660
-     * Removes any data dependency registered in WP_Scripts if its set.
661
-     * @param string $script_handle
662
-     */
663
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
664
-    {
665
-        if (isset($this->script_handles_with_data[$script_handle])) {
666
-            global $wp_scripts;
667
-            if ($wp_scripts->get_data($script_handle, 'data')) {
668
-                unset($wp_scripts->registered[$script_handle]->extra['data']);
669
-                unset($this->script_handles_with_data[$script_handle]);
670
-            }
671
-        }
672
-    }
673
-
674
-
675
-    /**
676
-     * Registers assets that are used in the WordPress admin.
677
-     */
678
-    private function registerAdminAssets()
679
-    {
680
-        wp_register_script(
681
-            'ee-wp-plugins-page',
682
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
683
-            array(
684
-                'jquery',
685
-                'ee-vendor-react'
686
-            ),
687
-            null,
688
-            true
689
-        );
690
-        wp_register_style(
691
-            'ee-wp-plugins-page',
692
-            $this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
693
-            array(),
694
-            null
695
-        );
696
-        $this->registerTranslationsForHandles(array('ee-wp-plugins-page'));
697
-    }
698
-
699
-
700
-    /**
701
-     * All handles that are registered via the registry that might have translations have their translations registered
702
-     *
703
-     * @param array $handles_to_register
704
-     */
705
-    private function registerTranslationsForHandles(array $handles_to_register)
706
-    {
707
-        foreach($handles_to_register as $handle) {
708
-            $this->i18n_registry->registerScriptI18n($handle, 'event_espresso');
709
-        }
710
-    }
483
+						'event_espresso'
484
+					),
485
+					$key
486
+				)
487
+			);
488
+		}
489
+		return true;
490
+	}
491
+
492
+
493
+
494
+	/**
495
+	 * registers core default stylesheets
496
+	 */
497
+	private function loadCoreCss()
498
+	{
499
+		if ($this->template_config->enable_default_style) {
500
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
501
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
502
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
503
+			wp_register_style(
504
+				'espresso_default',
505
+				$default_stylesheet_path,
506
+				array('dashicons'),
507
+				EVENT_ESPRESSO_VERSION
508
+			);
509
+			//Load custom style sheet if available
510
+			if ($this->template_config->custom_style_sheet !== null) {
511
+				wp_register_style(
512
+					'espresso_custom_css',
513
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
514
+					array('espresso_default'),
515
+					EVENT_ESPRESSO_VERSION
516
+				);
517
+			}
518
+		}
519
+	}
520
+
521
+
522
+
523
+	/**
524
+	 * registers core default javascript
525
+	 */
526
+	private function loadCoreJs()
527
+	{
528
+		// load core js
529
+		wp_register_script(
530
+			'espresso_core',
531
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
532
+			array('jquery'),
533
+			EVENT_ESPRESSO_VERSION,
534
+			true
535
+		);
536
+	}
537
+
538
+
539
+
540
+	/**
541
+	 * registers jQuery Validate for form validation
542
+	 */
543
+	private function loadJqueryValidate()
544
+	{
545
+		// register jQuery Validate and additional methods
546
+		wp_register_script(
547
+			'jquery-validate',
548
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
549
+			array('jquery'),
550
+			'1.15.0',
551
+			true
552
+		);
553
+		wp_register_script(
554
+			'jquery-validate-extra-methods',
555
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
556
+			array('jquery', 'jquery-validate'),
557
+			'1.15.0',
558
+			true
559
+		);
560
+	}
561
+
562
+
563
+
564
+	/**
565
+	 * registers accounting.js for performing client-side calculations
566
+	 */
567
+	private function loadAccountingJs()
568
+	{
569
+		//accounting.js library
570
+		// @link http://josscrowcroft.github.io/accounting.js/
571
+		wp_register_script(
572
+			'ee-accounting-core',
573
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
574
+			array('underscore'),
575
+			'0.3.2',
576
+			true
577
+		);
578
+		wp_register_script(
579
+			'ee-accounting',
580
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
581
+			array('ee-accounting-core'),
582
+			EVENT_ESPRESSO_VERSION,
583
+			true
584
+		);
585
+	}
586
+
587
+
588
+
589
+	/**
590
+	 * registers accounting.js for performing client-side calculations
591
+	 */
592
+	private function localizeAccountingJs()
593
+	{
594
+		wp_localize_script(
595
+			'ee-accounting',
596
+			'EE_ACCOUNTING_CFG',
597
+			array(
598
+				'currency' => array(
599
+					'symbol'    => $this->currency_config->sign,
600
+					'format'    => array(
601
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
602
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
603
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
604
+					),
605
+					'decimal'   => $this->currency_config->dec_mrk,
606
+					'thousand'  => $this->currency_config->thsnds,
607
+					'precision' => $this->currency_config->dec_plc,
608
+				),
609
+				'number'   => array(
610
+					'precision' => $this->currency_config->dec_plc,
611
+					'thousand'  => $this->currency_config->thsnds,
612
+					'decimal'   => $this->currency_config->dec_mrk,
613
+				),
614
+			)
615
+		);
616
+		$this->addRegisteredScriptHandlesWithData('ee-accounting');
617
+	}
618
+
619
+
620
+
621
+	/**
622
+	 * registers assets for cleaning your ears
623
+	 */
624
+	private function loadQtipJs()
625
+	{
626
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
627
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
628
+		if (apply_filters('FHEE_load_qtip', false)) {
629
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
630
+		}
631
+	}
632
+
633
+
634
+	/**
635
+	 * This is used to set registered script handles that have data.
636
+	 * @param string $script_handle
637
+	 */
638
+	private function addRegisteredScriptHandlesWithData($script_handle)
639
+	{
640
+		$this->script_handles_with_data[$script_handle] = $script_handle;
641
+	}
642
+
643
+
644
+	/**
645
+	 * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
646
+	 * Dependency stored in WP_Scripts if its set.
647
+	 */
648
+	private function removeAlreadyRegisteredDataForScriptHandles()
649
+	{
650
+		if (empty($this->script_handles_with_data)) {
651
+			return;
652
+		}
653
+		foreach ($this->script_handles_with_data as $script_handle) {
654
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
655
+		}
656
+	}
657
+
658
+
659
+	/**
660
+	 * Removes any data dependency registered in WP_Scripts if its set.
661
+	 * @param string $script_handle
662
+	 */
663
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
664
+	{
665
+		if (isset($this->script_handles_with_data[$script_handle])) {
666
+			global $wp_scripts;
667
+			if ($wp_scripts->get_data($script_handle, 'data')) {
668
+				unset($wp_scripts->registered[$script_handle]->extra['data']);
669
+				unset($this->script_handles_with_data[$script_handle]);
670
+			}
671
+		}
672
+	}
673
+
674
+
675
+	/**
676
+	 * Registers assets that are used in the WordPress admin.
677
+	 */
678
+	private function registerAdminAssets()
679
+	{
680
+		wp_register_script(
681
+			'ee-wp-plugins-page',
682
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
683
+			array(
684
+				'jquery',
685
+				'ee-vendor-react'
686
+			),
687
+			null,
688
+			true
689
+		);
690
+		wp_register_style(
691
+			'ee-wp-plugins-page',
692
+			$this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
693
+			array(),
694
+			null
695
+		);
696
+		$this->registerTranslationsForHandles(array('ee-wp-plugins-page'));
697
+	}
698
+
699
+
700
+	/**
701
+	 * All handles that are registered via the registry that might have translations have their translations registered
702
+	 *
703
+	 * @param array $handles_to_register
704
+	 */
705
+	private function registerTranslationsForHandles(array $handles_to_register)
706
+	{
707
+		foreach($handles_to_register as $handle) {
708
+			$this->i18n_registry->registerScriptI18n($handle, 'event_espresso');
709
+		}
710
+	}
711 711
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $this->registerManifestFile(
114 114
             self::ASSET_NAMESPACE,
115 115
             $this->domain->distributionAssetsUrl(),
116
-            $this->domain->distributionAssetsPath() . 'build-manifest.json'
116
+            $this->domain->distributionAssetsPath().'build-manifest.json'
117 117
         );
118 118
         add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
119 119
         add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             //js.api
171 171
             wp_register_script(
172 172
                 'eejs-api',
173
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
173
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
174 174
                 array('underscore', 'eejs-core'),
175 175
                 EVENT_ESPRESSO_VERSION,
176 176
                 true
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
179 179
             $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
180 180
         }
181
-        if (! is_admin()) {
181
+        if ( ! is_admin()) {
182 182
             $this->loadCoreCss();
183 183
         }
184 184
         $this->registerTranslationsForHandles(array('eejs-core'));
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function addTemplate($template_reference, $template_content)
279 279
     {
280
-        if (! isset($this->jsdata['templates'])) {
280
+        if ( ! isset($this->jsdata['templates'])) {
281 281
             $this->jsdata['templates'] = array();
282 282
         }
283 283
         //no overrides allowed.
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
             return;
426 426
         }
427 427
         $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
428
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
428
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
429 429
             $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
430 430
         }
431 431
     }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
      */
443 443
     private function decodeManifestFile($manifest_file)
444 444
     {
445
-        if (! file_exists($manifest_file)) {
445
+        if ( ! file_exists($manifest_file)) {
446 446
             throw new InvalidFilePathException($manifest_file);
447 447
         }
448 448
         return json_decode(file_get_contents($manifest_file), true);
@@ -497,9 +497,9 @@  discard block
 block discarded – undo
497 497
     private function loadCoreCss()
498 498
     {
499 499
         if ($this->template_config->enable_default_style) {
500
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
500
+            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
501 501
                 ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
502
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
502
+                : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css';
503 503
             wp_register_style(
504 504
                 'espresso_default',
505 505
                 $default_stylesheet_path,
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
             if ($this->template_config->custom_style_sheet !== null) {
511 511
                 wp_register_style(
512 512
                     'espresso_custom_css',
513
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
513
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
514 514
                     array('espresso_default'),
515 515
                     EVENT_ESPRESSO_VERSION
516 516
                 );
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
         // load core js
529 529
         wp_register_script(
530 530
             'espresso_core',
531
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
531
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
532 532
             array('jquery'),
533 533
             EVENT_ESPRESSO_VERSION,
534 534
             true
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
         // register jQuery Validate and additional methods
546 546
         wp_register_script(
547 547
             'jquery-validate',
548
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
548
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
549 549
             array('jquery'),
550 550
             '1.15.0',
551 551
             true
552 552
         );
553 553
         wp_register_script(
554 554
             'jquery-validate-extra-methods',
555
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
555
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
556 556
             array('jquery', 'jquery-validate'),
557 557
             '1.15.0',
558 558
             true
@@ -570,14 +570,14 @@  discard block
 block discarded – undo
570 570
         // @link http://josscrowcroft.github.io/accounting.js/
571 571
         wp_register_script(
572 572
             'ee-accounting-core',
573
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
573
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
574 574
             array('underscore'),
575 575
             '0.3.2',
576 576
             true
577 577
         );
578 578
         wp_register_script(
579 579
             'ee-accounting',
580
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
580
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
581 581
             array('ee-accounting-core'),
582 582
             EVENT_ESPRESSO_VERSION,
583 583
             true
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
      */
705 705
     private function registerTranslationsForHandles(array $handles_to_register)
706 706
     {
707
-        foreach($handles_to_register as $handle) {
707
+        foreach ($handles_to_register as $handle) {
708 708
             $this->i18n_registry->registerScriptI18n($handle, 'event_espresso');
709 709
         }
710 710
     }
Please login to merge, or discard this patch.
core/services/assets/I18nRegistry.php 2 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -14,228 +14,228 @@
 block discarded – undo
14 14
  */
15 15
 class I18nRegistry
16 16
 {
17
-    /**
18
-     * @var DomainInterface
19
-     */
20
-    private $domain;
21
-
22
-    /**
23
-     * Will hold all registered i18n scripts.
24
-     *
25
-     * @var array
26
-     */
27
-    private $registered_i18n = array();
28
-
29
-
30
-    /**
31
-     * Used to hold queued translations for the chunks loading in a view.
32
-     *
33
-     * @var array
34
-     */
35
-    private $queued_handle_translations = array();
36
-
37
-
38
-    /**
39
-     * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to
40
-     * translation strings.
41
-     *
42
-     * @var array
43
-     */
44
-    private $i18n_map;
45
-
46
-
47
-    /**
48
-     * I18nRegistry constructor.
49
-     *
50
-     * @param DomainInterface $domain
51
-     * @param array() $i18n_map  An array of script handle names and the strings translated for those handles.  If not
52
-     *                            provided, the class will look for map in root of plugin with filename of
53
-     *                            'translation-map.json'.
54
-     */
55
-    public function __construct(DomainInterface $domain, array $i18n_map = array())
56
-    {
57
-        $this->domain = $domain;
58
-        $this->setI18nMap($i18n_map);
59
-        add_filter('print_scripts_array', array($this, 'queueI18n'));
60
-    }
61
-
62
-
63
-    /**
64
-     * Used to register a script that has i18n strings for its $handle
65
-     *
66
-     * @param string $handle The script handle reference.
67
-     * @param string $domain The i18n domain for the strings.
68
-     */
69
-    public function registerScriptI18n($handle, $domain)
70
-    {
71
-        $this->registered_i18n[$handle] = $domain;
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data.
78
-     *
79
-     * @param array $handles Array of registered script handles.
80
-     * @return array
81
-     */
82
-    public function queueI18n(array $handles)
83
-    {
84
-        if (empty($this->registered_i18n) || empty($this->i18n_map)) {
85
-            return $handles;
86
-        }
87
-        foreach ($handles as $handle) {
88
-            $this->queueI18nTranslationsForHandle($handle);
89
-        }
90
-        if ($this->queued_handle_translations) {
91
-            foreach ($this->queued_handle_translations as $handle => $translations_for_domain) {
92
-                $this->registerInlineScript(
93
-                    $handle,
94
-                    $translations_for_domain['translations'],
95
-                    $translations_for_domain['domain']
96
-                );
97
-            }
98
-        }
99
-        return $handles;
100
-    }
101
-
102
-
103
-    /**
104
-     * Registers inline script with translations for given handle and domain.
105
-     *
106
-     * @param string $handle       Handle used to register javascript file containing translations.
107
-     * @param array  $translations Array of string translations.
108
-     * @param string $domain       Domain for translations.  If left empty then strings are registered with the default
109
-     *                             domain for the javascript.
110
-     */
111
-    private function registerInlineScript($handle, array $translations, $domain = '')
112
-    {
113
-        $script = $domain ?
114
-            'wp.i18n.setLocaleData( ' . json_encode($translations) . ', ' . $domain . ' );' :
115
-            'wp.i18n.setLocaleData( ' . json_encode($translations) . ' );';
116
-        wp_add_inline_script($handle, $script, 'before');
117
-    }
118
-
119
-
120
-    /**
121
-     * Queues up the translation strings for the given handle.
122
-     *
123
-     * @param string $handle The script handle being queued up.
124
-     */
125
-    private function queueI18nTranslationsForHandle($handle)
126
-    {
127
-        if (isset($this->registered_i18n[$handle])) {
128
-            $domain = $this->registered_i18n[$handle];
129
-            $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain);
130
-            if (count($translations) > 1) {
131
-                $this->queued_handle_translations[$handle] = array(
132
-                    'domain'       => $domain,
133
-                    'translations' => $translations,
134
-                );
135
-            }
136
-            unset($this->registered_i18n[$handle]);
137
-        }
138
-    }
139
-
140
-
141
-    /**
142
-     * Sets the internal i18n_map property.
143
-     * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map.
144
-     *
145
-     * @param array $i18n_map  If provided, an array of translation strings indexed by script handle names they
146
-     *                         correspond to.
147
-     */
148
-    private function setI18nMap(array $i18n_map)
149
-    {
150
-        if (empty($i18n_map)) {
151
-            $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json')
152
-                ? json_decode(
153
-                        file_get_contents($this->domain->pluginPath() . 'translation-map.json'),
154
-                        true
155
-                    )
156
-                : array();
157
-        }
158
-        $this->i18n_map = $i18n_map;
159
-    }
160
-
161
-
162
-    /**
163
-     * Get the jed locale data for a given $handle and domain
164
-     *
165
-     * @param string $handle The name for the script handle we want strings returned for.
166
-     * @param string $domain The i18n domain.
167
-     * @return array
168
-     */
169
-    protected function getJedLocaleDataForDomainAndChunk($handle, $domain)
170
-    {
171
-        $translations = $this->getJedLocaleData($domain);
172
-        // get index for adding back after extracting strings for this $chunk.
173
-        $index = $translations[''];
174
-        $translations = $this->getLocaleDataMatchingMap(
175
-            $this->getOriginalStringsForHandleFromMap($handle),
176
-            $translations
177
-        );
178
-        $translations[''] = $index;
179
-        return $translations;
180
-    }
181
-
182
-
183
-    /**
184
-     * Get locale data for given strings from given translations
185
-     *
186
-     * @param array $string_set   This is the subset of strings (msgIds) we want to extract from the translations array.
187
-     * @param array $translations Translation data to extra strings from.
188
-     * @return array
189
-     */
190
-    protected function getLocaleDataMatchingMap(array $string_set, array $translations)
191
-    {
192
-        if (empty($string_set)) {
193
-            return array();
194
-        }
195
-        // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are
196
-        // slashed also filter falsey values.
197
-        $string_set = array_unique(array_filter(wp_slash($string_set)));
198
-        return array_intersect_key($translations, array_flip($string_set));
199
-    }
200
-
201
-
202
-    /**
203
-     * Get original strings to translate for the given chunk from the map
204
-     *
205
-     * @param string $handle The script handle name to get strings from the map for.
206
-     * @return array
207
-     */
208
-    protected function getOriginalStringsForHandleFromMap($handle)
209
-    {
210
-        return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array();
211
-    }
212
-
213
-
214
-    /**
215
-     * Returns Jed-formatted localization data.
216
-     *
217
-     * @param  string $domain Translation domain.
218
-     * @return array
219
-     */
220
-    private function getJedLocaleData($domain)
221
-    {
222
-        $translations = get_translations_for_domain($domain);
223
-
224
-        $locale = array(
225
-            '' => array(
226
-                'domain' => $domain,
227
-                'lang'   => is_admin() ? get_user_locale() : get_locale(),
228
-            ),
229
-        );
230
-
231
-        if (! empty($translations->headers['Plural-Forms'])) {
232
-            $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
233
-        }
234
-
235
-        foreach ($translations->entries as $msgid => $entry) {
236
-            $locale[$msgid] = $entry->translations;
237
-        }
238
-
239
-        return $locale;
240
-    }
17
+	/**
18
+	 * @var DomainInterface
19
+	 */
20
+	private $domain;
21
+
22
+	/**
23
+	 * Will hold all registered i18n scripts.
24
+	 *
25
+	 * @var array
26
+	 */
27
+	private $registered_i18n = array();
28
+
29
+
30
+	/**
31
+	 * Used to hold queued translations for the chunks loading in a view.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	private $queued_handle_translations = array();
36
+
37
+
38
+	/**
39
+	 * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to
40
+	 * translation strings.
41
+	 *
42
+	 * @var array
43
+	 */
44
+	private $i18n_map;
45
+
46
+
47
+	/**
48
+	 * I18nRegistry constructor.
49
+	 *
50
+	 * @param DomainInterface $domain
51
+	 * @param array() $i18n_map  An array of script handle names and the strings translated for those handles.  If not
52
+	 *                            provided, the class will look for map in root of plugin with filename of
53
+	 *                            'translation-map.json'.
54
+	 */
55
+	public function __construct(DomainInterface $domain, array $i18n_map = array())
56
+	{
57
+		$this->domain = $domain;
58
+		$this->setI18nMap($i18n_map);
59
+		add_filter('print_scripts_array', array($this, 'queueI18n'));
60
+	}
61
+
62
+
63
+	/**
64
+	 * Used to register a script that has i18n strings for its $handle
65
+	 *
66
+	 * @param string $handle The script handle reference.
67
+	 * @param string $domain The i18n domain for the strings.
68
+	 */
69
+	public function registerScriptI18n($handle, $domain)
70
+	{
71
+		$this->registered_i18n[$handle] = $domain;
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data.
78
+	 *
79
+	 * @param array $handles Array of registered script handles.
80
+	 * @return array
81
+	 */
82
+	public function queueI18n(array $handles)
83
+	{
84
+		if (empty($this->registered_i18n) || empty($this->i18n_map)) {
85
+			return $handles;
86
+		}
87
+		foreach ($handles as $handle) {
88
+			$this->queueI18nTranslationsForHandle($handle);
89
+		}
90
+		if ($this->queued_handle_translations) {
91
+			foreach ($this->queued_handle_translations as $handle => $translations_for_domain) {
92
+				$this->registerInlineScript(
93
+					$handle,
94
+					$translations_for_domain['translations'],
95
+					$translations_for_domain['domain']
96
+				);
97
+			}
98
+		}
99
+		return $handles;
100
+	}
101
+
102
+
103
+	/**
104
+	 * Registers inline script with translations for given handle and domain.
105
+	 *
106
+	 * @param string $handle       Handle used to register javascript file containing translations.
107
+	 * @param array  $translations Array of string translations.
108
+	 * @param string $domain       Domain for translations.  If left empty then strings are registered with the default
109
+	 *                             domain for the javascript.
110
+	 */
111
+	private function registerInlineScript($handle, array $translations, $domain = '')
112
+	{
113
+		$script = $domain ?
114
+			'wp.i18n.setLocaleData( ' . json_encode($translations) . ', ' . $domain . ' );' :
115
+			'wp.i18n.setLocaleData( ' . json_encode($translations) . ' );';
116
+		wp_add_inline_script($handle, $script, 'before');
117
+	}
118
+
119
+
120
+	/**
121
+	 * Queues up the translation strings for the given handle.
122
+	 *
123
+	 * @param string $handle The script handle being queued up.
124
+	 */
125
+	private function queueI18nTranslationsForHandle($handle)
126
+	{
127
+		if (isset($this->registered_i18n[$handle])) {
128
+			$domain = $this->registered_i18n[$handle];
129
+			$translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain);
130
+			if (count($translations) > 1) {
131
+				$this->queued_handle_translations[$handle] = array(
132
+					'domain'       => $domain,
133
+					'translations' => $translations,
134
+				);
135
+			}
136
+			unset($this->registered_i18n[$handle]);
137
+		}
138
+	}
139
+
140
+
141
+	/**
142
+	 * Sets the internal i18n_map property.
143
+	 * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map.
144
+	 *
145
+	 * @param array $i18n_map  If provided, an array of translation strings indexed by script handle names they
146
+	 *                         correspond to.
147
+	 */
148
+	private function setI18nMap(array $i18n_map)
149
+	{
150
+		if (empty($i18n_map)) {
151
+			$i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json')
152
+				? json_decode(
153
+						file_get_contents($this->domain->pluginPath() . 'translation-map.json'),
154
+						true
155
+					)
156
+				: array();
157
+		}
158
+		$this->i18n_map = $i18n_map;
159
+	}
160
+
161
+
162
+	/**
163
+	 * Get the jed locale data for a given $handle and domain
164
+	 *
165
+	 * @param string $handle The name for the script handle we want strings returned for.
166
+	 * @param string $domain The i18n domain.
167
+	 * @return array
168
+	 */
169
+	protected function getJedLocaleDataForDomainAndChunk($handle, $domain)
170
+	{
171
+		$translations = $this->getJedLocaleData($domain);
172
+		// get index for adding back after extracting strings for this $chunk.
173
+		$index = $translations[''];
174
+		$translations = $this->getLocaleDataMatchingMap(
175
+			$this->getOriginalStringsForHandleFromMap($handle),
176
+			$translations
177
+		);
178
+		$translations[''] = $index;
179
+		return $translations;
180
+	}
181
+
182
+
183
+	/**
184
+	 * Get locale data for given strings from given translations
185
+	 *
186
+	 * @param array $string_set   This is the subset of strings (msgIds) we want to extract from the translations array.
187
+	 * @param array $translations Translation data to extra strings from.
188
+	 * @return array
189
+	 */
190
+	protected function getLocaleDataMatchingMap(array $string_set, array $translations)
191
+	{
192
+		if (empty($string_set)) {
193
+			return array();
194
+		}
195
+		// some strings with quotes in them will break on the array_flip, so making sure quotes in the string are
196
+		// slashed also filter falsey values.
197
+		$string_set = array_unique(array_filter(wp_slash($string_set)));
198
+		return array_intersect_key($translations, array_flip($string_set));
199
+	}
200
+
201
+
202
+	/**
203
+	 * Get original strings to translate for the given chunk from the map
204
+	 *
205
+	 * @param string $handle The script handle name to get strings from the map for.
206
+	 * @return array
207
+	 */
208
+	protected function getOriginalStringsForHandleFromMap($handle)
209
+	{
210
+		return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array();
211
+	}
212
+
213
+
214
+	/**
215
+	 * Returns Jed-formatted localization data.
216
+	 *
217
+	 * @param  string $domain Translation domain.
218
+	 * @return array
219
+	 */
220
+	private function getJedLocaleData($domain)
221
+	{
222
+		$translations = get_translations_for_domain($domain);
223
+
224
+		$locale = array(
225
+			'' => array(
226
+				'domain' => $domain,
227
+				'lang'   => is_admin() ? get_user_locale() : get_locale(),
228
+			),
229
+		);
230
+
231
+		if (! empty($translations->headers['Plural-Forms'])) {
232
+			$locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
233
+		}
234
+
235
+		foreach ($translations->entries as $msgid => $entry) {
236
+			$locale[$msgid] = $entry->translations;
237
+		}
238
+
239
+		return $locale;
240
+	}
241 241
 }
242 242
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -111,8 +111,7 @@  discard block
 block discarded – undo
111 111
     private function registerInlineScript($handle, array $translations, $domain = '')
112 112
     {
113 113
         $script = $domain ?
114
-            'wp.i18n.setLocaleData( ' . json_encode($translations) . ', ' . $domain . ' );' :
115
-            'wp.i18n.setLocaleData( ' . json_encode($translations) . ' );';
114
+            'wp.i18n.setLocaleData( '.json_encode($translations).', '.$domain.' );' : 'wp.i18n.setLocaleData( '.json_encode($translations).' );';
116 115
         wp_add_inline_script($handle, $script, 'before');
117 116
     }
118 117
 
@@ -148,9 +147,9 @@  discard block
 block discarded – undo
148 147
     private function setI18nMap(array $i18n_map)
149 148
     {
150 149
         if (empty($i18n_map)) {
151
-            $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json')
150
+            $i18n_map = file_exists($this->domain->pluginPath().'translation-map.json')
152 151
                 ? json_decode(
153
-                        file_get_contents($this->domain->pluginPath() . 'translation-map.json'),
152
+                        file_get_contents($this->domain->pluginPath().'translation-map.json'),
154 153
                         true
155 154
                     )
156 155
                 : array();
@@ -228,7 +227,7 @@  discard block
 block discarded – undo
228 227
             ),
229 228
         );
230 229
 
231
-        if (! empty($translations->headers['Plural-Forms'])) {
230
+        if ( ! empty($translations->headers['Plural-Forms'])) {
232 231
             $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
233 232
         }
234 233
 
Please login to merge, or discard this patch.