Completed
Branch BUG-10236-FIX-RESET-CAPABILITI... (cbd980)
by
unknown
26:22 queued 14:04
created
core/EE_Registry.core.php 1 patch
Indentation   +1393 added lines, -1393 removed lines patch added patch discarded remove patch
@@ -16,1435 +16,1435 @@
 block discarded – undo
16 16
 class EE_Registry
17 17
 {
18 18
 
19
-    /**
20
-     *    EE_Registry Object
21
-     *
22
-     * @var EE_Registry $_instance
23
-     * @access    private
24
-     */
25
-    private static $_instance = null;
26
-
27
-    /**
28
-     * @var EE_Dependency_Map $_dependency_map
29
-     * @access    protected
30
-     */
31
-    protected $_dependency_map = null;
32
-
33
-    /**
34
-     * @var array $_class_abbreviations
35
-     * @access    protected
36
-     */
37
-    protected $_class_abbreviations = array();
38
-
39
-    /**
40
-     * @access public
41
-     * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
-     */
43
-    public $BUS;
44
-
45
-    /**
46
-     *    EE_Cart Object
47
-     *
48
-     * @access    public
49
-     * @var    EE_Cart $CART
50
-     */
51
-    public $CART = null;
52
-
53
-    /**
54
-     *    EE_Config Object
55
-     *
56
-     * @access    public
57
-     * @var    EE_Config $CFG
58
-     */
59
-    public $CFG = null;
60
-
61
-    /**
62
-     * EE_Network_Config Object
63
-     *
64
-     * @access public
65
-     * @var EE_Network_Config $NET_CFG
66
-     */
67
-    public $NET_CFG = null;
68
-
69
-    /**
70
-     *    StdClass object for storing library classes in
71
-     *
72
-     * @public LIB
73
-     * @var StdClass $LIB
74
-     */
75
-    public $LIB = null;
76
-
77
-    /**
78
-     *    EE_Request_Handler Object
79
-     *
80
-     * @access    public
81
-     * @var    EE_Request_Handler $REQ
82
-     */
83
-    public $REQ = null;
84
-
85
-    /**
86
-     *    EE_Session Object
87
-     *
88
-     * @access    public
89
-     * @var    EE_Session $SSN
90
-     */
91
-    public $SSN = null;
92
-
93
-    /**
94
-     * holds the ee capabilities object.
95
-     *
96
-     * @since 4.5.0
97
-     * @var EE_Capabilities
98
-     */
99
-    public $CAP = null;
100
-
101
-    /**
102
-     * holds the EE_Message_Resource_Manager object.
103
-     *
104
-     * @since 4.9.0
105
-     * @var EE_Message_Resource_Manager
106
-     */
107
-    public $MRM = null;
108
-
109
-
110
-    /**
111
-     * Holds the Assets Registry instance
112
-     * @var Registry
113
-     */
114
-    public $AssetsRegistry = null;
115
-
116
-    /**
117
-     *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
-     *
119
-     * @access    public
120
-     * @var    EE_Addon[]
121
-     */
122
-    public $addons = null;
123
-
124
-    /**
125
-     *    $models
126
-     * @access    public
127
-     * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
-     */
129
-    public $models = array();
130
-
131
-    /**
132
-     *    $modules
133
-     * @access    public
134
-     * @var    EED_Module[] $modules
135
-     */
136
-    public $modules = null;
137
-
138
-    /**
139
-     *    $shortcodes
140
-     * @access    public
141
-     * @var    EES_Shortcode[] $shortcodes
142
-     */
143
-    public $shortcodes = null;
144
-
145
-    /**
146
-     *    $widgets
147
-     * @access    public
148
-     * @var    WP_Widget[] $widgets
149
-     */
150
-    public $widgets = null;
151
-
152
-    /**
153
-     * $non_abstract_db_models
154
-     * @access public but its better to use EE_Registry::non_abstract_db_models() as it verifies we've set this property before returning it
155
-     * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
-     * classnames (eg "EEM_Event")
159
-     */
160
-    public $non_abstract_db_models = array();
161
-
162
-
163
-    /**
164
-     *    $i18n_js_strings - internationalization for JS strings
165
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
166
-     *    in js file:  var translatedString = eei18n.string_key;
167
-     *
168
-     * @access    public
169
-     * @var    array
170
-     */
171
-    public static $i18n_js_strings = array();
172
-
173
-
174
-    /**
175
-     *    $main_file - path to espresso.php
176
-     *
177
-     * @access    public
178
-     * @var    array
179
-     */
180
-    public $main_file;
181
-
182
-    /**
183
-     * array of ReflectionClass objects where the key is the class name
184
-     *
185
-     * @access    public
186
-     * @var ReflectionClass[]
187
-     */
188
-    public $_reflectors;
189
-
190
-    /**
191
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
192
-     *
193
-     * @access    protected
194
-     * @var boolean $_cache_on
195
-     */
196
-    protected $_cache_on = true;
197
-
198
-
199
-
200
-    /**
201
-     * @singleton method used to instantiate class object
202
-     * @access    public
203
-     * @param  \EE_Dependency_Map $dependency_map
204
-     * @return \EE_Registry instance
205
-     */
206
-    public static function instance(\EE_Dependency_Map $dependency_map = null)
207
-    {
208
-        // check if class object is instantiated
209
-        if ( ! self::$_instance instanceof EE_Registry) {
210
-            self::$_instance = new EE_Registry($dependency_map);
211
-        }
212
-        return self::$_instance;
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     *protected constructor to prevent direct creation
219
-     *
220
-     * @Constructor
221
-     * @access protected
222
-     * @param  \EE_Dependency_Map $dependency_map
223
-     * @return \EE_Registry
224
-     */
225
-    protected function __construct(\EE_Dependency_Map $dependency_map)
226
-    {
227
-        $this->_dependency_map = $dependency_map;
228
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * initialize
235
-     */
236
-    public function initialize()
237
-    {
238
-        $this->_class_abbreviations = apply_filters(
239
-            'FHEE__EE_Registry____construct___class_abbreviations',
240
-            array(
241
-                'EE_Config'                                       => 'CFG',
242
-                'EE_Session'                                      => 'SSN',
243
-                'EE_Capabilities'                                 => 'CAP',
244
-                'EE_Cart'                                         => 'CART',
245
-                'EE_Network_Config'                               => 'NET_CFG',
246
-                'EE_Request_Handler'                              => 'REQ',
247
-                'EE_Message_Resource_Manager'                     => 'MRM',
248
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
249
-                'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
250
-            )
251
-        );
252
-        // class library
253
-        $this->LIB = new stdClass();
254
-        $this->addons = new stdClass();
255
-        $this->modules = new stdClass();
256
-        $this->shortcodes = new stdClass();
257
-        $this->widgets = new stdClass();
258
-        $this->load_core('Base', array(), true);
259
-        // add our request and response objects to the cache
260
-        $request_loader = $this->_dependency_map->class_loader('EE_Request');
261
-        $this->_set_cached_class(
262
-            $request_loader(),
263
-            'EE_Request'
264
-        );
265
-        $response_loader = $this->_dependency_map->class_loader('EE_Response');
266
-        $this->_set_cached_class(
267
-            $response_loader(),
268
-            'EE_Response'
269
-        );
270
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
271
-    }
272
-
273
-
274
-
275
-    /**
276
-     *    init
277
-     *
278
-     * @access    public
279
-     * @return    void
280
-     */
281
-    public function init()
282
-    {
283
-        // Get current page protocol
284
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
285
-        // Output admin-ajax.php URL with same protocol as current page
286
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
287
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * localize_i18n_js_strings
294
-     *
295
-     * @return string
296
-     */
297
-    public static function localize_i18n_js_strings()
298
-    {
299
-        $i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
300
-        foreach ($i18n_js_strings as $key => $value) {
301
-            if (is_scalar($value)) {
302
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
303
-            }
304
-        }
305
-        return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * @param mixed string | EED_Module $module
312
-     */
313
-    public function add_module($module)
314
-    {
315
-        if ($module instanceof EED_Module) {
316
-            $module_class = get_class($module);
317
-            $this->modules->{$module_class} = $module;
318
-        } else {
319
-            if ( ! class_exists('EE_Module_Request_Router')) {
320
-                $this->load_core('Module_Request_Router');
321
-            }
322
-            $this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
323
-        }
324
-    }
325
-
326
-
327
-
328
-    /**
329
-     * @param string $module_name
330
-     * @return mixed EED_Module | NULL
331
-     */
332
-    public function get_module($module_name = '')
333
-    {
334
-        return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
335
-    }
336
-
337
-
338
-
339
-    /**
340
-     *    loads core classes - must be singletons
341
-     *
342
-     * @access    public
343
-     * @param string $class_name - simple class name ie: session
344
-     * @param mixed  $arguments
345
-     * @param bool   $load_only
346
-     * @return mixed
347
-     */
348
-    public function load_core($class_name, $arguments = array(), $load_only = false)
349
-    {
350
-        $core_paths = apply_filters(
351
-            'FHEE__EE_Registry__load_core__core_paths',
352
-            array(
353
-                EE_CORE,
354
-                EE_ADMIN,
355
-                EE_CPTS,
356
-                EE_CORE . 'data_migration_scripts' . DS,
357
-                EE_CORE . 'request_stack' . DS,
358
-                EE_CORE . 'middleware' . DS,
359
-            )
360
-        );
361
-        // retrieve instantiated class
362
-        return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     *    loads service classes
369
-     *
370
-     * @access    public
371
-     * @param string $class_name - simple class name ie: session
372
-     * @param mixed  $arguments
373
-     * @param bool   $load_only
374
-     * @return mixed
375
-     */
376
-    public function load_service($class_name, $arguments = array(), $load_only = false)
377
-    {
378
-        $service_paths = apply_filters(
379
-            'FHEE__EE_Registry__load_service__service_paths',
380
-            array(
381
-                EE_CORE . 'services' . DS,
382
-            )
383
-        );
384
-        // retrieve instantiated class
385
-        return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
386
-    }
387
-
388
-
389
-
390
-    /**
391
-     *    loads data_migration_scripts
392
-     *
393
-     * @access    public
394
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
395
-     * @param mixed  $arguments
396
-     * @return EE_Data_Migration_Script_Base|mixed
397
-     */
398
-    public function load_dms($class_name, $arguments = array())
399
-    {
400
-        // retrieve instantiated class
401
-        return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     *    loads object creating classes - must be singletons
408
-     *
409
-     * @param string $class_name - simple class name ie: attendee
410
-     * @param mixed  $arguments  - an array of arguments to pass to the class
411
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
412
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
413
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
414
-     * @return EE_Base_Class | bool
415
-     */
416
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
-    {
418
-        $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
419
-            EE_CORE,
420
-            EE_CLASSES,
421
-            EE_BUSINESS,
422
-        ));
423
-        // retrieve instantiated class
424
-        return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     *    loads helper classes - must be singletons
431
-     *
432
-     * @param string $class_name - simple class name ie: price
433
-     * @param mixed  $arguments
434
-     * @param bool   $load_only
435
-     * @return EEH_Base | bool
436
-     */
437
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
438
-    {
439
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
440
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
441
-        // retrieve instantiated class
442
-        return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
443
-    }
444
-
445
-
446
-
447
-    /**
448
-     *    loads core classes - must be singletons
449
-     *
450
-     * @access    public
451
-     * @param string $class_name - simple class name ie: session
452
-     * @param mixed  $arguments
453
-     * @param bool   $load_only
454
-     * @param bool   $cache      whether to cache the object or not.
455
-     * @return mixed
456
-     */
457
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
458
-    {
459
-        $paths = array(
460
-            EE_LIBRARIES,
461
-            EE_LIBRARIES . 'messages' . DS,
462
-            EE_LIBRARIES . 'shortcodes' . DS,
463
-            EE_LIBRARIES . 'qtips' . DS,
464
-            EE_LIBRARIES . 'payment_methods' . DS,
465
-        );
466
-        // retrieve instantiated class
467
-        return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
468
-    }
469
-
470
-
471
-
472
-    /**
473
-     *    loads model classes - must be singletons
474
-     *
475
-     * @param string $class_name - simple class name ie: price
476
-     * @param mixed  $arguments
477
-     * @param bool   $load_only
478
-     * @return EEM_Base | bool
479
-     */
480
-    public function load_model($class_name, $arguments = array(), $load_only = false)
481
-    {
482
-        $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
483
-            EE_MODELS,
484
-            EE_CORE,
485
-        ));
486
-        // retrieve instantiated class
487
-        return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
488
-    }
489
-
490
-
491
-
492
-    /**
493
-     *    loads model classes - must be singletons
494
-     *
495
-     * @param string $class_name - simple class name ie: price
496
-     * @param mixed  $arguments
497
-     * @param bool   $load_only
498
-     * @return mixed | bool
499
-     */
500
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
501
-    {
502
-        $paths = array(
503
-            EE_MODELS . 'fields' . DS,
504
-            EE_MODELS . 'helpers' . DS,
505
-            EE_MODELS . 'relations' . DS,
506
-            EE_MODELS . 'strategies' . DS,
507
-        );
508
-        // retrieve instantiated class
509
-        return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
510
-    }
511
-
512
-
513
-
514
-    /**
515
-     * Determines if $model_name is the name of an actual EE model.
516
-     *
517
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
518
-     * @return boolean
519
-     */
520
-    public function is_model_name($model_name)
521
-    {
522
-        $this->_verify_models_discovered();
523
-        return isset($this->models[$model_name]) ? true : false;
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    generic class loader
530
-     *
531
-     * @param string $path_to_file - directory path to file location, not including filename
532
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
533
-     * @param string $type         - file type - core? class? helper? model?
534
-     * @param mixed  $arguments
535
-     * @param bool   $load_only
536
-     * @return mixed
537
-     */
538
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
539
-    {
540
-        // retrieve instantiated class
541
-        return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
542
-    }
543
-
544
-
545
-
546
-    /**
547
-     *    load_addon
548
-     *
549
-     * @param string $path_to_file - directory path to file location, not including filename
550
-     * @param string $class_name   - full class name  ie:  My_Class
551
-     * @param string $type         - file type - core? class? helper? model?
552
-     * @param mixed  $arguments
553
-     * @param bool   $load_only
554
-     * @return EE_Addon
555
-     */
556
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
557
-    {
558
-        // retrieve instantiated class
559
-        return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
560
-    }
561
-
562
-
563
-
564
-    /**
565
-     * instantiates, caches, and automatically resolves dependencies
566
-     * for classes that use a Fully Qualified Class Name.
567
-     * if the class is not capable of being loaded using PSR-4 autoloading,
568
-     * then you need to use one of the existing load_*() methods
569
-     * which can resolve the classname and filepath from the passed arguments
570
-     *
571
-     * @param bool|string $class_name   Fully Qualified Class Name
572
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
573
-     * @param bool        $cache        whether to cache the instantiated object for reuse
574
-     * @param bool        $from_db      some classes are instantiated from the db
575
-     *                                  and thus call a different method to instantiate
576
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
577
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
578
-     * @return mixed                    null = failure to load or instantiate class object.
579
-     *                                  object = class loaded and instantiated successfully.
580
-     *                                  bool = fail or success when $load_only is true
581
-     */
582
-    public function create(
583
-        $class_name = false,
584
-        $arguments = array(),
585
-        $cache = false,
586
-        $from_db = false,
587
-        $load_only = false,
588
-        $addon = false
589
-    ) {
590
-        $class_name = ltrim($class_name, '\\');
591
-        $class_name = $this->_dependency_map->get_alias($class_name);
592
-        if ( ! class_exists($class_name)) {
593
-            // maybe the class is registered with a preceding \
594
-            $class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
595
-            // still doesn't exist ?
596
-            if ( ! class_exists($class_name)) {
597
-                return null;
598
-            }
599
-        }
600
-        // if we're only loading the class and it already exists, then let's just return true immediately
601
-        if ($load_only) {
602
-            return true;
603
-        }
604
-        $addon = $addon ? 'addon' : '';
605
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
606
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
607
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
608
-        if ($this->_cache_on && $cache && ! $load_only) {
609
-            // return object if it's already cached
610
-            $cached_class = $this->_get_cached_class($class_name, $addon);
611
-            if ($cached_class !== null) {
612
-                return $cached_class;
613
-            }
614
-        }
615
-        // instantiate the requested object
616
-        $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
617
-        if ($this->_cache_on && $cache) {
618
-            // save it for later... kinda like gum  { : $
619
-            $this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
620
-        }
621
-        $this->_cache_on = true;
622
-        return $class_obj;
623
-    }
624
-
625
-
626
-
627
-    /**
628
-     * instantiates, caches, and injects dependencies for classes
629
-     *
630
-     * @param array       $file_paths   an array of paths to folders to look in
631
-     * @param string      $class_prefix EE  or EEM or... ???
632
-     * @param bool|string $class_name   $class name
633
-     * @param string      $type         file type - core? class? helper? model?
634
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
635
-     * @param bool        $from_db      some classes are instantiated from the db
636
-     *                                  and thus call a different method to instantiate
637
-     * @param bool        $cache        whether to cache the instantiated object for reuse
638
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
639
-     * @return null|object|bool         null = failure to load or instantiate class object.
640
-     *                                  object = class loaded and instantiated successfully.
641
-     *                                  bool = fail or success when $load_only is true
642
-     */
643
-    protected function _load(
644
-        $file_paths = array(),
645
-        $class_prefix = 'EE_',
646
-        $class_name = false,
647
-        $type = 'class',
648
-        $arguments = array(),
649
-        $from_db = false,
650
-        $cache = true,
651
-        $load_only = false
652
-    ) {
653
-        $class_name = ltrim($class_name, '\\');
654
-        // strip php file extension
655
-        $class_name = str_replace('.php', '', trim($class_name));
656
-        // does the class have a prefix ?
657
-        if ( ! empty($class_prefix) && $class_prefix != 'addon') {
658
-            // make sure $class_prefix is uppercase
659
-            $class_prefix = strtoupper(trim($class_prefix));
660
-            // add class prefix ONCE!!!
661
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
662
-        }
663
-        $class_name = $this->_dependency_map->get_alias($class_name);
664
-        $class_exists = class_exists($class_name);
665
-        // if we're only loading the class and it already exists, then let's just return true immediately
666
-        if ($load_only && $class_exists) {
667
-            return true;
668
-        }
669
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
670
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
671
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
672
-        if ($this->_cache_on && $cache && ! $load_only) {
673
-            // return object if it's already cached
674
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix);
675
-            if ($cached_class !== null) {
676
-                return $cached_class;
677
-            }
678
-        }
679
-        // if the class doesn't already exist.. then we need to try and find the file and load it
680
-        if ( ! $class_exists) {
681
-            // get full path to file
682
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
683
-            // load the file
684
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
685
-            // if loading failed, or we are only loading a file but NOT instantiating an object
686
-            if ( ! $loaded || $load_only) {
687
-                // return boolean if only loading, or null if an object was expected
688
-                return $load_only ? $loaded : null;
689
-            }
690
-        }
691
-        // instantiate the requested object
692
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
693
-        if ($this->_cache_on && $cache) {
694
-            // save it for later... kinda like gum  { : $
695
-            $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
696
-        }
697
-        $this->_cache_on = true;
698
-        return $class_obj;
699
-    }
700
-
701
-
702
-
703
-    /**
704
-     * _get_cached_class
705
-     * attempts to find a cached version of the requested class
706
-     * by looking in the following places:
707
-     *        $this->{$class_abbreviation}            ie:    $this->CART
708
-     *        $this->{$class_name}                        ie:    $this->Some_Class
709
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
710
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
711
-     *
712
-     * @access protected
713
-     * @param string $class_name
714
-     * @param string $class_prefix
715
-     * @return mixed
716
-     */
717
-    protected function _get_cached_class($class_name, $class_prefix = '')
718
-    {
719
-        if (isset($this->_class_abbreviations[$class_name])) {
720
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
721
-        } else {
722
-            // have to specify something, but not anything that will conflict
723
-            $class_abbreviation = 'FANCY_BATMAN_PANTS';
724
-        }
725
-        // check if class has already been loaded, and return it if it has been
726
-        if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
727
-            return $this->{$class_abbreviation};
728
-        } else if (isset ($this->{$class_name})) {
729
-            return $this->{$class_name};
730
-        } else if (isset ($this->LIB->{$class_name})) {
731
-            return $this->LIB->{$class_name};
732
-        } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
733
-            return $this->addons->{$class_name};
734
-        }
735
-        return null;
736
-    }
737
-
738
-
739
-
740
-    /**
741
-     * _resolve_path
742
-     * attempts to find a full valid filepath for the requested class.
743
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
744
-     * then returns that path if the target file has been found and is readable
745
-     *
746
-     * @access protected
747
-     * @param string $class_name
748
-     * @param string $type
749
-     * @param array  $file_paths
750
-     * @return string | bool
751
-     */
752
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
753
-    {
754
-        // make sure $file_paths is an array
755
-        $file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
756
-        // cycle thru paths
757
-        foreach ($file_paths as $key => $file_path) {
758
-            // convert all separators to proper DS, if no filepath, then use EE_CLASSES
759
-            $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
760
-            // prep file type
761
-            $type = ! empty($type) ? trim($type, '.') . '.' : '';
762
-            // build full file path
763
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
764
-            //does the file exist and can be read ?
765
-            if (is_readable($file_paths[$key])) {
766
-                return $file_paths[$key];
767
-            }
768
-        }
769
-        return false;
770
-    }
771
-
772
-
773
-
774
-    /**
775
-     * _require_file
776
-     * basically just performs a require_once()
777
-     * but with some error handling
778
-     *
779
-     * @access protected
780
-     * @param  string $path
781
-     * @param  string $class_name
782
-     * @param  string $type
783
-     * @param  array  $file_paths
784
-     * @return boolean
785
-     * @throws \EE_Error
786
-     */
787
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
788
-    {
789
-        // don't give up! you gotta...
790
-        try {
791
-            //does the file exist and can it be read ?
792
-            if ( ! $path) {
793
-                // so sorry, can't find the file
794
-                throw new EE_Error (
795
-                    sprintf(
796
-                        __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
797
-                        trim($type, '.'),
798
-                        $class_name,
799
-                        '<br />' . implode(',<br />', $file_paths)
800
-                    )
801
-                );
802
-            }
803
-            // get the file
804
-            require_once($path);
805
-            // if the class isn't already declared somewhere
806
-            if (class_exists($class_name, false) === false) {
807
-                // so sorry, not a class
808
-                throw new EE_Error(
809
-                    sprintf(
810
-                        __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
811
-                        $type,
812
-                        $path,
813
-                        $class_name
814
-                    )
815
-                );
816
-            }
817
-        } catch (EE_Error $e) {
818
-            $e->get_error();
819
-            return false;
820
-        }
821
-        return true;
822
-    }
823
-
824
-
825
-
826
-    /**
827
-     * _create_object
828
-     * Attempts to instantiate the requested class via any of the
829
-     * commonly used instantiation methods employed throughout EE.
830
-     * The priority for instantiation is as follows:
831
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
832
-     *        - model objects via their 'new_instance_from_db' method
833
-     *        - model objects via their 'new_instance' method
834
-     *        - "singleton" classes" via their 'instance' method
835
-     *    - standard instantiable classes via their __constructor
836
-     * Prior to instantiation, if the classname exists in the dependency_map,
837
-     * then the constructor for the requested class will be examined to determine
838
-     * if any dependencies exist, and if they can be injected.
839
-     * If so, then those classes will be added to the array of arguments passed to the constructor
840
-     *
841
-     * @access protected
842
-     * @param string $class_name
843
-     * @param array  $arguments
844
-     * @param string $type
845
-     * @param bool   $from_db
846
-     * @return null | object
847
-     * @throws \EE_Error
848
-     */
849
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
850
-    {
851
-        $class_obj = null;
852
-        $instantiation_mode = '0) none';
853
-        // don't give up! you gotta...
854
-        try {
855
-            // create reflection
856
-            $reflector = $this->get_ReflectionClass($class_name);
857
-            // make sure arguments are an array
858
-            $arguments = is_array($arguments) ? $arguments : array($arguments);
859
-            // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
860
-            // else wrap it in an additional array so that it doesn't get split into multiple parameters
861
-            $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
862
-                ? $arguments
863
-                : array($arguments);
864
-            // attempt to inject dependencies ?
865
-            if ($this->_dependency_map->has($class_name)) {
866
-                $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
867
-            }
868
-            // instantiate the class if possible
869
-            if ($reflector->isAbstract()) {
870
-                // nothing to instantiate, loading file was enough
871
-                // does not throw an exception so $instantiation_mode is unused
872
-                // $instantiation_mode = "1) no constructor abstract class";
873
-                $class_obj = true;
874
-            } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
875
-                // no constructor = static methods only... nothing to instantiate, loading file was enough
876
-                $instantiation_mode = "2) no constructor but instantiable";
877
-                $class_obj = $reflector->newInstance();
878
-            } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
879
-                $instantiation_mode = "3) new_instance_from_db()";
880
-                $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
881
-            } else if (method_exists($class_name, 'new_instance')) {
882
-                $instantiation_mode = "4) new_instance()";
883
-                $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
884
-            } else if (method_exists($class_name, 'instance')) {
885
-                $instantiation_mode = "5) instance()";
886
-                $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
887
-            } else if ($reflector->isInstantiable()) {
888
-                $instantiation_mode = "6) constructor";
889
-                $class_obj = $reflector->newInstanceArgs($arguments);
890
-            } else {
891
-                // heh ? something's not right !
892
-                throw new EE_Error(
893
-                    sprintf(
894
-                        __('The %s file %s could not be instantiated.', 'event_espresso'),
895
-                        $type,
896
-                        $class_name
897
-                    )
898
-                );
899
-            }
900
-        } catch (Exception $e) {
901
-            if ( ! $e instanceof EE_Error) {
902
-                $e = new EE_Error(
903
-                    sprintf(
904
-                        __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
905
-                        $class_name,
906
-                        '<br />',
907
-                        $e->getMessage(),
908
-                        $instantiation_mode
909
-                    )
910
-                );
911
-            }
912
-            $e->get_error();
913
-        }
914
-        return $class_obj;
915
-    }
916
-
917
-
918
-
919
-    /**
920
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
921
-     * @param array $array
922
-     * @return bool
923
-     */
924
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
925
-    {
926
-        return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
927
-    }
928
-
929
-
930
-
931
-    /**
932
-     * getReflectionClass
933
-     * checks if a ReflectionClass object has already been generated for a class
934
-     * and returns that instead of creating a new one
935
-     *
936
-     * @access public
937
-     * @param string $class_name
938
-     * @return ReflectionClass
939
-     */
940
-    public function get_ReflectionClass($class_name)
941
-    {
942
-        if (
943
-            ! isset($this->_reflectors[$class_name])
944
-            || ! $this->_reflectors[$class_name] instanceof ReflectionClass
945
-        ) {
946
-            $this->_reflectors[$class_name] = new ReflectionClass($class_name);
947
-        }
948
-        return $this->_reflectors[$class_name];
949
-    }
950
-
951
-
952
-
953
-    /**
954
-     * _resolve_dependencies
955
-     * examines the constructor for the requested class to determine
956
-     * if any dependencies exist, and if they can be injected.
957
-     * If so, then those classes will be added to the array of arguments passed to the constructor
958
-     * PLZ NOTE: this is achieved by type hinting the constructor params
959
-     * For example:
960
-     *        if attempting to load a class "Foo" with the following constructor:
961
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
962
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
963
-     *        but only IF they are NOT already present in the incoming arguments array,
964
-     *        and the correct classes can be loaded
965
-     *
966
-     * @access protected
967
-     * @param ReflectionClass $reflector
968
-     * @param string          $class_name
969
-     * @param array           $arguments
970
-     * @return array
971
-     * @throws \ReflectionException
972
-     */
973
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
974
-    {
975
-        // let's examine the constructor
976
-        $constructor = $reflector->getConstructor();
977
-        // whu? huh? nothing?
978
-        if ( ! $constructor) {
979
-            return $arguments;
980
-        }
981
-        // get constructor parameters
982
-        $params = $constructor->getParameters();
983
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
984
-        $argument_keys = array_keys($arguments);
985
-        // now loop thru all of the constructors expected parameters
986
-        foreach ($params as $index => $param) {
987
-            // is this a dependency for a specific class ?
988
-            $param_class = $param->getClass() ? $param->getClass()->name : null;
989
-            if (
990
-                // param is not even a class
991
-                empty($param_class)
992
-                // and something already exists in the incoming arguments for this param
993
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
994
-            ) {
995
-                // so let's skip this argument and move on to the next
996
-                continue;
997
-            } else if (
998
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
999
-                ! empty($param_class)
1000
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1001
-                && $arguments[$argument_keys[$index]] instanceof $param_class
1002
-            ) {
1003
-                // skip this argument and move on to the next
1004
-                continue;
1005
-            } else if (
1006
-                // parameter is type hinted as a class, and should be injected
1007
-                ! empty($param_class)
1008
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1009
-            ) {
1010
-                $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1011
-            } else {
1012
-                try {
1013
-                    $arguments[$index] = $param->getDefaultValue();
1014
-                } catch (ReflectionException $e) {
1015
-                    throw new ReflectionException(
1016
-                        sprintf(
1017
-                            __('%1$s for parameter "$%2$s"', 'event_espresso'),
1018
-                            $e->getMessage(),
1019
-                            $param->getName()
1020
-                        )
1021
-                    );
1022
-                }
1023
-            }
1024
-        }
1025
-        return $arguments;
1026
-    }
1027
-
1028
-
1029
-
1030
-    /**
1031
-     * @access protected
1032
-     * @param string $class_name
1033
-     * @param string $param_class
1034
-     * @param array  $arguments
1035
-     * @param mixed  $index
1036
-     * @return array
1037
-     */
1038
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1039
-    {
1040
-        $dependency = null;
1041
-        // should dependency be loaded from cache ?
1042
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1043
-                    !== EE_Dependency_Map::load_new_object
1044
-            ? true
1045
-            : false;
1046
-        // we might have a dependency...
1047
-        // let's MAYBE try and find it in our cache if that's what's been requested
1048
-        $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1049
-        // and grab it if it exists
1050
-        if ($cached_class instanceof $param_class) {
1051
-            $dependency = $cached_class;
1052
-        } else if ($param_class != $class_name) {
1053
-            // obtain the loader method from the dependency map
1054
-            $loader = $this->_dependency_map->class_loader($param_class);
1055
-            // is loader a custom closure ?
1056
-            if ($loader instanceof Closure) {
1057
-                $dependency = $loader();
1058
-            } else {
1059
-                // set the cache on property for the recursive loading call
1060
-                $this->_cache_on = $cache_on;
1061
-                // if not, then let's try and load it via the registry
1062
-                if (method_exists($this, $loader)) {
1063
-                    $dependency = $this->{$loader}($param_class);
1064
-                } else {
1065
-                    $dependency = $this->create($param_class, array(), $cache_on);
1066
-                }
1067
-            }
1068
-        }
1069
-        // did we successfully find the correct dependency ?
1070
-        if ($dependency instanceof $param_class) {
1071
-            // then let's inject it into the incoming array of arguments at the correct location
1072
-            if (isset($argument_keys[$index])) {
1073
-                $arguments[$argument_keys[$index]] = $dependency;
1074
-            } else {
1075
-                $arguments[$index] = $dependency;
1076
-            }
1077
-        }
1078
-        return $arguments;
1079
-    }
1080
-
1081
-
1082
-
1083
-    /**
1084
-     * _set_cached_class
1085
-     * attempts to cache the instantiated class locally
1086
-     * in one of the following places, in the following order:
1087
-     *        $this->{class_abbreviation}   ie:    $this->CART
1088
-     *        $this->{$class_name}          ie:    $this->Some_Class
1089
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1090
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1091
-     *
1092
-     * @access protected
1093
-     * @param object $class_obj
1094
-     * @param string $class_name
1095
-     * @param string $class_prefix
1096
-     * @param bool   $from_db
1097
-     * @return void
1098
-     */
1099
-    protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1100
-    {
1101
-        if (empty($class_obj)) {
1102
-            return;
1103
-        }
1104
-        // return newly instantiated class
1105
-        if (isset($this->_class_abbreviations[$class_name])) {
1106
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
1107
-            $this->{$class_abbreviation} = $class_obj;
1108
-        } else if (property_exists($this, $class_name)) {
1109
-            $this->{$class_name} = $class_obj;
1110
-        } else if ($class_prefix == 'addon') {
1111
-            $this->addons->{$class_name} = $class_obj;
1112
-        } else if ( ! $from_db) {
1113
-            $this->LIB->{$class_name} = $class_obj;
1114
-        }
1115
-    }
1116
-
1117
-
1118
-
1119
-    /**
1120
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1121
-     *
1122
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1123
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1124
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1125
-     * @param array  $arguments
1126
-     * @return object
1127
-     */
1128
-    public static function factory($classname, $arguments = array())
1129
-    {
1130
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1131
-        if ($loader instanceof Closure) {
1132
-            return $loader($arguments);
1133
-        } else if (method_exists(EE_Registry::instance(), $loader)) {
1134
-            return EE_Registry::instance()->{$loader}($classname, $arguments);
1135
-        }
1136
-        return null;
1137
-    }
1138
-
1139
-
1140
-
1141
-    /**
1142
-     * Gets the addon by its name/slug (not classname. For that, just
1143
-     * use the classname as the property name on EE_Config::instance()->addons)
1144
-     *
1145
-     * @param string $name
1146
-     * @return EE_Addon
1147
-     */
1148
-    public function get_addon_by_name($name)
1149
-    {
1150
-        foreach ($this->addons as $addon) {
1151
-            if ($addon->name() == $name) {
1152
-                return $addon;
1153
-            }
1154
-        }
1155
-        return null;
1156
-    }
1157
-
1158
-
1159
-
1160
-    /**
1161
-     * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1162
-     * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1163
-     *
1164
-     * @return EE_Addon[] where the KEYS are the addon's name()
1165
-     */
1166
-    public function get_addons_by_name()
1167
-    {
1168
-        $addons = array();
1169
-        foreach ($this->addons as $addon) {
1170
-            $addons[$addon->name()] = $addon;
1171
-        }
1172
-        return $addons;
1173
-    }
1174
-
1175
-
1176
-
1177
-    /**
1178
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1179
-     * a stale copy of it around
1180
-     *
1181
-     * @param string $model_name
1182
-     * @return \EEM_Base
1183
-     * @throws \EE_Error
1184
-     */
1185
-    public function reset_model($model_name)
1186
-    {
1187
-        $model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1188
-        if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1189
-            return null;
1190
-        }
1191
-        //get that model reset it and make sure we nuke the old reference to it
1192
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1193
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1194
-        } else {
1195
-            throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1196
-        }
1197
-        return $this->LIB->{$model_class_name};
1198
-    }
1199
-
1200
-
1201
-
1202
-    /**
1203
-     * Resets the registry.
1204
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1205
-     * is used in a multisite install.  Here is a list of things that are NOT reset.
1206
-     * - $_dependency_map
1207
-     * - $_class_abbreviations
1208
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1209
-     * - $REQ:  Still on the same request so no need to change.
1210
-     * - $CAP: There is no site specific state in the EE_Capability class.
1211
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1212
-     *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1213
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1214
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1215
-     *             switch or on the restore.
1216
-     * - $modules
1217
-     * - $shortcodes
1218
-     * - $widgets
1219
-     *
1220
-     * @param boolean $hard             whether to reset data in the database too, or just refresh
1221
-     *                                  the Registry to its state at the beginning of the request
1222
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1223
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1224
-     *                                  currently reinstantiate the singletons at the moment)
1225
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1226
-     *                                  code instead can just change the model context to a different blog id if necessary
1227
-     * @return EE_Registry
1228
-     */
1229
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1230
-    {
1231
-        $instance = self::instance();
1232
-        EEH_Activation::reset();
1233
-        //properties that get reset
1234
-        $instance->_cache_on = true;
1235
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1236
-        $instance->CART = null;
1237
-        $instance->MRM = null;
1238
-        $instance->AssetsRegistry = null;
1239
-        $instance->AssetsRegistry = $instance->create('EventEspresso\core\services\assets\Registry');
1240
-        //messages reset
1241
-        EED_Messages::reset();
1242
-        if ($reset_models) {
1243
-            foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1244
-                $instance->reset_model($model_name);
1245
-            }
1246
-        }
1247
-        $instance->LIB = new stdClass();
1248
-        return $instance;
1249
-    }
1250
-
1251
-
1252
-
1253
-    /**
1254
-     * @override magic methods
1255
-     * @return void
1256
-     */
1257
-    public final function __destruct()
1258
-    {
1259
-    }
1260
-
1261
-
1262
-
1263
-    /**
1264
-     * @param $a
1265
-     * @param $b
1266
-     */
1267
-    public final function __call($a, $b)
1268
-    {
1269
-    }
1270
-
1271
-
1272
-
1273
-    /**
1274
-     * @param $a
1275
-     */
1276
-    public final function __get($a)
1277
-    {
1278
-    }
1279
-
1280
-
1281
-
1282
-    /**
1283
-     * @param $a
1284
-     * @param $b
1285
-     */
1286
-    public final function __set($a, $b)
1287
-    {
1288
-    }
1289
-
1290
-
1291
-
1292
-    /**
1293
-     * @param $a
1294
-     */
1295
-    public final function __isset($a)
1296
-    {
1297
-    }
19
+	/**
20
+	 *    EE_Registry Object
21
+	 *
22
+	 * @var EE_Registry $_instance
23
+	 * @access    private
24
+	 */
25
+	private static $_instance = null;
26
+
27
+	/**
28
+	 * @var EE_Dependency_Map $_dependency_map
29
+	 * @access    protected
30
+	 */
31
+	protected $_dependency_map = null;
32
+
33
+	/**
34
+	 * @var array $_class_abbreviations
35
+	 * @access    protected
36
+	 */
37
+	protected $_class_abbreviations = array();
38
+
39
+	/**
40
+	 * @access public
41
+	 * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
+	 */
43
+	public $BUS;
44
+
45
+	/**
46
+	 *    EE_Cart Object
47
+	 *
48
+	 * @access    public
49
+	 * @var    EE_Cart $CART
50
+	 */
51
+	public $CART = null;
52
+
53
+	/**
54
+	 *    EE_Config Object
55
+	 *
56
+	 * @access    public
57
+	 * @var    EE_Config $CFG
58
+	 */
59
+	public $CFG = null;
60
+
61
+	/**
62
+	 * EE_Network_Config Object
63
+	 *
64
+	 * @access public
65
+	 * @var EE_Network_Config $NET_CFG
66
+	 */
67
+	public $NET_CFG = null;
68
+
69
+	/**
70
+	 *    StdClass object for storing library classes in
71
+	 *
72
+	 * @public LIB
73
+	 * @var StdClass $LIB
74
+	 */
75
+	public $LIB = null;
76
+
77
+	/**
78
+	 *    EE_Request_Handler Object
79
+	 *
80
+	 * @access    public
81
+	 * @var    EE_Request_Handler $REQ
82
+	 */
83
+	public $REQ = null;
84
+
85
+	/**
86
+	 *    EE_Session Object
87
+	 *
88
+	 * @access    public
89
+	 * @var    EE_Session $SSN
90
+	 */
91
+	public $SSN = null;
92
+
93
+	/**
94
+	 * holds the ee capabilities object.
95
+	 *
96
+	 * @since 4.5.0
97
+	 * @var EE_Capabilities
98
+	 */
99
+	public $CAP = null;
100
+
101
+	/**
102
+	 * holds the EE_Message_Resource_Manager object.
103
+	 *
104
+	 * @since 4.9.0
105
+	 * @var EE_Message_Resource_Manager
106
+	 */
107
+	public $MRM = null;
108
+
109
+
110
+	/**
111
+	 * Holds the Assets Registry instance
112
+	 * @var Registry
113
+	 */
114
+	public $AssetsRegistry = null;
115
+
116
+	/**
117
+	 *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
+	 *
119
+	 * @access    public
120
+	 * @var    EE_Addon[]
121
+	 */
122
+	public $addons = null;
123
+
124
+	/**
125
+	 *    $models
126
+	 * @access    public
127
+	 * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
+	 */
129
+	public $models = array();
130
+
131
+	/**
132
+	 *    $modules
133
+	 * @access    public
134
+	 * @var    EED_Module[] $modules
135
+	 */
136
+	public $modules = null;
137
+
138
+	/**
139
+	 *    $shortcodes
140
+	 * @access    public
141
+	 * @var    EES_Shortcode[] $shortcodes
142
+	 */
143
+	public $shortcodes = null;
144
+
145
+	/**
146
+	 *    $widgets
147
+	 * @access    public
148
+	 * @var    WP_Widget[] $widgets
149
+	 */
150
+	public $widgets = null;
151
+
152
+	/**
153
+	 * $non_abstract_db_models
154
+	 * @access public but its better to use EE_Registry::non_abstract_db_models() as it verifies we've set this property before returning it
155
+	 * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
+	 * classnames (eg "EEM_Event")
159
+	 */
160
+	public $non_abstract_db_models = array();
161
+
162
+
163
+	/**
164
+	 *    $i18n_js_strings - internationalization for JS strings
165
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
166
+	 *    in js file:  var translatedString = eei18n.string_key;
167
+	 *
168
+	 * @access    public
169
+	 * @var    array
170
+	 */
171
+	public static $i18n_js_strings = array();
172
+
173
+
174
+	/**
175
+	 *    $main_file - path to espresso.php
176
+	 *
177
+	 * @access    public
178
+	 * @var    array
179
+	 */
180
+	public $main_file;
181
+
182
+	/**
183
+	 * array of ReflectionClass objects where the key is the class name
184
+	 *
185
+	 * @access    public
186
+	 * @var ReflectionClass[]
187
+	 */
188
+	public $_reflectors;
189
+
190
+	/**
191
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
192
+	 *
193
+	 * @access    protected
194
+	 * @var boolean $_cache_on
195
+	 */
196
+	protected $_cache_on = true;
197
+
198
+
199
+
200
+	/**
201
+	 * @singleton method used to instantiate class object
202
+	 * @access    public
203
+	 * @param  \EE_Dependency_Map $dependency_map
204
+	 * @return \EE_Registry instance
205
+	 */
206
+	public static function instance(\EE_Dependency_Map $dependency_map = null)
207
+	{
208
+		// check if class object is instantiated
209
+		if ( ! self::$_instance instanceof EE_Registry) {
210
+			self::$_instance = new EE_Registry($dependency_map);
211
+		}
212
+		return self::$_instance;
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 *protected constructor to prevent direct creation
219
+	 *
220
+	 * @Constructor
221
+	 * @access protected
222
+	 * @param  \EE_Dependency_Map $dependency_map
223
+	 * @return \EE_Registry
224
+	 */
225
+	protected function __construct(\EE_Dependency_Map $dependency_map)
226
+	{
227
+		$this->_dependency_map = $dependency_map;
228
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * initialize
235
+	 */
236
+	public function initialize()
237
+	{
238
+		$this->_class_abbreviations = apply_filters(
239
+			'FHEE__EE_Registry____construct___class_abbreviations',
240
+			array(
241
+				'EE_Config'                                       => 'CFG',
242
+				'EE_Session'                                      => 'SSN',
243
+				'EE_Capabilities'                                 => 'CAP',
244
+				'EE_Cart'                                         => 'CART',
245
+				'EE_Network_Config'                               => 'NET_CFG',
246
+				'EE_Request_Handler'                              => 'REQ',
247
+				'EE_Message_Resource_Manager'                     => 'MRM',
248
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
249
+				'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
250
+			)
251
+		);
252
+		// class library
253
+		$this->LIB = new stdClass();
254
+		$this->addons = new stdClass();
255
+		$this->modules = new stdClass();
256
+		$this->shortcodes = new stdClass();
257
+		$this->widgets = new stdClass();
258
+		$this->load_core('Base', array(), true);
259
+		// add our request and response objects to the cache
260
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
261
+		$this->_set_cached_class(
262
+			$request_loader(),
263
+			'EE_Request'
264
+		);
265
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
266
+		$this->_set_cached_class(
267
+			$response_loader(),
268
+			'EE_Response'
269
+		);
270
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 *    init
277
+	 *
278
+	 * @access    public
279
+	 * @return    void
280
+	 */
281
+	public function init()
282
+	{
283
+		// Get current page protocol
284
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
285
+		// Output admin-ajax.php URL with same protocol as current page
286
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
287
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * localize_i18n_js_strings
294
+	 *
295
+	 * @return string
296
+	 */
297
+	public static function localize_i18n_js_strings()
298
+	{
299
+		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
300
+		foreach ($i18n_js_strings as $key => $value) {
301
+			if (is_scalar($value)) {
302
+				$i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
303
+			}
304
+		}
305
+		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * @param mixed string | EED_Module $module
312
+	 */
313
+	public function add_module($module)
314
+	{
315
+		if ($module instanceof EED_Module) {
316
+			$module_class = get_class($module);
317
+			$this->modules->{$module_class} = $module;
318
+		} else {
319
+			if ( ! class_exists('EE_Module_Request_Router')) {
320
+				$this->load_core('Module_Request_Router');
321
+			}
322
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
323
+		}
324
+	}
325
+
326
+
327
+
328
+	/**
329
+	 * @param string $module_name
330
+	 * @return mixed EED_Module | NULL
331
+	 */
332
+	public function get_module($module_name = '')
333
+	{
334
+		return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
335
+	}
336
+
337
+
338
+
339
+	/**
340
+	 *    loads core classes - must be singletons
341
+	 *
342
+	 * @access    public
343
+	 * @param string $class_name - simple class name ie: session
344
+	 * @param mixed  $arguments
345
+	 * @param bool   $load_only
346
+	 * @return mixed
347
+	 */
348
+	public function load_core($class_name, $arguments = array(), $load_only = false)
349
+	{
350
+		$core_paths = apply_filters(
351
+			'FHEE__EE_Registry__load_core__core_paths',
352
+			array(
353
+				EE_CORE,
354
+				EE_ADMIN,
355
+				EE_CPTS,
356
+				EE_CORE . 'data_migration_scripts' . DS,
357
+				EE_CORE . 'request_stack' . DS,
358
+				EE_CORE . 'middleware' . DS,
359
+			)
360
+		);
361
+		// retrieve instantiated class
362
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 *    loads service classes
369
+	 *
370
+	 * @access    public
371
+	 * @param string $class_name - simple class name ie: session
372
+	 * @param mixed  $arguments
373
+	 * @param bool   $load_only
374
+	 * @return mixed
375
+	 */
376
+	public function load_service($class_name, $arguments = array(), $load_only = false)
377
+	{
378
+		$service_paths = apply_filters(
379
+			'FHEE__EE_Registry__load_service__service_paths',
380
+			array(
381
+				EE_CORE . 'services' . DS,
382
+			)
383
+		);
384
+		// retrieve instantiated class
385
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
386
+	}
387
+
388
+
389
+
390
+	/**
391
+	 *    loads data_migration_scripts
392
+	 *
393
+	 * @access    public
394
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
395
+	 * @param mixed  $arguments
396
+	 * @return EE_Data_Migration_Script_Base|mixed
397
+	 */
398
+	public function load_dms($class_name, $arguments = array())
399
+	{
400
+		// retrieve instantiated class
401
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 *    loads object creating classes - must be singletons
408
+	 *
409
+	 * @param string $class_name - simple class name ie: attendee
410
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
411
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
412
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
413
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
414
+	 * @return EE_Base_Class | bool
415
+	 */
416
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
+	{
418
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
419
+			EE_CORE,
420
+			EE_CLASSES,
421
+			EE_BUSINESS,
422
+		));
423
+		// retrieve instantiated class
424
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 *    loads helper classes - must be singletons
431
+	 *
432
+	 * @param string $class_name - simple class name ie: price
433
+	 * @param mixed  $arguments
434
+	 * @param bool   $load_only
435
+	 * @return EEH_Base | bool
436
+	 */
437
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
438
+	{
439
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
440
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
441
+		// retrieve instantiated class
442
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
443
+	}
444
+
445
+
446
+
447
+	/**
448
+	 *    loads core classes - must be singletons
449
+	 *
450
+	 * @access    public
451
+	 * @param string $class_name - simple class name ie: session
452
+	 * @param mixed  $arguments
453
+	 * @param bool   $load_only
454
+	 * @param bool   $cache      whether to cache the object or not.
455
+	 * @return mixed
456
+	 */
457
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
458
+	{
459
+		$paths = array(
460
+			EE_LIBRARIES,
461
+			EE_LIBRARIES . 'messages' . DS,
462
+			EE_LIBRARIES . 'shortcodes' . DS,
463
+			EE_LIBRARIES . 'qtips' . DS,
464
+			EE_LIBRARIES . 'payment_methods' . DS,
465
+		);
466
+		// retrieve instantiated class
467
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
468
+	}
469
+
470
+
471
+
472
+	/**
473
+	 *    loads model classes - must be singletons
474
+	 *
475
+	 * @param string $class_name - simple class name ie: price
476
+	 * @param mixed  $arguments
477
+	 * @param bool   $load_only
478
+	 * @return EEM_Base | bool
479
+	 */
480
+	public function load_model($class_name, $arguments = array(), $load_only = false)
481
+	{
482
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
483
+			EE_MODELS,
484
+			EE_CORE,
485
+		));
486
+		// retrieve instantiated class
487
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
488
+	}
489
+
490
+
491
+
492
+	/**
493
+	 *    loads model classes - must be singletons
494
+	 *
495
+	 * @param string $class_name - simple class name ie: price
496
+	 * @param mixed  $arguments
497
+	 * @param bool   $load_only
498
+	 * @return mixed | bool
499
+	 */
500
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
501
+	{
502
+		$paths = array(
503
+			EE_MODELS . 'fields' . DS,
504
+			EE_MODELS . 'helpers' . DS,
505
+			EE_MODELS . 'relations' . DS,
506
+			EE_MODELS . 'strategies' . DS,
507
+		);
508
+		// retrieve instantiated class
509
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
510
+	}
511
+
512
+
513
+
514
+	/**
515
+	 * Determines if $model_name is the name of an actual EE model.
516
+	 *
517
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
518
+	 * @return boolean
519
+	 */
520
+	public function is_model_name($model_name)
521
+	{
522
+		$this->_verify_models_discovered();
523
+		return isset($this->models[$model_name]) ? true : false;
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    generic class loader
530
+	 *
531
+	 * @param string $path_to_file - directory path to file location, not including filename
532
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
533
+	 * @param string $type         - file type - core? class? helper? model?
534
+	 * @param mixed  $arguments
535
+	 * @param bool   $load_only
536
+	 * @return mixed
537
+	 */
538
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
539
+	{
540
+		// retrieve instantiated class
541
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
542
+	}
543
+
544
+
545
+
546
+	/**
547
+	 *    load_addon
548
+	 *
549
+	 * @param string $path_to_file - directory path to file location, not including filename
550
+	 * @param string $class_name   - full class name  ie:  My_Class
551
+	 * @param string $type         - file type - core? class? helper? model?
552
+	 * @param mixed  $arguments
553
+	 * @param bool   $load_only
554
+	 * @return EE_Addon
555
+	 */
556
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
557
+	{
558
+		// retrieve instantiated class
559
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
560
+	}
561
+
562
+
563
+
564
+	/**
565
+	 * instantiates, caches, and automatically resolves dependencies
566
+	 * for classes that use a Fully Qualified Class Name.
567
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
568
+	 * then you need to use one of the existing load_*() methods
569
+	 * which can resolve the classname and filepath from the passed arguments
570
+	 *
571
+	 * @param bool|string $class_name   Fully Qualified Class Name
572
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
573
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
574
+	 * @param bool        $from_db      some classes are instantiated from the db
575
+	 *                                  and thus call a different method to instantiate
576
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
577
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
578
+	 * @return mixed                    null = failure to load or instantiate class object.
579
+	 *                                  object = class loaded and instantiated successfully.
580
+	 *                                  bool = fail or success when $load_only is true
581
+	 */
582
+	public function create(
583
+		$class_name = false,
584
+		$arguments = array(),
585
+		$cache = false,
586
+		$from_db = false,
587
+		$load_only = false,
588
+		$addon = false
589
+	) {
590
+		$class_name = ltrim($class_name, '\\');
591
+		$class_name = $this->_dependency_map->get_alias($class_name);
592
+		if ( ! class_exists($class_name)) {
593
+			// maybe the class is registered with a preceding \
594
+			$class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
595
+			// still doesn't exist ?
596
+			if ( ! class_exists($class_name)) {
597
+				return null;
598
+			}
599
+		}
600
+		// if we're only loading the class and it already exists, then let's just return true immediately
601
+		if ($load_only) {
602
+			return true;
603
+		}
604
+		$addon = $addon ? 'addon' : '';
605
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
606
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
607
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
608
+		if ($this->_cache_on && $cache && ! $load_only) {
609
+			// return object if it's already cached
610
+			$cached_class = $this->_get_cached_class($class_name, $addon);
611
+			if ($cached_class !== null) {
612
+				return $cached_class;
613
+			}
614
+		}
615
+		// instantiate the requested object
616
+		$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
617
+		if ($this->_cache_on && $cache) {
618
+			// save it for later... kinda like gum  { : $
619
+			$this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
620
+		}
621
+		$this->_cache_on = true;
622
+		return $class_obj;
623
+	}
624
+
625
+
626
+
627
+	/**
628
+	 * instantiates, caches, and injects dependencies for classes
629
+	 *
630
+	 * @param array       $file_paths   an array of paths to folders to look in
631
+	 * @param string      $class_prefix EE  or EEM or... ???
632
+	 * @param bool|string $class_name   $class name
633
+	 * @param string      $type         file type - core? class? helper? model?
634
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
635
+	 * @param bool        $from_db      some classes are instantiated from the db
636
+	 *                                  and thus call a different method to instantiate
637
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
638
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
639
+	 * @return null|object|bool         null = failure to load or instantiate class object.
640
+	 *                                  object = class loaded and instantiated successfully.
641
+	 *                                  bool = fail or success when $load_only is true
642
+	 */
643
+	protected function _load(
644
+		$file_paths = array(),
645
+		$class_prefix = 'EE_',
646
+		$class_name = false,
647
+		$type = 'class',
648
+		$arguments = array(),
649
+		$from_db = false,
650
+		$cache = true,
651
+		$load_only = false
652
+	) {
653
+		$class_name = ltrim($class_name, '\\');
654
+		// strip php file extension
655
+		$class_name = str_replace('.php', '', trim($class_name));
656
+		// does the class have a prefix ?
657
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
658
+			// make sure $class_prefix is uppercase
659
+			$class_prefix = strtoupper(trim($class_prefix));
660
+			// add class prefix ONCE!!!
661
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
662
+		}
663
+		$class_name = $this->_dependency_map->get_alias($class_name);
664
+		$class_exists = class_exists($class_name);
665
+		// if we're only loading the class and it already exists, then let's just return true immediately
666
+		if ($load_only && $class_exists) {
667
+			return true;
668
+		}
669
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
670
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
671
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
672
+		if ($this->_cache_on && $cache && ! $load_only) {
673
+			// return object if it's already cached
674
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
675
+			if ($cached_class !== null) {
676
+				return $cached_class;
677
+			}
678
+		}
679
+		// if the class doesn't already exist.. then we need to try and find the file and load it
680
+		if ( ! $class_exists) {
681
+			// get full path to file
682
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
683
+			// load the file
684
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
685
+			// if loading failed, or we are only loading a file but NOT instantiating an object
686
+			if ( ! $loaded || $load_only) {
687
+				// return boolean if only loading, or null if an object was expected
688
+				return $load_only ? $loaded : null;
689
+			}
690
+		}
691
+		// instantiate the requested object
692
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
693
+		if ($this->_cache_on && $cache) {
694
+			// save it for later... kinda like gum  { : $
695
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
696
+		}
697
+		$this->_cache_on = true;
698
+		return $class_obj;
699
+	}
700
+
701
+
702
+
703
+	/**
704
+	 * _get_cached_class
705
+	 * attempts to find a cached version of the requested class
706
+	 * by looking in the following places:
707
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
708
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
709
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
710
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
711
+	 *
712
+	 * @access protected
713
+	 * @param string $class_name
714
+	 * @param string $class_prefix
715
+	 * @return mixed
716
+	 */
717
+	protected function _get_cached_class($class_name, $class_prefix = '')
718
+	{
719
+		if (isset($this->_class_abbreviations[$class_name])) {
720
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
721
+		} else {
722
+			// have to specify something, but not anything that will conflict
723
+			$class_abbreviation = 'FANCY_BATMAN_PANTS';
724
+		}
725
+		// check if class has already been loaded, and return it if it has been
726
+		if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
727
+			return $this->{$class_abbreviation};
728
+		} else if (isset ($this->{$class_name})) {
729
+			return $this->{$class_name};
730
+		} else if (isset ($this->LIB->{$class_name})) {
731
+			return $this->LIB->{$class_name};
732
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
733
+			return $this->addons->{$class_name};
734
+		}
735
+		return null;
736
+	}
737
+
738
+
739
+
740
+	/**
741
+	 * _resolve_path
742
+	 * attempts to find a full valid filepath for the requested class.
743
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
744
+	 * then returns that path if the target file has been found and is readable
745
+	 *
746
+	 * @access protected
747
+	 * @param string $class_name
748
+	 * @param string $type
749
+	 * @param array  $file_paths
750
+	 * @return string | bool
751
+	 */
752
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
753
+	{
754
+		// make sure $file_paths is an array
755
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
756
+		// cycle thru paths
757
+		foreach ($file_paths as $key => $file_path) {
758
+			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
759
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
760
+			// prep file type
761
+			$type = ! empty($type) ? trim($type, '.') . '.' : '';
762
+			// build full file path
763
+			$file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
764
+			//does the file exist and can be read ?
765
+			if (is_readable($file_paths[$key])) {
766
+				return $file_paths[$key];
767
+			}
768
+		}
769
+		return false;
770
+	}
771
+
772
+
773
+
774
+	/**
775
+	 * _require_file
776
+	 * basically just performs a require_once()
777
+	 * but with some error handling
778
+	 *
779
+	 * @access protected
780
+	 * @param  string $path
781
+	 * @param  string $class_name
782
+	 * @param  string $type
783
+	 * @param  array  $file_paths
784
+	 * @return boolean
785
+	 * @throws \EE_Error
786
+	 */
787
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
788
+	{
789
+		// don't give up! you gotta...
790
+		try {
791
+			//does the file exist and can it be read ?
792
+			if ( ! $path) {
793
+				// so sorry, can't find the file
794
+				throw new EE_Error (
795
+					sprintf(
796
+						__('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
797
+						trim($type, '.'),
798
+						$class_name,
799
+						'<br />' . implode(',<br />', $file_paths)
800
+					)
801
+				);
802
+			}
803
+			// get the file
804
+			require_once($path);
805
+			// if the class isn't already declared somewhere
806
+			if (class_exists($class_name, false) === false) {
807
+				// so sorry, not a class
808
+				throw new EE_Error(
809
+					sprintf(
810
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
811
+						$type,
812
+						$path,
813
+						$class_name
814
+					)
815
+				);
816
+			}
817
+		} catch (EE_Error $e) {
818
+			$e->get_error();
819
+			return false;
820
+		}
821
+		return true;
822
+	}
823
+
824
+
825
+
826
+	/**
827
+	 * _create_object
828
+	 * Attempts to instantiate the requested class via any of the
829
+	 * commonly used instantiation methods employed throughout EE.
830
+	 * The priority for instantiation is as follows:
831
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
832
+	 *        - model objects via their 'new_instance_from_db' method
833
+	 *        - model objects via their 'new_instance' method
834
+	 *        - "singleton" classes" via their 'instance' method
835
+	 *    - standard instantiable classes via their __constructor
836
+	 * Prior to instantiation, if the classname exists in the dependency_map,
837
+	 * then the constructor for the requested class will be examined to determine
838
+	 * if any dependencies exist, and if they can be injected.
839
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
840
+	 *
841
+	 * @access protected
842
+	 * @param string $class_name
843
+	 * @param array  $arguments
844
+	 * @param string $type
845
+	 * @param bool   $from_db
846
+	 * @return null | object
847
+	 * @throws \EE_Error
848
+	 */
849
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
850
+	{
851
+		$class_obj = null;
852
+		$instantiation_mode = '0) none';
853
+		// don't give up! you gotta...
854
+		try {
855
+			// create reflection
856
+			$reflector = $this->get_ReflectionClass($class_name);
857
+			// make sure arguments are an array
858
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
859
+			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
860
+			// else wrap it in an additional array so that it doesn't get split into multiple parameters
861
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
862
+				? $arguments
863
+				: array($arguments);
864
+			// attempt to inject dependencies ?
865
+			if ($this->_dependency_map->has($class_name)) {
866
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
867
+			}
868
+			// instantiate the class if possible
869
+			if ($reflector->isAbstract()) {
870
+				// nothing to instantiate, loading file was enough
871
+				// does not throw an exception so $instantiation_mode is unused
872
+				// $instantiation_mode = "1) no constructor abstract class";
873
+				$class_obj = true;
874
+			} else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
875
+				// no constructor = static methods only... nothing to instantiate, loading file was enough
876
+				$instantiation_mode = "2) no constructor but instantiable";
877
+				$class_obj = $reflector->newInstance();
878
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
879
+				$instantiation_mode = "3) new_instance_from_db()";
880
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
881
+			} else if (method_exists($class_name, 'new_instance')) {
882
+				$instantiation_mode = "4) new_instance()";
883
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
884
+			} else if (method_exists($class_name, 'instance')) {
885
+				$instantiation_mode = "5) instance()";
886
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
887
+			} else if ($reflector->isInstantiable()) {
888
+				$instantiation_mode = "6) constructor";
889
+				$class_obj = $reflector->newInstanceArgs($arguments);
890
+			} else {
891
+				// heh ? something's not right !
892
+				throw new EE_Error(
893
+					sprintf(
894
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
895
+						$type,
896
+						$class_name
897
+					)
898
+				);
899
+			}
900
+		} catch (Exception $e) {
901
+			if ( ! $e instanceof EE_Error) {
902
+				$e = new EE_Error(
903
+					sprintf(
904
+						__('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
905
+						$class_name,
906
+						'<br />',
907
+						$e->getMessage(),
908
+						$instantiation_mode
909
+					)
910
+				);
911
+			}
912
+			$e->get_error();
913
+		}
914
+		return $class_obj;
915
+	}
916
+
917
+
918
+
919
+	/**
920
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
921
+	 * @param array $array
922
+	 * @return bool
923
+	 */
924
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
925
+	{
926
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
927
+	}
928
+
929
+
930
+
931
+	/**
932
+	 * getReflectionClass
933
+	 * checks if a ReflectionClass object has already been generated for a class
934
+	 * and returns that instead of creating a new one
935
+	 *
936
+	 * @access public
937
+	 * @param string $class_name
938
+	 * @return ReflectionClass
939
+	 */
940
+	public function get_ReflectionClass($class_name)
941
+	{
942
+		if (
943
+			! isset($this->_reflectors[$class_name])
944
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
945
+		) {
946
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
947
+		}
948
+		return $this->_reflectors[$class_name];
949
+	}
950
+
951
+
952
+
953
+	/**
954
+	 * _resolve_dependencies
955
+	 * examines the constructor for the requested class to determine
956
+	 * if any dependencies exist, and if they can be injected.
957
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
958
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
959
+	 * For example:
960
+	 *        if attempting to load a class "Foo" with the following constructor:
961
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
962
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
963
+	 *        but only IF they are NOT already present in the incoming arguments array,
964
+	 *        and the correct classes can be loaded
965
+	 *
966
+	 * @access protected
967
+	 * @param ReflectionClass $reflector
968
+	 * @param string          $class_name
969
+	 * @param array           $arguments
970
+	 * @return array
971
+	 * @throws \ReflectionException
972
+	 */
973
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
974
+	{
975
+		// let's examine the constructor
976
+		$constructor = $reflector->getConstructor();
977
+		// whu? huh? nothing?
978
+		if ( ! $constructor) {
979
+			return $arguments;
980
+		}
981
+		// get constructor parameters
982
+		$params = $constructor->getParameters();
983
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
984
+		$argument_keys = array_keys($arguments);
985
+		// now loop thru all of the constructors expected parameters
986
+		foreach ($params as $index => $param) {
987
+			// is this a dependency for a specific class ?
988
+			$param_class = $param->getClass() ? $param->getClass()->name : null;
989
+			if (
990
+				// param is not even a class
991
+				empty($param_class)
992
+				// and something already exists in the incoming arguments for this param
993
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
994
+			) {
995
+				// so let's skip this argument and move on to the next
996
+				continue;
997
+			} else if (
998
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
999
+				! empty($param_class)
1000
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1001
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
1002
+			) {
1003
+				// skip this argument and move on to the next
1004
+				continue;
1005
+			} else if (
1006
+				// parameter is type hinted as a class, and should be injected
1007
+				! empty($param_class)
1008
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1009
+			) {
1010
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1011
+			} else {
1012
+				try {
1013
+					$arguments[$index] = $param->getDefaultValue();
1014
+				} catch (ReflectionException $e) {
1015
+					throw new ReflectionException(
1016
+						sprintf(
1017
+							__('%1$s for parameter "$%2$s"', 'event_espresso'),
1018
+							$e->getMessage(),
1019
+							$param->getName()
1020
+						)
1021
+					);
1022
+				}
1023
+			}
1024
+		}
1025
+		return $arguments;
1026
+	}
1027
+
1028
+
1029
+
1030
+	/**
1031
+	 * @access protected
1032
+	 * @param string $class_name
1033
+	 * @param string $param_class
1034
+	 * @param array  $arguments
1035
+	 * @param mixed  $index
1036
+	 * @return array
1037
+	 */
1038
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1039
+	{
1040
+		$dependency = null;
1041
+		// should dependency be loaded from cache ?
1042
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1043
+					!== EE_Dependency_Map::load_new_object
1044
+			? true
1045
+			: false;
1046
+		// we might have a dependency...
1047
+		// let's MAYBE try and find it in our cache if that's what's been requested
1048
+		$cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1049
+		// and grab it if it exists
1050
+		if ($cached_class instanceof $param_class) {
1051
+			$dependency = $cached_class;
1052
+		} else if ($param_class != $class_name) {
1053
+			// obtain the loader method from the dependency map
1054
+			$loader = $this->_dependency_map->class_loader($param_class);
1055
+			// is loader a custom closure ?
1056
+			if ($loader instanceof Closure) {
1057
+				$dependency = $loader();
1058
+			} else {
1059
+				// set the cache on property for the recursive loading call
1060
+				$this->_cache_on = $cache_on;
1061
+				// if not, then let's try and load it via the registry
1062
+				if (method_exists($this, $loader)) {
1063
+					$dependency = $this->{$loader}($param_class);
1064
+				} else {
1065
+					$dependency = $this->create($param_class, array(), $cache_on);
1066
+				}
1067
+			}
1068
+		}
1069
+		// did we successfully find the correct dependency ?
1070
+		if ($dependency instanceof $param_class) {
1071
+			// then let's inject it into the incoming array of arguments at the correct location
1072
+			if (isset($argument_keys[$index])) {
1073
+				$arguments[$argument_keys[$index]] = $dependency;
1074
+			} else {
1075
+				$arguments[$index] = $dependency;
1076
+			}
1077
+		}
1078
+		return $arguments;
1079
+	}
1080
+
1081
+
1082
+
1083
+	/**
1084
+	 * _set_cached_class
1085
+	 * attempts to cache the instantiated class locally
1086
+	 * in one of the following places, in the following order:
1087
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1088
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1089
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1090
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1091
+	 *
1092
+	 * @access protected
1093
+	 * @param object $class_obj
1094
+	 * @param string $class_name
1095
+	 * @param string $class_prefix
1096
+	 * @param bool   $from_db
1097
+	 * @return void
1098
+	 */
1099
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1100
+	{
1101
+		if (empty($class_obj)) {
1102
+			return;
1103
+		}
1104
+		// return newly instantiated class
1105
+		if (isset($this->_class_abbreviations[$class_name])) {
1106
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
1107
+			$this->{$class_abbreviation} = $class_obj;
1108
+		} else if (property_exists($this, $class_name)) {
1109
+			$this->{$class_name} = $class_obj;
1110
+		} else if ($class_prefix == 'addon') {
1111
+			$this->addons->{$class_name} = $class_obj;
1112
+		} else if ( ! $from_db) {
1113
+			$this->LIB->{$class_name} = $class_obj;
1114
+		}
1115
+	}
1116
+
1117
+
1118
+
1119
+	/**
1120
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1121
+	 *
1122
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1123
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1124
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1125
+	 * @param array  $arguments
1126
+	 * @return object
1127
+	 */
1128
+	public static function factory($classname, $arguments = array())
1129
+	{
1130
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1131
+		if ($loader instanceof Closure) {
1132
+			return $loader($arguments);
1133
+		} else if (method_exists(EE_Registry::instance(), $loader)) {
1134
+			return EE_Registry::instance()->{$loader}($classname, $arguments);
1135
+		}
1136
+		return null;
1137
+	}
1138
+
1139
+
1140
+
1141
+	/**
1142
+	 * Gets the addon by its name/slug (not classname. For that, just
1143
+	 * use the classname as the property name on EE_Config::instance()->addons)
1144
+	 *
1145
+	 * @param string $name
1146
+	 * @return EE_Addon
1147
+	 */
1148
+	public function get_addon_by_name($name)
1149
+	{
1150
+		foreach ($this->addons as $addon) {
1151
+			if ($addon->name() == $name) {
1152
+				return $addon;
1153
+			}
1154
+		}
1155
+		return null;
1156
+	}
1157
+
1158
+
1159
+
1160
+	/**
1161
+	 * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1162
+	 * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1163
+	 *
1164
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1165
+	 */
1166
+	public function get_addons_by_name()
1167
+	{
1168
+		$addons = array();
1169
+		foreach ($this->addons as $addon) {
1170
+			$addons[$addon->name()] = $addon;
1171
+		}
1172
+		return $addons;
1173
+	}
1174
+
1175
+
1176
+
1177
+	/**
1178
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1179
+	 * a stale copy of it around
1180
+	 *
1181
+	 * @param string $model_name
1182
+	 * @return \EEM_Base
1183
+	 * @throws \EE_Error
1184
+	 */
1185
+	public function reset_model($model_name)
1186
+	{
1187
+		$model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1188
+		if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1189
+			return null;
1190
+		}
1191
+		//get that model reset it and make sure we nuke the old reference to it
1192
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1193
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1194
+		} else {
1195
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1196
+		}
1197
+		return $this->LIB->{$model_class_name};
1198
+	}
1199
+
1200
+
1201
+
1202
+	/**
1203
+	 * Resets the registry.
1204
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1205
+	 * is used in a multisite install.  Here is a list of things that are NOT reset.
1206
+	 * - $_dependency_map
1207
+	 * - $_class_abbreviations
1208
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1209
+	 * - $REQ:  Still on the same request so no need to change.
1210
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1211
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1212
+	 *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1213
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1214
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1215
+	 *             switch or on the restore.
1216
+	 * - $modules
1217
+	 * - $shortcodes
1218
+	 * - $widgets
1219
+	 *
1220
+	 * @param boolean $hard             whether to reset data in the database too, or just refresh
1221
+	 *                                  the Registry to its state at the beginning of the request
1222
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1223
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1224
+	 *                                  currently reinstantiate the singletons at the moment)
1225
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1226
+	 *                                  code instead can just change the model context to a different blog id if necessary
1227
+	 * @return EE_Registry
1228
+	 */
1229
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1230
+	{
1231
+		$instance = self::instance();
1232
+		EEH_Activation::reset();
1233
+		//properties that get reset
1234
+		$instance->_cache_on = true;
1235
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1236
+		$instance->CART = null;
1237
+		$instance->MRM = null;
1238
+		$instance->AssetsRegistry = null;
1239
+		$instance->AssetsRegistry = $instance->create('EventEspresso\core\services\assets\Registry');
1240
+		//messages reset
1241
+		EED_Messages::reset();
1242
+		if ($reset_models) {
1243
+			foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1244
+				$instance->reset_model($model_name);
1245
+			}
1246
+		}
1247
+		$instance->LIB = new stdClass();
1248
+		return $instance;
1249
+	}
1250
+
1251
+
1252
+
1253
+	/**
1254
+	 * @override magic methods
1255
+	 * @return void
1256
+	 */
1257
+	public final function __destruct()
1258
+	{
1259
+	}
1260
+
1261
+
1262
+
1263
+	/**
1264
+	 * @param $a
1265
+	 * @param $b
1266
+	 */
1267
+	public final function __call($a, $b)
1268
+	{
1269
+	}
1270
+
1271
+
1272
+
1273
+	/**
1274
+	 * @param $a
1275
+	 */
1276
+	public final function __get($a)
1277
+	{
1278
+	}
1279
+
1280
+
1281
+
1282
+	/**
1283
+	 * @param $a
1284
+	 * @param $b
1285
+	 */
1286
+	public final function __set($a, $b)
1287
+	{
1288
+	}
1289
+
1290
+
1291
+
1292
+	/**
1293
+	 * @param $a
1294
+	 */
1295
+	public final function __isset($a)
1296
+	{
1297
+	}
1298 1298
 
1299 1299
 
1300 1300
 
1301
-    /**
1302
-     * @param $a
1303
-     */
1304
-    public final function __unset($a)
1305
-    {
1306
-    }
1301
+	/**
1302
+	 * @param $a
1303
+	 */
1304
+	public final function __unset($a)
1305
+	{
1306
+	}
1307 1307
 
1308 1308
 
1309 1309
 
1310
-    /**
1311
-     * @return array
1312
-     */
1313
-    public final function __sleep()
1314
-    {
1315
-        return array();
1316
-    }
1310
+	/**
1311
+	 * @return array
1312
+	 */
1313
+	public final function __sleep()
1314
+	{
1315
+		return array();
1316
+	}
1317 1317
 
1318 1318
 
1319 1319
 
1320
-    public final function __wakeup()
1321
-    {
1322
-    }
1320
+	public final function __wakeup()
1321
+	{
1322
+	}
1323 1323
 
1324 1324
 
1325 1325
 
1326
-    /**
1327
-     * @return string
1328
-     */
1329
-    public final function __toString()
1330
-    {
1331
-        return '';
1332
-    }
1326
+	/**
1327
+	 * @return string
1328
+	 */
1329
+	public final function __toString()
1330
+	{
1331
+		return '';
1332
+	}
1333 1333
 
1334 1334
 
1335 1335
 
1336
-    public final function __invoke()
1337
-    {
1338
-    }
1336
+	public final function __invoke()
1337
+	{
1338
+	}
1339 1339
 
1340 1340
 
1341 1341
 
1342
-    public final static function __set_state($array = array())
1343
-    {
1344
-        return EE_Registry::instance();
1345
-    }
1342
+	public final static function __set_state($array = array())
1343
+	{
1344
+		return EE_Registry::instance();
1345
+	}
1346 1346
 
1347 1347
 
1348 1348
 
1349
-    public final function __clone()
1350
-    {
1351
-    }
1349
+	public final function __clone()
1350
+	{
1351
+	}
1352 1352
 
1353 1353
 
1354 1354
 
1355
-    /**
1356
-     * @param $a
1357
-     * @param $b
1358
-     */
1359
-    public final static function __callStatic($a, $b)
1360
-    {
1361
-    }
1355
+	/**
1356
+	 * @param $a
1357
+	 * @param $b
1358
+	 */
1359
+	public final static function __callStatic($a, $b)
1360
+	{
1361
+	}
1362 1362
 
1363 1363
 
1364 1364
 
1365
-    /**
1366
-     * Gets all the custom post type models defined
1367
-     *
1368
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1369
-     */
1370
-    public function cpt_models()
1371
-    {
1372
-        $cpt_models = array();
1373
-        foreach ($this->non_abstract_db_models() as $short_name => $classname) {
1374
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1375
-                $cpt_models[$short_name] = $classname;
1376
-            }
1377
-        }
1378
-        return $cpt_models;
1379
-    }
1365
+	/**
1366
+	 * Gets all the custom post type models defined
1367
+	 *
1368
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1369
+	 */
1370
+	public function cpt_models()
1371
+	{
1372
+		$cpt_models = array();
1373
+		foreach ($this->non_abstract_db_models() as $short_name => $classname) {
1374
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1375
+				$cpt_models[$short_name] = $classname;
1376
+			}
1377
+		}
1378
+		return $cpt_models;
1379
+	}
1380 1380
 
