Completed
Branch BUG/11361/fix-log-calls-using-... (7ad8bc)
by
unknown
27:20 queued 14:31
created
core/EE_Dependency_Map.core.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\request\RequestInterface;
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10
-if (! defined('EVENT_ESPRESSO_VERSION')) {
10
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
11 11
     exit('No direct script access allowed');
12 12
 }
13 13
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public static function instance() {
131 131
         // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
132
+        if ( ! self::$_instance instanceof EE_Dependency_Map) {
133 133
             self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134 134
         }
135 135
         return self::$_instance;
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
     ) {
212 212
         $class = trim($class, '\\');
213 213
         $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
214
+        if (empty(self::$_instance->_dependency_map[$class])) {
215
+            self::$_instance->_dependency_map[$class] = array();
216 216
         }
217 217
         // we need to make sure that any aliases used when registering a dependency
218 218
         // get resolved to the correct class name
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             $alias = self::$_instance->get_alias($dependency);
221 221
             if (
222 222
                 $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
223
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
224 224
             ) {
225 225
                 unset($dependencies[$dependency]);
226 226
                 $dependencies[$alias] = $load_source;
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234 234
         // Union is way faster than array_merge() but should be used with caution...
235 235
         // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
236
+        $dependencies += self::$_instance->_dependency_map[$class];
237 237
         // now we need to ensure that the resulting dependencies
238 238
         // array only has the entries that are required for the class
239 239
         // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
240
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
241 241
         // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
242
+        self::$_instance->_dependency_map[$class] = $dependency_count
243 243
             // then truncate the  final array to match that count
244 244
             ? array_slice($dependencies, 0, $dependency_count)
245 245
             // otherwise just take the incoming array because nothing previously existed
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public static function register_class_loader($class_name, $loader = 'load_core')
259 259
     {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
260
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261 261
             throw new DomainException(
262 262
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263 263
             );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             );
282 282
         }
283 283
         $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
284
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
285 285
             self::$_instance->_class_loaders[$class_name] = $loader;
286 286
             return true;
287 287
         }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     public function class_loader($class_name)