1381 1381
 
1382 1382
 
1383
-    /**
1384
-     * Gets all the non-abstract database model names. If we haven't yet discovered what they are, does that
1385
-     * @return array keys are model names (eg "Event") and values are their classnames (eg "EEM_Event")
1386
-     */
1387
-    public function non_abstract_db_models()
1388
-    {
1389
-        $this->_verify_models_discovered();
1390
-        return $this->non_abstract_db_models;
1391
-    }
1383
+	/**
1384
+	 * Gets all the non-abstract database model names. If we haven't yet discovered what they are, does that
1385
+	 * @return array keys are model names (eg "Event") and values are their classnames (eg "EEM_Event")
1386
+	 */
1387
+	public function non_abstract_db_models()
1388
+	{
1389
+		$this->_verify_models_discovered();
1390
+		return $this->non_abstract_db_models;
1391
+	}
1392 1392
 
1393 1393
 
1394 1394
 
1395
-    /**
1396
-     * Gets the names of all the "models", including abstract and "non-database" models.
1397
-     * Mainly all the classes from core/db_models.
1398
-     * You may want to use EE_Registry::non_abstract_db_models instead
1399
-     * @return array keys are model names (eg "Event") and values are their classnames (eg "EEM_Event")
1400
-     */
1401
-    public function models()
1402
-    {
1403
-        $this->_verify_models_discovered();
1404
-        return $this->models;
1405
-    }
1395
+	/**
1396
+	 * Gets the names of all the "models", including abstract and "non-database" models.
1397
+	 * Mainly all the classes from core/db_models.
1398
+	 * You may want to use EE_Registry::non_abstract_db_models instead
1399
+	 * @return array keys are model names (eg "Event") and values are their classnames (eg "EEM_Event")
1400
+	 */
1401
+	public function models()
1402
+	{
1403
+		$this->_verify_models_discovered();
1404
+		return $this->models;
1405
+	}
1406 1406
 