367 367
     {
368 368
         // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
369
+        if (strpos($class_name, 'EEM_') === 0) {
370 370
             return 'load_model';
371 371
         }
372 372
         $class_name = $this->get_alias($class_name);
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
     public function add_alias($class_name, $alias, $for_class = '')
396 396
     {
397 397
         if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
398
+            if ( ! isset($this->_aliases[$for_class])) {
399 399
                 $this->_aliases[$for_class] = array();
400 400
             }
401 401
             $this->_aliases[$for_class][$class_name] = $alias;
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
      */
442 442
     public function get_alias($class_name = '', $for_class = '')
443 443
     {
444
-        if (! $this->has_alias($class_name, $for_class)) {
444
+        if ( ! $this->has_alias($class_name, $for_class)) {
445 445
             return $class_name;
446 446
         }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
447
+        if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) {
448 448
             return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449 449
         }
450 450
         return $this->get_alias($this->_aliases[$class_name]);
@@ -714,13 +714,13 @@  discard block
 block discarded – undo
714 714
             'EE_Front_Controller'      => 'load_core',
715 715
             'EE_Module_Request_Router' => 'load_core',
716 716
             'EE_Registry'              => 'load_core',
717
-            'EE_Request'               => function () use (&$legacy_request) {
717
+            'EE_Request'               => function() use (&$legacy_request) {
718 718
                 return $legacy_request;
719 719
             },
720
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
720
+            'EventEspresso\core\services\request\Request' => function() use (&$request) {
721 721
                 return $request;
722 722
             },
723
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
723
+            'EventEspresso\core\services\request\Response' => function() use (&$response) {
724 724
                 return $response;
725 725
             },
726 726
             'EE_Request_Handler'       => 'load_core',
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
743 743
             'EE_Message_Template_Group_Collection' => 'load_lib',
744 744
             'EE_Payment_Method_Manager'            => 'load_lib',
745
-            'EE_Messages_Generator'                => function () {
745
+            'EE_Messages_Generator'                => function() {
746 746
                 return EE_Registry::instance()->load_lib(
747 747
                     'Messages_Generator',
748 748
                     array(),
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
                     false
751 751
                 );
752 752
             },
753
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
753
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
754 754
                 return EE_Registry::instance()->load_lib(
755 755
                     'Messages_Template_Defaults',
756 756
                     $arguments,
@@ -763,22 +763,22 @@  discard block
 block discarded – undo
763 763
             // 'EEM_Message_Template_Group'           => 'load_model',
764 764
             // 'EEM_Message_Template'                 => 'load_model',
765 765
             //load_helper
766
-            'EEH_Parse_Shortcodes'                 => function () {
766
+            'EEH_Parse_Shortcodes'                 => function() {
767 767
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
768 768
                     return new EEH_Parse_Shortcodes();
769 769
                 }
770 770
                 return null;
771 771
             },
772
-            'EE_Template_Config'                   => function () {
772
+            'EE_Template_Config'                   => function() {
773 773
                 return EE_Config::instance()->template_settings;
774 774
             },
775
-            'EE_Currency_Config'                   => function () {
775
+            'EE_Currency_Config'                   => function() {
776 776
                 return EE_Config::instance()->currency;
777 777
             },
778
-            'EE_Registration_Config'                   => function () {
778
+            'EE_Registration_Config'                   => function() {
779 779
                 return EE_Config::instance()->registration;
780 780
             },
781
-            'EventEspresso\core\services\loaders\Loader' => function () {
781
+            'EventEspresso\core\services\loaders\Loader' => function() {
782 782
                 return LoaderFactory::getLoader();
783 783
             },
784 784
         );
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
             'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
835 835
             'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
836 836
         );
837
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
837
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
838 838
             $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
839 839
         }
840 840
     }
Please login to merge, or discard this patch.
Indentation   +831 added lines, -831 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use EventEspresso\core\services\request\ResponseInterface;
9 9
 
10 10
 if (! defined('EVENT_ESPRESSO_VERSION')) {
11
-    exit('No direct script access allowed');
11
+	exit('No direct script access allowed');
12 12
 }
13 13
 
14 14
 
@@ -25,836 +25,836 @@  discard block
 block discarded – undo
25 25
 class EE_Dependency_Map
26 26
 {
27 27
 
28
-    /**
29
-     * This means that the requested class dependency is not present in the dependency map
30
-     */
31
-    const not_registered = 0;
32
-
33
-    /**
34
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
-     */
36
-    const load_new_object = 1;
37
-
38
-    /**
39
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
-     */
42
-    const load_from_cache = 2;
43
-
44
-    /**
45
-     * When registering a dependency,
46
-     * this indicates to keep any existing dependencies that already exist,
47
-     * and simply discard any new dependencies declared in the incoming data
48
-     */
49
-    const KEEP_EXISTING_DEPENDENCIES = 0;
50
-
51
-    /**
52
-     * When registering a dependency,
53
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
-     */
55
-    const OVERWRITE_DEPENDENCIES = 1;
56
-
57
-
58
-
59
-    /**
60
-     * @type EE_Dependency_Map $_instance
61
-     */
62
-    protected static $_instance;
63
-
64
-    /**
65
-     * @type RequestInterface $request
66
-     */
67
-    protected $request;
68
-
69
-    /**
70
-     * @type LegacyRequestInterface $legacy_request
71
-     */
72
-    protected $legacy_request;
73
-
74
-    /**
75
-     * @type ResponseInterface $response
76
-     */
77
-    protected $response;
78
-
79
-    /**
80
-     * @type LoaderInterface $loader
81
-     */
82
-    protected $loader;
83
-
84
-    /**
85
-     * @type array $_dependency_map
86
-     */
87
-    protected $_dependency_map = array();
88
-
89
-    /**
90
-     * @type array $_class_loaders
91
-     */
92
-    protected $_class_loaders = array();
93
-
94
-    /**
95
-     * @type array $_aliases
96
-     */
97
-    protected $_aliases = array();
98
-
99
-
100
-
101
-    /**
102
-     * EE_Dependency_Map constructor.
103
-     */
104
-    protected function __construct()
105
-    {
106
-        // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
-        do_action('EE_Dependency_Map____construct');
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidArgumentException
116
-     */
117
-    public function initialize()
118
-    {
119
-        $this->_register_core_dependencies();
120
-        $this->_register_core_class_loaders();
121
-        $this->_register_core_aliases();
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @singleton method used to instantiate class object
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance() {
131
-        // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
-            self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
-        }
135
-        return self::$_instance;
136
-    }
137
-
138
-
139
-    /**
140
-     * @param RequestInterface $request
141
-     */
142
-    public function setRequest(RequestInterface $request)
143
-    {
144
-        $this->request = $request;
145
-    }
146
-
147
-
148
-    /**
149
-     * @param LegacyRequestInterface $legacy_request
150
-     */
151
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
-    {
153
-        $this->legacy_request = $legacy_request;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param ResponseInterface $response
159
-     */
160
-    public function setResponse(ResponseInterface $response)
161
-    {
162
-        $this->response = $response;
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * @param LoaderInterface $loader
169
-     */
170
-    public function setLoader(LoaderInterface $loader)
171
-    {
172
-        $this->loader = $loader;
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * @param string $class
179
-     * @param array  $dependencies
180
-     * @param int    $overwrite
181
-     * @return bool
182
-     */
183
-    public static function register_dependencies(
184
-        $class,
185
-        array $dependencies,
186
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
-    ) {
188
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Assigns an array of class names and corresponding load sources (new or cached)
195
-     * to the class specified by the first parameter.
196
-     * IMPORTANT !!!
197
-     * The order of elements in the incoming $dependencies array MUST match
198
-     * the order of the constructor parameters for the class in question.
199
-     * This is especially important when overriding any existing dependencies that are registered.
200
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
-     *
202
-     * @param string $class
203
-     * @param array  $dependencies
204
-     * @param int    $overwrite
205
-     * @return bool
206
-     */
207
-    public function registerDependencies(
208
-        $class,
209
-        array $dependencies,
210
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
-    ) {
212
-        $class = trim($class, '\\');
213
-        $registered = false;
214
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
215
-            self::$_instance->_dependency_map[ $class ] = array();
216
-        }
217
-        // we need to make sure that any aliases used when registering a dependency
218
-        // get resolved to the correct class name
219
-        foreach ($dependencies as $dependency => $load_source) {
220
-            $alias = self::$_instance->get_alias($dependency);
221
-            if (
222
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
-            ) {
225
-                unset($dependencies[$dependency]);
226
-                $dependencies[$alias] = $load_source;
227
-                $registered = true;
228
-            }
229
-        }
230
-        // now add our two lists of dependencies together.
231
-        // using Union (+=) favours the arrays in precedence from left to right,
232
-        // so $dependencies is NOT overwritten because it is listed first
233
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
-        // Union is way faster than array_merge() but should be used with caution...
235
-        // especially with numerically indexed arrays
236
-        $dependencies += self::$_instance->_dependency_map[ $class ];
237
-        // now we need to ensure that the resulting dependencies
238
-        // array only has the entries that are required for the class
239
-        // so first count how many dependencies were originally registered for the class
240
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
-        // if that count is non-zero (meaning dependencies were already registered)
242
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
243
-            // then truncate the  final array to match that count
244
-            ? array_slice($dependencies, 0, $dependency_count)
245
-            // otherwise just take the incoming array because nothing previously existed
246
-            : $dependencies;
247
-        return $registered;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @param string $class_name
254
-     * @param string $loader
255
-     * @return bool
256
-     * @throws DomainException
257
-     */
258
-    public static function register_class_loader($class_name, $loader = 'load_core')
259
-    {
260
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
-            throw new DomainException(
262
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
-            );
264
-        }
265
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
266
-        if (
267
-            ! is_callable($loader)
268
-            && (
269
-                strpos($loader, 'load_') !== 0
270
-                || ! method_exists('EE_Registry', $loader)
271
-            )
272
-        ) {
273
-            throw new DomainException(
274
-                sprintf(
275
-                    esc_html__(
276
-                        '"%1$s" is not a valid loader method on EE_Registry.',
277
-                        'event_espresso'
278
-                    ),
279
-                    $loader
280
-                )
281
-            );
282
-        }
283
-        $class_name = self::$_instance->get_alias($class_name);
284
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
-            self::$_instance->_class_loaders[$class_name] = $loader;
286
-            return true;
287
-        }
288
-        return false;
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * @return array
295
-     */
296
-    public function dependency_map()
297
-    {
298
-        return $this->_dependency_map;
299
-    }
300
-
301
-
302
-
303
-    /**
304
-     * returns TRUE if dependency map contains a listing for the provided class name
305
-     *
306
-     * @param string $class_name
307
-     * @return boolean
308
-     */
309
-    public function has($class_name = '')
310
-    {
311
-        // all legacy models have the same dependencies
312
-        if (strpos($class_name, 'EEM_') === 0) {
313
-            $class_name = 'LEGACY_MODELS';
314
-        }
315
-        return isset($this->_dependency_map[$class_name]) ? true : false;
316
-    }
317
-
318
-
319
-
320
-    /**
321
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
-     *
323
-     * @param string $class_name
324
-     * @param string $dependency
325
-     * @return bool
326
-     */
327
-    public function has_dependency_for_class($class_name = '', $dependency = '')
328
-    {
329
-        // all legacy models have the same dependencies
330
-        if (strpos($class_name, 'EEM_') === 0) {
331
-            $class_name = 'LEGACY_MODELS';
332
-        }
333
-        $dependency = $this->get_alias($dependency);
334
-        return isset($this->_dependency_map[$class_name][$dependency])
335
-            ? true
336
-            : false;
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
-     *
344
-     * @param string $class_name
345
-     * @param string $dependency
346
-     * @return int
347
-     */
348
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
-    {
350
-        // all legacy models have the same dependencies
351
-        if (strpos($class_name, 'EEM_') === 0) {
352
-            $class_name = 'LEGACY_MODELS';
353
-        }
354
-        $dependency = $this->get_alias($dependency);
355
-        return $this->has_dependency_for_class($class_name, $dependency)
356
-            ? $this->_dependency_map[$class_name][$dependency]
357
-            : EE_Dependency_Map::not_registered;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * @param string $class_name
364
-     * @return string | Closure
365
-     */
366
-    public function class_loader($class_name)
367
-    {
368
-        // all legacy models use load_model()
369
-        if(strpos($class_name, 'EEM_') === 0){
370
-            return 'load_model';
371
-        }
372
-        $class_name = $this->get_alias($class_name);
373
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
-    }
375
-
376
-
377
-
378
-    /**
379
-     * @return array
380
-     */
381
-    public function class_loaders()
382
-    {
383
-        return $this->_class_loaders;
384
-    }
385
-
386
-
387
-
388
-    /**
389
-     * adds an alias for a classname
390
-     *
391
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
392
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
-     */
395
-    public function add_alias($class_name, $alias, $for_class = '')
396
-    {
397
-        if ($for_class !== '') {
398
-            if (! isset($this->_aliases[$for_class])) {
399
-                $this->_aliases[$for_class] = array();
400
-            }
401
-            $this->_aliases[$for_class][$class_name] = $alias;
402
-        }
403
-        $this->_aliases[$class_name] = $alias;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * returns TRUE if the provided class name has an alias
410
-     *
411
-     * @param string $class_name
412
-     * @param string $for_class
413
-     * @return bool
414
-     */
415
-    public function has_alias($class_name = '', $for_class = '')
416
-    {
417
-        return isset($this->_aliases[$for_class][$class_name])
418
-               || (
419
-                   isset($this->_aliases[$class_name])
420
-                   && ! is_array($this->_aliases[$class_name])
421
-               );
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * returns alias for class name if one exists, otherwise returns the original classname
428
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
429
-     *  for example:
430
-     *      if the following two entries were added to the _aliases array:
431
-     *          array(
432
-     *              'interface_alias'           => 'some\namespace\interface'
433
-     *              'some\namespace\interface'  => 'some\namespace\classname'
434
-     *          )
435
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
-     *      to load an instance of 'some\namespace\classname'
437
-     *
438
-     * @param string $class_name
439
-     * @param string $for_class
440
-     * @return string
441
-     */
442
-    public function get_alias($class_name = '', $for_class = '')
443
-    {
444
-        if (! $this->has_alias($class_name, $for_class)) {
445
-            return $class_name;
446
-        }
447
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
-        }
450
-        return $this->get_alias($this->_aliases[$class_name]);
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
-     * This is done by using the following class constants:
459
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
461
-     */
462
-    protected function _register_core_dependencies()
463
-    {
464
-        $this->_dependency_map = array(
465
-            'EE_Request_Handler'                                                                                          => array(
466
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
467
-            ),
468
-            'EE_System'                                                                                                   => array(
469
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
-            ),
474
-            'EE_Session'                                                                                                  => array(
475
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
476
-                'EventEspresso\core\services\request\Request'             => EE_Dependency_Map::load_from_cache,
477
-                'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
478
-            ),
479
-            'EE_Cart'                                                                                                     => array(
480
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
481
-            ),
482
-            'EE_Front_Controller'                                                                                         => array(
483
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
484
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
485
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messenger_Collection_Loader'                                                                              => array(
488
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
489
-            ),
490
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
491
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
492
-            ),
493
-            'EE_Message_Resource_Manager'                                                                                 => array(
494
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
495
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
496
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
497
-            ),
498
-            'EE_Message_Factory'                                                                                          => array(
499
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
500
-            ),
501
-            'EE_messages'                                                                                                 => array(
502
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
503
-            ),
504
-            'EE_Messages_Generator'                                                                                       => array(
505
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
506
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
507
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
508
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EE_Messages_Processor'                                                                                       => array(
511
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
512
-            ),
513
-            'EE_Messages_Queue'                                                                                           => array(
514
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
515
-            ),
516
-            'EE_Messages_Template_Defaults'                                                                               => array(
517
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
518
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
519
-            ),
520
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
521
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
522
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
525
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
528
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
529
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
530
-            ),
531
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
532
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
533
-            ),
534
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
535
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
536
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
537
-            ),
538
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
539
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
540
-            ),
541
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
542
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
543
-            ),
544
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
545
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
546
-            ),
547
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
548
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
549
-            ),
550
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
551
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
552
-            ),
553
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
554
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
555
-            ),
556
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
557
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
558
-            ),
559
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
560
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
561
-            ),
562
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
563
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
564
-            ),
565
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
566
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
567
-            ),
568
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
569
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
572
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
573
-            ),
574
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
575
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
576
-            ),
577
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
578
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
579
-            ),
580
-            'EE_Data_Migration_Class_Base'                                                                                => array(
581
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
582
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
583
-            ),
584
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
585
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
586
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
587
-            ),
588
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
589
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
590
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
591
-            ),
592
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
593
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
594
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
595
-            ),
596
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
597
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
598
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
599
-            ),
600
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
601
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
602
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
603
-            ),
604
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
605
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
606
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
607
-            ),
608
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
609
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
610
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
611
-            ),
612
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
613
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
614
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
617
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
618
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
619
-            ),
620
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
621
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
622
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
623
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
624
-            ),
625
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
626
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
638
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
641
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
644
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
647
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
648
-            ),
649
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
650
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
651
-            ),
652
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
653
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
654
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
655
-            ),
656
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
657
-                null,
658
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
659
-            ),
660
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
661
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
662
-            ),
663
-            'LEGACY_MODELS'                                                   => array(
664
-                null,
665
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
666
-            ),
667
-            'EE_Module_Request_Router' => array(
668
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
669
-            ),
670
-            'EE_Registration_Processor' => array(
671
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
674
-                null,
675
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
676
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
677
-            ),
678
-        );
679
-    }
680
-
681
-
682
-
683
-    /**
684
-     * Registers how core classes are loaded.
685
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
686
-     *        'EE_Request_Handler' => 'load_core'
687
-     *        'EE_Messages_Queue'  => 'load_lib'
688
-     *        'EEH_Debug_Tools'    => 'load_helper'
689
-     * or, if greater control is required, by providing a custom closure. For example:
690
-     *        'Some_Class' => function () {
691
-     *            return new Some_Class();
692
-     *        },
693
-     * This is required for instantiating dependencies
694
-     * where an interface has been type hinted in a class constructor. For example:
695
-     *        'Required_Interface' => function () {
696
-     *            return new A_Class_That_Implements_Required_Interface();
697
-     *        },
698
-     *
699
-     * @throws InvalidInterfaceException
700
-     * @throws InvalidDataTypeException
701
-     * @throws InvalidArgumentException
702
-     */
703
-    protected function _register_core_class_loaders()
704
-    {
705
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
706
-        //be used in a closure.
707
-        $request = &$this->request;
708
-        $response = &$this->response;
709
-        $legacy_request = &$this->legacy_request;
710
-        // $loader = &$this->loader;
711
-        $this->_class_loaders = array(
712
-            //load_core
713
-            'EE_Capabilities'          => 'load_core',
714
-            'EE_Encryption'            => 'load_core',
715
-            'EE_Front_Controller'      => 'load_core',
716
-            'EE_Module_Request_Router' => 'load_core',
717
-            'EE_Registry'              => 'load_core',
718
-            'EE_Request'               => function () use (&$legacy_request) {
719
-                return $legacy_request;
720
-            },
721
-            'EventEspresso\core\services\request\Request' => function () use (&$request) {
722
-                return $request;
723
-            },
724
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
725
-                return $response;
726
-            },
727
-            'EE_Request_Handler'       => 'load_core',
728
-            'EE_Session'               => 'load_core',
729
-            'EE_Cron_Tasks'            => 'load_core',
730
-            'EE_System'                => 'load_core',
731
-            'EE_Maintenance_Mode'      => 'load_core',
732
-            'EE_Register_CPTs'         => 'load_core',
733
-            'EE_Admin'                 => 'load_core',
734
-            //load_lib
735
-            'EE_Message_Resource_Manager'          => 'load_lib',
736
-            'EE_Message_Type_Collection'           => 'load_lib',
737
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
738
-            'EE_Messenger_Collection'              => 'load_lib',
739
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
740
-            'EE_Messages_Processor'                => 'load_lib',
741
-            'EE_Message_Repository'                => 'load_lib',
742
-            'EE_Messages_Queue'                    => 'load_lib',
743
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
744
-            'EE_Message_Template_Group_Collection' => 'load_lib',
745
-            'EE_Payment_Method_Manager'            => 'load_lib',
746
-            'EE_Messages_Generator'                => function () {
747
-                return EE_Registry::instance()->load_lib(
748
-                    'Messages_Generator',
749
-                    array(),
750
-                    false,
751
-                    false
752
-                );
753
-            },
754
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
755
-                return EE_Registry::instance()->load_lib(
756
-                    'Messages_Template_Defaults',
757
-                    $arguments,
758
-                    false,
759
-                    false
760
-                );
761
-            },
762
-            //load_model
763
-            // 'EEM_Attendee'                         => 'load_model',
764
-            // 'EEM_Message_Template_Group'           => 'load_model',
765
-            // 'EEM_Message_Template'                 => 'load_model',
766
-            //load_helper
767
-            'EEH_Parse_Shortcodes'                 => function () {
768
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
769
-                    return new EEH_Parse_Shortcodes();
770
-                }
771
-                return null;
772
-            },
773
-            'EE_Template_Config'                   => function () {
774
-                return EE_Config::instance()->template_settings;
775
-            },
776
-            'EE_Currency_Config'                   => function () {
777
-                return EE_Config::instance()->currency;
778
-            },
779
-            'EE_Registration_Config'                   => function () {
780
-                return EE_Config::instance()->registration;
781
-            },
782
-            'EventEspresso\core\services\loaders\Loader' => function () {
783
-                return LoaderFactory::getLoader();
784
-            },
785
-        );
786
-    }
787
-
788
-
789
-
790
-    /**
791
-     * can be used for supplying alternate names for classes,
792
-     * or for connecting interface names to instantiable classes
793
-     */
794
-    protected function _register_core_aliases()
795
-    {
796
-        $this->_aliases = array(
797
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
798
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
799
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
800
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
801
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
802
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
803
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
804
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
805
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
806
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
807
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
808
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
809
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
810
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
811
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
812
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
813
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
814
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
815
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
816
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
817
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
818
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
819
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
820
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
821
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
822
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
823
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
824
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
825
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
826
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
827
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
828
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
829
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
830
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
831
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
832
-            'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
833
-            'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
834
-            'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
835
-            'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
836
-            'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
837
-        );
838
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
839
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
840
-        }
841
-    }
842
-
843
-
844
-
845
-    /**
846
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
847
-     * request Primarily used by unit tests.
848
-     *
849
-     * @throws InvalidDataTypeException
850
-     * @throws InvalidInterfaceException
851
-     * @throws InvalidArgumentException
852
-     */
853
-    public function reset()
854
-    {
855
-        $this->_register_core_class_loaders();
856
-        $this->_register_core_dependencies();
857
-    }
28
+	/**
29
+	 * This means that the requested class dependency is not present in the dependency map
30
+	 */
31
+	const not_registered = 0;
32
+
33
+	/**
34
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
35
+	 */
36
+	const load_new_object = 1;
37
+
38
+	/**
39
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
40
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
41
+	 */
42
+	const load_from_cache = 2;
43
+
44
+	/**
45
+	 * When registering a dependency,
46
+	 * this indicates to keep any existing dependencies that already exist,
47
+	 * and simply discard any new dependencies declared in the incoming data
48
+	 */
49
+	const KEEP_EXISTING_DEPENDENCIES = 0;
50
+
51
+	/**
52
+	 * When registering a dependency,
53
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
54
+	 */
55
+	const OVERWRITE_DEPENDENCIES = 1;
56
+
57
+
58
+
59
+	/**
60
+	 * @type EE_Dependency_Map $_instance
61
+	 */
62
+	protected static $_instance;
63
+
64
+	/**
65
+	 * @type RequestInterface $request
66
+	 */
67
+	protected $request;
68
+
69
+	/**
70
+	 * @type LegacyRequestInterface $legacy_request
71
+	 */
72
+	protected $legacy_request;
73
+
74
+	/**
75
+	 * @type ResponseInterface $response
76
+	 */
77
+	protected $response;
78
+
79
+	/**
80
+	 * @type LoaderInterface $loader
81
+	 */
82
+	protected $loader;
83
+
84
+	/**
85
+	 * @type array $_dependency_map
86
+	 */
87
+	protected $_dependency_map = array();
88
+
89
+	/**
90
+	 * @type array $_class_loaders
91
+	 */
92
+	protected $_class_loaders = array();
93
+
94
+	/**
95
+	 * @type array $_aliases
96
+	 */
97
+	protected $_aliases = array();
98
+
99
+
100
+
101
+	/**
102
+	 * EE_Dependency_Map constructor.
103
+	 */
104
+	protected function __construct()
105
+	{
106
+		// add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
107
+		do_action('EE_Dependency_Map____construct');
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidArgumentException
116
+	 */
117
+	public function initialize()
118
+	{
119
+		$this->_register_core_dependencies();
120
+		$this->_register_core_class_loaders();
121
+		$this->_register_core_aliases();
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @singleton method used to instantiate class object
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance() {
131
+		// check if class object is instantiated, and instantiated properly
132
+		if (! self::$_instance instanceof EE_Dependency_Map) {
133
+			self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/);
134
+		}
135
+		return self::$_instance;
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param RequestInterface $request
141
+	 */
142
+	public function setRequest(RequestInterface $request)
143
+	{
144
+		$this->request = $request;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param LegacyRequestInterface $legacy_request
150
+	 */
151
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
152
+	{
153
+		$this->legacy_request = $legacy_request;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param ResponseInterface $response
159
+	 */
160
+	public function setResponse(ResponseInterface $response)
161
+	{
162
+		$this->response = $response;
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * @param LoaderInterface $loader
169
+	 */
170
+	public function setLoader(LoaderInterface $loader)
171
+	{
172
+		$this->loader = $loader;
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * @param string $class
179
+	 * @param array  $dependencies
180
+	 * @param int    $overwrite
181
+	 * @return bool
182
+	 */
183
+	public static function register_dependencies(
184
+		$class,
185
+		array $dependencies,
186
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
187
+	) {
188
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Assigns an array of class names and corresponding load sources (new or cached)
195
+	 * to the class specified by the first parameter.
196
+	 * IMPORTANT !!!
197
+	 * The order of elements in the incoming $dependencies array MUST match
198
+	 * the order of the constructor parameters for the class in question.
199
+	 * This is especially important when overriding any existing dependencies that are registered.
200
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
201
+	 *
202
+	 * @param string $class
203
+	 * @param array  $dependencies
204
+	 * @param int    $overwrite
205
+	 * @return bool
206
+	 */
207
+	public function registerDependencies(
208
+		$class,
209
+		array $dependencies,
210
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
211
+	) {
212
+		$class = trim($class, '\\');
213
+		$registered = false;
214
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
215
+			self::$_instance->_dependency_map[ $class ] = array();
216
+		}
217
+		// we need to make sure that any aliases used when registering a dependency
218
+		// get resolved to the correct class name
219
+		foreach ($dependencies as $dependency => $load_source) {
220
+			$alias = self::$_instance->get_alias($dependency);
221
+			if (
222
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
223
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
224
+			) {
225
+				unset($dependencies[$dependency]);
226
+				$dependencies[$alias] = $load_source;
227
+				$registered = true;
228
+			}
229
+		}
230
+		// now add our two lists of dependencies together.
231
+		// using Union (+=) favours the arrays in precedence from left to right,
232
+		// so $dependencies is NOT overwritten because it is listed first
233
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
234
+		// Union is way faster than array_merge() but should be used with caution...
235
+		// especially with numerically indexed arrays
236
+		$dependencies += self::$_instance->_dependency_map[ $class ];
237
+		// now we need to ensure that the resulting dependencies
238
+		// array only has the entries that are required for the class
239
+		// so first count how many dependencies were originally registered for the class
240
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
241
+		// if that count is non-zero (meaning dependencies were already registered)
242
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
243
+			// then truncate the  final array to match that count
244
+			? array_slice($dependencies, 0, $dependency_count)
245
+			// otherwise just take the incoming array because nothing previously existed
246
+			: $dependencies;
247
+		return $registered;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @param string $class_name
254
+	 * @param string $loader
255
+	 * @return bool
256
+	 * @throws DomainException
257
+	 */
258
+	public static function register_class_loader($class_name, $loader = 'load_core')
259
+	{
260
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
261
+			throw new DomainException(
262
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
263
+			);
264
+		}
265
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
266
+		if (
267
+			! is_callable($loader)
268
+			&& (
269
+				strpos($loader, 'load_') !== 0
270
+				|| ! method_exists('EE_Registry', $loader)
271
+			)
272
+		) {
273
+			throw new DomainException(
274
+				sprintf(
275
+					esc_html__(
276
+						'"%1$s" is not a valid loader method on EE_Registry.',
277
+						'event_espresso'
278
+					),
279
+					$loader
280
+				)
281
+			);
282
+		}
283
+		$class_name = self::$_instance->get_alias($class_name);
284
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
285
+			self::$_instance->_class_loaders[$class_name] = $loader;
286
+			return true;
287
+		}
288
+		return false;
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * @return array
295
+	 */
296
+	public function dependency_map()
297
+	{
298
+		return $this->_dependency_map;
299
+	}
300
+
301
+
302
+
303
+	/**
304
+	 * returns TRUE if dependency map contains a listing for the provided class name
305
+	 *
306
+	 * @param string $class_name
307
+	 * @return boolean
308
+	 */
309
+	public function has($class_name = '')
310
+	{
311
+		// all legacy models have the same dependencies
312
+		if (strpos($class_name, 'EEM_') === 0) {
313
+			$class_name = 'LEGACY_MODELS';
314
+		}
315
+		return isset($this->_dependency_map[$class_name]) ? true : false;
316
+	}
317
+
318
+
319
+
320
+	/**
321
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
322
+	 *
323
+	 * @param string $class_name
324
+	 * @param string $dependency
325
+	 * @return bool
326
+	 */
327
+	public function has_dependency_for_class($class_name = '', $dependency = '')
328
+	{
329
+		// all legacy models have the same dependencies
330
+		if (strpos($class_name, 'EEM_') === 0) {
331
+			$class_name = 'LEGACY_MODELS';
332
+		}
333
+		$dependency = $this->get_alias($dependency);
334
+		return isset($this->_dependency_map[$class_name][$dependency])
335
+			? true
336
+			: false;
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
343
+	 *
344
+	 * @param string $class_name
345
+	 * @param string $dependency
346
+	 * @return int
347
+	 */
348
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
349
+	{
350
+		// all legacy models have the same dependencies
351
+		if (strpos($class_name, 'EEM_') === 0) {
352
+			$class_name = 'LEGACY_MODELS';
353
+		}
354
+		$dependency = $this->get_alias($dependency);
355
+		return $this->has_dependency_for_class($class_name, $dependency)
356
+			? $this->_dependency_map[$class_name][$dependency]
357
+			: EE_Dependency_Map::not_registered;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * @param string $class_name
364
+	 * @return string | Closure
365
+	 */
366
+	public function class_loader($class_name)
367
+	{
368
+		// all legacy models use load_model()
369
+		if(strpos($class_name, 'EEM_') === 0){
370
+			return 'load_model';
371
+		}
372
+		$class_name = $this->get_alias($class_name);
373
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
374
+	}
375
+
376
+
377
+
378
+	/**
379
+	 * @return array
380
+	 */
381
+	public function class_loaders()
382
+	{
383
+		return $this->_class_loaders;
384
+	}
385
+
386
+
387
+
388
+	/**
389
+	 * adds an alias for a classname
390
+	 *
391
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
392
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
393
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
394
+	 */
395
+	public function add_alias($class_name, $alias, $for_class = '')
396
+	{
397
+		if ($for_class !== '') {
398
+			if (! isset($this->_aliases[$for_class])) {
399
+				$this->_aliases[$for_class] = array();
400
+			}
401
+			$this->_aliases[$for_class][$class_name] = $alias;
402
+		}
403
+		$this->_aliases[$class_name] = $alias;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * returns TRUE if the provided class name has an alias
410
+	 *
411
+	 * @param string $class_name
412
+	 * @param string $for_class
413
+	 * @return bool
414
+	 */
415
+	public function has_alias($class_name = '', $for_class = '')
416
+	{
417
+		return isset($this->_aliases[$for_class][$class_name])
418
+			   || (
419
+				   isset($this->_aliases[$class_name])
420
+				   && ! is_array($this->_aliases[$class_name])
421
+			   );
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * returns alias for class name if one exists, otherwise returns the original classname
428
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
429
+	 *  for example:
430
+	 *      if the following two entries were added to the _aliases array:
431
+	 *          array(
432
+	 *              'interface_alias'           => 'some\namespace\interface'
433
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
434
+	 *          )
435
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
+	 *      to load an instance of 'some\namespace\classname'
437
+	 *
438
+	 * @param string $class_name
439
+	 * @param string $for_class
440
+	 * @return string
441
+	 */
442
+	public function get_alias($class_name = '', $for_class = '')
443
+	{
444
+		if (! $this->has_alias($class_name, $for_class)) {
445
+			return $class_name;
446
+		}
447
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
448
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
449
+		}
450
+		return $this->get_alias($this->_aliases[$class_name]);
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
457
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
458
+	 * This is done by using the following class constants:
459
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
460
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
461
+	 */
462
+	protected function _register_core_dependencies()
463
+	{
464
+		$this->_dependency_map = array(
465
+			'EE_Request_Handler'                                                                                          => array(
466
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
467
+			),
468
+			'EE_System'                                                                                                   => array(
469
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
470
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
471
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
472
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
473
+			),
474
+			'EE_Session'                                                                                                  => array(
475
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
476
+				'EventEspresso\core\services\request\Request'             => EE_Dependency_Map::load_from_cache,
477
+				'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
478
+			),
479
+			'EE_Cart'                                                                                                     => array(
480
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
481
+			),
482
+			'EE_Front_Controller'                                                                                         => array(
483
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
484
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
485
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messenger_Collection_Loader'                                                                              => array(
488
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
489
+			),
490
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
491
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
492
+			),
493
+			'EE_Message_Resource_Manager'                                                                                 => array(
494
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
495
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
496
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
497
+			),
498
+			'EE_Message_Factory'                                                                                          => array(
499
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
500
+			),
501
+			'EE_messages'                                                                                                 => array(
502
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
503
+			),
504
+			'EE_Messages_Generator'                                                                                       => array(
505
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
506
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
507
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
508
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EE_Messages_Processor'                                                                                       => array(
511
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
512
+			),
513
+			'EE_Messages_Queue'                                                                                           => array(
514
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
515
+			),
516
+			'EE_Messages_Template_Defaults'                                                                               => array(
517
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
518
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
519
+			),
520
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
521
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
522
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
525
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
528
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
529
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
530
+			),
531
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
532
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
533
+			),
534
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
535
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
536
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
537
+			),
538
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
539
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
540
+			),
541
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
542
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
543
+			),
544
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
545
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
546
+			),
547
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
548
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
549
+			),
550
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
551
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
552
+			),
553
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
554
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
555
+			),
556
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
557
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
558
+			),
559
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
560
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
561
+			),
562
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
563
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
564
+			),
565
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
566
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
567
+			),
568
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
569
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
572
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
573
+			),
574
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
575
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
576
+			),
577
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
578
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
579
+			),
580
+			'EE_Data_Migration_Class_Base'                                                                                => array(
581
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
582
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
583
+			),
584
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
585
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
586
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
587
+			),
588
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
589
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
590
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
591
+			),
592
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
593
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
594
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
595
+			),
596
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
597
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
598
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
599
+			),
600
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
601
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
602
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
603
+			),
604
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
605
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
606
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
607
+			),
608
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
609
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
610
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
611
+			),
612
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
613
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
614
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
617
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
618
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
619
+			),
620
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
621
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
622
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
623
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache
624
+			),
625
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
626
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
638
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
641
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
644
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
647
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
648
+			),
649
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
650
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
651
+			),
652
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
653
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
654
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
655
+			),
656
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
657
+				null,
658
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
659
+			),
660
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
661
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
662
+			),
663
+			'LEGACY_MODELS'                                                   => array(
664
+				null,
665
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
666
+			),
667
+			'EE_Module_Request_Router' => array(
668
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
669
+			),
670
+			'EE_Registration_Processor' => array(
671
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
674
+				null,
675
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
676
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
677
+			),
678
+		);
679
+	}
680
+
681
+
682
+
683
+	/**
684
+	 * Registers how core classes are loaded.
685
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
686
+	 *        'EE_Request_Handler' => 'load_core'
687
+	 *        'EE_Messages_Queue'  => 'load_lib'
688
+	 *        'EEH_Debug_Tools'    => 'load_helper'
689
+	 * or, if greater control is required, by providing a custom closure. For example:
690
+	 *        'Some_Class' => function () {
691
+	 *            return new Some_Class();
692
+	 *        },
693
+	 * This is required for instantiating dependencies
694
+	 * where an interface has been type hinted in a class constructor. For example:
695
+	 *        'Required_Interface' => function () {
696
+	 *            return new A_Class_That_Implements_Required_Interface();
697
+	 *        },
698
+	 *
699
+	 * @throws InvalidInterfaceException
700
+	 * @throws InvalidDataTypeException
701
+	 * @throws InvalidArgumentException
702
+	 */
703
+	protected function _register_core_class_loaders()
704
+	{
705
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
706
+		//be used in a closure.
707
+		$request = &$this->request;
708
+		$response = &$this->response;
709
+		$legacy_request = &$this->legacy_request;
710
+		// $loader = &$this->loader;
711
+		$this->_class_loaders = array(
712
+			//load_core
713
+			'EE_Capabilities'          => 'load_core',
714
+			'EE_Encryption'            => 'load_core',
715
+			'EE_Front_Controller'      => 'load_core',
716
+			'EE_Module_Request_Router' => 'load_core',
717
+			'EE_Registry'              => 'load_core',
718
+			'EE_Request'               => function () use (&$legacy_request) {
719
+				return $legacy_request;
720
+			},
721
+			'EventEspresso\core\services\request\Request' => function () use (&$request) {
722
+				return $request;
723
+			},
724
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
725
+				return $response;
726
+			},
727
+			'EE_Request_Handler'       => 'load_core',
728
+			'EE_Session'               => 'load_core',
729
+			'EE_Cron_Tasks'            => 'load_core',
730
+			'EE_System'                => 'load_core',
731
+			'EE_Maintenance_Mode'      => 'load_core',
732
+			'EE_Register_CPTs'         => 'load_core',
733
+			'EE_Admin'                 => 'load_core',
734
+			//load_lib
735
+			'EE_Message_Resource_Manager'          => 'load_lib',
736
+			'EE_Message_Type_Collection'           => 'load_lib',
737
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
738
+			'EE_Messenger_Collection'              => 'load_lib',
739
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
740
+			'EE_Messages_Processor'                => 'load_lib',
741
+			'EE_Message_Repository'                => 'load_lib',
742
+			'EE_Messages_Queue'                    => 'load_lib',
743
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
744
+			'EE_Message_Template_Group_Collection' => 'load_lib',
745
+			'EE_Payment_Method_Manager'            => 'load_lib',
746
+			'EE_Messages_Generator'                => function () {
747
+				return EE_Registry::instance()->load_lib(
748
+					'Messages_Generator',
749
+					array(),
750
+					false,
751
+					false
752
+				);
753
+			},
754
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
755
+				return EE_Registry::instance()->load_lib(
756
+					'Messages_Template_Defaults',
757
+					$arguments,
758
+					false,
759
+					false
760
+				);
761
+			},
762
+			//load_model
763
+			// 'EEM_Attendee'                         => 'load_model',
764
+			// 'EEM_Message_Template_Group'           => 'load_model',
765
+			// 'EEM_Message_Template'                 => 'load_model',
766
+			//load_helper
767
+			'EEH_Parse_Shortcodes'                 => function () {
768
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
769
+					return new EEH_Parse_Shortcodes();
770
+				}
771
+				return null;
772
+			},
773
+			'EE_Template_Config'                   => function () {
774
+				return EE_Config::instance()->template_settings;
775
+			},
776
+			'EE_Currency_Config'                   => function () {
777
+				return EE_Config::instance()->currency;
778
+			},
779
+			'EE_Registration_Config'                   => function () {
780
+				return EE_Config::instance()->registration;
781
+			},
782
+			'EventEspresso\core\services\loaders\Loader' => function () {
783
+				return LoaderFactory::getLoader();
784
+			},
785
+		);
786
+	}
787
+
788
+
789
+
790
+	/**
791
+	 * can be used for supplying alternate names for classes,
792
+	 * or for connecting interface names to instantiable classes
793
+	 */
794
+	protected function _register_core_aliases()
795
+	{
796
+		$this->_aliases = array(
797
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
798
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
799
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
800
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
801
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
802
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
803
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
804
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
805
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
806
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
807
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
808
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
809
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
810
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
811
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
812
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
813
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
814
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
815
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
816
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
817
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
818
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
819
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
820
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
821
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
822
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
823
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
824
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
825
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
826
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
827
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
828
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
829
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
830
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
831
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
832
+			'NoticesContainerInterface'                                           => 'EventEspresso\core\services\notices\NoticesContainerInterface',
833
+			'EventEspresso\core\services\notices\NoticesContainerInterface'       => 'EventEspresso\core\services\notices\NoticesContainer',
834
+			'EventEspresso\core\services\request\RequestInterface'                => 'EventEspresso\core\services\request\Request',
835
+			'EventEspresso\core\services\request\ResponseInterface'               => 'EventEspresso\core\services\request\Response',
836
+			'EventEspresso\core\domain\DomainInterface'                           => 'EventEspresso\core\domain\Domain',
837
+		);
838
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
839
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
840
+		}
841
+	}
842
+
843
+
844
+
845
+	/**
846
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
847
+	 * request Primarily used by unit tests.
848
+	 *
849
+	 * @throws InvalidDataTypeException
850
+	 * @throws InvalidInterfaceException
851
+	 * @throws InvalidArgumentException
852
+	 */
853
+	public function reset()
854
+	{
855
+		$this->_register_core_class_loaders();
856
+		$this->_register_core_dependencies();
857
+	}
858 858
 