1407 1407
 
1408 1408
 
1409
-    /**
1410
-     * Discovers all the models in core/db_models and remembers them on properties
1411
-     * models and non_abstract_db_models
1412
-     * @return void
1413
-     */
1414
-    private function _verify_models_discovered()
1415
-    {
1416
-        if( ! $this->non_abstract_db_models
1417
-            || ! $this->models){
1418
-            //get all the files in the EE_MODELS folder that end in .model.php
1419
-            $models = glob(EE_MODELS . '*.model.php');
1420
-            $model_names = array();
1421
-            $non_abstract_db_models = array();
1422
-            foreach ($models as $model) {
1423
-                // get model classname
1424
-                $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
1425
-                $short_name = str_replace('EEM_', '', $classname);
1426
-                $reflectionClass = $this->get_ReflectionClass($classname);
1427
-                if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
1428
-                    $non_abstract_db_models[$short_name] = $classname;
1429
-                }
1430
-                $model_names[$short_name] = $classname;
1431
-            }
1432
-            //continue using legacy filter names (originally this logic was contained elsewhere)
1433
-            $this->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
1434
-            $this->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names',
1435
-                $non_abstract_db_models);
1436
-        }
1437
-    }
1438
-
1439
-
1440
-
1441
-    /**
1442
-     * @return \EE_Config
1443
-     */
1444
-    public static function CFG()
1445
-    {
1446
-        return self::instance()->CFG;
1447
-    }
1409
+	/**
1410
+	 * Discovers all the models in core/db_models and remembers them on properties
1411
+	 * models and non_abstract_db_models
1412
+	 * @return void
1413
+	 */
1414
+	private function _verify_models_discovered()
1415
+	{
1416
+		if( ! $this->non_abstract_db_models
1417
+			|| ! $this->models){
1418
+			//get all the files in the EE_MODELS folder that end in .model.php
1419
+			$models = glob(EE_MODELS . '*.model.php');
1420
+			$model_names = array();
1421
+			$non_abstract_db_models = array();
1422
+			foreach ($models as $model) {
1423
+				// get model classname
1424
+				$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
1425
+				$short_name = str_replace('EEM_', '', $classname);
1426
+				$reflectionClass = $this->get_ReflectionClass($classname);
1427
+				if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
1428
+					$non_abstract_db_models[$short_name] = $classname;
1429
+				}
1430
+				$model_names[$short_name] = $classname;
1431
+			}
1432
+			//continue using legacy filter names (originally this logic was contained elsewhere)
1433
+			$this->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
1434
+			$this->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names',
1435
+				$non_abstract_db_models);
1436
+		}
1437
+	}
1438
+
1439
+
1440
+
1441
+	/**
1442
+	 * @return \EE_Config
1443
+	 */
1444
+	public static function CFG()
1445
+	{
1446
+		return self::instance()->CFG;
1447
+	}
1448 1448
 