859 859
 
860 860
 }
Please login to merge, or discard this patch.
core/services/request/InvalidRequestStackMiddlewareException.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -19,33 +19,33 @@
 block discarded – undo
19 19
 class InvalidRequestStackMiddlewareException extends InvalidDataTypeException
20 20
 {
21 21
 
22
-    /**
23
-     * @param  mixed     $middleware_app_class
24
-     * @param  string    $message
25
-     * @param int        $code
26
-     * @param Exception $previous
27
-     */
28
-    public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null)
29
-    {
30
-        if(is_array($middleware_app_class)) {
31
-            $middleware_app_class = reset($middleware_app_class);
32
-        }
33
-        if (empty($message)) {
34
-            $message = sprintf(
35
-                esc_html__(
36
-                    'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.',
37
-                    'event_espresso'
38
-                ),
39
-                $middleware_app_class
40
-            );
41
-        }
42
-        parent::__construct(
43
-            '$middleware_app_class',
44
-            $middleware_app_class,
45
-            'EventEspresso\core\services\request\middleware\Middleware',
46
-            $message,
47
-            $code,
48
-            $previous
49
-        );
50
-    }
22
+	/**
23
+	 * @param  mixed     $middleware_app_class
24
+	 * @param  string    $message
25
+	 * @param int        $code
26
+	 * @param Exception $previous
27
+	 */
28
+	public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null)
29
+	{
30
+		if(is_array($middleware_app_class)) {
31
+			$middleware_app_class = reset($middleware_app_class);
32
+		}
33
+		if (empty($message)) {
34
+			$message = sprintf(
35
+				esc_html__(
36
+					'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.',
37
+					'event_espresso'
38
+				),
39
+				$middleware_app_class
40
+			);
41
+		}
42
+		parent::__construct(
43
+			'$middleware_app_class',
44
+			$middleware_app_class,
45
+			'EventEspresso\core\services\request\middleware\Middleware',
46
+			$message,
47
+			$code,
48
+			$previous
49
+		);
50
+	}
51 51
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
      */
28 28
     public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null)