1449 1449
 
1450 1450
 }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/BaseCoreAdmin.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@
 block discarded – undo
13 13
 trait BaseCoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * Core method for going to an Event Espresso Admin page.
18
-     * @param string $page
19
-     * @param string $action
20
-     * @param string $additional_params
21
-     */
22
-    public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
-    {
24
-        $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
-    }
16
+	/**
17
+	 * Core method for going to an Event Espresso Admin page.
18
+	 * @param string $page
19
+	 * @param string $action
20
+	 * @param string $additional_params
21
+	 */
22
+	public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
+	{
24
+		$this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
-     * @return \EventEspressoAcceptanceTester;
31
-     */
32
-    protected function actor()
33
-    {
34
-        /** @var \EventEspressoAcceptanceTester $this */
35
-        return $this;
36
-    }
28
+	/**
29
+	 * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
+	 * @return \EventEspressoAcceptanceTester;
31
+	 */
32
+	protected function actor()
33
+	{
34
+		/** @var \EventEspressoAcceptanceTester $this */
35
+		return $this;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Use this to set the per page option for a list table page.
41
-     * Assumes you are on a page that has this field exposed.
42
-     *
43
-     * @param int|string $per_page_value
44
-     * @throws \Codeception\Exception\TestRuntimeException
45
-     */
46
-    public function setPerPageOptionForScreen($per_page_value)
47
-    {
48
-        $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
49
-        $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
50
-        $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
51
-        $this->actor()->wait(8);
52
-    }
39
+	/**
40
+	 * Use this to set the per page option for a list table page.
41
+	 * Assumes you are on a page that has this field exposed.
42
+	 *
43
+	 * @param int|string $per_page_value
44
+	 * @throws \Codeception\Exception\TestRuntimeException
45
+	 */
46
+	public function setPerPageOptionForScreen($per_page_value)
47
+	{
48
+		$this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
49
+		$this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
50
+		$this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
51
+		$this->actor()->wait(8);
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * Use this to append a given value to a wpEditor instance.
58
-     * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and
59
-     * the value is added to the text area.
60
-     *
61
-     * @param $field_reference
62
-     * @param $value
63
-     * @throws \Codeception\Exception\ElementNotFound
64
-     */
65
-    public function appendToWPEditorField($field_reference, $value)
66
-    {
67
-        $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference));
68
-        $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value);
69
-    }
56
+	/**
57
+	 * Use this to append a given value to a wpEditor instance.
58
+	 * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and
59
+	 * the value is added to the text area.
60
+	 *
61
+	 * @param $field_reference
62
+	 * @param $value
63
+	 * @throws \Codeception\Exception\ElementNotFound
64
+	 */
65
+	public function appendToWPEditorField($field_reference, $value)
66
+	{
67
+		$this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference));
68
+		$this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value);
69
+	}
70 70
 }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/MessagesAdmin.php 1 patch
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -10,228 +10,228 @@
 block discarded – undo
10 10
  */
11 11
 trait MessagesAdmin
12 12
 {
13
-    /**
14
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
15
-     *                                  a string.
16
-     */
17
-    public function amOnMessagesActivityListTablePage($additional_params = '')
18
-    {
19
-        $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
-    }
21
-
22
-    /**
23
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
24
-     *                                  a string.
25
-     */
26
-    public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
-    {
28
-        $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
-    }
30
-
31
-
32
-    /**
33
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
34
-     *                                  a string.
35
-     */
36
-    public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
-    {
38
-        $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
-    }
40
-
41
-
42
-    /**
43
-     * Directs to message settings page
44
-     */
45
-    public function amOnMessageSettingsPage()
46
-    {
47
-        $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
-    }
49
-
50
-
51
-    public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
-    {
53
-        $this->actor()->dragAndDrop(
54
-            MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
-            MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
-        );
57
-    }
58
-
59
-
60
-    /**
61
-     * Assumes you are already on the list table page that has the ui for editing the template.
62
-     * @param string $message_type_slug
63
-     * @param string $context [optional] if you want to click directly to the given context in the editor
64
-     */
65
-    public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
-    {
67
-        $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
-    }
69
-
70
-
71
-    /**
72
-     * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
-     * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
-     *
75
-     * @param int    $expected_occurence_count
76
-     * @param string $text_to_check_for
77
-     * @param string $field
78
-     * @param string $message_type_label
79
-     * @param string $message_status
80
-     * @param string $messenger
81
-     * @param string $context
82
-     */
83
-    public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
-        $expected_occurence_count,
85
-        $text_to_check_for,
86
-        $field,
87
-        $message_type_label,
88
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
-        $messenger = 'Email',
90
-        $context = 'Event Admin'
91
-    ) {
92
-        $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
-            $field,
94
-            $message_type_label,
95
-            $message_status,
96
-            $messenger,
97
-            $context,
98
-            $text_to_check_for,
99
-            0
100
-        ));
101
-        $actual_count = count($elements);
102
-        $this->actor()->assertEquals(
103
-            $expected_occurence_count,
104
-            $actual_count,
105
-            sprintf(
106
-                'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
-                $expected_occurence_count,
108
-                $text_to_check_for,
109
-                $field,
110
-                $actual_count
111
-            )
112
-        );
113
-    }
114
-
115
-
116
-    /**
117
-     * This will create a custom message template for the given messenger and message type from the context of the
118
-     * default (global) message template list table.
119
-     * Also takes care of verifying the template was created.
120
-     * @param string $message_type_label
121
-     * @param string $messenger_label
122
-     */
123
-    public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
-    {
125
-        $this->amOnDefaultMessageTemplateListTablePage();
126
-        $this->actor()->click(
127
-            MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
-                $message_type_label,
129
-                $messenger_label
130
-            )
131
-        );
132
-        $this->actor()->seeInField('#title', 'New Custom Template');
133
-    }
134
-
135
-
136
-    /**
137
-     * This switches the context of the current messages template to the given reference.
138
-     * @param string $context_reference  This should be the visible label for the option.
139
-     */
140
-    public function switchContextTo($context_reference)
141
-    {
142
-        $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
-        $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
-        $this->actor()->waitForText($context_reference, 10, 'h1');
145
-    }
146
-
147
-
148
-    /**
149
-     * This takes care of clicking the View Message icon for the given parameters.
150
-     * Assumes you are already viewing the messages activity list table.
151
-     * @param        $message_type_label
152
-     * @param        $message_status
153
-     * @param string $messenger
154
-     * @param string $context
155
-     * @param int    $number_in_set
156
-     */
157
-    public function viewMessageInMessagesListTableFor(
158
-        $message_type_label,
159
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
160
-        $messenger = 'Email',
161
-        $context = 'Event Admin',
162
-        $number_in_set = 1
163
-    ) {
164
-        $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
165
-            $message_type_label,
166
-            $message_status,
167
-            $messenger,
168
-            $context,
169
-            $number_in_set
170
-        ));
171
-    }
172
-
173
-
174
-    /**
175
-     * Takes care of deleting a message matching the given parameters via the message activity list table.
176
-     * Assumes you are already viewing the messages activity list table.
177
-     * @param        $message_type_label
178
-     * @param        $message_status
179
-     * @param string $messenger
180
-     * @param string $context
181
-     * @param int    $number_in_set
182
-     */
183
-    public function deleteMessageInMessagesListTableFor(
184
-        $message_type_label,
185
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
186
-        $messenger = 'Email',
187
-        $context = 'Event Admin',
188
-        $number_in_set = 1
189
-    ) {
190
-        $this->actor()->moveMouseOver(
191
-            MessagesPage::messagesActivityListTableCellSelectorFor(
192
-                'to',
193
-                $message_type_label,
194
-                $message_status,
195
-                $messenger,
196
-                $context,
197
-                '',
198
-                $number_in_set
199
-            )
200
-        );
201
-        $this->actor()->click(
202
-            MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
203
-                $message_type_label,
204
-                $message_status,
205
-                $messenger,
206
-                $context,
207
-                $number_in_set
208
-            )
209
-        );
210
-        $this->actor()->waitForText('successfully deleted');
211
-    }
212
-
213
-
214
-    /**
215
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
216
-     * list table, this will take care of validating the given text is in that window.
217
-     * @param string $text_to_view
218
-     */
219
-    public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
220
-    {
221
-        $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
222
-        $this->actor()->switchToIframe('message-view-window');
223
-        $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
224
-        $this->actor()->switchToIframe();
225
-    }
226
-
227
-
228
-    /**
229
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
230
-     * list table, this will take care of validating the given text is NOT that window.
231
-     * @param string $text_to_view
232
-     */
233
-    public function dontSeeTextInViewMessageModal($text_to_view)
234
-    {
235
-        $this->seeTextInViewMessageModal($text_to_view, true);
236
-    }
13
+	/**
14
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
15
+	 *                                  a string.
16
+	 */
17
+	public function amOnMessagesActivityListTablePage($additional_params = '')
18
+	{
19
+		$this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
+	}
21
+
22
+	/**
23
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
24
+	 *                                  a string.
25
+	 */
26
+	public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
+	{
28
+		$this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
34
+	 *                                  a string.
35
+	 */
36
+	public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
+	{
38
+		$this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
+	}
40
+
41
+
42
+	/**
43
+	 * Directs to message settings page
44
+	 */
45
+	public function amOnMessageSettingsPage()
46
+	{
47
+		$this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
+	}
49
+
50
+
51
+	public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
+	{
53
+		$this->actor()->dragAndDrop(
54
+			MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
+			MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
+		);
57
+	}
58
+
59
+
60
+	/**
61
+	 * Assumes you are already on the list table page that has the ui for editing the template.
62
+	 * @param string $message_type_slug
63
+	 * @param string $context [optional] if you want to click directly to the given context in the editor
64
+	 */
65
+	public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
+	{
67
+		$this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
+	}
69
+
70
+
71
+	/**
72
+	 * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
+	 * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
+	 *
75
+	 * @param int    $expected_occurence_count
76
+	 * @param string $text_to_check_for
77
+	 * @param string $field
78
+	 * @param string $message_type_label
79
+	 * @param string $message_status
80
+	 * @param string $messenger
81
+	 * @param string $context
82
+	 */
83
+	public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
+		$expected_occurence_count,
85
+		$text_to_check_for,
86
+		$field,
87
+		$message_type_label,
88
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
+		$messenger = 'Email',
90
+		$context = 'Event Admin'
91
+	) {
92
+		$elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
+			$field,
94
+			$message_type_label,
95
+			$message_status,
96
+			$messenger,
97
+			$context,
98
+			$text_to_check_for,
99
+			0
100
+		));
101
+		$actual_count = count($elements);
102
+		$this->actor()->assertEquals(
103
+			$expected_occurence_count,
104
+			$actual_count,
105
+			sprintf(
106
+				'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
+				$expected_occurence_count,
108
+				$text_to_check_for,
109
+				$field,
110
+				$actual_count
111
+			)
112
+		);
113
+	}
114
+
115
+
116
+	/**
117
+	 * This will create a custom message template for the given messenger and message type from the context of the
118
+	 * default (global) message template list table.
119
+	 * Also takes care of verifying the template was created.
120
+	 * @param string $message_type_label
121
+	 * @param string $messenger_label
122
+	 */
123
+	public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
+	{
125
+		$this->amOnDefaultMessageTemplateListTablePage();
126
+		$this->actor()->click(
127
+			MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
+				$message_type_label,
129
+				$messenger_label
130
+			)
131
+		);
132
+		$this->actor()->seeInField('#title', 'New Custom Template');
133
+	}
134
+
135
+
136
+	/**
137
+	 * This switches the context of the current messages template to the given reference.
138
+	 * @param string $context_reference  This should be the visible label for the option.
139
+	 */
140
+	public function switchContextTo($context_reference)
141
+	{
142
+		$this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
+		$this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
+		$this->actor()->waitForText($context_reference, 10, 'h1');
145
+	}
146
+
147
+
148
+	/**
149
+	 * This takes care of clicking the View Message icon for the given parameters.
150
+	 * Assumes you are already viewing the messages activity list table.
151
+	 * @param        $message_type_label
152
+	 * @param        $message_status
153
+	 * @param string $messenger
154
+	 * @param string $context
155
+	 * @param int    $number_in_set
156
+	 */
157
+	public function viewMessageInMessagesListTableFor(
158
+		$message_type_label,
159
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
160
+		$messenger = 'Email',
161
+		$context = 'Event Admin',
162
+		$number_in_set = 1
163
+	) {
164
+		$this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
165
+			$message_type_label,
166
+			$message_status,
167
+			$messenger,
168
+			$context,
169
+			$number_in_set
170
+		));
171
+	}
172
+
173
+
174
+	/**
175
+	 * Takes care of deleting a message matching the given parameters via the message activity list table.
176
+	 * Assumes you are already viewing the messages activity list table.
177
+	 * @param        $message_type_label
178
+	 * @param        $message_status
179
+	 * @param string $messenger
180
+	 * @param string $context
181
+	 * @param int    $number_in_set
182
+	 */
183
+	public function deleteMessageInMessagesListTableFor(
184
+		$message_type_label,
185
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
186
+		$messenger = 'Email',
187
+		$context = 'Event Admin',
188
+		$number_in_set = 1
189
+	) {
190
+		$this->actor()->moveMouseOver(
191
+			MessagesPage::messagesActivityListTableCellSelectorFor(
192
+				'to',
193
+				$message_type_label,
194
+				$message_status,
195
+				$messenger,
196
+				$context,
197
+				'',
198
+				$number_in_set
199
+			)
200
+		);
201
+		$this->actor()->click(
202
+			MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
203
+				$message_type_label,
204
+				$message_status,
205
+				$messenger,
206
+				$context,
207
+				$number_in_set
208
+			)
209
+		);
210
+		$this->actor()->waitForText('successfully deleted');
211
+	}
212
+
213
+
214
+	/**
215
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
216
+	 * list table, this will take care of validating the given text is in that window.
217
+	 * @param string $text_to_view
218
+	 */
219
+	public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
220
+	{
221
+		$this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
222
+		$this->actor()->switchToIframe('message-view-window');
223
+		$should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
224
+		$this->actor()->switchToIframe();
225
+	}
226
+
227
+
228
+	/**
229
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
230
+	 * list table, this will take care of validating the given text is NOT that window.
231
+	 * @param string $text_to_view
232
+	 */
233
+	public function dontSeeTextInViewMessageModal($text_to_view)
234
+	{
235
+		$this->seeTextInViewMessageModal($text_to_view, true);
236
+	}
237 237
 }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,84 +14,84 @@
 block discarded – undo