29 29
     {
30
-        if(is_array($middleware_app_class)) {
30
+        if (is_array($middleware_app_class)) {
31 31
             $middleware_app_class = reset($middleware_app_class);
32 32
         }
33 33
         if (empty($message)) {
Please login to merge, or discard this patch.
core/services/request/RequestStackBuilder.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -24,97 +24,97 @@
 block discarded – undo
24 24
 class RequestStackBuilder extends SplDoublyLinkedList
25 25
 {
26 26
 
27
-    /**
28
-     * @type LoaderInterface $loader
29
-     */
30
-    private $loader;
27
+	/**
28
+	 * @type LoaderInterface $loader
29
+	 */
30
+	private $loader;
31 31
 
32 32
 
33
-    /**
34
-     * RequestStackBuilder constructor.
35
-     *
36
-     * @param LoaderInterface $loader
37
-     */
38
-    public function __construct(LoaderInterface $loader)
39
-    {
40
-        $this->loader = $loader;
41
-        $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
42
-    }
33
+	/**
34
+	 * RequestStackBuilder constructor.
35
+	 *
36
+	 * @param LoaderInterface $loader
37
+	 */
38
+	public function __construct(LoaderInterface $loader)
39
+	{
40
+		$this->loader = $loader;
41
+		$this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * builds decorated middleware stack
47
-     * by continuously injecting previous middleware app into the next
48
-     *
49
-     * @param RequestStackCoreAppInterface $application
50
-     * @return RequestStack
51
-     * @throws Exception
52
-     */
53
-    public function resolve(RequestStackCoreAppInterface $application)
54
-    {
55
-        $core_app = $application;
56
-        // NOW... because the RequestStack is following the decorator pattern,
57
-        // the first stack app we add will end up at the center of the stack,
58
-        // and will end up being the last item to actually run, but we don't want that!
59
-        // Basically we're dealing with TWO stacks, and transferring items from one to the other,
60
-        // BUT... we want the final stack to be in the same order as the first.
61
-        // So we need to reverse the iterator mode when transferring items,
62
-        // because if we don't, the second stack will end  up in the incorrect order.
63
-        $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
64
-        for ($this->rewind(); $this->valid(); $this->next()) {
65
-            try {
66
-                $middleware_app       = $this->validateMiddlewareAppDetails($this->current(), true);
67
-                $middleware_app_class = array_shift($middleware_app);
68
-                $middleware_app_args  = is_array($middleware_app) ? $middleware_app : array();
69
-                $middleware_app_args  = array($application, $this->loader) + $middleware_app_args;
70
-                $application          = $this->loader->getShared($middleware_app_class, $middleware_app_args);
71
-            } catch (InvalidRequestStackMiddlewareException $exception) {
72
-                if(WP_DEBUG) {
73
-                    new ExceptionStackTraceDisplay($exception);
74
-                    continue;
75
-                }
76
-                error_log($exception->getMessage());
77
-            }
78
-        }
79
-        return new RequestStack($application, $core_app);
80
-    }
45
+	/**
46
+	 * builds decorated middleware stack
47
+	 * by continuously injecting previous middleware app into the next
48
+	 *
49
+	 * @param RequestStackCoreAppInterface $application
50
+	 * @return RequestStack
51
+	 * @throws Exception
52
+	 */
53
+	public function resolve(RequestStackCoreAppInterface $application)
54
+	{
55
+		$core_app = $application;
56
+		// NOW... because the RequestStack is following the decorator pattern,
57
+		// the first stack app we add will end up at the center of the stack,
58
+		// and will end up being the last item to actually run, but we don't want that!
59
+		// Basically we're dealing with TWO stacks, and transferring items from one to the other,
60
+		// BUT... we want the final stack to be in the same order as the first.
61
+		// So we need to reverse the iterator mode when transferring items,
62
+		// because if we don't, the second stack will end  up in the incorrect order.
63
+		$this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
64
+		for ($this->rewind(); $this->valid(); $this->next()) {
65
+			try {
66
+				$middleware_app       = $this->validateMiddlewareAppDetails($this->current(), true);
67
+				$middleware_app_class = array_shift($middleware_app);
68
+				$middleware_app_args  = is_array($middleware_app) ? $middleware_app : array();
69
+				$middleware_app_args  = array($application, $this->loader) + $middleware_app_args;
70
+				$application          = $this->loader->getShared($middleware_app_class, $middleware_app_args);
71
+			} catch (InvalidRequestStackMiddlewareException $exception) {
72
+				if(WP_DEBUG) {
73
+					new ExceptionStackTraceDisplay($exception);
74
+					continue;
75
+				}
76
+				error_log($exception->getMessage());
77
+			}
78
+		}
79
+		return new RequestStack($application, $core_app);
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Ensures that the app details that have been pushed onto RequestStackBuilder
85
-     * are all ordered correctly so that the middleware can be properly constructed
86
-     *
87
-     * @param array $middleware_app
88
-     * @param bool  $recurse
89
-     * @return array
90
-     * @throws InvalidRequestStackMiddlewareException
91
-     */
92
-    protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false)
93
-    {
94
-        $middleware_app_class = reset($middleware_app);
95
-        // is array empty ?
96
-        if($middleware_app_class === false) {
97
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
98
-        }
99
-        // are the class and arguments in the wrong order ?
100
-        if(is_array($middleware_app_class)) {
101
-            if ($recurse === true) {
102
-                return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
103
-            }
104
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
105
-        }
106
-        // is filter callback working like legacy middleware and sending a numerically indexed array ?
107
-        if(is_int($middleware_app_class)) {
108
-            if ($recurse === true) {
109
-                $middleware_app = array_reverse($middleware_app);
110
-                return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
111
-            }
112
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
113
-        }
114
-        // is $middleware_app_class a valid FQCN (or class is already loaded) ?
115
-        if(! class_exists($middleware_app_class)) {
116
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
117
-        }
118
-        return $middleware_app;
119
-    }
83
+	/**
84
+	 * Ensures that the app details that have been pushed onto RequestStackBuilder
85
+	 * are all ordered correctly so that the middleware can be properly constructed
86
+	 *
87
+	 * @param array $middleware_app
88
+	 * @param bool  $recurse
89
+	 * @return array
90
+	 * @throws InvalidRequestStackMiddlewareException
91
+	 */
92
+	protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false)
93
+	{
94
+		$middleware_app_class = reset($middleware_app);
95
+		// is array empty ?
96
+		if($middleware_app_class === false) {
97
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
98
+		}
99
+		// are the class and arguments in the wrong order ?
100
+		if(is_array($middleware_app_class)) {
101
+			if ($recurse === true) {
102
+				return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
103
+			}
104
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
105
+		}
106
+		// is filter callback working like legacy middleware and sending a numerically indexed array ?
107
+		if(is_int($middleware_app_class)) {
108
+			if ($recurse === true) {
109
+				$middleware_app = array_reverse($middleware_app);
110
+				return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
111
+			}
112
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
113
+		}
114
+		// is $middleware_app_class a valid FQCN (or class is already loaded) ?
115
+		if(! class_exists($middleware_app_class)) {
116
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
117
+		}
118
+		return $middleware_app;
119
+	}
120 120
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                 $middleware_app_args  = array($application, $this->loader) + $middleware_app_args;
70 70
                 $application          = $this->loader->getShared($middleware_app_class, $middleware_app_args);
71 71
             } catch (InvalidRequestStackMiddlewareException $exception) {
72
-                if(WP_DEBUG) {
72
+                if (WP_DEBUG) {
73 73
                     new ExceptionStackTraceDisplay($exception);
74 74
                     continue;
75 75
                 }
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $middleware_app_class = reset($middleware_app);
95 95
         // is array empty ?
96
-        if($middleware_app_class === false) {
96
+        if ($middleware_app_class === false) {
97 97
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
98 98
         }
99 99
         // are the class and arguments in the wrong order ?
100
-        if(is_array($middleware_app_class)) {
100
+        if (is_array($middleware_app_class)) {
101 101
             if ($recurse === true) {
102 102
                 return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
103 103
             }
104 104
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
105 105
         }
106 106
         // is filter callback working like legacy middleware and sending a numerically indexed array ?
107
-        if(is_int($middleware_app_class)) {
107
+        if (is_int($middleware_app_class)) {
108 108
             if ($recurse === true) {
109 109
                 $middleware_app = array_reverse($middleware_app);
110 110
                 return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
113 113
         }
114 114
         // is $middleware_app_class a valid FQCN (or class is already loaded) ?
115
-        if(! class_exists($middleware_app_class)) {
115
+        if ( ! class_exists($middleware_app_class)) {
116 116
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
117 117
         }
118 118
         return $middleware_app;
Please login to merge, or discard this patch.
core/domain/DomainInterface.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -16,49 +16,49 @@
 block discarded – undo
16 16
 interface DomainInterface extends InterminableInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @return string
21
-     * @throws DomainException
22
-     */
23
-    public function pluginFile();
19
+	/**
20
+	 * @return string
21
+	 * @throws DomainException
22
+	 */
23
+	public function pluginFile();
24 24
 
25 25
 
26
-    /**
27
-     * @return string
28
-     * @throws DomainException
29
-     */
30
-    public function pluginBasename();
26
+	/**
27
+	 * @return string
28
+	 * @throws DomainException
29
+	 */
30
+	public function pluginBasename();
31 31
 
32 32
 
33
-    /**
34
-     * @return string
35
-     */
36
-    public function pluginPath();
33
+	/**
34
+	 * @return string
35
+	 */
36
+	public function pluginPath();
37 37
 
38 38
 
39
-    /**
40
-     * @return string
41
-     * @throws DomainException
42
-     */
43
-    public function pluginUrl();
39
+	/**
40
+	 * @return string
41
+	 * @throws DomainException
42
+	 */
43
+	public function pluginUrl();
44 44
 
45 45
 
46
-    /**
47
-     * @return string
48
-     * @throws DomainException
49
-     */
50
-    public function version();
46
+	/**
47
+	 * @return string
48
+	 * @throws DomainException
49
+	 */
50
+	public function version();
51 51
 
52 52
 
53
-    /**
54
-     * @return string
55
-     */
56
-    public function distributionAssetsPath();
53
+	/**
54
+	 * @return string
55
+	 */
56
+	public function distributionAssetsPath();
57 57
 
58 58
 
59
-    /**
60
-     * @return string
61
-     */
62
-    public function distributionAssetsUrl();
59
+	/**
60
+	 * @return string
61
+	 */
62
+	public function distributionAssetsUrl();
63 63
 
64 64
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 1 patch
Indentation   +449 added lines, -449 removed lines patch added patch discarded remove patch
@@ -24,459 +24,459 @@
 block discarded – undo
24 24
 class Registry
25 25
 {
26 26
 
27
-    /**
28
-     * @var EE_Template_Config $template_config
29
-     */
30
-    protected $template_config;
31
-
32
-    /**
33
-     * @var EE_Currency_Config $currency_config
34
-     */
35
-    protected $currency_config;
36
-
37
-    /**
38
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
39
-     *
40
-     * @var array
41
-     */
42
-    protected $jsdata = array();
43
-
44
-
45
-    /**
46
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
-     * page source.
48
-     * @var array
49
-     */
50
-    protected $script_handles_with_data = array();
51
-
52
-
53
-    /**
54
-     * @var DomainInterface
55
-     */
56
-    protected $domain;
57
-
58
-
59
-    /**
60
-     * Registry constructor.
61
-     * Hooking into WP actions for script registry.
62
-     *
63
-     * @param EE_Template_Config $template_config
64
-     * @param EE_Currency_Config $currency_config
65
-     * @param DomainInterface    $domain
66
-     */
67
-    public function __construct(
68
-        EE_Template_Config $template_config,
69
-        EE_Currency_Config $currency_config,
70
-        DomainInterface $domain
71
-    ) {
72
-        $this->template_config = $template_config;
73
-        $this->currency_config = $currency_config;
74
-        $this->domain = $domain;
75
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
76
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
77
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
78
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
79
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
80
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     * Callback for the WP script actions.
87
-     * Used to register globally accessible core scripts.
88
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
89
-     */
90
-    public function scripts()
91
-    {
92
-        global $wp_version;
93
-        wp_register_script(
94
-            'eejs-core',
95
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
96
-            array(),
97
-            EVENT_ESPRESSO_VERSION,
98
-            true
99
-        );
100
-        //only run this if WordPress 4.4.0 > is in use.
101
-        if (version_compare($wp_version, '4.4.0', '>')) {
102
-            //js.api
103
-            wp_register_script(
104
-                'eejs-api',
105
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
106
-                array('underscore', 'eejs-core'),
107
-                EVENT_ESPRESSO_VERSION,
108
-                true
109
-            );
110
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
111
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
112
-        }
113
-        if (! is_admin()) {
114
-            $this->loadCoreCss();
115
-        }
116
-        $this->loadCoreJs();
117
-        $this->loadJqueryValidate();
118
-        $this->loadAccountingJs();
119
-        $this->loadQtipJs();
120
-    }
121
-
122
-
123
-
124
-    /**
125
-     * Call back for the script print in frontend and backend.
126
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
127
-     *
128
-     * @since 4.9.31.rc.015
129
-     */
130
-    public function enqueueData()
131
-    {
132
-        $this->removeAlreadyRegisteredDataForScriptHandles();
133
-        wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
134
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
135
-        $this->localizeAccountingJs();
136
-        $this->addRegisteredScriptHandlesWithData('eejs-core');
137
-        $this->addRegisteredScriptHandlesWithData('espresso_core');
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * Used to add data to eejs.data object.
144
-     * Note:  Overriding existing data is not allowed.
145
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
146
-     * If the data you add is something like this:
147
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
148
-     * It will be exposed in the page source as:
149
-     *  eejs.data.my_plugin_data.foo == gar
150
-     *
151
-     * @param string       $key   Key used to access your data
152
-     * @param string|array $value Value to attach to key
153
-     * @throws InvalidArgumentException
154
-     */
155
-    public function addData($key, $value)
156
-    {
157
-        if ($this->verifyDataNotExisting($key)) {
158
-            $this->jsdata[$key] = $value;
159
-        }
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
166
-     * elements in an array.
167
-     * When you use this method, the value you include will be appended to the end of an array on $key.
168
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
169
-     * object like this, eejs.data.test = [ my_data,
170
-     * ]
171
-     * If there has already been a scalar value attached to the data object given key, then
172
-     * this will throw an exception.
173
-     *
174
-     * @param string       $key   Key to attach data to.
175
-     * @param string|array $value Value being registered.
176
-     * @throws InvalidArgumentException
177
-     */
178
-    public function pushData($key, $value)
179
-    {
180
-        if (isset($this->jsdata[$key])
181
-            && ! is_array($this->jsdata[$key])
182
-        ) {
183
-            throw new invalidArgumentException(
184
-                sprintf(
185
-                    __(
186
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
27
+	/**
28
+	 * @var EE_Template_Config $template_config
29
+	 */
30
+	protected $template_config;
31
+
32
+	/**
33
+	 * @var EE_Currency_Config $currency_config
34
+	 */
35
+	protected $currency_config;
36
+
37
+	/**
38
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected $jsdata = array();
43
+
44
+
45
+	/**
46
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
+	 * page source.
48
+	 * @var array
49
+	 */
50
+	protected $script_handles_with_data = array();
51
+
52
+
53
+	/**
54
+	 * @var DomainInterface
55
+	 */
56
+	protected $domain;
57
+
58
+
59
+	/**
60
+	 * Registry constructor.
61
+	 * Hooking into WP actions for script registry.
62
+	 *
63
+	 * @param EE_Template_Config $template_config
64
+	 * @param EE_Currency_Config $currency_config
65
+	 * @param DomainInterface    $domain
66
+	 */
67
+	public function __construct(
68
+		EE_Template_Config $template_config,
69
+		EE_Currency_Config $currency_config,
70
+		DomainInterface $domain
71
+	) {
72
+		$this->template_config = $template_config;
73
+		$this->currency_config = $currency_config;
74
+		$this->domain = $domain;
75
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
76
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
77
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
78
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
79
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
80
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 * Callback for the WP script actions.
87
+	 * Used to register globally accessible core scripts.
88
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
89
+	 */
90
+	public function scripts()
91
+	{
92
+		global $wp_version;
93
+		wp_register_script(
94
+			'eejs-core',
95
+			EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
96
+			array(),
97
+			EVENT_ESPRESSO_VERSION,
98
+			true
99
+		);
100
+		//only run this if WordPress 4.4.0 > is in use.
101
+		if (version_compare($wp_version, '4.4.0', '>')) {
102
+			//js.api
103
+			wp_register_script(
104
+				'eejs-api',
105
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
106
+				array('underscore', 'eejs-core'),
107
+				EVENT_ESPRESSO_VERSION,
108
+				true
109
+			);
110
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
111
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
112
+		}
113
+		if (! is_admin()) {
114
+			$this->loadCoreCss();
115
+		}
116
+		$this->loadCoreJs();
117
+		$this->loadJqueryValidate();
118
+		$this->loadAccountingJs();
119
+		$this->loadQtipJs();
120
+	}
121
+
122
+
123
+
124
+	/**
125
+	 * Call back for the script print in frontend and backend.
126
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
127
+	 *
128
+	 * @since 4.9.31.rc.015
129
+	 */
130
+	public function enqueueData()
131
+	{
132
+		$this->removeAlreadyRegisteredDataForScriptHandles();
133
+		wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
134
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
135
+		$this->localizeAccountingJs();
136
+		$this->addRegisteredScriptHandlesWithData('eejs-core');
137
+		$this->addRegisteredScriptHandlesWithData('espresso_core');
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * Used to add data to eejs.data object.
144
+	 * Note:  Overriding existing data is not allowed.
145
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
146
+	 * If the data you add is something like this:
147
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
148
+	 * It will be exposed in the page source as:
149
+	 *  eejs.data.my_plugin_data.foo == gar
150
+	 *
151
+	 * @param string       $key   Key used to access your data
152
+	 * @param string|array $value Value to attach to key
153
+	 * @throws InvalidArgumentException
154
+	 */
155
+	public function addData($key, $value)
156
+	{
157
+		if ($this->verifyDataNotExisting($key)) {
158
+			$this->jsdata[$key] = $value;
159
+		}
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
166
+	 * elements in an array.
167
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
168
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
169
+	 * object like this, eejs.data.test = [ my_data,
170
+	 * ]
171
+	 * If there has already been a scalar value attached to the data object given key, then
172
+	 * this will throw an exception.
173
+	 *
174
+	 * @param string       $key   Key to attach data to.
175
+	 * @param string|array $value Value being registered.
176
+	 * @throws InvalidArgumentException
177
+	 */
178
+	public function pushData($key, $value)
179
+	{
180
+		if (isset($this->jsdata[$key])
181
+			&& ! is_array($this->jsdata[$key])
182
+		) {
183
+			throw new invalidArgumentException(
184
+				sprintf(
185
+					__(
186
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
187 187
                          push values to this data element when it is an array.',
188
-                        'event_espresso'
189
-                    ),
190
-                    $key,
191
-                    __METHOD__
192
-                )
193
-            );
194
-        }
195
-        $this->jsdata[$key][] = $value;
196
-    }
197
-
198
-
199
-
200
-    /**
201
-     * Used to set content used by javascript for a template.
202
-     * Note: Overrides of existing registered templates are not allowed.
203
-     *
204
-     * @param string $template_reference
205
-     * @param string $template_content
206
-     * @throws InvalidArgumentException
207
-     */
208
-    public function addTemplate($template_reference, $template_content)
209
-    {
210
-        if (! isset($this->jsdata['templates'])) {
211
-            $this->jsdata['templates'] = array();
212
-        }
213
-        //no overrides allowed.
214
-        if (isset($this->jsdata['templates'][$template_reference])) {
215
-            throw new invalidArgumentException(
216
-                sprintf(
217
-                    __(
218
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
219
-                        'event_espresso'
220
-                    ),
221
-                    $template_reference
222
-                )
223
-            );
224
-        }
225
-        $this->jsdata['templates'][$template_reference] = $template_content;
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     * Retrieve the template content already registered for the given reference.
232
-     *
233
-     * @param string $template_reference
234
-     * @return string
235
-     */
236
-    public function getTemplate($template_reference)
237
-    {
238
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
239
-            ? $this->jsdata['templates'][$template_reference]
240
-            : '';
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * Retrieve registered data.
247
-     *
248
-     * @param string $key Name of key to attach data to.
249
-     * @return mixed                If there is no for the given key, then false is returned.
250
-     */
251
-    public function getData($key)
252
-    {
253
-        return isset($this->jsdata[$key])
254
-            ? $this->jsdata[$key]
255
-            : false;
256
-    }
257
-
258
-
259
-
260
-    /**
261
-     * Verifies whether the given data exists already on the jsdata array.
262
-     * Overriding data is not allowed.
263
-     *
264
-     * @param string $key Index for data.
265
-     * @return bool        If valid then return true.
266
-     * @throws InvalidArgumentException if data already exists.
267
-     */
268
-    protected function verifyDataNotExisting($key)
269
-    {
270
-        if (isset($this->jsdata[$key])) {
271
-            if (is_array($this->jsdata[$key])) {
272
-                throw new InvalidArgumentException(
273
-                    sprintf(
274
-                        __(
275
-                            'The value for %1$s already exists in the Registry::eejs object.
188
+						'event_espresso'
189
+					),
190
+					$key,
191
+					__METHOD__
192
+				)
193
+			);
194
+		}
195
+		$this->jsdata[$key][] = $value;
196
+	}
197
+
198
+
199
+
200
+	/**
201
+	 * Used to set content used by javascript for a template.
202
+	 * Note: Overrides of existing registered templates are not allowed.
203
+	 *
204
+	 * @param string $template_reference
205
+	 * @param string $template_content
206
+	 * @throws InvalidArgumentException
207
+	 */
208
+	public function addTemplate($template_reference, $template_content)
209
+	{
210
+		if (! isset($this->jsdata['templates'])) {
211
+			$this->jsdata['templates'] = array();
212
+		}
213
+		//no overrides allowed.
214
+		if (isset($this->jsdata['templates'][$template_reference])) {
215
+			throw new invalidArgumentException(
216
+				sprintf(
217
+					__(
218
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
219
+						'event_espresso'
220
+					),
221
+					$template_reference
222
+				)
223
+			);
224
+		}
225
+		$this->jsdata['templates'][$template_reference] = $template_content;
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 * Retrieve the template content already registered for the given reference.
232
+	 *
233
+	 * @param string $template_reference
234
+	 * @return string
235
+	 */
236
+	public function getTemplate($template_reference)
237
+	{
238
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
239
+			? $this->jsdata['templates'][$template_reference]
240
+			: '';
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * Retrieve registered data.
247
+	 *
248
+	 * @param string $key Name of key to attach data to.
249
+	 * @return mixed                If there is no for the given key, then false is returned.
250
+	 */
251
+	public function getData($key)
252
+	{
253
+		return isset($this->jsdata[$key])
254
+			? $this->jsdata[$key]
255
+			: false;
256
+	}
257
+
258
+
259
+
260
+	/**
261
+	 * Verifies whether the given data exists already on the jsdata array.
262
+	 * Overriding data is not allowed.
263
+	 *
264
+	 * @param string $key Index for data.
265
+	 * @return bool        If valid then return true.
266
+	 * @throws InvalidArgumentException if data already exists.
267
+	 */
268
+	protected function verifyDataNotExisting($key)
269
+	{
270
+		if (isset($this->jsdata[$key])) {
271
+			if (is_array($this->jsdata[$key])) {
272
+				throw new InvalidArgumentException(
273
+					sprintf(
274
+						__(
275
+							'The value for %1$s already exists in the Registry::eejs object.
276 276
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
277 277
                             %2$s method to push your value to the array.',
278
-                            'event_espresso'
279
-                        ),
280
-                        $key,
281
-                        'pushData()'
282
-                    )
283
-                );
284
-            }
285
-            throw new InvalidArgumentException(
286
-                sprintf(
287
-                    __(
288
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
278
+							'event_espresso'
279
+						),
280
+						$key,
281
+						'pushData()'
282
+					)
283
+				);
284
+			}
285
+			throw new InvalidArgumentException(
286
+				sprintf(
287
+					__(
288
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
289 289
                         allowed.  Consider attaching your value to a different key',
290
-                        'event_espresso'
291
-                    ),
292
-                    $key
293
-                )
294
-            );
295
-        }
296
-        return true;
297
-    }
298
-
299
-
300
-
301
-    /**
302
-     * registers core default stylesheets
303
-     */
304
-    private function loadCoreCss()
305
-    {
306
-        if ($this->template_config->enable_default_style) {
307
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
308
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
309
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
310
-            wp_register_style(
311
-                'espresso_default',
312
-                $default_stylesheet_path,
313
-                array('dashicons'),
314
-                EVENT_ESPRESSO_VERSION
315
-            );
316
-            //Load custom style sheet if available
317
-            if ($this->template_config->custom_style_sheet !== null) {
318
-                wp_register_style(
319
-                    'espresso_custom_css',
320
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
321
-                    array('espresso_default'),
322
-                    EVENT_ESPRESSO_VERSION
323
-                );
324
-            }
325
-        }
326
-    }
327
-
328
-
329
-
330
-    /**
331
-     * registers core default javascript
332
-     */
333
-    private function loadCoreJs()
334
-    {
335
-        // load core js
336
-        wp_register_script(
337
-            'espresso_core',
338
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
339
-            array('jquery'),
340
-            EVENT_ESPRESSO_VERSION,
341
-            true
342
-        );
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * registers jQuery Validate for form validation
349
-     */
350
-    private function loadJqueryValidate()
351
-    {
352
-        // register jQuery Validate and additional methods
353
-        wp_register_script(
354
-            'jquery-validate',
355
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
356
-            array('jquery'),
357
-            '1.15.0',
358
-            true
359
-        );
360
-        wp_register_script(
361
-            'jquery-validate-extra-methods',
362
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
363
-            array('jquery', 'jquery-validate'),
364
-            '1.15.0',
365
-            true
366
-        );
367
-    }
368
-
369
-
370
-
371
-    /**
372
-     * registers accounting.js for performing client-side calculations
373
-     */
374
-    private function loadAccountingJs()
375
-    {
376
-        //accounting.js library
377
-        // @link http://josscrowcroft.github.io/accounting.js/
378
-        wp_register_script(
379
-            'ee-accounting-core',
380
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
381
-            array('underscore'),
382
-            '0.3.2',
383
-            true
384
-        );
385
-        wp_register_script(
386
-            'ee-accounting',
387
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
388
-            array('ee-accounting-core'),
389
-            EVENT_ESPRESSO_VERSION,
390
-            true
391
-        );
392
-    }
393
-
394
-
395
-
396
-    /**
397
-     * registers accounting.js for performing client-side calculations
398
-     */
399
-    private function localizeAccountingJs()
400
-    {
401
-        wp_localize_script(
402
-            'ee-accounting',
403
-            'EE_ACCOUNTING_CFG',
404
-            array(
405
-                'currency' => array(
406
-                    'symbol'    => $this->currency_config->sign,
407
-                    'format'    => array(
408
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
409
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
410
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
411
-                    ),
412
-                    'decimal'   => $this->currency_config->dec_mrk,
413
-                    'thousand'  => $this->currency_config->thsnds,
414
-                    'precision' => $this->currency_config->dec_plc,
415
-                ),
416
-                'number'   => array(
417
-                    'precision' => $this->currency_config->dec_plc,
418
-                    'thousand'  => $this->currency_config->thsnds,
419
-                    'decimal'   => $this->currency_config->dec_mrk,
420
-                ),
421
-            )
422
-        );
423
-        $this->addRegisteredScriptHandlesWithData('ee-accounting');
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * registers assets for cleaning your ears
430
-     */
431
-    private function loadQtipJs()
432
-    {
433
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
434
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
435
-        if (apply_filters('FHEE_load_qtip', false)) {
436
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
437
-        }
438
-    }
439
-
440
-
441
-    /**
442
-     * This is used to set registered script handles that have data.
443
-     * @param string $script_handle
444
-     */
445
-    private function addRegisteredScriptHandlesWithData($script_handle)
446
-    {
447
-        $this->script_handles_with_data[$script_handle] = $script_handle;
448
-    }
449
-
450
-
451
-    /**
452
-     * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
453
-     * Dependency stored in WP_Scripts if its set.
454
-     */
455
-    private function removeAlreadyRegisteredDataForScriptHandles()
456
-    {
457
-        if (empty($this->script_handles_with_data)) {
458
-            return;
459
-        }
460
-        foreach ($this->script_handles_with_data as $script_handle) {
461
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
462
-        }
463
-    }
464
-
465
-
466
-    /**
467
-     * Removes any data dependency registered in WP_Scripts if its set.
468
-     * @param string $script_handle
469
-     */
470
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
471
-    {
472
-        if (isset($this->script_handles_with_data[$script_handle])) {
473
-            global $wp_scripts;
474
-            if ($wp_scripts->get_data($script_handle, 'data')) {
475
-                unset($wp_scripts->registered[$script_handle]->extra['data']);
476
-                unset($this->script_handles_with_data[$script_handle]);
477
-            }
478
-        }
479
-    }
290
+						'event_espresso'
291
+					),
292
+					$key
293
+				)
294
+			);
295
+		}
296
+		return true;
297
+	}
298
+
299
+
300
+
301
+	/**
302
+	 * registers core default stylesheets
303
+	 */
304
+	private function loadCoreCss()
305
+	{
306
+		if ($this->template_config->enable_default_style) {
307
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
308
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
309
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
310
+			wp_register_style(
311
+				'espresso_default',
312
+				$default_stylesheet_path,
313
+				array('dashicons'),
314
+				EVENT_ESPRESSO_VERSION
315
+			);
316
+			//Load custom style sheet if available
317
+			if ($this->template_config->custom_style_sheet !== null) {
318
+				wp_register_style(
319
+					'espresso_custom_css',
320
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
321
+					array('espresso_default'),
322
+					EVENT_ESPRESSO_VERSION
323
+				);
324
+			}
325
+		}
326
+	}
327
+
328
+
329
+
330
+	/**
331
+	 * registers core default javascript
332
+	 */
333
+	private function loadCoreJs()
334
+	{
335
+		// load core js
336
+		wp_register_script(
337
+			'espresso_core',
338
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
339
+			array('jquery'),
340
+			EVENT_ESPRESSO_VERSION,
341
+			true
342
+		);
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * registers jQuery Validate for form validation
349
+	 */
350
+	private function loadJqueryValidate()
351
+	{
352
+		// register jQuery Validate and additional methods
353
+		wp_register_script(
354
+			'jquery-validate',
355
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
356
+			array('jquery'),
357
+			'1.15.0',
358
+			true
359
+		);
360
+		wp_register_script(
361
+			'jquery-validate-extra-methods',
362
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
363
+			array('jquery', 'jquery-validate'),
364
+			'1.15.0',
365
+			true
366
+		);
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 * registers accounting.js for performing client-side calculations
373
+	 */
374
+	private function loadAccountingJs()
375
+	{
376
+		//accounting.js library
377
+		// @link http://josscrowcroft.github.io/accounting.js/
378
+		wp_register_script(
379
+			'ee-accounting-core',
380
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
381
+			array('underscore'),
382
+			'0.3.2',
383
+			true
384
+		);
385
+		wp_register_script(
386
+			'ee-accounting',
387
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
388
+			array('ee-accounting-core'),
389
+			EVENT_ESPRESSO_VERSION,
390
+			true
391
+		);
392
+	}
393
+
394
+
395
+
396
+	/**
397
+	 * registers accounting.js for performing client-side calculations
398
+	 */
399
+	private function localizeAccountingJs()
400
+	{
401
+		wp_localize_script(
402
+			'ee-accounting',
403
+			'EE_ACCOUNTING_CFG',
404
+			array(
405
+				'currency' => array(
406
+					'symbol'    => $this->currency_config->sign,
407
+					'format'    => array(
408
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
409
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
410
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
411
+					),
412
+					'decimal'   => $this->currency_config->dec_mrk,
413
+					'thousand'  => $this->currency_config->thsnds,
414
+					'precision' => $this->currency_config->dec_plc,
415
+				),
416
+				'number'   => array(
417
+					'precision' => $this->currency_config->dec_plc,
418
+					'thousand'  => $this->currency_config->thsnds,
419
+					'decimal'   => $this->currency_config->dec_mrk,
420
+				),
421
+			)
422
+		);
423
+		$this->addRegisteredScriptHandlesWithData('ee-accounting');
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * registers assets for cleaning your ears
430
+	 */
431
+	private function loadQtipJs()
432
+	{
433
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
434
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
435
+		if (apply_filters('FHEE_load_qtip', false)) {
436
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
437
+		}
438
+	}
439
+
440
+
441
+	/**
442
+	 * This is used to set registered script handles that have data.
443
+	 * @param string $script_handle
444
+	 */
445
+	private function addRegisteredScriptHandlesWithData($script_handle)
446
+	{
447
+		$this->script_handles_with_data[$script_handle] = $script_handle;
448
+	}
449
+
450
+
451
+	/**
452
+	 * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
453
+	 * Dependency stored in WP_Scripts if its set.
454
+	 */
455
+	private function removeAlreadyRegisteredDataForScriptHandles()
456
+	{
457
+		if (empty($this->script_handles_with_data)) {
458
+			return;
459
+		}
460
+		foreach ($this->script_handles_with_data as $script_handle) {
461
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
462
+		}
463
+	}
464
+
465
+
466
+	/**
467
+	 * Removes any data dependency registered in WP_Scripts if its set.
468
+	 * @param string $script_handle
469
+	 */
470
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
471
+	{
472
+		if (isset($this->script_handles_with_data[$script_handle])) {
473
+			global $wp_scripts;
474
+			if ($wp_scripts->get_data($script_handle, 'data')) {
475
+				unset($wp_scripts->registered[$script_handle]->extra['data']);
476
+				unset($this->script_handles_with_data[$script_handle]);
477
+			}
478
+		}
479
+	}
480 480
 
481 481
 
482 482
 }
Please login to merge, or discard this patch.
message_type/newsletter/EE_Messages_Email_Newsletter_Validator.class.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since           4.3.0
8 8
  */
9 9
 if (! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -21,59 +21,59 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class EE_Messages_Email_Newsletter_Validator extends EE_Messages_Validator
23 23
 {
24
-    public function __construct($fields, $context)
25
-    {
26
-        $this->_m_name = 'email';
27
-        $this->_mt_name = 'newsletter';
24
+	public function __construct($fields, $context)
25
+	{
26
+		$this->_m_name = 'email';
27
+		$this->_mt_name = 'newsletter';
28 28
 
29
-        parent::__construct($fields, $context);
30
-    }
29
+		parent::__construct($fields, $context);
30
+	}
31 31
 
32
-    /**
33
-     * custom validator (restricting what was originally set by the messenger)
34
-     */
35
-    protected function _modify_validator()
36
-    {
37
-        if ($this->_context == 'attendee') {
38
-            $this->_valid_shortcodes_modifier[$this->_context]['from'] = array(
39
-                'recipient_details',
40
-                'email',
41
-                'organization',
42
-            );
43
-        }
32
+	/**
33
+	 * custom validator (restricting what was originally set by the messenger)
34
+	 */
35
+	protected function _modify_validator()
36
+	{
37
+		if ($this->_context == 'attendee') {
38
+			$this->_valid_shortcodes_modifier[$this->_context]['from'] = array(
39
+				'recipient_details',
40
+				'email',
41
+				'organization',
42
+			);
43
+		}
44 44
 
45
-        //excluded shortcodes
46
-        $fields = array('to', 'from', 'subject', 'content', 'newsletter_content');
47
-        foreach ($fields as $field) {
48
-            $this->_specific_shortcode_excludes[$field] = array(
49
-                '[RECIPIENT_REGISTRATION_CODE]',
50
-                '[EVENT_AUTHOR_FORMATTED_EMAIL]',
51
-                '[EVENT_AUTHOR_EMAIL]',
52
-            );
53
-        }
54
-        $add_excludes = array(
55
-            '[RECIPIENT_FNAME]',
56
-            '[RECIPIENT_LNAME]',
57
-            '[RECIPIENT_EMAIL]',
58
-            '[COMPANY]',
59
-            '[CO_ADD1]',
60
-            '[CO_ADD2]',
61
-            '[CO_CITY]',
62
-            '[CO_STATE]',
63
-            '[CO_ZIP]',
64
-            '[CO_LOGO]',
65
-            '[CO_PHONE]',
66
-            '[CO_LOGO_URL]',
67
-            '[CO_FACEBOOK_URL]',
68
-            '[CO_TWITTER_URL]',
69
-            '[CO_PINTEREST_URL]',
70
-            '[CO_GOOGLE_URL]',
71
-            '[CO_LINKEDIN_URL]',
72
-            '[CO_INSTAGRAM_URL]',
73
-        );
74
-        $this->_specific_shortcode_excludes['from'] = array_merge($this->_specific_shortcode_excludes['from'],
75
-            $add_excludes);
76
-        $this->_specific_shortcode_excludes['content'] = array_merge($this->_specific_shortcode_excludes['content'],
77
-            array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'));
78
-    }
45
+		//excluded shortcodes
46
+		$fields = array('to', 'from', 'subject', 'content', 'newsletter_content');
47
+		foreach ($fields as $field) {
48
+			$this->_specific_shortcode_excludes[$field] = array(
49
+				'[RECIPIENT_REGISTRATION_CODE]',
50
+				'[EVENT_AUTHOR_FORMATTED_EMAIL]',
51
+				'[EVENT_AUTHOR_EMAIL]',
52
+			);
53
+		}
54
+		$add_excludes = array(
55
+			'[RECIPIENT_FNAME]',
56
+			'[RECIPIENT_LNAME]',
57
+			'[RECIPIENT_EMAIL]',
58
+			'[COMPANY]',
59
+			'[CO_ADD1]',
60
+			'[CO_ADD2]',
61
+			'[CO_CITY]',
62
+			'[CO_STATE]',
63
+			'[CO_ZIP]',
64
+			'[CO_LOGO]',
65
+			'[CO_PHONE]',
66
+			'[CO_LOGO_URL]',
67
+			'[CO_FACEBOOK_URL]',
68
+			'[CO_TWITTER_URL]',
69
+			'[CO_PINTEREST_URL]',
70
+			'[CO_GOOGLE_URL]',
71
+			'[CO_LINKEDIN_URL]',
72
+			'[CO_INSTAGRAM_URL]',
73
+		);
74
+		$this->_specific_shortcode_excludes['from'] = array_merge($this->_specific_shortcode_excludes['from'],
75
+			$add_excludes);
76
+		$this->_specific_shortcode_excludes['content'] = array_merge($this->_specific_shortcode_excludes['content'],
77
+			array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'));
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @subpackage      helpers
7 7
  * @since           4.3.0
8 8
  */
9
-if (! defined('EVENT_ESPRESSO_VERSION')) {
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10 10
     exit('No direct script access allowed');
11 11
 }
12 12
 
Please login to merge, or discard this patch.
messages/message_type/newsletter/EE_Newsletter_message_type.class.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since           4.3.0
8 8
  */
9 9
 if (! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -23,152 +23,152 @@  discard block
 block discarded – undo
23 23
 class EE_Newsletter_message_type extends EE_message_type
24 24
 {
25 25
 
26
-    public function __construct()
27
-    {
28
-        $this->name = 'newsletter';
29
-        $this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.',
30
-            'event_espresso');
31
-        $this->label = array(
32
-            'singular' => __('batch', 'event_espresso'),
33
-            'plural'   => __('batches', 'event_espresso'),
34
-        );
35
-        $this->_master_templates = array(
36
-            'email' => 'registration',
37
-        );
38
-
39
-        parent::__construct();
40
-    }
41
-
42
-
43
-    protected function _set_admin_pages()
44
-    {
45
-        $this->admin_registered_pages = array(); //no admin pages to register this with.
46
-    }
47
-
48
-
49
-    protected function _set_data_handler()
50
-    {
51
-        $this->_data_handler = 'Registrations';
52
-        $this->_single_message = $this->_data instanceof EE_Registration;
53
-    }
54
-
55
-
56
-    protected function _get_data_for_context($context, EE_Registration $registration, $id)
57
-    {
58
-        //newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects.
59
-        return array($registration);
60
-    }
61
-
62
-
63
-    protected function _set_admin_settings_fields()
64
-    {
65
-        $this->_admin_settings_fields = array();
66
-    }
67
-
68
-
69
-    protected function _set_contexts()
70
-    {
71
-        $this->_context_label = array(
72
-            'label'       => __('recipient', 'event_espresso'),
73
-            'plural'      => __('recipients', 'event_espresso'),
74
-            'description' => __('Recipient\'s are who will receive the message.', 'event_espresso'),
75
-        );
76
-
77
-        $this->_contexts = array(
78
-            'attendee' => array(
79
-                'label'       => __('Registrant', 'event_espresso'),
80
-                'description' => __('This template goes to selected registrants.', 'event_espresso'),
81
-            ),
82
-        );
83
-    }
84
-
85
-
86
-    /**
87
-     * used to set the valid shortcodes.
88
-     * For the newsletter message type we only have two valid shortcode libraries in use, recipient details and
89
-     * organization.  That's it!
90
-     *
91
-     * @since   4.3.0
92
-     * @return  void
93
-     */
94
-    protected function _set_valid_shortcodes()
95
-    {
96
-        parent::_set_valid_shortcodes();
97
-
98
-        $included_shortcodes = array(
99
-            'recipient_details',
100
-            'organization',
101
-            'newsletter',
102
-        );
103
-
104
-        foreach ($this->_valid_shortcodes as $context => $shortcodes) {
105
-            foreach ($shortcodes as $key => $shortcode) {
106
-                if (! in_array($shortcode, $included_shortcodes)) {
107
-                    unset($this->_valid_shortcodes[$context][$key]);
108
-                }
109
-            }
110
-            $this->_valid_shortcodes[$context][] = 'newsletter';
111
-        }
112
-
113
-    }
114
-
115
-
116
-    /**
117
-     * Override default _attendee_addressees in EE_message_type because we want to loop through the registrations
118
-     * for EE_message_type.
119
-     */
120
-    protected function _attendee_addressees()
121
-    {
122
-        $addressee = array();
123
-
124
-        //looping through registrations
125
-        foreach ($this->_data->registrations as $reg_id => $details) {
126
-            //set $attendee array to blank on each loop
127
-            $aee = array();
128
-
129
-            //need to get the attendee from this registration.
130
-            $attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee
131
-                ? $details['att_obj']
132
-                : null;
133
-
134
-            if (! $attendee instanceof EE_Attendee) {
135
-                continue;
136
-            }
137
-
138
-            //set $aee from attendee object
139
-            $aee['att_obj'] = $attendee;
140
-            $aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs'])
141
-                ? $this->_data->attendees[$attendee->ID()]['reg_objs']
142
-                : array();
143
-            $aee['attendee_email'] = $attendee->email();
144
-            $aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs'])
145
-                ? $this->_data->attendees[$attendee->ID()]['tkt_objs']
146
-                : array();
147
-
148
-            if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) {
149
-                $aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
150
-                $aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
151
-            } else {
152
-                $aee['evt_objs'] = $aee['events'] = array();
153
-            }
154
-
155
-            $aee['reg_obj'] = isset($details['reg_obj'])
156
-                ? $details['reg_obj']
157
-                : null;
158
-            $aee['attendees'] = $this->_data->attendees;
159
-
160
-            //merge in the primary attendee data
161
-            $aee = array_merge($this->_default_addressee_data, $aee);
162
-
163
-            //make sure txn is set
164
-            if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) {
165
-                $aee['txn'] = $aee['reg_obj']->transaction();
166
-            }
167
-
168
-            $addressee[] = new EE_Messages_Addressee($aee);
169
-        }
170
-        return $addressee;
171
-    }
26
+	public function __construct()
27
+	{
28
+		$this->name = 'newsletter';
29
+		$this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.',
30
+			'event_espresso');
31
+		$this->label = array(
32
+			'singular' => __('batch', 'event_espresso'),
33
+			'plural'   => __('batches', 'event_espresso'),
34
+		);
35
+		$this->_master_templates = array(
36
+			'email' => 'registration',
37
+		);
38
+
39
+		parent::__construct();
40
+	}
41
+
42
+
43
+	protected function _set_admin_pages()
44
+	{
45
+		$this->admin_registered_pages = array(); //no admin pages to register this with.
46
+	}
47
+
48
+
49
+	protected function _set_data_handler()
50
+	{
51
+		$this->_data_handler = 'Registrations';
52
+		$this->_single_message = $this->_data instanceof EE_Registration;
53
+	}
54
+
55
+
56
+	protected function _get_data_for_context($context, EE_Registration $registration, $id)
57
+	{
58
+		//newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects.
59
+		return array($registration);
60
+	}
61
+
62
+
63
+	protected function _set_admin_settings_fields()
64
+	{
65
+		$this->_admin_settings_fields = array();
66
+	}
67
+
68
+
69
+	protected function _set_contexts()
70
+	{
71
+		$this->_context_label = array(
72
+			'label'       => __('recipient', 'event_espresso'),
73
+			'plural'      => __('recipients', 'event_espresso'),
74
+			'description' => __('Recipient\'s are who will receive the message.', 'event_espresso'),
75
+		);
76
+
77
+		$this->_contexts = array(
78
+			'attendee' => array(
79
+				'label'       => __('Registrant', 'event_espresso'),
80
+				'description' => __('This template goes to selected registrants.', 'event_espresso'),
81
+			),
82
+		);
83
+	}
84
+
85
+
86
+	/**
87
+	 * used to set the valid shortcodes.
88
+	 * For the newsletter message type we only have two valid shortcode libraries in use, recipient details and
89
+	 * organization.  That's it!
90
+	 *
91
+	 * @since   4.3.0
92
+	 * @return  void
93
+	 */
94
+	protected function _set_valid_shortcodes()
95
+	{
96
+		parent::_set_valid_shortcodes();
97
+
98
+		$included_shortcodes = array(
99
+			'recipient_details',
100
+			'organization',
101
+			'newsletter',
102
+		);
103
+
104
+		foreach ($this->_valid_shortcodes as $context => $shortcodes) {
105
+			foreach ($shortcodes as $key => $shortcode) {
106
+				if (! in_array($shortcode, $included_shortcodes)) {
107
+					unset($this->_valid_shortcodes[$context][$key]);
108
+				}
109
+			}
110
+			$this->_valid_shortcodes[$context][] = 'newsletter';
111
+		}
112
+
113
+	}
114
+
115
+
116
+	/**
117
+	 * Override default _attendee_addressees in EE_message_type because we want to loop through the registrations
118
+	 * for EE_message_type.
119
+	 */
120
+	protected function _attendee_addressees()
121
+	{
122
+		$addressee = array();
123
+
124
+		//looping through registrations
125
+		foreach ($this->_data->registrations as $reg_id => $details) {
126
+			//set $attendee array to blank on each loop
127
+			$aee = array();
128
+
129
+			//need to get the attendee from this registration.
130
+			$attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee
131
+				? $details['att_obj']
132
+				: null;
133
+
134
+			if (! $attendee instanceof EE_Attendee) {
135
+				continue;
136
+			}
137
+
138
+			//set $aee from attendee object
139
+			$aee['att_obj'] = $attendee;
140
+			$aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs'])
141
+				? $this->_data->attendees[$attendee->ID()]['reg_objs']
142
+				: array();
143
+			$aee['attendee_email'] = $attendee->email();
144
+			$aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs'])
145
+				? $this->_data->attendees[$attendee->ID()]['tkt_objs']
146
+				: array();
147
+
148
+			if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) {
149
+				$aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
150
+				$aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
151
+			} else {
152
+				$aee['evt_objs'] = $aee['events'] = array();
153
+			}
154
+
155
+			$aee['reg_obj'] = isset($details['reg_obj'])
156
+				? $details['reg_obj']
157
+				: null;
158
+			$aee['attendees'] = $this->_data->attendees;
159
+
160
+			//merge in the primary attendee data
161
+			$aee = array_merge($this->_default_addressee_data, $aee);
162
+
163
+			//make sure txn is set
164
+			if (empty($aee['txn']) && $aee['reg_obj'] instanceof EE_Registration) {
165
+				$aee['txn'] = $aee['reg_obj']->transaction();
166
+			}
167
+
168
+			$addressee[] = new EE_Messages_Addressee($aee);
169
+		}
170
+		return $addressee;
171
+	}
172 172
 
173 173
 
174 174
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @subpackage      helpers
7 7
  * @since           4.3.0
8 8
  */
9
-if (! defined('EVENT_ESPRESSO_VERSION')) {
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10 10
     exit('No direct script access allowed');
11 11
 }
12 12
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
         foreach ($this->_valid_shortcodes as $context => $shortcodes) {
105 105
             foreach ($shortcodes as $key => $shortcode) {
106
-                if (! in_array($shortcode, $included_shortcodes)) {
106
+                if ( ! in_array($shortcode, $included_shortcodes)) {
107 107
                     unset($this->_valid_shortcodes[$context][$key]);
108 108
                 }
109 109
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                 ? $details['att_obj']
132 132
                 : null;
133 133
 
134
-            if (! $attendee instanceof EE_Attendee) {
134
+            if ( ! $attendee instanceof EE_Attendee) {
135 135
                 continue;
136 136
             }
137 137
 
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Indentation   +1002 added lines, -1002 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -27,838 +27,838 @@  discard block
 block discarded – undo
27 27
 class Payments_Admin_Page extends EE_Admin_Page
28 28
 {
29 29
 
30
-    /**
31
-     * Variables used for when we're re-sorting the logs results, in case
32
-     * we needed to do two queries and we need to resort
33
-     *
34
-     * @var string
35
-     */
36
-    private $_sort_logs_again_direction;
37
-
38
-
39
-
40
-    /**
41
-     * @Constructor
42
-     * @access public
43
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
44
-     * @return \Payments_Admin_Page
45
-     */
46
-    public function __construct($routing = true)
47
-    {
48
-        parent::__construct($routing);
49
-    }
50
-
51
-
52
-
53
-    protected function _init_page_props()
54
-    {
55
-        $this->page_slug = EE_PAYMENTS_PG_SLUG;
56
-        $this->page_label = __('Payment Methods', 'event_espresso');
57
-        $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
58
-        $this->_admin_base_path = EE_PAYMENTS_ADMIN;
59
-    }
60
-
61
-
62
-
63
-    protected function _ajax_hooks()
64
-    {
65
-        //todo: all hooks for ajax goes here.
66
-    }
67
-
68
-
69
-
70
-    protected function _define_page_props()
71
-    {
72
-        $this->_admin_page_title = $this->page_label;
73
-        $this->_labels = array(
74
-            'publishbox' => __('Update Settings', 'event_espresso'),
75
-        );
76
-    }
77
-
78
-
79
-
80
-    protected function _set_page_routes()
81
-    {
82
-        /**
83
-         * note that with payment method capabilities, although we've implemented
84
-         * capability mapping which will be used for accessing payment methods owned by
85
-         * other users.  This is not fully implemented yet in the payment method ui.
86
-         * Currently only the "plural" caps are in active use.
87
-         * When cap mapping is implemented, some routes will need to use the singular form of
88
-         * capability method and also include the $id of the payment method for the route.
89
-         **/
90
-        $this->_page_routes = array(
91
-            'default'                   => array(
92
-                'func'       => '_payment_methods_list',
93
-                'capability' => 'ee_edit_payment_methods',
94
-            ),
95
-            'payment_settings'          => array(
96
-                'func'       => '_payment_settings',
97
-                'capability' => 'ee_manage_gateways',
98
-            ),
99
-            'activate_payment_method'   => array(
100
-                'func'       => '_activate_payment_method',
101
-                'noheader'   => true,
102
-                'capability' => 'ee_edit_payment_methods',
103
-            ),
104
-            'deactivate_payment_method' => array(
105
-                'func'       => '_deactivate_payment_method',
106
-                'noheader'   => true,
107
-                'capability' => 'ee_delete_payment_methods',
108
-            ),
109
-            'update_payment_method'     => array(
110
-                'func'               => '_update_payment_method',
111
-                'noheader'           => true,
112
-                'headers_sent_route' => 'default',
113
-                'capability'         => 'ee_edit_payment_methods',
114
-            ),
115
-            'update_payment_settings'   => array(
116
-                'func'       => '_update_payment_settings',
117
-                'noheader'   => true,
118
-                'capability' => 'ee_manage_gateways',
119
-            ),
120
-            'payment_log'               => array(
121
-                'func'       => '_payment_log_overview_list_table',
122
-                'capability' => 'ee_read_payment_methods',
123
-            ),
124
-            'payment_log_details'       => array(
125
-                'func'       => '_payment_log_details',
126
-                'capability' => 'ee_read_payment_methods',
127
-            ),
128
-        );
129
-    }
130
-
131
-
132
-
133
-    protected function _set_page_config()
134
-    {
135
-        $payment_method_list_config = array(
136
-            'nav'           => array(
137
-                'label' => __('Payment Methods', 'event_espresso'),
138
-                'order' => 10,
139
-            ),
140
-            'metaboxes'     => $this->_default_espresso_metaboxes,
141
-            'help_tabs'     => array_merge(
142
-                array(
143
-                    'payment_methods_overview_help_tab' => array(
144
-                        'title'    => __('Payment Methods Overview', 'event_espresso'),
145
-                        'filename' => 'payment_methods_overview',
146
-                    ),
147
-                ),
148
-                $this->_add_payment_method_help_tabs()),
149
-            'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
150
-            'require_nonce' => false,
151
-        );
152
-        $this->_page_config = array(
153
-            'default'          => $payment_method_list_config,
154
-            'payment_settings' => array(
155
-                'nav'           => array(
156
-                    'label' => __('Settings', 'event_espresso'),
157
-                    'order' => 20,
158
-                ),
159
-                'help_tabs'     => array(
160
-                    'payment_methods_settings_help_tab' => array(
161
-                        'title'    => __('Payment Method Settings', 'event_espresso'),
162
-                        'filename' => 'payment_methods_settings',
163
-                    ),
164
-                ),
165
-                //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
166
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
167
-                'require_nonce' => false,
168
-            ),
169
-            'payment_log'      => array(
170
-                'nav'           => array(
171
-                    'label' => __("Logs", 'event_espresso'),
172
-                    'order' => 30,
173
-                ),
174
-                'list_table'    => 'Payment_Log_Admin_List_Table',
175
-                'metaboxes'     => $this->_default_espresso_metaboxes,
176
-                'require_nonce' => false,
177
-            ),
178
-        );
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * @return array
185
-     */
186
-    protected function _add_payment_method_help_tabs()
187
-    {
188
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
189
-        $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
190
-        $all_pmt_help_tabs_config = array();
191
-        foreach ($payment_method_types as $payment_method_type) {
192
-            if (! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(),
193
-                'specific_payment_method_type_access')
194
-            ) {
195
-                continue;
196
-            }
197
-            foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
198
-                $template_args = isset($config['template_args']) ? $config['template_args'] : array();
199
-                $template_args['admin_page_obj'] = $this;
200
-                $all_pmt_help_tabs_config[$help_tab_name] = array(
201
-                    'title'   => $config['title'],
202
-                    'content' => EEH_Template::display_template(
203
-                        $payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php',
204
-                        $template_args,
205
-                        true),
206
-                );
207
-            }
208
-        }
209
-        return $all_pmt_help_tabs_config;
210
-    }
211
-
212
-
213
-
214
-    //none of the below group are currently used for Gateway Settings
215
-    protected function _add_screen_options()
216
-    {
217
-    }
218
-
219
-
220
-
221
-    protected function _add_feature_pointers()
222
-    {
223
-    }
224
-
225
-
226
-
227
-    public function admin_init()
228
-    {
229
-    }
230
-
231
-
232
-
233
-    public function admin_notices()
234
-    {
235
-    }
236
-
237
-
238
-
239
-    public function admin_footer_scripts()
240
-    {
241
-    }
242
-
243
-
244
-
245
-    public function load_scripts_styles()
246
-    {
247
-        wp_enqueue_script('ee_admin_js');
248
-        wp_enqueue_script('ee-text-links');
249
-        wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
250
-            array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, true);
251
-    }
252
-
253
-
254
-
255
-    public function load_scripts_styles_default()
256
-    {
257
-        //styles
258
-        wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(),
259
-            EVENT_ESPRESSO_VERSION);
260
-        wp_enqueue_style('espresso_payments');
261
-        wp_enqueue_style('ee-text-links');
262
-        //scripts
263
-    }
264
-
265
-
266
-
267
-    protected function _payment_methods_list()
268
-    {
269
-        /**
270
-         * first let's ensure payment methods have been setup. We do this here because when people activate a
271
-         * payment method for the first time (as an addon), it may not setup its capabilities or get registered correctly due
272
-         * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
273
-         * recheck here.
274
-         */
275
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
276
-        EEM_Payment_Method::instance()->verify_button_urls();
277
-        //setup tabs, one for each payment method type
278
-        $tabs = array();
279
-        $payment_methods = array();
280
-        foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
281
-            // we don't want to show admin-only PMTs for now
282
-            if ($pmt_obj instanceof EE_PMT_Admin_Only) {
283
-                continue;
284
-            }
285
-            //check access
286
-            if (! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(),
287
-                'specific_payment_method_type_access')
288
-            ) {
289
-                continue;
290
-            }
291
-            //check for any active pms of that type
292
-            $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
293
-            if (! $payment_method instanceof EE_Payment_Method) {
294
-                $payment_method = EE_Payment_Method::new_instance(
295
-                    array(
296
-                        'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
297
-                        'PMD_type'       => $pmt_obj->system_name(),
298
-                        'PMD_name'       => $pmt_obj->pretty_name(),
299
-                        'PMD_admin_name' => $pmt_obj->pretty_name(),
300
-                    )
301
-                );
302
-            }
303
-            $payment_methods[$payment_method->slug()] = $payment_method;
304
-        }
305
-        $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
306
-            $payment_methods);
307
-        foreach ($payment_methods as $payment_method) {
308
-            if ($payment_method instanceof EE_Payment_Method) {
309
-                add_meta_box(
310
-                //html id
311
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
312
-                    //title
313
-                    sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
314
-                    //callback
315
-                    array($this, 'payment_method_settings_meta_box'),
316
-                    //post type
317
-                    null,
318
-                    //context
319
-                    'normal',
320
-                    //priority
321
-                    'default',
322
-                    //callback args
323
-                    array('payment_method' => $payment_method)
324
-                );
325
-                //setup for tabbed content
326
-                $tabs[$payment_method->slug()] = array(
327
-                    'label' => $payment_method->admin_name(),
328
-                    'class' => $payment_method->active() ? 'gateway-active' : '',
329
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
330
-                    'title' => __('Modify this Payment Method', 'event_espresso'),
331
-                    'slug'  => $payment_method->slug(),
332
-                );
333
-            }
334
-        }
335
-        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links',
336
-            '|', $this->_get_active_payment_method_slug());
337
-        $this->display_admin_page_with_sidebar();
338
-    }
339
-
340
-
341
-
342
-    /**
343
-     *   _get_active_payment_method_slug
344
-     *
345
-     * @return string
346
-     */
347
-    protected function _get_active_payment_method_slug()
348
-    {
349
-        $payment_method_slug = false;
350
-        //decide which payment method tab to open first, as dictated by the request's 'payment_method'
351
-        if (isset($this->_req_data['payment_method'])) {
352
-            // if they provided the current payment method, use it
353
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
354
-        }
355
-        $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
356
-        // if that didn't work or wasn't provided, find another way to select the current pm
357
-        if (! $this->_verify_payment_method($payment_method)) {
358
-            // like, looking for an active one
359
-            $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
360
-            // test that one as well
361
-            if ($this->_verify_payment_method($payment_method)) {
362
-                $payment_method_slug = $payment_method->slug();
363
-            } else {
364
-                $payment_method_slug = 'paypal_standard';
365
-            }
366
-        }
367
-        return $payment_method_slug;
368
-    }
369
-
370
-
371
-
372
-    /**
373
-     *    payment_method_settings_meta_box
374
-     *    returns TRUE if the passed payment method is properly constructed and the logged in user has the correct
375
-     *    capabilities to access it
376
-     *
377
-     * @param \EE_Payment_Method $payment_method
378
-     * @return boolean
379
-     */
380
-    protected function _verify_payment_method($payment_method)
381
-    {
382
-        if (
383
-            $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
384
-            && EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(),
385
-                'specific_payment_method_type_access')
386
-        ) {
387
-            return true;
388
-        }
389
-        return false;
390
-    }
391
-
392
-
393
-
394
-    /**
395
-     *    payment_method_settings_meta_box
396
-     *
397
-     * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
398
-     * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
399
-     *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
400
-     * @return string
401
-     * @throws EE_Error
402
-     */
403
-    public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
404
-    {
405
-        $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
406
-            ? $metabox['args']['payment_method'] : null;
407
-        if (! $payment_method instanceof EE_Payment_Method) {
408
-            throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied',
409
-                'event_espresso')));
410
-        }
411
-        $payment_method_scopes = $payment_method->active();
412
-        // if the payment method really exists show its form, otherwise the activation template
413
-        if ($payment_method->ID() && ! empty($payment_method_scopes)) {
414
-            $form = $this->_generate_payment_method_settings_form($payment_method);
415
-            if ($form->form_data_present_in($this->_req_data)) {
416
-                $form->receive_form_submission($this->_req_data);
417
-            }
418
-            echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
419
-        } else {
420
-            echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
421
-        }
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * Gets the form for all the settings related to this payment method type
428
-     *
429
-     * @access protected
430
-     * @param \EE_Payment_Method $payment_method
431
-     * @return \EE_Form_Section_Proper
432
-     */
433
-    protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method)
434
-    {
435
-        if (! $payment_method instanceof EE_Payment_Method) {
436
-            return new EE_Form_Section_Proper();
437
-        }
438
-        return new EE_Form_Section_Proper(
439
-            array(
440
-                'name'            => $payment_method->slug() . '_settings_form',
441
-                'html_id'         => $payment_method->slug() . '_settings_form',
442
-                'action'          => EE_Admin_Page::add_query_args_and_nonce(
443
-                    array(
444
-                        'action'         => 'update_payment_method',
445
-                        'payment_method' => $payment_method->slug(),
446
-                    ),
447
-                    EE_PAYMENTS_ADMIN_URL
448
-                ),
449
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
450
-                'subsections'     => apply_filters(
451
-                    'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
452
-                    array(
453
-                        'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
454
-                        'currency_support'        => $this->_currency_support($payment_method),
455
-                        'payment_method_settings' => $this->_payment_method_settings($payment_method),
456
-                        'update'                  => $this->_update_payment_method_button($payment_method),
457
-                        'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
458
-                        'fine_print'              => $this->_fine_print(),
459
-                    ),
460
-                    $payment_method
461
-                ),
462
-            )
463
-        );
464
-    }
465
-
466
-
467
-
468
-    /**
469
-     * _pci_dss_compliance
470
-     *
471
-     * @access protected
472
-     * @param \EE_Payment_Method $payment_method
473
-     * @return \EE_Form_Section_Proper
474
-     */
475
-    protected function _pci_dss_compliance(EE_Payment_Method $payment_method)
476
-    {
477
-        if ($payment_method->type_obj()->requires_https()) {
478
-            return new EE_Form_Section_HTML(
479
-                EEH_HTML::tr(
480
-                    EEH_HTML::th(
481
-                        EEH_HTML::label(
482
-                            EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
483
-                        )
484
-                    ) .
485
-                    EEH_HTML::td(
486
-                        EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
487
-                            'event_espresso'))
488
-                        .
489
-                        EEH_HTML::br()
490
-                        .
491
-                        __('Learn more about ', 'event_espresso')
492
-                        . EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php',
493
-                            __('PCI DSS compliance', 'event_espresso'))
494
-                    )
495
-                )
496
-            );
497
-        } else {
498
-            return new EE_Form_Section_HTML('');
499
-        }
500
-    }
501
-
502
-
503
-
504
-    /**
505
-     * _currency_support
506
-     *
507
-     * @access protected
508
-     * @param \EE_Payment_Method $payment_method
509
-     * @return \EE_Form_Section_Proper
510
-     */
511
-    protected function _currency_support(EE_Payment_Method $payment_method)
512
-    {
513
-        if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
514
-            return new EE_Form_Section_HTML(
515
-                EEH_HTML::tr(
516
-                    EEH_HTML::th(
517
-                        EEH_HTML::label(
518
-                            EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
519
-                        )
520
-                    ) .
521
-                    EEH_HTML::td(
522
-                        EEH_HTML::strong(
523
-                            sprintf(
524
-                                __('This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
525
-                                    'event_espresso'),
526
-                                EE_Config::instance()->currency->code
527
-                            )
528
-                        )
529
-                    )
530
-                )
531
-            );
532
-        } else {
533
-            return new EE_Form_Section_HTML('');
534
-        }
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * _update_payment_method_button
541
-     *
542
-     * @access protected
543
-     * @param \EE_Payment_Method $payment_method
544
-     * @return \EE_Form_Section_HTML
545
-     */
546
-    protected function _payment_method_settings(EE_Payment_Method $payment_method)
547
-    {
548
-        //modify the form so we only have/show fields that will be implemented for this version
549
-        return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
550
-    }
551
-
552
-
553
-
554
-    /**
555
-     * Simplifies the form to merely reproduce 4.1's gateway settings functionality
556
-     *
557
-     * @param EE_Form_Section_Proper $form_section
558
-     * @param string                 $payment_method_name
559
-     * @return \EE_Payment_Method_Form
560
-     * @throws \EE_Error
561
-     */
562
-    protected function _simplify_form($form_section, $payment_method_name = '')
563
-    {
564
-        if ($form_section instanceof EE_Payment_Method_Form) {
565
-            $form_section->exclude(
566
-                array(
567
-                    'PMD_type', //dont want them changing the type
568
-                    'PMD_slug', //or the slug (probably never)
569
-                    'PMD_wp_user', //or the user's ID
570
-                    'Currency' //or the currency, until the rest of EE supports simultaneous currencies
571
-                )
572
-            );
573
-            return $form_section;
574
-        } else {
575
-            throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
576
-                'event_espresso'), $payment_method_name));
577
-        }
578
-    }
579
-
580
-
581
-
582
-    /**
583
-     * _update_payment_method_button
584
-     *
585
-     * @access protected
586
-     * @param \EE_Payment_Method $payment_method
587
-     * @return \EE_Form_Section_HTML
588
-     */
589
-    protected function _update_payment_method_button(EE_Payment_Method $payment_method)
590
-    {
591
-        $update_button = new EE_Submit_Input(
592
-            array(
593
-                'name'       => 'submit',
594
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
595
-                'default'    => sprintf(__('Update %s Payment Settings', 'event_espresso'),
596
-                    $payment_method->admin_name()),
597
-                'html_label' => EEH_HTML::nbsp(),
598
-            )
599
-        );
600
-        return new EE_Form_Section_HTML(
601
-            EEH_HTML::no_row(EEH_HTML::br(2)) .
602
-            EEH_HTML::tr(
603
-                EEH_HTML::th(__('Update Settings', 'event_espresso')) .
604
-                EEH_HTML::td(
605
-                    $update_button->get_html_for_input()
606
-                )
607
-            )
608
-        );
609
-    }
610
-
611
-
612
-
613
-    /**
614
-     * _deactivate_payment_method_button
615
-     *
616
-     * @access protected
617
-     * @param \EE_Payment_Method $payment_method
618
-     * @return \EE_Form_Section_Proper
619
-     */
620
-    protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
621
-    {
622
-        $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'),
623
-            $payment_method->admin_name());
624
-        return new EE_Form_Section_HTML(
625
-            EEH_HTML::tr(
626
-                EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) .
627
-                EEH_HTML::td(
628
-                    EEH_HTML::link(
629
-                        EE_Admin_Page::add_query_args_and_nonce(
630
-                            array(
631
-                                'action'         => 'deactivate_payment_method',
632
-                                'payment_method' => $payment_method->slug(),
633
-                            ),
634
-                            EE_PAYMENTS_ADMIN_URL
635
-                        ),
636
-                        $link_text_and_title,
637
-                        $link_text_and_title,
638
-                        'deactivate_' . $payment_method->slug(),
639
-                        'espresso-button button-secondary'
640
-                    )
641
-                )
642
-            )
643
-        );
644
-    }
645
-
646
-
647
-
648
-    /**
649
-     * _activate_payment_method_button
650
-     *
651
-     * @access protected
652
-     * @param \EE_Payment_Method $payment_method
653
-     * @return \EE_Form_Section_Proper
654
-     */
655
-    protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
656
-    {
657
-        $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'),
658
-            $payment_method->admin_name());
659
-        return new EE_Form_Section_Proper(
660
-            array(
661
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
662
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
663
-                'action'          => '#',
664
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
665
-                'subsections'     => apply_filters(
666
-                    'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
667
-                    array(
668
-                        new EE_Form_Section_HTML(
669
-                            EEH_HTML::tr(
670
-                                EEH_HTML::td($payment_method->type_obj()->introductory_html(),
671
-                                    '',
672
-                                    '',
673
-                                    '',
674
-                                    'colspan="2"'
675
-                                )
676
-                            ) .
677
-                            EEH_HTML::tr(
678
-                                EEH_HTML::th(
679
-                                    EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
680
-                                ) .
681
-                                EEH_HTML::td(
682
-                                    EEH_HTML::link(
683
-                                        EE_Admin_Page::add_query_args_and_nonce(
684
-                                            array(
685
-                                                'action'              => 'activate_payment_method',
686
-                                                'payment_method_type' => $payment_method->type(),
687
-                                            ),
688
-                                            EE_PAYMENTS_ADMIN_URL
689
-                                        ),
690
-                                        $link_text_and_title,
691
-                                        $link_text_and_title,
692
-                                        'activate_' . $payment_method->slug(),
693
-                                        'espresso-button-green button-primary'
694
-                                    )
695
-                                )
696
-                            )
697
-                        ),
698
-                    ),
699
-                    $payment_method
700
-                ),
701
-            )
702
-        );
703
-    }
704
-
705
-
706
-
707
-    /**
708
-     * _fine_print
709
-     *
710
-     * @access protected
711
-     * @return \EE_Form_Section_HTML
712
-     */
713
-    protected function _fine_print()
714
-    {
715
-        return new EE_Form_Section_HTML(
716
-            EEH_HTML::tr(
717
-                EEH_HTML::th() .
718
-                EEH_HTML::td(
719
-                    EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
720
-                )
721
-            )
722
-        );
723
-    }
724
-
725
-
726
-
727
-    /**
728
-     * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
729
-     *
730
-     * @global WP_User $current_user
731
-     */
732
-    protected function _activate_payment_method()
733
-    {
734
-        if (isset($this->_req_data['payment_method_type'])) {
735
-            $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
736
-            //see if one exists
737
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
738
-            $payment_method = EE_Payment_Method_Manager::instance()
739
-                                                       ->activate_a_payment_method_of_type($payment_method_type);
740
-            $this->_redirect_after_action(1, 'Payment Method', 'activated',
741
-                array('action' => 'default', 'payment_method' => $payment_method->slug()));
742
-        } else {
743
-            $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
744
-        }
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     * Deactivates the payment method with the specified slug, and redirects.
751
-     */
752
-    protected function _deactivate_payment_method()
753
-    {
754
-        if (isset($this->_req_data['payment_method'])) {
755
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
756
-            //deactivate it
757
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
758
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
759
-            $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated',
760
-                array('action' => 'default', 'payment_method' => $payment_method_slug));
761
-        } else {
762
-            $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
763
-        }
764
-    }
765
-
766
-
767
-
768
-    /**
769
-     * Processes the payment method form that was submitted. This is slightly trickier than usual form
770
-     * processing because we first need to identify WHICH form was processed and which payment method
771
-     * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
772
-     * form's data is saved and we redirect to the default payment methods page, setting the updated payment method
773
-     * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
774
-     * subsequently called 'headers_sent_func' which is _payment_methods_list)
775
-     *
776
-     * @return void
777
-     */
778
-    protected function _update_payment_method()
779
-    {
780
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
781
-            //ok let's find which gateway form to use based on the form input
782
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
783
-            /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
784
-            $correct_pmt_form_to_use = null;
785
-            $payment_method = null;
786
-            foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
787
-                //get the form and simplify it, like what we do when we display it
788
-                $pmt_form = $this->_generate_payment_method_settings_form($payment_method);
789
-                if ($pmt_form->form_data_present_in($this->_req_data)) {
790
-                    $correct_pmt_form_to_use = $pmt_form;
791
-                    break;
792
-                }
793
-            }
794
-            //if we couldn't find the correct payment method type...
795
-            if (! $correct_pmt_form_to_use) {
796
-                EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support",
797
-                    'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
798
-                $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
799
-            }
800
-            $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
801
-            if ($correct_pmt_form_to_use->is_valid()) {
802
-                $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
803
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
804
-                    throw new EE_Error(
805
-                        sprintf(
806
-                            __('The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
807
-                                'event_espresso'),
808
-                            'payment_method_settings'
809
-                        )
810
-                    );
811
-                }
812
-                $payment_settings_subform->save();
813
-                /** @var $pm EE_Payment_Method */
814
-                $this->_redirect_after_action(true, 'Payment Method', 'updated',
815
-                    array('action' => 'default', 'payment_method' => $payment_method->slug()));
816
-            } else {
817
-                EE_Error::add_error(
818
-                    sprintf(
819
-                        __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
820
-                            'event_espresso'),
821
-                        $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
822
-                            : __('"(unknown)"', 'event_espresso')
823
-                    ),
824
-                    __FILE__,
825
-                    __FUNCTION__,
826
-                    __LINE__
827
-                );
828
-            }
829
-        }
830
-        return;
831
-    }
832
-
833
-
834
-
835
-    protected function _payment_settings()
836
-    {
837
-        $this->_template_args['values'] = $this->_yes_no_values;
838
-        $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options)
839
-            ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : false;
840
-        $this->_set_add_edit_form_tags('update_payment_settings');
841
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
842
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH
843
-                                                                                     . 'payment_settings.template.php',
844
-            $this->_template_args, true);
845
-        $this->display_admin_page_with_sidebar();
846
-    }
847
-
848
-
849
-
850
-    /**
851
-     *        _update_payment_settings
852
-     *
853
-     * @access protected
854
-     * @return array
855
-     */
856
-    protected function _update_payment_settings()
857
-    {
858
-        EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options'])
859
-            ? $this->_req_data['show_pending_payment_options'] : false;
860
-        EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG',
861
-            EE_Registry::instance()->CFG);
30
+	/**
31
+	 * Variables used for when we're re-sorting the logs results, in case
32
+	 * we needed to do two queries and we need to resort
33
+	 *
34
+	 * @var string
35
+	 */
36
+	private $_sort_logs_again_direction;
37
+
38
+
39
+
40
+	/**
41
+	 * @Constructor
42
+	 * @access public
43
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
44
+	 * @return \Payments_Admin_Page
45
+	 */
46
+	public function __construct($routing = true)
47
+	{
48
+		parent::__construct($routing);
49
+	}
50
+
51
+
52
+
53
+	protected function _init_page_props()
54
+	{
55
+		$this->page_slug = EE_PAYMENTS_PG_SLUG;
56
+		$this->page_label = __('Payment Methods', 'event_espresso');
57
+		$this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
58
+		$this->_admin_base_path = EE_PAYMENTS_ADMIN;
59
+	}
60
+
61
+
62
+
63
+	protected function _ajax_hooks()
64
+	{
65
+		//todo: all hooks for ajax goes here.
66
+	}
67
+
68
+
69
+
70
+	protected function _define_page_props()
71
+	{
72
+		$this->_admin_page_title = $this->page_label;
73
+		$this->_labels = array(
74
+			'publishbox' => __('Update Settings', 'event_espresso'),
75
+		);
76
+	}
77
+
78
+
79
+
80
+	protected function _set_page_routes()
81
+	{
82
+		/**
83
+		 * note that with payment method capabilities, although we've implemented
84
+		 * capability mapping which will be used for accessing payment methods owned by
85
+		 * other users.  This is not fully implemented yet in the payment method ui.
86
+		 * Currently only the "plural" caps are in active use.
87
+		 * When cap mapping is implemented, some routes will need to use the singular form of
88
+		 * capability method and also include the $id of the payment method for the route.
89
+		 **/
90
+		$this->_page_routes = array(
91
+			'default'                   => array(
92
+				'func'       => '_payment_methods_list',
93
+				'capability' => 'ee_edit_payment_methods',
94
+			),
95
+			'payment_settings'          => array(
96
+				'func'       => '_payment_settings',
97
+				'capability' => 'ee_manage_gateways',
98
+			),
99
+			'activate_payment_method'   => array(
100
+				'func'       => '_activate_payment_method',
101
+				'noheader'   => true,
102
+				'capability' => 'ee_edit_payment_methods',
103
+			),
104
+			'deactivate_payment_method' => array(
105
+				'func'       => '_deactivate_payment_method',
106
+				'noheader'   => true,
107
+				'capability' => 'ee_delete_payment_methods',
108
+			),
109
+			'update_payment_method'     => array(
110
+				'func'               => '_update_payment_method',
111
+				'noheader'           => true,
112
+				'headers_sent_route' => 'default',
113
+				'capability'         => 'ee_edit_payment_methods',
114
+			),
115
+			'update_payment_settings'   => array(
116
+				'func'       => '_update_payment_settings',
117
+				'noheader'   => true,
118
+				'capability' => 'ee_manage_gateways',
119
+			),
120
+			'payment_log'               => array(
121
+				'func'       => '_payment_log_overview_list_table',
122
+				'capability' => 'ee_read_payment_methods',
123
+			),
124
+			'payment_log_details'       => array(
125
+				'func'       => '_payment_log_details',
126
+				'capability' => 'ee_read_payment_methods',
127
+			),
128
+		);
129
+	}
130
+
131
+
132
+
133
+	protected function _set_page_config()
134
+	{
135
+		$payment_method_list_config = array(
136
+			'nav'           => array(
137
+				'label' => __('Payment Methods', 'event_espresso'),
138
+				'order' => 10,
139
+			),
140
+			'metaboxes'     => $this->_default_espresso_metaboxes,
141
+			'help_tabs'     => array_merge(
142
+				array(
143
+					'payment_methods_overview_help_tab' => array(
144
+						'title'    => __('Payment Methods Overview', 'event_espresso'),
145
+						'filename' => 'payment_methods_overview',
146
+					),
147
+				),
148
+				$this->_add_payment_method_help_tabs()),
149
+			'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
150
+			'require_nonce' => false,
151
+		);
152
+		$this->_page_config = array(
153
+			'default'          => $payment_method_list_config,
154
+			'payment_settings' => array(
155
+				'nav'           => array(
156
+					'label' => __('Settings', 'event_espresso'),
157
+					'order' => 20,
158
+				),
159
+				'help_tabs'     => array(
160
+					'payment_methods_settings_help_tab' => array(
161
+						'title'    => __('Payment Method Settings', 'event_espresso'),
162
+						'filename' => 'payment_methods_settings',
163
+					),
164
+				),
165
+				//'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
166
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
167
+				'require_nonce' => false,
168
+			),
169
+			'payment_log'      => array(
170
+				'nav'           => array(
171
+					'label' => __("Logs", 'event_espresso'),
172
+					'order' => 30,
173
+				),
174
+				'list_table'    => 'Payment_Log_Admin_List_Table',
175
+				'metaboxes'     => $this->_default_espresso_metaboxes,
176
+				'require_nonce' => false,
177
+			),
178
+		);
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * @return array
185
+	 */
186
+	protected function _add_payment_method_help_tabs()
187
+	{
188
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
189
+		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
190
+		$all_pmt_help_tabs_config = array();
191
+		foreach ($payment_method_types as $payment_method_type) {
192
+			if (! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(),
193
+				'specific_payment_method_type_access')
194
+			) {
195
+				continue;
196
+			}
197
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
198
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
199
+				$template_args['admin_page_obj'] = $this;
200
+				$all_pmt_help_tabs_config[$help_tab_name] = array(
201
+					'title'   => $config['title'],
202
+					'content' => EEH_Template::display_template(
203
+						$payment_method_type->file_folder() . 'help_tabs' . DS . $config['filename'] . '.help_tab.php',
204
+						$template_args,
205
+						true),
206
+				);
207
+			}
208
+		}
209
+		return $all_pmt_help_tabs_config;
210
+	}
211
+
212
+
213
+
214
+	//none of the below group are currently used for Gateway Settings
215
+	protected function _add_screen_options()
216
+	{
217
+	}
218
+
219
+
220
+
221
+	protected function _add_feature_pointers()
222
+	{
223
+	}
224
+
225
+
226
+
227
+	public function admin_init()
228
+	{
229
+	}
230
+
231
+
232
+
233
+	public function admin_notices()
234
+	{
235
+	}
236
+
237
+
238
+
239
+	public function admin_footer_scripts()
240
+	{
241
+	}
242
+
243
+
244
+
245
+	public function load_scripts_styles()
246
+	{
247
+		wp_enqueue_script('ee_admin_js');
248
+		wp_enqueue_script('ee-text-links');
249
+		wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
250
+			array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, true);
251
+	}
252
+
253
+
254
+
255
+	public function load_scripts_styles_default()
256
+	{
257
+		//styles
258
+		wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(),
259
+			EVENT_ESPRESSO_VERSION);
260
+		wp_enqueue_style('espresso_payments');
261
+		wp_enqueue_style('ee-text-links');
262
+		//scripts
263
+	}
264
+
265
+
266
+
267
+	protected function _payment_methods_list()
268
+	{
269
+		/**
270
+		 * first let's ensure payment methods have been setup. We do this here because when people activate a
271
+		 * payment method for the first time (as an addon), it may not setup its capabilities or get registered correctly due
272
+		 * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
273
+		 * recheck here.
274
+		 */
275
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
276
+		EEM_Payment_Method::instance()->verify_button_urls();
277
+		//setup tabs, one for each payment method type
278
+		$tabs = array();
279
+		$payment_methods = array();
280
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
281
+			// we don't want to show admin-only PMTs for now
282
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
283
+				continue;
284
+			}
285
+			//check access
286
+			if (! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(),
287
+				'specific_payment_method_type_access')
288
+			) {
289
+				continue;
290
+			}
291
+			//check for any active pms of that type
292
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
293
+			if (! $payment_method instanceof EE_Payment_Method) {
294
+				$payment_method = EE_Payment_Method::new_instance(
295
+					array(
296
+						'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
297
+						'PMD_type'       => $pmt_obj->system_name(),
298
+						'PMD_name'       => $pmt_obj->pretty_name(),
299
+						'PMD_admin_name' => $pmt_obj->pretty_name(),
300
+					)
301
+				);
302
+			}
303
+			$payment_methods[$payment_method->slug()] = $payment_method;
304
+		}
305
+		$payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
306
+			$payment_methods);
307
+		foreach ($payment_methods as $payment_method) {
308
+			if ($payment_method instanceof EE_Payment_Method) {
309
+				add_meta_box(
310
+				//html id
311
+					'espresso_' . $payment_method->slug() . '_payment_settings',
312
+					//title
313
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
314
+					//callback
315
+					array($this, 'payment_method_settings_meta_box'),
316
+					//post type
317
+					null,
318
+					//context
319
+					'normal',
320
+					//priority
321
+					'default',
322
+					//callback args
323
+					array('payment_method' => $payment_method)
324
+				);
325
+				//setup for tabbed content
326
+				$tabs[$payment_method->slug()] = array(
327
+					'label' => $payment_method->admin_name(),
328
+					'class' => $payment_method->active() ? 'gateway-active' : '',
329
+					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
330
+					'title' => __('Modify this Payment Method', 'event_espresso'),
331
+					'slug'  => $payment_method->slug(),
332
+				);
333
+			}
334
+		}
335
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links',
336
+			'|', $this->_get_active_payment_method_slug());
337
+		$this->display_admin_page_with_sidebar();
338
+	}
339
+
340
+
341
+
342
+	/**
343
+	 *   _get_active_payment_method_slug
344
+	 *
345
+	 * @return string
346
+	 */
347
+	protected function _get_active_payment_method_slug()
348
+	{
349
+		$payment_method_slug = false;
350
+		//decide which payment method tab to open first, as dictated by the request's 'payment_method'
351
+		if (isset($this->_req_data['payment_method'])) {
352
+			// if they provided the current payment method, use it
353
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
354
+		}
355
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
356
+		// if that didn't work or wasn't provided, find another way to select the current pm
357
+		if (! $this->_verify_payment_method($payment_method)) {
358
+			// like, looking for an active one
359
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
360
+			// test that one as well
361
+			if ($this->_verify_payment_method($payment_method)) {
362
+				$payment_method_slug = $payment_method->slug();
363
+			} else {
364
+				$payment_method_slug = 'paypal_standard';
365
+			}
366
+		}
367
+		return $payment_method_slug;
368
+	}
369
+
370
+
371
+
372
+	/**
373
+	 *    payment_method_settings_meta_box
374
+	 *    returns TRUE if the passed payment method is properly constructed and the logged in user has the correct
375
+	 *    capabilities to access it
376
+	 *
377
+	 * @param \EE_Payment_Method $payment_method
378
+	 * @return boolean
379
+	 */
380
+	protected function _verify_payment_method($payment_method)
381
+	{
382
+		if (
383
+			$payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
384
+			&& EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(),
385
+				'specific_payment_method_type_access')
386
+		) {
387
+			return true;
388
+		}
389
+		return false;
390
+	}
391
+
392
+
393
+
394
+	/**
395
+	 *    payment_method_settings_meta_box
396
+	 *
397
+	 * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
398
+	 * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
399
+	 *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
400
+	 * @return string
401
+	 * @throws EE_Error
402
+	 */
403
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
404
+	{
405
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
406
+			? $metabox['args']['payment_method'] : null;
407
+		if (! $payment_method instanceof EE_Payment_Method) {
408
+			throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied',
409
+				'event_espresso')));
410
+		}
411
+		$payment_method_scopes = $payment_method->active();
412
+		// if the payment method really exists show its form, otherwise the activation template
413
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
414
+			$form = $this->_generate_payment_method_settings_form($payment_method);
415
+			if ($form->form_data_present_in($this->_req_data)) {
416
+				$form->receive_form_submission($this->_req_data);
417
+			}
418
+			echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
419
+		} else {
420
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
421
+		}
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * Gets the form for all the settings related to this payment method type
428
+	 *
429
+	 * @access protected
430
+	 * @param \EE_Payment_Method $payment_method
431
+	 * @return \EE_Form_Section_Proper
432
+	 */
433
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method)
434
+	{
435
+		if (! $payment_method instanceof EE_Payment_Method) {
436
+			return new EE_Form_Section_Proper();
437
+		}
438
+		return new EE_Form_Section_Proper(
439
+			array(
440
+				'name'            => $payment_method->slug() . '_settings_form',
441
+				'html_id'         => $payment_method->slug() . '_settings_form',
442
+				'action'          => EE_Admin_Page::add_query_args_and_nonce(
443
+					array(
444
+						'action'         => 'update_payment_method',
445
+						'payment_method' => $payment_method->slug(),
446
+					),
447
+					EE_PAYMENTS_ADMIN_URL
448
+				),
449
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
450
+				'subsections'     => apply_filters(
451
+					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
452
+					array(
453
+						'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
454
+						'currency_support'        => $this->_currency_support($payment_method),
455
+						'payment_method_settings' => $this->_payment_method_settings($payment_method),
456
+						'update'                  => $this->_update_payment_method_button($payment_method),
457
+						'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
458
+						'fine_print'              => $this->_fine_print(),
459
+					),
460
+					$payment_method
461
+				),
462
+			)
463
+		);
464
+	}
465
+
466
+
467
+
468
+	/**
469
+	 * _pci_dss_compliance
470
+	 *
471
+	 * @access protected
472
+	 * @param \EE_Payment_Method $payment_method
473
+	 * @return \EE_Form_Section_Proper
474
+	 */
475
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method)
476
+	{
477
+		if ($payment_method->type_obj()->requires_https()) {
478
+			return new EE_Form_Section_HTML(
479
+				EEH_HTML::tr(
480
+					EEH_HTML::th(
481
+						EEH_HTML::label(
482
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
483
+						)
484
+					) .
485
+					EEH_HTML::td(
486
+						EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
487
+							'event_espresso'))
488
+						.
489
+						EEH_HTML::br()
490
+						.
491
+						__('Learn more about ', 'event_espresso')
492
+						. EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php',
493
+							__('PCI DSS compliance', 'event_espresso'))
494
+					)
495
+				)
496
+			);
497
+		} else {
498
+			return new EE_Form_Section_HTML('');
499
+		}
500
+	}
501
+
502
+
503
+
504
+	/**
505
+	 * _currency_support
506
+	 *
507
+	 * @access protected
508
+	 * @param \EE_Payment_Method $payment_method
509
+	 * @return \EE_Form_Section_Proper
510
+	 */
511
+	protected function _currency_support(EE_Payment_Method $payment_method)
512
+	{
513
+		if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
514
+			return new EE_Form_Section_HTML(
515
+				EEH_HTML::tr(
516
+					EEH_HTML::th(
517
+						EEH_HTML::label(
518
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
519
+						)
520
+					) .
521
+					EEH_HTML::td(
522
+						EEH_HTML::strong(
523
+							sprintf(
524
+								__('This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.',
525
+									'event_espresso'),
526
+								EE_Config::instance()->currency->code
527
+							)
528
+						)
529
+					)
530
+				)
531
+			);
532
+		} else {
533
+			return new EE_Form_Section_HTML('');
534
+		}
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * _update_payment_method_button
541
+	 *
542
+	 * @access protected
543
+	 * @param \EE_Payment_Method $payment_method
544
+	 * @return \EE_Form_Section_HTML
545
+	 */
546
+	protected function _payment_method_settings(EE_Payment_Method $payment_method)
547
+	{
548
+		//modify the form so we only have/show fields that will be implemented for this version
549
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
550
+	}
551
+
552
+
553
+
554
+	/**
555
+	 * Simplifies the form to merely reproduce 4.1's gateway settings functionality
556
+	 *
557
+	 * @param EE_Form_Section_Proper $form_section
558
+	 * @param string                 $payment_method_name
559
+	 * @return \EE_Payment_Method_Form
560
+	 * @throws \EE_Error
561
+	 */
562
+	protected function _simplify_form($form_section, $payment_method_name = '')
563
+	{
564
+		if ($form_section instanceof EE_Payment_Method_Form) {
565
+			$form_section->exclude(
566
+				array(
567
+					'PMD_type', //dont want them changing the type
568
+					'PMD_slug', //or the slug (probably never)
569
+					'PMD_wp_user', //or the user's ID
570
+					'Currency' //or the currency, until the rest of EE supports simultaneous currencies
571
+				)
572
+			);
573
+			return $form_section;
574
+		} else {
575
+			throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
576
+				'event_espresso'), $payment_method_name));
577
+		}
578
+	}
579
+
580
+
581
+
582
+	/**
583
+	 * _update_payment_method_button
584
+	 *
585
+	 * @access protected
586
+	 * @param \EE_Payment_Method $payment_method
587
+	 * @return \EE_Form_Section_HTML
588
+	 */
589
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method)
590
+	{
591
+		$update_button = new EE_Submit_Input(
592
+			array(
593
+				'name'       => 'submit',
594
+				'html_id'    => 'save_' . $payment_method->slug() . '_settings',
595
+				'default'    => sprintf(__('Update %s Payment Settings', 'event_espresso'),
596
+					$payment_method->admin_name()),
597
+				'html_label' => EEH_HTML::nbsp(),
598
+			)
599
+		);
600
+		return new EE_Form_Section_HTML(
601
+			EEH_HTML::no_row(EEH_HTML::br(2)) .
602
+			EEH_HTML::tr(
603
+				EEH_HTML::th(__('Update Settings', 'event_espresso')) .
604
+				EEH_HTML::td(
605
+					$update_button->get_html_for_input()
606
+				)
607
+			)
608
+		);
609
+	}
610
+
611
+
612
+
613
+	/**
614
+	 * _deactivate_payment_method_button
615
+	 *
616
+	 * @access protected
617
+	 * @param \EE_Payment_Method $payment_method
618
+	 * @return \EE_Form_Section_Proper
619
+	 */
620
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
621
+	{
622
+		$link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'),
623
+			$payment_method->admin_name());
624
+		return new EE_Form_Section_HTML(
625
+			EEH_HTML::tr(
626
+				EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')) .
627
+				EEH_HTML::td(
628
+					EEH_HTML::link(
629
+						EE_Admin_Page::add_query_args_and_nonce(
630
+							array(
631
+								'action'         => 'deactivate_payment_method',
632
+								'payment_method' => $payment_method->slug(),
633
+							),
634
+							EE_PAYMENTS_ADMIN_URL
635
+						),
636
+						$link_text_and_title,
637
+						$link_text_and_title,
638
+						'deactivate_' . $payment_method->slug(),
639
+						'espresso-button button-secondary'
640
+					)
641
+				)
642
+			)
643
+		);
644
+	}
645
+
646
+
647
+
648
+	/**
649
+	 * _activate_payment_method_button
650
+	 *
651
+	 * @access protected
652
+	 * @param \EE_Payment_Method $payment_method
653
+	 * @return \EE_Form_Section_Proper
654
+	 */
655
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
656
+	{
657
+		$link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'),
658
+			$payment_method->admin_name());
659
+		return new EE_Form_Section_Proper(
660
+			array(
661
+				'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
662
+				'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
663
+				'action'          => '#',
664
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
665
+				'subsections'     => apply_filters(
666
+					'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
667
+					array(
668
+						new EE_Form_Section_HTML(
669
+							EEH_HTML::tr(
670
+								EEH_HTML::td($payment_method->type_obj()->introductory_html(),
671
+									'',
672
+									'',
673
+									'',
674
+									'colspan="2"'
675
+								)
676
+							) .
677
+							EEH_HTML::tr(
678
+								EEH_HTML::th(
679
+									EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
680
+								) .
681
+								EEH_HTML::td(
682
+									EEH_HTML::link(
683
+										EE_Admin_Page::add_query_args_and_nonce(
684
+											array(
685
+												'action'              => 'activate_payment_method',
686
+												'payment_method_type' => $payment_method->type(),
687
+											),
688
+											EE_PAYMENTS_ADMIN_URL
689
+										),
690
+										$link_text_and_title,
691
+										$link_text_and_title,
692
+										'activate_' . $payment_method->slug(),
693
+										'espresso-button-green button-primary'
694
+									)
695
+								)
696
+							)
697
+						),
698
+					),
699
+					$payment_method
700
+				),
701
+			)
702
+		);
703
+	}
704
+
705
+
706
+
707
+	/**
708
+	 * _fine_print
709
+	 *
710
+	 * @access protected
711
+	 * @return \EE_Form_Section_HTML
712
+	 */
713
+	protected function _fine_print()
714
+	{
715
+		return new EE_Form_Section_HTML(
716
+			EEH_HTML::tr(
717
+				EEH_HTML::th() .
718
+				EEH_HTML::td(
719
+					EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
720
+				)
721
+			)
722
+		);
723
+	}
724
+
725
+
726
+
727
+	/**
728
+	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
729
+	 *
730
+	 * @global WP_User $current_user
731
+	 */
732
+	protected function _activate_payment_method()
733
+	{
734
+		if (isset($this->_req_data['payment_method_type'])) {
735
+			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
736
+			//see if one exists
737
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
738
+			$payment_method = EE_Payment_Method_Manager::instance()
739
+													   ->activate_a_payment_method_of_type($payment_method_type);
740
+			$this->_redirect_after_action(1, 'Payment Method', 'activated',
741
+				array('action' => 'default', 'payment_method' => $payment_method->slug()));
742
+		} else {
743
+			$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
744
+		}
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 * Deactivates the payment method with the specified slug, and redirects.
751
+	 */
752
+	protected function _deactivate_payment_method()
753
+	{
754
+		if (isset($this->_req_data['payment_method'])) {
755
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
756
+			//deactivate it
757
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
758
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
759
+			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated',
760
+				array('action' => 'default', 'payment_method' => $payment_method_slug));
761
+		} else {
762
+			$this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
763
+		}
764
+	}
765
+
766
+
767
+
768
+	/**
769
+	 * Processes the payment method form that was submitted. This is slightly trickier than usual form
770
+	 * processing because we first need to identify WHICH form was processed and which payment method
771
+	 * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
772
+	 * form's data is saved and we redirect to the default payment methods page, setting the updated payment method
773
+	 * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
774
+	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
775
+	 *
776
+	 * @return void
777
+	 */
778
+	protected function _update_payment_method()
779
+	{
780
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
781
+			//ok let's find which gateway form to use based on the form input
782
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
783
+			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
784
+			$correct_pmt_form_to_use = null;
785
+			$payment_method = null;
786
+			foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
787
+				//get the form and simplify it, like what we do when we display it
788
+				$pmt_form = $this->_generate_payment_method_settings_form($payment_method);
789
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
790
+					$correct_pmt_form_to_use = $pmt_form;
791
+					break;
792
+				}
793
+			}
794
+			//if we couldn't find the correct payment method type...
795
+			if (! $correct_pmt_form_to_use) {
796
+				EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support",
797
+					'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
798
+				$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
799
+			}
800
+			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
801
+			if ($correct_pmt_form_to_use->is_valid()) {
802
+				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
803
+				if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
804
+					throw new EE_Error(
805
+						sprintf(
806
+							__('The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
807
+								'event_espresso'),
808
+							'payment_method_settings'
809
+						)
810
+					);
811
+				}
812
+				$payment_settings_subform->save();
813
+				/** @var $pm EE_Payment_Method */
814
+				$this->_redirect_after_action(true, 'Payment Method', 'updated',
815
+					array('action' => 'default', 'payment_method' => $payment_method->slug()));
816
+			} else {
817
+				EE_Error::add_error(
818
+					sprintf(
819
+						__('Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
820
+							'event_espresso'),
821
+						$payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
822
+							: __('"(unknown)"', 'event_espresso')
823
+					),
824
+					__FILE__,
825
+					__FUNCTION__,
826
+					__LINE__
827
+				);
828
+			}
829
+		}
830
+		return;
831
+	}
832
+
833
+
834
+
835
+	protected function _payment_settings()
836
+	{
837
+		$this->_template_args['values'] = $this->_yes_no_values;
838
+		$this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options)
839
+			? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : false;
840
+		$this->_set_add_edit_form_tags('update_payment_settings');
841
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
842
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH
843
+																					 . 'payment_settings.template.php',
844
+			$this->_template_args, true);
845
+		$this->display_admin_page_with_sidebar();
846
+	}
847
+
848
+
849
+
850
+	/**
851
+	 *        _update_payment_settings
852
+	 *
853
+	 * @access protected
854
+	 * @return array
855
+	 */
856
+	protected function _update_payment_settings()
857
+	{
858
+		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options'])
859
+			? $this->_req_data['show_pending_payment_options'] : false;
860
+		EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG',
861
+			EE_Registry::instance()->CFG);
862 862
 //		 $superform = new EE_Form_Section_Proper(