14 14
 trait EventsAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $additional_params
19
-     */
20
-    public function amOnDefaultEventsListTablePage($additional_params = '')
21
-    {
22
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
-    }
17
+	/**
18
+	 * @param string $additional_params
19
+	 */
20
+	public function amOnDefaultEventsListTablePage($additional_params = '')
21
+	{
22
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Triggers the publishing of the Event.
28
-     */
29
-    public function publishEvent()
30
-    {
31
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
-    }
26
+	/**
27
+	 * Triggers the publishing of the Event.
28
+	 */
29
+	public function publishEvent()
30
+	{
31
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
37
-     * First this will search using the given title and then attempt to edit from the results of the search.
38
-     *
39
-     * Assumes actor is already logged in.
40
-     * @param $event_title
41
-     */
42
-    public function amEditingTheEventWithTitle($event_title)
43
-    {
44
-        $this->amOnDefaultEventsListTablePage();
45
-        $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
46
-        $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
47
-        $this->actor()->waitForText('Displaying search results for');
48
-        $this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
49
-    }
35
+	/**
36
+	 * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
37
+	 * First this will search using the given title and then attempt to edit from the results of the search.
38
+	 *
39
+	 * Assumes actor is already logged in.
40
+	 * @param $event_title
41
+	 */
42
+	public function amEditingTheEventWithTitle($event_title)
43
+	{
44
+		$this->amOnDefaultEventsListTablePage();
45
+		$this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
46
+		$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
47
+		$this->actor()->waitForText('Displaying search results for');
48
+		$this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
54
-     * link for the event in the event list table.
55
-     * Assumes the actor is already logged in and on the Event list table page.
56
-     *
57
-     * @param string $event_title
58
-     */
59
-    public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
60
-    {
61
-        $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
62
-        $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
63
-    }
52
+	/**
53
+	 * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
54
+	 * link for the event in the event list table.
55
+	 * Assumes the actor is already logged in and on the Event list table page.
56
+	 *
57
+	 * @param string $event_title
58
+	 */
59
+	public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
60
+	{
61
+		$this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
62
+		$this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * Use to change the default registration status for the event.
68
-     * Assumes the view is already on the event editor.
69
-     * @param $registration_status
70
-     */
71
-    public function changeDefaultRegistrationStatusTo($registration_status)
72
-    {
73
-        $this->actor()->selectOption(
74
-            EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
75
-            $registration_status
76
-        );
77
-    }
66
+	/**
67
+	 * Use to change the default registration status for the event.
68
+	 * Assumes the view is already on the event editor.
69
+	 * @param $registration_status
70
+	 */
71
+	public function changeDefaultRegistrationStatusTo($registration_status)
72
+	{
73
+		$this->actor()->selectOption(
74
+			EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
75
+			$registration_status
76
+		);
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * Use this from the context of the event editor to select the given custom template for a given message type and
82
-     * messenger.
83
-     *
84
-     * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
85
-     * @param string $messenger_slug      The slug for the messenger (eg 'email')
86
-     * @param string $custom_template_label The visible label in the select input for the custom template you want
87
-     *                                      selected.
88
-     */
89
-    public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
90
-    {
91
-        $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
92
-        $this->actor()->selectOption(
93
-            EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
94
-            $custom_template_label
95
-        );
96
-    }
80
+	/**
81
+	 * Use this from the context of the event editor to select the given custom template for a given message type and
82
+	 * messenger.
83
+	 *
84
+	 * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
85
+	 * @param string $messenger_slug      The slug for the messenger (eg 'email')
86
+	 * @param string $custom_template_label The visible label in the select input for the custom template you want
87
+	 *                                      selected.
88
+	 */
89
+	public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
90
+	{
91
+		$this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
92
+		$this->actor()->selectOption(
93
+			EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
94
+			$custom_template_label
95
+		);
96
+	}
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/CoreAdmin.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -13,84 +13,84 @@
 block discarded – undo
13 13
 class CoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * @var string
18
-     */
19
-    const URL_PREFIX = 'admin.php?page=';
20
-
21
-
22
-    /**
23
-     * This is the selector for the next page button on list tables.
24
-     * @var string
25
-     */
26
-    const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
27
-
28
-
29
-    /**
30
-     * The selector for the search input submit button on list table pages
31
-     * @var string
32
-     */
33
-    const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
34
-
35
-
36
-    /**
37
-     * Selector for the screen options dropdown.
38
-     * @var string
39
-     */
40
-    const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
41
-
42
-
43
-    /**
44
-     * Selector for the per page field setting selector (found within screen options dropdown)
45
-     * @var string
46
-     */
47
-    const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
48
-
49
-
50
-    /**
51
-     * Selector for apply screen options settings.
52
-     * @var string
53
-     */
54
-    const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
55
-
56
-
57
-    /**
58
-     * Get the EE admin url for the given properties.
59
-     * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
60
-     * with `amOnAdminPage` action.
61
-     *
62
-     * @param string $page
63
-     * @param string $action
64
-     * @param string $additional_params
65
-     * @return string
66
-     */
67
-    public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
68
-    {
69
-        $url = self::URL_PREFIX . $page;
70
-        $url .= $action ? '&action=' . $action : '';
71
-        $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
72
-        return $url;
73
-    }
74
-
75
-
76
-    /**
77
-     * Returns the selector for the text tab switcher for a wp-editor instance.
78
-     * @param $field_reference
79
-     * @return string
80
-     */
81
-    public static function wpEditorTextTabSelector($field_reference)
82
-    {
83
-        return '#content-' . $field_reference . '-content-html';
84
-    }
85
-
86
-
87
-    /**
88
-     * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance.
89
-     * @param $field_reference
90
-     * @return string
91
-     */
92
-    public static function wpEditorTextAreaSelector($field_reference)
93
-    {
94
-        return '#content-' . $field_reference . '-content';
95
-    }
16
+	/**
17
+	 * @var string
18
+	 */
19
+	const URL_PREFIX = 'admin.php?page=';
20
+
21
+
22
+	/**
23
+	 * This is the selector for the next page button on list tables.
24
+	 * @var string
25
+	 */
26
+	const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
27
+
28
+
29
+	/**
30
+	 * The selector for the search input submit button on list table pages
31
+	 * @var string
32
+	 */
33
+	const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
34
+
35
+
36
+	/**
37
+	 * Selector for the screen options dropdown.
38
+	 * @var string
39
+	 */
40
+	const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
41
+
42
+
43
+	/**
44
+	 * Selector for the per page field setting selector (found within screen options dropdown)
45
+	 * @var string
46
+	 */
47
+	const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
48
+
49
+
50
+	/**
51
+	 * Selector for apply screen options settings.
52
+	 * @var string
53
+	 */
54
+	const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
55
+
56
+
57
+	/**
58
+	 * Get the EE admin url for the given properties.
59
+	 * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
60
+	 * with `amOnAdminPage` action.
61
+	 *
62
+	 * @param string $page
63
+	 * @param string $action
64
+	 * @param string $additional_params
65
+	 * @return string
66
+	 */
67
+	public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
68
+	{
69
+		$url = self::URL_PREFIX . $page;
70
+		$url .= $action ? '&action=' . $action : '';
71
+		$url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
72
+		return $url;
73
+	}
74
+
75
+
76
+	/**
77
+	 * Returns the selector for the text tab switcher for a wp-editor instance.
78
+	 * @param $field_reference
79
+	 * @return string
80
+	 */
81
+	public static function wpEditorTextTabSelector($field_reference)
82
+	{
83
+		return '#content-' . $field_reference . '-content-html';
84
+	}
85
+
86
+
87
+	/**
88
+	 * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance.
89
+	 * @param $field_reference
90
+	 * @return string
91
+	 */
92
+	public static function wpEditorTextAreaSelector($field_reference)
93
+	{
94
+		return '#content-' . $field_reference . '-content';
95
+	}
96 96
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
68 68
     {
69
-        $url = self::URL_PREFIX . $page;
70
-        $url .= $action ? '&action=' . $action : '';
71
-        $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
69
+        $url = self::URL_PREFIX.$page;
70
+        $url .= $action ? '&action='.$action : '';
71
+        $url .= $additional_params ? '&'.ltrim('&', ltrim('?', $additional_params)) : '';
72 72
         return $url;
73 73
     }
74 74
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public static function wpEditorTextTabSelector($field_reference)
82 82
     {
83
-        return '#content-' . $field_reference . '-content-html';
83
+        return '#content-'.$field_reference.'-content-html';
84 84
     }
85 85
 
86 86
 
@@ -91,6 +91,6 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public static function wpEditorTextAreaSelector($field_reference)
93 93
     {
94
-        return '#content-' . $field_reference . '-content';
94
+        return '#content-'.$field_reference.'-content';
95 95
     }
96 96
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/MessagesAdmin.php 1 patch
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -12,255 +12,255 @@
 block discarded – undo
12 12
 class MessagesAdmin extends CoreAdmin
13 13
 {
14 14
 
15
-    /**
16
-     * Context slug for the admin messages context.
17
-     * @var string
18
-     */
19
-    const ADMIN_CONTEXT_SLUG = 'admin';
15
+	/**
16
+	 * Context slug for the admin messages context.
17
+	 * @var string
18
+	 */
19
+	const ADMIN_CONTEXT_SLUG = 'admin';
20 20
 
21
-    /**
22
-     * Context slug for the primary attendee messages context
23
-     * @var string
24
-     */
25
-    const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
21
+	/**
22
+	 * Context slug for the primary attendee messages context
23
+	 * @var string
24
+	 */
25
+	const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
26 26
 
27 27
 
28
-    /**
29
-     * Status reference for the EEM_Message::status_sent status.
30
-     * @var string
31
-     */
32
-    const MESSAGE_STATUS_SENT = 'MSN';
28
+	/**
29
+	 * Status reference for the EEM_Message::status_sent status.
30
+	 * @var string
31
+	 */
32
+	const MESSAGE_STATUS_SENT = 'MSN';
33 33
 
34 34
 
35
-    /**
36
-     * Message type slug for the Payment Failed message type
37
-     */
38
-    const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
35
+	/**
36
+	 * Message type slug for the Payment Failed message type
37
+	 */
38
+	const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
39 39
 
40 40
 
41
-    /**
42
-     * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
43
-     * @var string
44
-     */
45
-    const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
46
-        '#global_messages_settings-do-messages-on-same-request';
47
-
41
+	/**
42
+	 * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
43
+	 * @var string
44
+	 */
45
+	const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
46
+		'#global_messages_settings-do-messages-on-same-request';
47
+
48 48
 
49
-    /**
50
-     * Selector for the Global Messages Settings submit button in the Messages Settings tab.
51
-     * @var string
52
-     */
53
-    const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
54
-
55
-
56
-    /**
57
-     * This is the container where active message types for a messenger are found/dragged to.
58
-     * @var string
59
-     */
60
-    const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
61
-
62
-
63
-    /**
64
-     * Locator for the context switcher selector on the Message Template Editor page.
65
-     * @var string
66
-     */
67
-    const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
68
-
69
-
70
-    /**
71
-     * Locator for the context switcher submit button in the Message Template Editor page.
72
-     * @var string
73
-     */
74
-    const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
75
-
76
-
77
-    /**
78
-     * Locator for the dialog container used for housing viewed messages in the message activity list table.
79
-     * @var string
80
-     */
81
-    const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
82
-
83
-
84
-
85
-    /**
86
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
87
-     *                                  a string.
88
-     * @return string
89
-     */
90
-    public static function messageActivityListTableUrl($additional_params = '')
91
-    {
92
-        return self::adminUrl('espresso_messages', 'default', $additional_params);
93
-    }
94
-
95
-
96
-    /**
97
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
98
-     *                                  a string.
99
-     * @return string
100
-     */
101
-    public static function defaultMessageTemplateListTableUrl($additional_params = '')
102
-    {
103
-        return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
104
-    }
105
-
106
-
107
-    /**
108
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
109
-     *                                  a string.
110
-     * @return string
111
-     */
112
-    public static function customMessageTemplateListTableUrl($additional_params = '')
113
-    {
114
-        return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
115
-    }
116
-
117
-
118
-    /**
119
-     * @return string
120
-     */
121
-    public static function messageSettingsUrl()
122
-    {
123
-        return self::adminUrl('espresso_messages', 'settings');
124
-    }
125
-
126
-
127
-
128
-    public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
129
-        $message_type_slug,
130
-        $messenger_slug = 'email'
131
-    ) {
132
-        return "#$message_type_slug-messagetype-$messenger_slug";
133
-    }
134
-
135
-
136
-    /**
137
-     * @param string $message_type_slug
138
-     * @param string $context
139
-     * @return string
140
-     */
141
-    public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
142
-    {
143
-        return $context
144
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
145
-            : '.' . $message_type_slug . '-edit-link';
146
-    }
147
-
148
-
149
-    /**
150
-     * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
151
-     *
152
-     * @param        $field
153
-     * @param        $message_type_label
154
-     * @param string $message_status
155
-     * @param string $messenger
156
-     * @param string $context
157
-     * @param string $table_cell_content_for_field
158
-     * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
159
-     *                                This allows you to indicate which item from the set to match.  If this is set to 0
160
-     *                                then all matches for the locator will be returned.
161
-     * @return string
162
-     */
163
-    public static function messagesActivityListTableCellSelectorFor(
164
-        $field,
165
-        $message_type_label,
166
-        $message_status = self::MESSAGE_STATUS_SENT,
167
-        $messenger = 'Email',
168
-        $context = 'Event Admin',
169
-        $table_cell_content_for_field = '',
170
-        $number_in_set = 1
171
-    ) {
172
-        $selector = $number_in_set > 0 ? '(' : '';
173
-        $selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
174
-                     . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
175
-        if ($messenger) {
176
-            $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
177
-        }
178
-        $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
179
-        $selector .= $table_cell_content_for_field
180
-            ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
181
-            : "/ancestor::tr/td[contains(@class, 'column-$field')]";
182
-        $selector .= $number_in_set > 0 ? ")[$number_in_set]" : '';
183
-        return $selector;
184
-    }
185
-
186
-
187
-    /**
188
-     * Selector for the Create Custom button found in the message template list table.
189
-     * @param string $message_type_label
190
-     * @param string $messenger_label
191
-     * @return string
192
-     */
193
-    public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
194
-    {
195
-        $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
196
-                    . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
197
-                    . "//ancestor::tr/td/a[@class='button button-small']";
198
-        return $selector;
199
-    }
200
-
201
-
202
-    /**
203
-     * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
204
-     * the FIRST match (which will be the latest message sent if the table is default sorted).
205
-     *
206
-     * @param string $message_type_label    The visible message type label for the row you want to match
207
-     * @param string $message_status        The status of the message for the row you want to match.
208
-     * @param string $messenger             The visible messenger label for the row you want to match.
209
-     * @param string $context               The visible context label for the row you want to match.
210
-     * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
211
-     *                                      view. This allows you to indicate which item from the set to match.
212
-     * @return string
213
-     */
214
-    public static function messagesActivityListTableViewButtonSelectorFor(
215
-        $message_type_label,
216
-        $message_status = self::MESSAGE_STATUS_SENT,
217
-        $messenger = 'Email',
218
-        $context = 'Event Admin',
219
-        $number_in_set = 1
220
-    ) {
221
-        $selector = self::messagesActivityListTableCellSelectorFor(
222
-            'action',
223
-            $message_type_label,
224
-            $message_status,
225
-            $messenger,
226
-            $context,
227
-            '',
228
-            $number_in_set
229
-        );
230
-        $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
231
-                     . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
232
-        return $selector;
233
-    }
234
-
235
-
236
-
237
-    /**
238
-     * Locator for the delete action link for a message item in the message activity list table.
239
-     * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
240
-     * @param        $message_type_label
241
-     * @param string $message_status
242
-     * @param string $messenger
243
-     * @param string $context
244
-     * @param int    $number_in_set
245
-     * @return string
246
-     */
247
-    public static function messagesActivityListTableDeleteActionSelectorFor(
248
-        $message_type_label,
249
-        $message_status = self::MESSAGE_STATUS_SENT,
250
-        $messenger = 'Email',
251
-        $context = 'Event Admin',
252
-        $number_in_set = 1
253
-    ) {
254
-        $selector = self::messagesActivityListTableCellSelectorFor(
255
-            'to',
256
-            $message_type_label,
257
-            $message_status,
258
-            $messenger,
259
-            $context,
260
-            '',
261
-            $number_in_set
262
-        );
263
-        $selector .= "/div/span[@class='delete']/a";
264
-        return $selector;
265
-    }
49
+	/**
50
+	 * Selector for the Global Messages Settings submit button in the Messages Settings tab.
51
+	 * @var string
52
+	 */
53
+	const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
54
+
55
+
56
+	/**
57
+	 * This is the container where active message types for a messenger are found/dragged to.
58
+	 * @var string
59
+	 */
60
+	const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
61
+
62
+
63
+	/**
64
+	 * Locator for the context switcher selector on the Message Template Editor page.
65
+	 * @var string
66
+	 */
67
+	const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
68
+
69
+
70
+	/**
71
+	 * Locator for the context switcher submit button in the Message Template Editor page.
72
+	 * @var string
73
+	 */
74
+	const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
75
+
76
+
77
+	/**
78
+	 * Locator for the dialog container used for housing viewed messages in the message activity list table.
79
+	 * @var string
80
+	 */
81
+	const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
82
+
83
+
84
+
85
+	/**
86
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
87
+	 *                                  a string.
88
+	 * @return string
89
+	 */
90
+	public static function messageActivityListTableUrl($additional_params = '')
91
+	{
92
+		return self::adminUrl('espresso_messages', 'default', $additional_params);
93
+	}
94
+
95
+
96
+	/**
97
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
98
+	 *                                  a string.
99
+	 * @return string
100
+	 */
101
+	public static function defaultMessageTemplateListTableUrl($additional_params = '')
102
+	{
103
+		return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
109
+	 *                                  a string.
110
+	 * @return string
111
+	 */
112
+	public static function customMessageTemplateListTableUrl($additional_params = '')
113
+	{
114
+		return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return string
120
+	 */
121
+	public static function messageSettingsUrl()
122
+	{
123
+		return self::adminUrl('espresso_messages', 'settings');
124
+	}
125
+
126
+
127
+
128
+	public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
129
+		$message_type_slug,
130
+		$messenger_slug = 'email'
131
+	) {
132
+		return "#$message_type_slug-messagetype-$messenger_slug";
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param string $message_type_slug
138
+	 * @param string $context
139
+	 * @return string
140
+	 */
141
+	public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
142
+	{
143
+		return $context
144
+			? '.' . $message_type_slug . '-' . $context . '-edit-link'
145
+			: '.' . $message_type_slug . '-edit-link';
146
+	}
147
+
148
+
149
+	/**
150
+	 * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
151
+	 *
152
+	 * @param        $field
153
+	 * @param        $message_type_label
154
+	 * @param string $message_status
155
+	 * @param string $messenger
156
+	 * @param string $context
157
+	 * @param string $table_cell_content_for_field
158
+	 * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
159
+	 *                                This allows you to indicate which item from the set to match.  If this is set to 0
160
+	 *                                then all matches for the locator will be returned.
161
+	 * @return string
162
+	 */
163
+	public static function messagesActivityListTableCellSelectorFor(
164
+		$field,
165
+		$message_type_label,
166
+		$message_status = self::MESSAGE_STATUS_SENT,
167
+		$messenger = 'Email',
168
+		$context = 'Event Admin',
169
+		$table_cell_content_for_field = '',
170
+		$number_in_set = 1
171
+	) {
172
+		$selector = $number_in_set > 0 ? '(' : '';
173
+		$selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
174
+					 . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
175
+		if ($messenger) {
176
+			$selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
177
+		}
178
+		$selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
179
+		$selector .= $table_cell_content_for_field
180
+			? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
181
+			: "/ancestor::tr/td[contains(@class, 'column-$field')]";
182
+		$selector .= $number_in_set > 0 ? ")[$number_in_set]" : '';
183
+		return $selector;
184
+	}
185
+
186
+
187
+	/**
188
+	 * Selector for the Create Custom button found in the message template list table.
189
+	 * @param string $message_type_label
190
+	 * @param string $messenger_label
191
+	 * @return string
192
+	 */
193
+	public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
194
+	{
195
+		$selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
196
+					. "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
197
+					. "//ancestor::tr/td/a[@class='button button-small']";
198
+		return $selector;
199
+	}
200
+
201
+
202
+	/**
203
+	 * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
204
+	 * the FIRST match (which will be the latest message sent if the table is default sorted).
205
+	 *
206
+	 * @param string $message_type_label    The visible message type label for the row you want to match
207
+	 * @param string $message_status        The status of the message for the row you want to match.
208
+	 * @param string $messenger             The visible messenger label for the row you want to match.
209
+	 * @param string $context               The visible context label for the row you want to match.
210
+	 * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
211
+	 *                                      view. This allows you to indicate which item from the set to match.
212
+	 * @return string
213
+	 */
214
+	public static function messagesActivityListTableViewButtonSelectorFor(
215
+		$message_type_label,
216
+		$message_status = self::MESSAGE_STATUS_SENT,
217
+		$messenger = 'Email',
218
+		$context = 'Event Admin',
219
+		$number_in_set = 1
220
+	) {
221
+		$selector = self::messagesActivityListTableCellSelectorFor(
222
+			'action',
223
+			$message_type_label,
224
+			$message_status,
225
+			$messenger,
226
+			$context,
227
+			'',
228
+			$number_in_set
229
+		);
230
+		$selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
231
+					 . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
232
+		return $selector;
233
+	}
234
+
235
+
236
+
237
+	/**
238
+	 * Locator for the delete action link for a message item in the message activity list table.
239
+	 * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
240
+	 * @param        $message_type_label
241
+	 * @param string $message_status
242
+	 * @param string $messenger
243
+	 * @param string $context
244
+	 * @param int    $number_in_set
245
+	 * @return string
246
+	 */
247
+	public static function messagesActivityListTableDeleteActionSelectorFor(
248
+		$message_type_label,
249
+		$message_status = self::MESSAGE_STATUS_SENT,
250
+		$messenger = 'Email',
251
+		$context = 'Event Admin',
252
+		$number_in_set = 1
253
+	) {
254
+		$selector = self::messagesActivityListTableCellSelectorFor(
255
+			'to',
256
+			$message_type_label,
257
+			$message_status,
258
+			$messenger,
259
+			$context,
260
+			'',
261
+			$number_in_set
262
+		);
263
+		$selector .= "/div/span[@class='delete']/a";
264
+		return $selector;
265
+	}
266 266
 }
267 267
\ No newline at end of file
Please login to merge, or discard this patch.