863 863
 //		 	array(
864 864
 //		 		'subsections' => array(
@@ -876,179 +876,179 @@  discard block
 block discarded – undo
876 876
 //		 	);
877 877
 //		 	$this->_redirect_after_action( 0, 'settings', 'updated', array( 'action' => 'payment_settings' ) );
878 878
 //		 }
879
-        $what = __('Payment Settings', 'event_espresso');
880
-        $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__,
881
-            __LINE__);
882
-        $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'),
883
-            array('action' => 'payment_settings'));
884
-    }
879
+		$what = __('Payment Settings', 'event_espresso');
880
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__,
881
+			__LINE__);
882
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'),
883
+			array('action' => 'payment_settings'));
884
+	}
885 885
 
886 886
 
887 887
 
888
-    protected function _payment_log_overview_list_table()
889
-    {
888
+	protected function _payment_log_overview_list_table()
889
+	{
890 890
 //		$this->_search_btn_label = __('Payment Log', 'event_espresso');
891
-        $this->display_admin_list_table_page_with_sidebar();
892
-    }
893
-
894
-
895
-
896
-    protected function _set_list_table_views_payment_log()
897
-    {
898
-        $this->_views = array(
899
-            'all' => array(
900
-                'slug'  => 'all',
901
-                'label' => __('View All Logs', 'event_espresso'),
902
-                'count' => 0,
903
-            ),
904
-        );
905
-    }
906
-
907
-
908
-
909
-    /**
910
-     * @param int  $per_page
911
-     * @param int  $current_page
912
-     * @param bool $count
913
-     * @return array
914
-     */
915
-    public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
916
-    {
917
-        EE_Registry::instance()->load_model('Change_Log');
918
-        //we may need to do multiple queries (joining differently), so we actually wan tan array of query params
919
-        $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
920
-        //check if they've selected a specific payment method
921
-        if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
922
-            $query_params[0]['OR*pm_or_pay_pm'] = array(
923
-                'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
924
-                'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
925
-            );
926
-        }
927
-        //take into account search
928
-        if (isset($this->_req_data['s']) && $this->_req_data['s']) {
929
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
930
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
931
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
932
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
933
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
934
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
935
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
936
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
937
-            $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
938
-            $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
939
-            $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
940
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
941
-        }
942
-        if (isset($this->_req_data['payment-filter-start-date'])
943
-            && isset($this->_req_data['payment-filter-end-date'])
944
-        ) {
945
-            //add date
946
-            $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
947
-            $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
948
-            //make sure our timestamps start and end right at the boundaries for each day
949
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
950
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
951
-            //convert to timestamps
952
-            $start_date = strtotime($start_date);
953
-            $end_date = strtotime($end_date);
954
-            //makes sure start date is the lowest value and vice versa
955
-            $start_date = min($start_date, $end_date);
956
-            $end_date = max($start_date, $end_date);
957
-            //convert for query
958
-            $start_date = EEM_Change_Log::instance()
959
-                                        ->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date),
960
-                                            'Y-m-d H:i:s');
961
-            $end_date = EEM_Change_Log::instance()
962
-                                      ->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date),
963
-                                          'Y-m-d H:i:s');
964
-            $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
965
-        }
966
-        if ($count) {
967
-            return EEM_Change_Log::instance()->count($query_params);
968
-        }
969
-        if (isset($this->_req_data['order'])) {
970
-            $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
971
-                : 'DESC';
972
-            $query_params['order_by'] = array('LOG_time' => $sort);
973
-        } else {
974
-            $query_params['order_by'] = array('LOG_time' => 'DESC');
975
-        }
976
-        $offset = ($current_page - 1) * $per_page;
977
-        if (! isset($this->_req_data['download_results'])) {
978
-            $query_params['limit'] = array($offset, $per_page);
979
-        }
980
-        //now they've requested to instead just download the file instead of viewing it.
981
-        if (isset($this->_req_data['download_results'])) {
982
-            $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
983
-            header('Content-Disposition: attachment');
984
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
985
-            echo "<h1>Payment Logs for " . site_url() . "</h1>";
986
-            echo "<h3>Query:</h3>";
987
-            var_dump($query_params);
988
-            echo "<h3>Results:</h3>";
989
-            var_dump($wpdb_results);
990
-            die;
991
-        }
992
-        $results = EEM_Change_Log::instance()->get_all($query_params);
993
-        return $results;
994
-    }
995
-
996
-
997
-
998
-    /**
999
-     * Used by usort to RE-sort log query results, because we lose the ordering
1000
-     * because we're possibly combining the results from two queries
1001
-     *
1002
-     * @param EE_Change_Log $logA
1003
-     * @param EE_Change_Log $logB
1004
-     * @return int
1005
-     */
1006
-    protected function _sort_logs_again($logA, $logB)
1007
-    {
1008
-        $timeA = $logA->get_raw('LOG_time');
1009
-        $timeB = $logB->get_raw('LOG_time');
1010
-        if ($timeA == $timeB) {
1011
-            return 0;
1012
-        }
1013
-        $comparison = $timeA < $timeB ? -1 : 1;
1014
-        if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1015
-            return $comparison * -1;
1016
-        } else {
1017
-            return $comparison;
1018
-        }
1019
-    }
1020
-
1021
-
1022
-
1023
-    protected function _payment_log_details()
1024
-    {
1025
-        EE_Registry::instance()->load_model('Change_Log');
1026
-        /** @var $payment_log EE_Change_Log */
1027
-        $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1028
-        $payment_method = null;
1029
-        $transaction = null;
1030
-        if ($payment_log instanceof EE_Change_Log) {
1031
-            if ($payment_log->object() instanceof EE_Payment) {
1032
-                $payment_method = $payment_log->object()->payment_method();
1033
-                $transaction = $payment_log->object()->transaction();
1034
-            } elseif ($payment_log->object() instanceof EE_Payment_Method) {
1035
-                $payment_method = $payment_log->object();
1036
-            } elseif( $payment_log->object() instanceof EE_Transaction) {
1037
-                $transaction = $payment_log->object();
1038
-                $payment_method = $transaction->payment_method();
1039
-            }
1040
-        }
1041
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1042
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1043
-            array(
1044
-                'payment_log'    => $payment_log,
1045
-                'payment_method' => $payment_method,
1046
-                'transaction'    => $transaction,
1047
-            ),
1048
-            true
1049
-        );
1050
-        $this->display_admin_page_with_sidebar();
1051
-    }
891
+		$this->display_admin_list_table_page_with_sidebar();
892
+	}
893
+
894
+
895
+
896
+	protected function _set_list_table_views_payment_log()
897
+	{
898
+		$this->_views = array(
899
+			'all' => array(
900
+				'slug'  => 'all',
901
+				'label' => __('View All Logs', 'event_espresso'),
902
+				'count' => 0,
903
+			),
904
+		);
905
+	}
906
+
907
+
908
+
909
+	/**
910
+	 * @param int  $per_page
911
+	 * @param int  $current_page
912
+	 * @param bool $count
913
+	 * @return array
914
+	 */
915
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
916
+	{
917
+		EE_Registry::instance()->load_model('Change_Log');
918
+		//we may need to do multiple queries (joining differently), so we actually wan tan array of query params
919
+		$query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
920
+		//check if they've selected a specific payment method
921
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
922
+			$query_params[0]['OR*pm_or_pay_pm'] = array(
923
+				'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
924
+				'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
925
+			);
926
+		}
927
+		//take into account search
928
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
929
+			$similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
930
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
931
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
932
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
933
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
934
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
935
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
936
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
937
+			$query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
938
+			$query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
939
+			$query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
940
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
941
+		}
942
+		if (isset($this->_req_data['payment-filter-start-date'])
943
+			&& isset($this->_req_data['payment-filter-end-date'])
944
+		) {
945
+			//add date
946
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
947
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
948
+			//make sure our timestamps start and end right at the boundaries for each day
949
+			$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
950
+			$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
951
+			//convert to timestamps
952
+			$start_date = strtotime($start_date);
953
+			$end_date = strtotime($end_date);
954
+			//makes sure start date is the lowest value and vice versa
955
+			$start_date = min($start_date, $end_date);
956
+			$end_date = max($start_date, $end_date);
957
+			//convert for query
958
+			$start_date = EEM_Change_Log::instance()
959
+										->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date),
960
+											'Y-m-d H:i:s');
961
+			$end_date = EEM_Change_Log::instance()
962
+									  ->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date),
963
+										  'Y-m-d H:i:s');
964
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
965
+		}
966
+		if ($count) {
967
+			return EEM_Change_Log::instance()->count($query_params);
968
+		}
969
+		if (isset($this->_req_data['order'])) {
970
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
971
+				: 'DESC';
972
+			$query_params['order_by'] = array('LOG_time' => $sort);
973
+		} else {
974
+			$query_params['order_by'] = array('LOG_time' => 'DESC');
975
+		}
976
+		$offset = ($current_page - 1) * $per_page;
977
+		if (! isset($this->_req_data['download_results'])) {
978
+			$query_params['limit'] = array($offset, $per_page);
979
+		}
980
+		//now they've requested to instead just download the file instead of viewing it.
981
+		if (isset($this->_req_data['download_results'])) {
982
+			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
983
+			header('Content-Disposition: attachment');
984
+			header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
985
+			echo "<h1>Payment Logs for " . site_url() . "</h1>";
986
+			echo "<h3>Query:</h3>";
987
+			var_dump($query_params);
988
+			echo "<h3>Results:</h3>";
989
+			var_dump($wpdb_results);
990
+			die;
991
+		}
992
+		$results = EEM_Change_Log::instance()->get_all($query_params);
993
+		return $results;
994
+	}
995
+
996
+
997
+
998
+	/**
999
+	 * Used by usort to RE-sort log query results, because we lose the ordering
1000
+	 * because we're possibly combining the results from two queries
1001
+	 *
1002
+	 * @param EE_Change_Log $logA
1003
+	 * @param EE_Change_Log $logB
1004
+	 * @return int
1005
+	 */
1006
+	protected function _sort_logs_again($logA, $logB)
1007
+	{
1008
+		$timeA = $logA->get_raw('LOG_time');
1009
+		$timeB = $logB->get_raw('LOG_time');
1010
+		if ($timeA == $timeB) {
1011
+			return 0;
1012
+		}
1013
+		$comparison = $timeA < $timeB ? -1 : 1;
1014
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1015
+			return $comparison * -1;
1016
+		} else {
1017
+			return $comparison;
1018
+		}
1019
+	}
1020
+
1021
+
1022
+
1023
+	protected function _payment_log_details()
1024
+	{
1025
+		EE_Registry::instance()->load_model('Change_Log');
1026
+		/** @var $payment_log EE_Change_Log */
1027
+		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1028
+		$payment_method = null;
1029
+		$transaction = null;
1030
+		if ($payment_log instanceof EE_Change_Log) {
1031
+			if ($payment_log->object() instanceof EE_Payment) {
1032
+				$payment_method = $payment_log->object()->payment_method();
1033
+				$transaction = $payment_log->object()->transaction();
1034
+			} elseif ($payment_log->object() instanceof EE_Payment_Method) {
1035
+				$payment_method = $payment_log->object();
1036
+			} elseif( $payment_log->object() instanceof EE_Transaction) {
1037
+				$transaction = $payment_log->object();
1038
+				$payment_method = $transaction->payment_method();
1039
+			}
1040
+		}
1041
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1042
+			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1043
+			array(
1044
+				'payment_log'    => $payment_log,
1045
+				'payment_method' => $payment_method,
1046
+				'transaction'    => $transaction,
1047
+			),
1048
+			true
1049
+		);
1050
+		$this->display_admin_page_with_sidebar();
1051
+	}
1052 1052
 
1053 1053
 
1054 1054
 } //end Payments_Admin_Page class
Please login to merge, or discard this patch.