Completed
Branch fix-caching-loader-test (55a737)
by
unknown
23:20 queued 15:31
created
admin_pages/payments/Payments_Admin_Page.core.php 2 patches
Indentation   +1207 added lines, -1207 removed lines patch added patch discarded remove patch
@@ -16,1211 +16,1211 @@
 block discarded – undo
16 16
  */
17 17
 class Payments_Admin_Page extends EE_Admin_Page
18 18
 {
19
-    /**
20
-     * Variables used for when we're re-sorting the logs results,
21
-     * in case we needed to do two queries, and we need to resort
22
-     *
23
-     * @var string
24
-     */
25
-    private $_sort_logs_again_direction;
26
-
27
-
28
-    /**
29
-     * @Constructor
30
-     * @access public
31
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
-     * @throws EE_Error
33
-     * @throws InvalidArgumentException
34
-     * @throws InvalidDataTypeException
35
-     * @throws InvalidInterfaceException
36
-     * @throws ReflectionException
37
-     */
38
-    public function __construct($routing = true)
39
-    {
40
-        parent::__construct($routing);
41
-    }
42
-
43
-
44
-    protected function _init_page_props()
45
-    {
46
-        $this->page_slug = EE_PAYMENTS_PG_SLUG;
47
-        $this->page_label = esc_html__('Payment Methods', 'event_espresso');
48
-        $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
-        $this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
-    }
51
-
52
-
53
-    protected function _ajax_hooks()
54
-    {
55
-        // todo: all hooks for ajax goes here.
56
-    }
57
-
58
-
59
-    protected function _define_page_props()
60
-    {
61
-        $this->_admin_page_title = $this->page_label;
62
-        $this->_labels = array(
63
-            'publishbox' => esc_html__('Update Settings', 'event_espresso'),
64
-        );
65
-    }
66
-
67
-
68
-    protected function _set_page_routes()
69
-    {
70
-        /**
71
-         * note that with payment method capabilities, although we've implemented
72
-         * capability mapping which will be used for accessing payment methods owned by
73
-         * other users.  This is not fully implemented yet in the payment method ui.
74
-         * Currently, only the "plural" caps are in active use.
75
-         * When cap mapping is implemented, some routes will need to use the singular form of
76
-         * capability method and also include the $id of the payment method for the route.
77
-         **/
78
-        $this->_page_routes = array(
79
-            'default'                   => array(
80
-                'func'       => '_payment_methods_list',
81
-                'capability' => 'ee_edit_payment_methods',
82
-            ),
83
-            'payment_settings'          => array(
84
-                'func'       => '_payment_settings',
85
-                'capability' => 'ee_manage_gateways',
86
-            ),
87
-            'activate_payment_method'   => array(
88
-                'func'       => '_activate_payment_method',
89
-                'noheader'   => true,
90
-                'capability' => 'ee_edit_payment_methods',
91
-            ),
92
-            'deactivate_payment_method' => array(
93
-                'func'       => '_deactivate_payment_method',
94
-                'noheader'   => true,
95
-                'capability' => 'ee_delete_payment_methods',
96
-            ),
97
-            'update_payment_method'     => array(
98
-                'func'               => '_update_payment_method',
99
-                'noheader'           => true,
100
-                'headers_sent_route' => 'default',
101
-                'capability'         => 'ee_edit_payment_methods',
102
-            ),
103
-            'update_payment_settings'   => array(
104
-                'func'       => '_update_payment_settings',
105
-                'noheader'   => true,
106
-                'capability' => 'ee_manage_gateways',
107
-            ),
108
-            'payment_log'               => array(
109
-                'func'       => '_payment_log_overview_list_table',
110
-                'capability' => 'ee_read_payment_methods',
111
-            ),
112
-            'payment_log_details'       => array(
113
-                'func'       => '_payment_log_details',
114
-                'capability' => 'ee_read_payment_methods',
115
-            ),
116
-        );
117
-    }
118
-
119
-
120
-    /**
121
-     * @throws EE_Error
122
-     * @throws ReflectionException
123
-     */
124
-    protected function _set_page_config()
125
-    {
126
-        $payment_method_list_config = array(
127
-            'nav'           => array(
128
-                'label' => esc_html__('Payment Methods', 'event_espresso'),
129
-                'icon' => 'dashicons-bank',
130
-                'order' => 10,
131
-            ),
132
-            'metaboxes'     => $this->_default_espresso_metaboxes,
133
-            'help_tabs'     => array_merge(
134
-                array(
135
-                    'payment_methods_overview_help_tab' => array(
136
-                        'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
137
-                        'filename' => 'payment_methods_overview',
138
-                    ),
139
-                ),
140
-                $this->_add_payment_method_help_tabs()
141
-            ),
142
-            'require_nonce' => false,
143
-        );
144
-        $this->_page_config = array(
145
-            'default'          => $payment_method_list_config,
146
-            'payment_settings' => array(
147
-                'nav'           => array(
148
-                    'label' => esc_html__('Settings', 'event_espresso'),
149
-                    'icon' => 'dashicons-admin-generic',
150
-                    'order' => 20,
151
-                ),
152
-                'help_tabs'     => array(
153
-                    'payment_methods_settings_help_tab' => array(
154
-                        'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
155
-                        'filename' => 'payment_methods_settings',
156
-                    ),
157
-                ),
158
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
159
-                'require_nonce' => false,
160
-            ),
161
-            'payment_log'      => array(
162
-                'nav'           => array(
163
-                    'label' => esc_html__("Logs", 'event_espresso'),
164
-                    'icon' => 'dashicons-text-page',
165
-                    'order' => 30,
166
-                ),
167
-                'list_table'    => 'Payment_Log_Admin_List_Table',
168
-                'metaboxes'     => $this->_default_espresso_metaboxes,
169
-                'require_nonce' => false,
170
-            ),
171
-        );
172
-    }
173
-
174
-
175
-    /**
176
-     * @return array
177
-     * @throws DomainException
178
-     * @throws EE_Error
179
-     * @throws InvalidArgumentException
180
-     * @throws InvalidDataTypeException
181
-     * @throws InvalidInterfaceException
182
-     * @throws ReflectionException
183
-     */
184
-    protected function _add_payment_method_help_tabs()
185
-    {
186
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
187
-        $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
188
-        $all_pmt_help_tabs_config = array();
189
-        foreach ($payment_method_types as $payment_method_type) {
190
-            if (
191
-                ! EE_Registry::instance()->CAP->current_user_can(
192
-                    $payment_method_type->cap_name(),
193
-                    'specific_payment_method_type_access'
194
-                )
195
-            ) {
196
-                continue;
197
-            }
198
-            foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199
-                $template_args = isset($config['template_args']) ? $config['template_args'] : array();
200
-                $template_args['admin_page_obj'] = $this;
201
-                $all_pmt_help_tabs_config[ $help_tab_name ] = array(
202
-                    'title'   => $config['title'],
203
-                    'content' => EEH_Template::display_template(
204
-                        $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
205
-                        $template_args,
206
-                        true
207
-                    ),
208
-                );
209
-            }
210
-        }
211
-        return $all_pmt_help_tabs_config;
212
-    }
213
-
214
-
215
-    // none of the below group are currently used for Gateway Settings
216
-    protected function _add_screen_options()
217
-    {
218
-    }
219
-
220
-
221
-    protected function _add_feature_pointers()
222
-    {
223
-    }
224
-
225
-
226
-    public function admin_init()
227
-    {
228
-    }
229
-
230
-
231
-    public function admin_notices()
232
-    {
233
-    }
234
-
235
-
236
-    public function admin_footer_scripts()
237
-    {
238
-    }
239
-
240
-
241
-    public function load_scripts_styles()
242
-    {
243
-        // styles
244
-        wp_enqueue_style('espresso-ui-theme');
245
-        wp_enqueue_style('ee-text-links-css');
246
-        wp_register_style(
247
-            'espresso_payments',
248
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
249
-            [],
250
-            EVENT_ESPRESSO_VERSION
251
-        );
252
-        // scripts
253
-        wp_enqueue_script('ee_admin_js');
254
-        wp_enqueue_script('ee-text-links-js');
255
-        wp_enqueue_script(
256
-            'espresso_payments',
257
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
258
-            ['ee-datepicker'],
259
-            EVENT_ESPRESSO_VERSION,
260
-            true
261
-        );
262
-    }
263
-
264
-
265
-    public function load_scripts_styles_default()
266
-    {
267
-        wp_enqueue_style('espresso_payments');
268
-        wp_enqueue_style('ee-text-links-css');
269
-    }
270
-
271
-
272
-    public function load_scripts_styles_payment_log_details()
273
-    {
274
-        wp_enqueue_style('espresso_payments');
275
-    }
276
-
277
-
278
-    /**
279
-     * @throws EE_Error
280
-     * @throws ReflectionException
281
-     */
282
-    protected function _payment_methods_list()
283
-    {
284
-        /**
285
-         * first let's ensure payment methods have been set up.
286
-         * We do this here because when people activate a payment method for the first time (as an addon),
287
-         * it may not set up its capabilities or get registered correctly due to the loading process.
288
-         * However, people MUST set up the details for the payment method,
289
-         * so it's safe to do a recheck here.
290
-         */
291
-        EE_Registry::instance()->load_lib('Payment_Method_Manager');
292
-        EEM_Payment_Method::instance()->verify_button_urls();
293
-        // set up tabs, one for each payment method type
294
-        $tabs = array();
295
-        $payment_methods = array();
296
-        foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
297
-            // we don't want to show admin-only PMTs for now
298
-            if ($pmt_obj instanceof EE_PMT_Admin_Only) {
299
-                continue;
300
-            }
301
-            // check access
302
-            if (
303
-                ! EE_Registry::instance()->CAP->current_user_can(
304
-                    $pmt_obj->cap_name(),
305
-                    'specific_payment_method_type_access'
306
-                )
307
-            ) {
308
-                continue;
309
-            }
310
-            // check for any active pms of that type
311
-            $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
312
-            if (! $payment_method instanceof EE_Payment_Method) {
313
-                $payment_method = EE_Payment_Method::new_instance(
314
-                    array(
315
-                        'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
316
-                        'PMD_type'       => $pmt_obj->system_name(),
317
-                        'PMD_name'       => $pmt_obj->pretty_name(),
318
-                        'PMD_admin_name' => $pmt_obj->pretty_name(),
319
-                    )
320
-                );
321
-            }
322
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
323
-        }
324
-        $payment_methods = apply_filters(
325
-            'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
326
-            $payment_methods
327
-        );
328
-        foreach ($payment_methods as $payment_method) {
329
-            if ($payment_method instanceof EE_Payment_Method) {
330
-                $this->addMetaBox(
331
-                    // html id
332
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
333
-                    // title
334
-                    sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
335
-                    // callback
336
-                    array($this, 'payment_method_settings_meta_box'),
337
-                    // post type
338
-                    null,
339
-                    // context
340
-                    'normal',
341
-                    // priority
342
-                    'default',
343
-                    // callback args
344
-                    array('payment_method' => $payment_method)
345
-                );
346
-                // setup for tabbed content
347
-                $tabs[ $payment_method->slug() ] = array(
348
-                    'label' => $payment_method->admin_name(),
349
-                    'class' => $payment_method->active() ? 'gateway-active' : '',
350
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
351
-                    'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
352
-                    'slug'  => $payment_method->slug(),
353
-                    'icon'  => $payment_method->active()
354
-                        ? '<span class="dashicons dashicons-yes-alt"></span>'
355
-                        : '<span class="dashicons dashicons-remove"></span>',
356
-                );
357
-            }
358
-        }
359
-        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
360
-            $tabs,
361
-            'payment_method_links',
362
-            '',
363
-            $this->_get_active_payment_method_slug()
364
-        );
365
-        $this->display_admin_page_with_sidebar();
366
-    }
367
-
368
-
369
-    /**
370
-     *   _get_active_payment_method_slug
371
-     *
372
-     * @return string
373
-     * @throws EE_Error
374
-     */
375
-    protected function _get_active_payment_method_slug()
376
-    {
377
-        $payment_method_slug = false;
378
-        // decide which payment method tab to open first, as dictated by the request's 'payment_method'
379
-        if (isset($this->_req_data['payment_method'])) {
380
-            // if they provided the current payment method, use it
381
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
382
-        }
383
-        /** @var EE_Payment_Method $payment_method */
384
-        $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
385
-        // if that didn't work or wasn't provided, find another way to select the current pm
386
-        if (! $this->_verify_payment_method($payment_method)) {
387
-            // like, looking for an active one
388
-            $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
389
-            // test that one as well
390
-            if ($this->_verify_payment_method($payment_method)) {
391
-                $payment_method_slug = $payment_method->slug();
392
-            } else {
393
-                $payment_method_slug = 'paypal_standard';
394
-            }
395
-        }
396
-        return $payment_method_slug;
397
-    }
398
-
399
-
400
-    /**
401
-     *    payment_method_settings_meta_box
402
-     *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
403
-     *    capabilities to access it
404
-     *
405
-     * @param EE_Payment_Method $payment_method
406
-     * @return boolean
407
-     * @throws EE_Error
408
-     */
409
-    protected function _verify_payment_method($payment_method)
410
-    {
411
-        if (
412
-            $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
413
-            && EE_Registry::instance()->CAP->current_user_can(
414
-                $payment_method->type_obj()->cap_name(),
415
-                'specific_payment_method_type_access'
416
-            )
417
-        ) {
418
-            return true;
419
-        }
420
-        return false;
421
-    }
422
-
423
-
424
-    /**
425
-     *    payment_method_settings_meta_box
426
-     *
427
-     * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
428
-     * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
429
-     *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
430
-     * @return void
431
-     * @throws EE_Error
432
-     * @throws ReflectionException
433
-     */
434
-    public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
435
-    {
436
-        $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
437
-            ? $metabox['args']['payment_method'] : null;
438
-        if (! $payment_method instanceof EE_Payment_Method) {
439
-            throw new EE_Error(
440
-                esc_html__(
441
-                    'Payment method metabox setup incorrectly. No Payment method object was supplied',
442
-                    'event_espresso'
443
-                )
444
-            );
445
-        }
446
-        $payment_method_scopes = $payment_method->active();
447
-        // if the payment method really exists show its form, otherwise the activation template
448
-        if ($payment_method->ID() && ! empty($payment_method_scopes)) {
449
-            $form = $this->_generate_payment_method_settings_form($payment_method);
450
-            if ($form->form_data_present_in($this->_req_data)) {
451
-                $form->receive_form_submission($this->_req_data);
452
-            }
453
-            echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
454
-        } else {
455
-            echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
456
-        }
457
-    }
458
-
459
-
460
-    /**
461
-     * Gets the form for all the settings related to this payment method type
462
-     *
463
-     * @access protected
464
-     * @param EE_Payment_Method $payment_method
465
-     * @return EE_Form_Section_Proper
466
-     * @throws EE_Error
467
-     */
468
-    protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
469
-    {
470
-        if (! $payment_method instanceof EE_Payment_Method) {
471
-            return new EE_Form_Section_Proper();
472
-        }
473
-        $subsections = apply_filters(
474
-            'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
475
-            [
476
-                'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
477
-                'currency_support'        => $this->_currency_support($payment_method),
478
-                'payment_method_settings' => $this->_payment_method_settings($payment_method),
479
-                'update'                  => $this->_update_payment_method_button($payment_method),
480
-                'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
481
-                'fine_print'              => $this->_fine_print(),
482
-            ],
483
-            $payment_method
484
-        );
485
-        return new EE_Form_Section_Proper(
486
-            array(
487
-                'name'            => $payment_method->slug() . '_settings_form',
488
-                'html_id'         => $payment_method->slug() . '_settings_form',
489
-                'action'          => EE_Admin_Page::add_query_args_and_nonce(
490
-                    array(
491
-                        'action'         => 'update_payment_method',
492
-                        'payment_method' => $payment_method->slug(),
493
-                    ),
494
-                    EE_PAYMENTS_ADMIN_URL
495
-                ),
496
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
497
-                'subsections'     => array_filter($subsections),
498
-            )
499
-        );
500
-    }
501
-
502
-
503
-    /**
504
-     * _pci_dss_compliance
505
-     *
506
-     * @access protected
507
-     * @param EE_Payment_Method $payment_method
508
-     * @return EE_Form_Section_HTML|null
509
-     * @throws EE_Error
510
-     */
511
-    protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
512
-    {
513
-        if (!$payment_method->type_obj()->requires_https()) {
514
-            return null;
515
-        }
516
-        return new EE_Form_Section_HTML(
517
-            EEH_HTML::table(
518
-                EEH_HTML::tr(
519
-                    EEH_HTML::th(
520
-                        EEH_HTML::label(
521
-                            EEH_HTML::strong(
522
-                                esc_html__('IMPORTANT', 'event_espresso'),
523
-                                '',
524
-                                'important-notice'
525
-                            )
526
-                        )
527
-                    ) .
528
-                    EEH_HTML::td(
529
-                        EEH_HTML::strong(
530
-                            esc_html__(
531
-                                'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
532
-                                'event_espresso'
533
-                            )
534
-                        )
535
-                        .
536
-                        EEH_HTML::br()
537
-                        .
538
-                        esc_html__('Learn more about ', 'event_espresso')
539
-                        . EEH_HTML::link(
540
-                            'https://www.pcisecuritystandards.org/merchants/index.php',
541
-                            esc_html__('PCI DSS compliance', 'event_espresso')
542
-                        )
543
-                    )
544
-                )
545
-            )
546
-        );
547
-    }
548
-
549
-
550
-    /**
551
-     * _currency_support
552
-     *
553
-     * @access protected
554
-     * @param EE_Payment_Method $payment_method
555
-     * @return EE_Form_Section_HTML|null
556
-     * @throws EE_Error
557
-     */
558
-    protected function _currency_support(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
559
-    {
560
-        if ($payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
561
-            return null;
562
-        }
563
-        return new EE_Form_Section_HTML(
564
-            EEH_HTML::table(
565
-                EEH_HTML::tr(
566
-                    EEH_HTML::th(
567
-                        EEH_HTML::label(
568
-                            EEH_HTML::strong(
569
-                                esc_html__('IMPORTANT', 'event_espresso'),
570
-                                '',
571
-                                'important-notice'
572
-                            )
573
-                        )
574
-                    ) .
575
-                    EEH_HTML::td(
576
-                        EEH_HTML::strong(
577
-                            sprintf(
578
-                                esc_html__(
579
-                                    '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.',
580
-                                    'event_espresso'
581
-                                ),
582
-                                EE_Config::instance()->currency->code
583
-                            )
584
-                        )
585
-                    )
586
-                )
587
-            )
588
-        );
589
-    }
590
-
591
-
592
-    /**
593
-     * _update_payment_method_button
594
-     *
595
-     * @access protected
596
-     * @param EE_Payment_Method $payment_method
597
-     * @return EE_Payment_Method_Form
598
-     * @throws EE_Error
599
-     */
600
-    protected function _payment_method_settings(EE_Payment_Method $payment_method)
601
-    {
602
-        // modify the form, so we only have/show fields that will be implemented for this version
603
-        return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
604
-    }
605
-
606
-
607
-    /**
608
-     * Simplifies the form to merely reproduce 4.1's gateway settings functionality
609
-     *
610
-     * @param EE_Form_Section_Proper $form_section
611
-     * @param string                 $payment_method_name
612
-     * @return EE_Payment_Method_Form
613
-     * @throws EE_Error
614
-     */
615
-    protected function _simplify_form($form_section, $payment_method_name = '')
616
-    {
617
-        if ($form_section instanceof EE_Payment_Method_Form) {
618
-            $form_section->exclude(
619
-                array(
620
-                    'PMD_type', // don't want them changing the type
621
-                    'PMD_slug', // or the slug (probably never)
622
-                    'PMD_wp_user', // or the user's ID
623
-                    'Currency' // or the currency, until the rest of EE supports simultaneous currencies
624
-                )
625
-            );
626
-            return $form_section;
627
-        } else {
628
-            throw new EE_Error(
629
-                sprintf(
630
-                    esc_html__(
631
-                        'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
632
-                        'event_espresso'
633
-                    ),
634
-                    $payment_method_name
635
-                )
636
-            );
637
-        }
638
-    }
639
-
640
-
641
-    /**
642
-     * _update_payment_method_button
643
-     *
644
-     * @access protected
645
-     * @param EE_Payment_Method $payment_method
646
-     * @return EE_Form_Section_HTML
647
-     * @throws EE_Error
648
-     */
649
-    protected function _update_payment_method_button(EE_Payment_Method $payment_method)
650
-    {
651
-        $update_button = new EE_Submit_Input(
652
-            array(
653
-                'name'       => 'submit',
654
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
655
-                'default'    => sprintf(
656
-                    esc_html__('Update %s Payment Settings', 'event_espresso'),
657
-                    $payment_method->admin_name()
658
-                ),
659
-                'html_label' => EEH_HTML::nbsp(),
660
-            )
661
-        );
662
-        return new EE_Form_Section_HTML(
663
-            EEH_HTML::table(
664
-                EEH_HTML::no_row(EEH_HTML::br(2)) .
665
-                EEH_HTML::tr(
666
-                    EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
667
-                    EEH_HTML::td(
668
-                        $update_button->get_html_for_input()
669
-                    )
670
-                )
671
-            )
672
-        );
673
-    }
674
-
675
-
676
-    /**
677
-     * _deactivate_payment_method_button
678
-     *
679
-     * @access protected
680
-     * @param EE_Payment_Method $payment_method
681
-     * @return EE_Form_Section_HTML
682
-     */
683
-    protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
684
-    {
685
-        $link_text_and_title = sprintf(
686
-            esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
687
-            $payment_method->admin_name()
688
-        );
689
-        return new EE_Form_Section_HTML(
690
-            EEH_HTML::table(
691
-                EEH_HTML::tr(
692
-                    EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
693
-                    EEH_HTML::td(
694
-                        EEH_HTML::link(
695
-                            EE_Admin_Page::add_query_args_and_nonce(
696
-                                array(
697
-                                    'action'         => 'deactivate_payment_method',
698
-                                    'payment_method' => $payment_method->slug(),
699
-                                ),
700
-                                EE_PAYMENTS_ADMIN_URL
701
-                            ),
702
-                            $link_text_and_title,
703
-                            $link_text_and_title,
704
-                            'deactivate_' . $payment_method->slug(),
705
-                            'button button--secondary'
706
-                        )
707
-                    )
708
-                )
709
-            )
710
-        );
711
-    }
712
-
713
-
714
-    /**
715
-     * _activate_payment_method_button
716
-     *
717
-     * @access protected
718
-     * @param EE_Payment_Method $payment_method
719
-     * @return EE_Form_Section_Proper
720
-     * @throws EE_Error
721
-     */
722
-    protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
723
-    {
724
-        $link_text_and_title = sprintf(
725
-            esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
726
-            $payment_method->admin_name()
727
-        );
728
-        return new EE_Form_Section_Proper(
729
-            array(
730
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
731
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
732
-                'action'          => '#',
733
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
734
-                'subsections'     => apply_filters(
735
-                    'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
736
-                    array(
737
-                        new EE_Form_Section_HTML(
738
-                            EEH_HTML::table(
739
-                                EEH_HTML::tr(
740
-                                    EEH_HTML::td(
741
-                                        $payment_method->type_obj()->introductory_html(),
742
-                                        '',
743
-                                        '',
744
-                                        '',
745
-                                        'colspan="2"'
746
-                                    )
747
-                                ) .
748
-                                EEH_HTML::tr(
749
-                                    EEH_HTML::th(
750
-                                        EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
751
-                                    ) .
752
-                                    EEH_HTML::td(
753
-                                        EEH_HTML::link(
754
-                                            EE_Admin_Page::add_query_args_and_nonce(
755
-                                                array(
756
-                                                    'action'              => 'activate_payment_method',
757
-                                                    'payment_method_type' => $payment_method->type(),
758
-                                                ),
759
-                                                EE_PAYMENTS_ADMIN_URL
760
-                                            ),
761
-                                            $link_text_and_title,
762
-                                            $link_text_and_title,
763
-                                            'activate_' . $payment_method->slug(),
764
-                                            'button button--primary-alt'
765
-                                        )
766
-                                    )
767
-                                )
768
-                            )
769
-                        ),
770
-                    ),
771
-                    $payment_method
772
-                ),
773
-            )
774
-        );
775
-    }
776
-
777
-
778
-    /**
779
-     * _fine_print
780
-     *
781
-     * @access protected
782
-     * @return EE_Form_Section_HTML
783
-     */
784
-    protected function _fine_print()
785
-    {
786
-        return new EE_Form_Section_HTML(
787
-            EEH_HTML::table(
788
-                EEH_HTML::tr(
789
-                    EEH_HTML::th() .
790
-                    EEH_HTML::td(
791
-                        EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
792
-                    )
793
-                )
794
-            )
795
-        );
796
-    }
797
-
798
-
799
-    /**
800
-     * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
801
-     *
802
-     * @throws EE_Error
803
-     * @throws ReflectionException
804
-     * @global WP_User $current_user
805
-     */
806
-    protected function _activate_payment_method()
807
-    {
808
-        if (isset($this->_req_data['payment_method_type'])) {
809
-            $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
810
-            // see if one exists
811
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
812
-            $payment_method = EE_Payment_Method_Manager::instance()
813
-                                                       ->activate_a_payment_method_of_type($payment_method_type);
814
-            $this->_redirect_after_action(
815
-                1,
816
-                'Payment Method',
817
-                'activated',
818
-                array('action' => 'default', 'payment_method' => $payment_method->slug())
819
-            );
820
-        } else {
821
-            $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
822
-        }
823
-    }
824
-
825
-
826
-    /**
827
-     * @throws EE_Error
828
-     * @throws ReflectionException
829
-     */
830
-    protected function _deactivate_payment_method()
831
-    {
832
-        if (isset($this->_req_data['payment_method'])) {
833
-            $payment_method_slug = sanitize_key($this->_req_data['payment_method']);
834
-            // deactivate it
835
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
836
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
837
-            $this->_redirect_after_action(
838
-                $count_updated,
839
-                'Payment Method',
840
-                'deactivated',
841
-                array('action' => 'default', 'payment_method' => $payment_method_slug)
842
-            );
843
-        } else {
844
-            $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
845
-        }
846
-    }
847
-
848
-
849
-    /**
850
-     * Processes the payment method form that was submitted. This is slightly trickier than usual form
851
-     * processing because we first need to identify WHICH form was processed and which payment method
852
-     * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
853
-     * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
854
-     * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
855
-     * subsequently called 'headers_sent_func' which is _payment_methods_list)
856
-     *
857
-     * @return void
858
-     * @throws EE_Error
859
-     * @throws ReflectionException
860
-     */
861
-    protected function _update_payment_method()
862
-    {
863
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
864
-            // ok let's find which gateway form to use based on the form input
865
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
866
-            /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
867
-            $correct_pmt_form_to_use = null;
868
-            $payment_method = null;
869
-            foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
870
-                if ($payment_method instanceof EE_Payment_Method) {
871
-                    // get the form and simplify it, like what we do when we display it
872
-                    $pmt_form = $this->_generate_payment_method_settings_form($payment_method);
873
-                    if ($pmt_form->form_data_present_in($this->_req_data)) {
874
-                        $correct_pmt_form_to_use = $pmt_form;
875
-                        break;
876
-                    }
877
-                }
878
-            }
879
-            // if we couldn't find the correct payment method type...
880
-            if (! $correct_pmt_form_to_use) {
881
-                EE_Error::add_error(
882
-                    esc_html__(
883
-                        "We could not find which payment method type your form submission related to. Please contact support",
884
-                        'event_espresso'
885
-                    ),
886
-                    __FILE__,
887
-                    __FUNCTION__,
888
-                    __LINE__
889
-                );
890
-                $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
891
-            }
892
-            $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
893
-            if ($correct_pmt_form_to_use->is_valid()) {
894
-                $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
895
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
896
-                    throw new EE_Error(
897
-                        sprintf(
898
-                            esc_html__(
899
-                                'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
900
-                                'event_espresso'
901
-                            ),
902
-                            'payment_method_settings'
903
-                        )
904
-                    );
905
-                }
906
-                $payment_settings_subform->save();
907
-                /** @var $pm EE_Payment_Method */
908
-                $this->_redirect_after_action(
909
-                    true,
910
-                    'Payment Method',
911
-                    'updated',
912
-                    array('action' => 'default', 'payment_method' => $payment_method->slug())
913
-                );
914
-            } else {
915
-                EE_Error::add_error(
916
-                    sprintf(
917
-                        esc_html__(
918
-                            'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
919
-                            'event_espresso'
920
-                        ),
921
-                        $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
922
-                            : esc_html__('"(unknown)"', 'event_espresso')
923
-                    ),
924
-                    __FILE__,
925
-                    __FUNCTION__,
926
-                    __LINE__
927
-                );
928
-            }
929
-        }
930
-    }
931
-
932
-
933
-    /**
934
-     * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
935
-     * @throws DomainException
936
-     * @throws EE_Error
937
-     * @throws InvalidArgumentException
938
-     * @throws InvalidDataTypeException
939
-     * @throws InvalidInterfaceException
940
-     */
941
-    protected function _payment_settings()
942
-    {
943
-        $form = $this->getPaymentSettingsForm();
944
-        $this->_set_add_edit_form_tags('update_payment_settings');
945
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
946
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
947
-            $form->get_html_and_js(),
948
-            '',
949
-            'padding'
950
-        );
951
-        $this->display_admin_page_with_sidebar();
952
-    }
953
-
954
-
955
-    /**
956
-     *        _update_payment_settings
957
-     *
958
-     * @access protected
959
-     * @return void
960
-     * @throws EE_Error
961
-     * @throws InvalidArgumentException
962
-     * @throws InvalidDataTypeException
963
-     * @throws InvalidInterfaceException
964
-     */
965
-    protected function _update_payment_settings()
966
-    {
967
-        $form = $this->getPaymentSettingsForm();
968
-        if ($form->was_submitted($this->_req_data)) {
969
-            $form->receive_form_submission($this->_req_data);
970
-            if ($form->is_valid()) {
971
-                /**
972
-                 * @var $reg_config EE_Registration_Config
973
-                 */
974
-                $loader = LoaderFactory::getLoader();
975
-                $reg_config = $loader->getShared('EE_Registration_Config');
976
-                $valid_data = $form->valid_data();
977
-                $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
978
-                $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
979
-            }
980
-        }
981
-        EE_Registry::instance()->CFG = apply_filters(
982
-            'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
983
-            EE_Registry::instance()->CFG
984
-        );
985
-
986
-        $what = esc_html__('Payment Settings', 'event_espresso');
987
-        $success = $this->_update_espresso_configuration(
988
-            $what,
989
-            EE_Registry::instance()->CFG,
990
-            __FILE__,
991
-            __FUNCTION__,
992
-            __LINE__
993
-        );
994
-        $this->_redirect_after_action(
995
-            $success,
996
-            $what,
997
-            esc_html__('updated', 'event_espresso'),
998
-            array('action' => 'payment_settings')
999
-        );
1000
-    }
1001
-
1002
-
1003
-    /**
1004
-     * Gets the form used for updating payment settings
1005
-     *
1006
-     * @return EE_Form_Section_Proper
1007
-     * @throws EE_Error
1008
-     * @throws InvalidArgumentException
1009
-     * @throws InvalidDataTypeException
1010
-     * @throws InvalidInterfaceException
1011
-     */
1012
-    protected function getPaymentSettingsForm()
1013
-    {
1014
-        /**
1015
-         * @var $reg_config EE_Registration_Config
1016
-         */
1017
-        $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1018
-        return new EE_Form_Section_Proper(
1019
-            array(
1020
-                'name' => 'payment-settings',
1021
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1022
-                'subsections' => array(
1023
-                    'show_pending_payment_options' => new EE_Yes_No_Input(
1024
-                        array(
1025
-                            'html_name' => 'show_pending_payment_options',
1026
-                            'default' => $reg_config->show_pending_payment_options,
1027
-                            'html_help_text' => esc_html__(
1028
-                                "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
1029
-                                'event_espresso'
1030
-                            )
1031
-                        )
1032
-                    ),
1033
-                    'gateway_log_lifespan' => new EE_Select_Input(
1034
-                        $reg_config->gatewayLogLifespanOptions(),
1035
-                        array(
1036
-                            'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1037
-                            'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'),
1038
-                            'default' => $reg_config->gateway_log_lifespan,
1039
-                        )
1040
-                    )
1041
-                )
1042
-            )
1043
-        );
1044
-    }
1045
-
1046
-
1047
-    /**
1048
-     * @throws EE_Error
1049
-     */
1050
-    protected function _payment_log_overview_list_table()
1051
-    {
1052
-        $this->display_admin_list_table_page_with_sidebar();
1053
-    }
1054
-
1055
-
1056
-    protected function _set_list_table_views_payment_log()
1057
-    {
1058
-        $this->_views = array(
1059
-            'all' => array(
1060
-                'slug'  => 'all',
1061
-                'label' => esc_html__('View All Logs', 'event_espresso'),
1062
-                'count' => 0,
1063
-            ),
1064
-        );
1065
-    }
1066
-
1067
-
1068
-    /**
1069
-     * @param int  $per_page
1070
-     * @param int  $current_page
1071
-     * @param bool $count
1072
-     * @return array|int
1073
-     * @throws EE_Error
1074
-     * @throws ReflectionException
1075
-     */
1076
-    public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1077
-    {
1078
-        EE_Registry::instance()->load_model('Change_Log');
1079
-        // we may need to do multiple queries (joining differently), so we actually want an array of query params
1080
-        $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1081
-        // check if they've selected a specific payment method
1082
-        if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1083
-            $query_params[0]['OR*pm_or_pay_pm'] = array(
1084
-                'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1085
-                'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1086
-            );
1087
-        }
1088
-        // take into account search
1089
-        if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1090
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1091
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1092
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1093
-            $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1094
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1095
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1096
-            $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1097
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1098
-            $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1099
-            $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1100
-            $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1101
-            $query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1102
-        }
1103
-        if (
1104
-            isset($this->_req_data['payment-filter-start-date'])
1105
-            && isset($this->_req_data['payment-filter-end-date'])
1106
-        ) {
1107
-            // add date
1108
-            $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1109
-            $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1110
-            // make sure our timestamps start and end right at the boundaries for each day
1111
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1112
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1113
-            // convert to timestamps
1114
-            $start_date = strtotime($start_date);
1115
-            $end_date = strtotime($end_date);
1116
-            // makes sure start date is the lowest value and vice versa
1117
-            $start_date = min($start_date, $end_date);
1118
-            $end_date = max($start_date, $end_date);
1119
-            // convert for query
1120
-            $start_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1121
-                'LOG_time',
1122
-                date('Y-m-d H:i:s', $start_date),
1123
-                'Y-m-d H:i:s'
1124
-            );
1125
-            $end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1126
-                'LOG_time',
1127
-                date('Y-m-d H:i:s', $end_date),
1128
-                'Y-m-d H:i:s'
1129
-            );
1130
-            $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1131
-        }
1132
-        if ($count) {
1133
-            return EEM_Change_Log::instance()->count($query_params);
1134
-        }
1135
-        if (isset($this->_req_data['order'])) {
1136
-            $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1137
-                ? $this->_req_data['order']
1138
-                : 'DESC';
1139
-            $query_params['order_by'] = array('LOG_time' => $sort);
1140
-        } else {
1141
-            $query_params['order_by'] = array('LOG_time' => 'DESC');
1142
-        }
1143
-        $offset = ($current_page - 1) * $per_page;
1144
-        if (! isset($this->_req_data['download_results'])) {
1145
-            $query_params['limit'] = array($offset, $per_page);
1146
-        }
1147
-        // now they've requested to instead just download the file instead of viewing it.
1148
-        if (isset($this->_req_data['download_results'])) {
1149
-            $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1150
-            header('Content-Disposition: attachment');
1151
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1152
-            echo '<h1> '
1153
-                . sprintf(
1154
-                    esc_html__('Payment Logs for %1$s', 'event_espresso'),
1155
-                    esc_url_raw(site_url())
1156
-                )
1157
-                . '</h1 >';
1158
-            echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1159
-            echo esc_html(var_export($query_params, true));
1160
-            echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1161
-            echo esc_html(var_export($wpdb_results, true));
1162
-            die;
1163
-        }
1164
-        return EEM_Change_Log::instance()->get_all($query_params);
1165
-    }
1166
-
1167
-
1168
-    /**
1169
-     * Used by usort to RE-sort log query results, because we lose the ordering
1170
-     * because we're possibly combining the results from two queries
1171
-     *
1172
-     * @param EE_Change_Log $logA
1173
-     * @param EE_Change_Log $logB
1174
-     * @return int
1175
-     * @throws EE_Error
1176
-     * @throws ReflectionException
1177
-     */
1178
-    protected function _sort_logs_again($logA, $logB)
1179
-    {
1180
-        $timeA = $logA->get_raw('LOG_time');
1181
-        $timeB = $logB->get_raw('LOG_time');
1182
-        if ($timeA == $timeB) {
1183
-            return 0;
1184
-        }
1185
-        $comparison = $timeA < $timeB ? -1 : 1;
1186
-        if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1187
-            return $comparison * -1;
1188
-        }
1189
-        return $comparison;
1190
-    }
1191
-
1192
-
1193
-    /**
1194
-     * @throws EE_Error
1195
-     * @throws ReflectionException
1196
-     */
1197
-    protected function _payment_log_details()
1198
-    {
1199
-        EE_Registry::instance()->load_model('Change_Log');
1200
-        /** @var $payment_log EE_Change_Log */
1201
-        $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1202
-        $payment_method = null;
1203
-        $transaction = null;
1204
-        if ($payment_log instanceof EE_Change_Log) {
1205
-            if ($payment_log->object() instanceof EE_Payment) {
1206
-                $payment_method = $payment_log->object()->payment_method();
1207
-                $transaction = $payment_log->object()->transaction();
1208
-            } elseif ($payment_log->object() instanceof EE_Payment_Method) {
1209
-                $payment_method = $payment_log->object();
1210
-            } elseif ($payment_log->object() instanceof EE_Transaction) {
1211
-                $transaction = $payment_log->object();
1212
-                $payment_method = $transaction->payment_method();
1213
-            }
1214
-        }
1215
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1216
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1217
-            array(
1218
-                'payment_log'    => $payment_log,
1219
-                'payment_method' => $payment_method,
1220
-                'transaction'    => $transaction,
1221
-            ),
1222
-            true
1223
-        );
1224
-        $this->display_admin_page_with_no_sidebar();
1225
-    }
19
+	/**
20
+	 * Variables used for when we're re-sorting the logs results,
21
+	 * in case we needed to do two queries, and we need to resort
22
+	 *
23
+	 * @var string
24
+	 */
25
+	private $_sort_logs_again_direction;
26
+
27
+
28
+	/**
29
+	 * @Constructor
30
+	 * @access public
31
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
32
+	 * @throws EE_Error
33
+	 * @throws InvalidArgumentException
34
+	 * @throws InvalidDataTypeException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws ReflectionException
37
+	 */
38
+	public function __construct($routing = true)
39
+	{
40
+		parent::__construct($routing);
41
+	}
42
+
43
+
44
+	protected function _init_page_props()
45
+	{
46
+		$this->page_slug = EE_PAYMENTS_PG_SLUG;
47
+		$this->page_label = esc_html__('Payment Methods', 'event_espresso');
48
+		$this->_admin_base_url = EE_PAYMENTS_ADMIN_URL;
49
+		$this->_admin_base_path = EE_PAYMENTS_ADMIN;
50
+	}
51
+
52
+
53
+	protected function _ajax_hooks()
54
+	{
55
+		// todo: all hooks for ajax goes here.
56
+	}
57
+
58
+
59
+	protected function _define_page_props()
60
+	{
61
+		$this->_admin_page_title = $this->page_label;
62
+		$this->_labels = array(
63
+			'publishbox' => esc_html__('Update Settings', 'event_espresso'),
64
+		);
65
+	}
66
+
67
+
68
+	protected function _set_page_routes()
69
+	{
70
+		/**
71
+		 * note that with payment method capabilities, although we've implemented
72
+		 * capability mapping which will be used for accessing payment methods owned by
73
+		 * other users.  This is not fully implemented yet in the payment method ui.
74
+		 * Currently, only the "plural" caps are in active use.
75
+		 * When cap mapping is implemented, some routes will need to use the singular form of
76
+		 * capability method and also include the $id of the payment method for the route.
77
+		 **/
78
+		$this->_page_routes = array(
79
+			'default'                   => array(
80
+				'func'       => '_payment_methods_list',
81
+				'capability' => 'ee_edit_payment_methods',
82
+			),
83
+			'payment_settings'          => array(
84
+				'func'       => '_payment_settings',
85
+				'capability' => 'ee_manage_gateways',
86
+			),
87
+			'activate_payment_method'   => array(
88
+				'func'       => '_activate_payment_method',
89
+				'noheader'   => true,
90
+				'capability' => 'ee_edit_payment_methods',
91
+			),
92
+			'deactivate_payment_method' => array(
93
+				'func'       => '_deactivate_payment_method',
94
+				'noheader'   => true,
95
+				'capability' => 'ee_delete_payment_methods',
96
+			),
97
+			'update_payment_method'     => array(
98
+				'func'               => '_update_payment_method',
99
+				'noheader'           => true,
100
+				'headers_sent_route' => 'default',
101
+				'capability'         => 'ee_edit_payment_methods',
102
+			),
103
+			'update_payment_settings'   => array(
104
+				'func'       => '_update_payment_settings',
105
+				'noheader'   => true,
106
+				'capability' => 'ee_manage_gateways',
107
+			),
108
+			'payment_log'               => array(
109
+				'func'       => '_payment_log_overview_list_table',
110
+				'capability' => 'ee_read_payment_methods',
111
+			),
112
+			'payment_log_details'       => array(
113
+				'func'       => '_payment_log_details',
114
+				'capability' => 'ee_read_payment_methods',
115
+			),
116
+		);
117
+	}
118
+
119
+
120
+	/**
121
+	 * @throws EE_Error
122
+	 * @throws ReflectionException
123
+	 */
124
+	protected function _set_page_config()
125
+	{
126
+		$payment_method_list_config = array(
127
+			'nav'           => array(
128
+				'label' => esc_html__('Payment Methods', 'event_espresso'),
129
+				'icon' => 'dashicons-bank',
130
+				'order' => 10,
131
+			),
132
+			'metaboxes'     => $this->_default_espresso_metaboxes,
133
+			'help_tabs'     => array_merge(
134
+				array(
135
+					'payment_methods_overview_help_tab' => array(
136
+						'title'    => esc_html__('Payment Methods Overview', 'event_espresso'),
137
+						'filename' => 'payment_methods_overview',
138
+					),
139
+				),
140
+				$this->_add_payment_method_help_tabs()
141
+			),
142
+			'require_nonce' => false,
143
+		);
144
+		$this->_page_config = array(
145
+			'default'          => $payment_method_list_config,
146
+			'payment_settings' => array(
147
+				'nav'           => array(
148
+					'label' => esc_html__('Settings', 'event_espresso'),
149
+					'icon' => 'dashicons-admin-generic',
150
+					'order' => 20,
151
+				),
152
+				'help_tabs'     => array(
153
+					'payment_methods_settings_help_tab' => array(
154
+						'title'    => esc_html__('Payment Method Settings', 'event_espresso'),
155
+						'filename' => 'payment_methods_settings',
156
+					),
157
+				),
158
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
159
+				'require_nonce' => false,
160
+			),
161
+			'payment_log'      => array(
162
+				'nav'           => array(
163
+					'label' => esc_html__("Logs", 'event_espresso'),
164
+					'icon' => 'dashicons-text-page',
165
+					'order' => 30,
166
+				),
167
+				'list_table'    => 'Payment_Log_Admin_List_Table',
168
+				'metaboxes'     => $this->_default_espresso_metaboxes,
169
+				'require_nonce' => false,
170
+			),
171
+		);
172
+	}
173
+
174
+
175
+	/**
176
+	 * @return array
177
+	 * @throws DomainException
178
+	 * @throws EE_Error
179
+	 * @throws InvalidArgumentException
180
+	 * @throws InvalidDataTypeException
181
+	 * @throws InvalidInterfaceException
182
+	 * @throws ReflectionException
183
+	 */
184
+	protected function _add_payment_method_help_tabs()
185
+	{
186
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
187
+		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
188
+		$all_pmt_help_tabs_config = array();
189
+		foreach ($payment_method_types as $payment_method_type) {
190
+			if (
191
+				! EE_Registry::instance()->CAP->current_user_can(
192
+					$payment_method_type->cap_name(),
193
+					'specific_payment_method_type_access'
194
+				)
195
+			) {
196
+				continue;
197
+			}
198
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
200
+				$template_args['admin_page_obj'] = $this;
201
+				$all_pmt_help_tabs_config[ $help_tab_name ] = array(
202
+					'title'   => $config['title'],
203
+					'content' => EEH_Template::display_template(
204
+						$payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
205
+						$template_args,
206
+						true
207
+					),
208
+				);
209
+			}
210
+		}
211
+		return $all_pmt_help_tabs_config;
212
+	}
213
+
214
+
215
+	// none of the below group are currently used for Gateway Settings
216
+	protected function _add_screen_options()
217
+	{
218
+	}
219
+
220
+
221
+	protected function _add_feature_pointers()
222
+	{
223
+	}
224
+
225
+
226
+	public function admin_init()
227
+	{
228
+	}
229
+
230
+
231
+	public function admin_notices()
232
+	{
233
+	}
234
+
235
+
236
+	public function admin_footer_scripts()
237
+	{
238
+	}
239
+
240
+
241
+	public function load_scripts_styles()
242
+	{
243
+		// styles
244
+		wp_enqueue_style('espresso-ui-theme');
245
+		wp_enqueue_style('ee-text-links-css');
246
+		wp_register_style(
247
+			'espresso_payments',
248
+			EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
249
+			[],
250
+			EVENT_ESPRESSO_VERSION
251
+		);
252
+		// scripts
253
+		wp_enqueue_script('ee_admin_js');
254
+		wp_enqueue_script('ee-text-links-js');
255
+		wp_enqueue_script(
256
+			'espresso_payments',
257
+			EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
258
+			['ee-datepicker'],
259
+			EVENT_ESPRESSO_VERSION,
260
+			true
261
+		);
262
+	}
263
+
264
+
265
+	public function load_scripts_styles_default()
266
+	{
267
+		wp_enqueue_style('espresso_payments');
268
+		wp_enqueue_style('ee-text-links-css');
269
+	}
270
+
271
+
272
+	public function load_scripts_styles_payment_log_details()
273
+	{
274
+		wp_enqueue_style('espresso_payments');
275
+	}
276
+
277
+
278
+	/**
279
+	 * @throws EE_Error
280
+	 * @throws ReflectionException
281
+	 */
282
+	protected function _payment_methods_list()
283
+	{
284
+		/**
285
+		 * first let's ensure payment methods have been set up.
286
+		 * We do this here because when people activate a payment method for the first time (as an addon),
287
+		 * it may not set up its capabilities or get registered correctly due to the loading process.
288
+		 * However, people MUST set up the details for the payment method,
289
+		 * so it's safe to do a recheck here.
290
+		 */
291
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
292
+		EEM_Payment_Method::instance()->verify_button_urls();
293
+		// set up tabs, one for each payment method type
294
+		$tabs = array();
295
+		$payment_methods = array();
296
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
297
+			// we don't want to show admin-only PMTs for now
298
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
299
+				continue;
300
+			}
301
+			// check access
302
+			if (
303
+				! EE_Registry::instance()->CAP->current_user_can(
304
+					$pmt_obj->cap_name(),
305
+					'specific_payment_method_type_access'
306
+				)
307
+			) {
308
+				continue;
309
+			}
310
+			// check for any active pms of that type
311
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
312
+			if (! $payment_method instanceof EE_Payment_Method) {
313
+				$payment_method = EE_Payment_Method::new_instance(
314
+					array(
315
+						'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
316
+						'PMD_type'       => $pmt_obj->system_name(),
317
+						'PMD_name'       => $pmt_obj->pretty_name(),
318
+						'PMD_admin_name' => $pmt_obj->pretty_name(),
319
+					)
320
+				);
321
+			}
322
+			$payment_methods[ $payment_method->slug() ] = $payment_method;
323
+		}
324
+		$payment_methods = apply_filters(
325
+			'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
326
+			$payment_methods
327
+		);
328
+		foreach ($payment_methods as $payment_method) {
329
+			if ($payment_method instanceof EE_Payment_Method) {
330
+				$this->addMetaBox(
331
+					// html id
332
+					'espresso_' . $payment_method->slug() . '_payment_settings',
333
+					// title
334
+					sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
335
+					// callback
336
+					array($this, 'payment_method_settings_meta_box'),
337
+					// post type
338
+					null,
339
+					// context
340
+					'normal',
341
+					// priority
342
+					'default',
343
+					// callback args
344
+					array('payment_method' => $payment_method)
345
+				);
346
+				// setup for tabbed content
347
+				$tabs[ $payment_method->slug() ] = array(
348
+					'label' => $payment_method->admin_name(),
349
+					'class' => $payment_method->active() ? 'gateway-active' : '',
350
+					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
351
+					'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
352
+					'slug'  => $payment_method->slug(),
353
+					'icon'  => $payment_method->active()
354
+						? '<span class="dashicons dashicons-yes-alt"></span>'
355
+						: '<span class="dashicons dashicons-remove"></span>',
356
+				);
357
+			}
358
+		}
359
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
360
+			$tabs,
361
+			'payment_method_links',
362
+			'',
363
+			$this->_get_active_payment_method_slug()
364
+		);
365
+		$this->display_admin_page_with_sidebar();
366
+	}
367
+
368
+
369
+	/**
370
+	 *   _get_active_payment_method_slug
371
+	 *
372
+	 * @return string
373
+	 * @throws EE_Error
374
+	 */
375
+	protected function _get_active_payment_method_slug()
376
+	{
377
+		$payment_method_slug = false;
378
+		// decide which payment method tab to open first, as dictated by the request's 'payment_method'
379
+		if (isset($this->_req_data['payment_method'])) {
380
+			// if they provided the current payment method, use it
381
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
382
+		}
383
+		/** @var EE_Payment_Method $payment_method */
384
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
385
+		// if that didn't work or wasn't provided, find another way to select the current pm
386
+		if (! $this->_verify_payment_method($payment_method)) {
387
+			// like, looking for an active one
388
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
389
+			// test that one as well
390
+			if ($this->_verify_payment_method($payment_method)) {
391
+				$payment_method_slug = $payment_method->slug();
392
+			} else {
393
+				$payment_method_slug = 'paypal_standard';
394
+			}
395
+		}
396
+		return $payment_method_slug;
397
+	}
398
+
399
+
400
+	/**
401
+	 *    payment_method_settings_meta_box
402
+	 *    returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct
403
+	 *    capabilities to access it
404
+	 *
405
+	 * @param EE_Payment_Method $payment_method
406
+	 * @return boolean
407
+	 * @throws EE_Error
408
+	 */
409
+	protected function _verify_payment_method($payment_method)
410
+	{
411
+		if (
412
+			$payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base
413
+			&& EE_Registry::instance()->CAP->current_user_can(
414
+				$payment_method->type_obj()->cap_name(),
415
+				'specific_payment_method_type_access'
416
+			)
417
+		) {
418
+			return true;
419
+		}
420
+		return false;
421
+	}
422
+
423
+
424
+	/**
425
+	 *    payment_method_settings_meta_box
426
+	 *
427
+	 * @param NULL  $post_obj_which_is_null is an object containing the current post (as a $post object)
428
+	 * @param array $metabox                is an array with metabox id, title, callback, and args elements. the value
429
+	 *                                      at 'args' has key 'payment_method', as set within _payment_methods_list
430
+	 * @return void
431
+	 * @throws EE_Error
432
+	 * @throws ReflectionException
433
+	 */
434
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox)
435
+	{
436
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
437
+			? $metabox['args']['payment_method'] : null;
438
+		if (! $payment_method instanceof EE_Payment_Method) {
439
+			throw new EE_Error(
440
+				esc_html__(
441
+					'Payment method metabox setup incorrectly. No Payment method object was supplied',
442
+					'event_espresso'
443
+				)
444
+			);
445
+		}
446
+		$payment_method_scopes = $payment_method->active();
447
+		// if the payment method really exists show its form, otherwise the activation template
448
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
449
+			$form = $this->_generate_payment_method_settings_form($payment_method);
450
+			if ($form->form_data_present_in($this->_req_data)) {
451
+				$form->receive_form_submission($this->_req_data);
452
+			}
453
+			echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
454
+		} else {
455
+			echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
456
+		}
457
+	}
458
+
459
+
460
+	/**
461
+	 * Gets the form for all the settings related to this payment method type
462
+	 *
463
+	 * @access protected
464
+	 * @param EE_Payment_Method $payment_method
465
+	 * @return EE_Form_Section_Proper
466
+	 * @throws EE_Error
467
+	 */
468
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
469
+	{
470
+		if (! $payment_method instanceof EE_Payment_Method) {
471
+			return new EE_Form_Section_Proper();
472
+		}
473
+		$subsections = apply_filters(
474
+			'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
475
+			[
476
+				'pci_dss_compliance'      => $this->_pci_dss_compliance($payment_method),
477
+				'currency_support'        => $this->_currency_support($payment_method),
478
+				'payment_method_settings' => $this->_payment_method_settings($payment_method),
479
+				'update'                  => $this->_update_payment_method_button($payment_method),
480
+				'deactivate'              => $this->_deactivate_payment_method_button($payment_method),
481
+				'fine_print'              => $this->_fine_print(),
482
+			],
483
+			$payment_method
484
+		);
485
+		return new EE_Form_Section_Proper(
486
+			array(
487
+				'name'            => $payment_method->slug() . '_settings_form',
488
+				'html_id'         => $payment_method->slug() . '_settings_form',
489
+				'action'          => EE_Admin_Page::add_query_args_and_nonce(
490
+					array(
491
+						'action'         => 'update_payment_method',
492
+						'payment_method' => $payment_method->slug(),
493
+					),
494
+					EE_PAYMENTS_ADMIN_URL
495
+				),
496
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
497
+				'subsections'     => array_filter($subsections),
498
+			)
499
+		);
500
+	}
501
+
502
+
503
+	/**
504
+	 * _pci_dss_compliance
505
+	 *
506
+	 * @access protected
507
+	 * @param EE_Payment_Method $payment_method
508
+	 * @return EE_Form_Section_HTML|null
509
+	 * @throws EE_Error
510
+	 */
511
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
512
+	{
513
+		if (!$payment_method->type_obj()->requires_https()) {
514
+			return null;
515
+		}
516
+		return new EE_Form_Section_HTML(
517
+			EEH_HTML::table(
518
+				EEH_HTML::tr(
519
+					EEH_HTML::th(
520
+						EEH_HTML::label(
521
+							EEH_HTML::strong(
522
+								esc_html__('IMPORTANT', 'event_espresso'),
523
+								'',
524
+								'important-notice'
525
+							)
526
+						)
527
+					) .
528
+					EEH_HTML::td(
529
+						EEH_HTML::strong(
530
+							esc_html__(
531
+								'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.',
532
+								'event_espresso'
533
+							)
534
+						)
535
+						.
536
+						EEH_HTML::br()
537
+						.
538
+						esc_html__('Learn more about ', 'event_espresso')
539
+						. EEH_HTML::link(
540
+							'https://www.pcisecuritystandards.org/merchants/index.php',
541
+							esc_html__('PCI DSS compliance', 'event_espresso')
542
+						)
543
+					)
544
+				)
545
+			)
546
+		);
547
+	}
548
+
549
+
550
+	/**
551
+	 * _currency_support
552
+	 *
553
+	 * @access protected
554
+	 * @param EE_Payment_Method $payment_method
555
+	 * @return EE_Form_Section_HTML|null
556
+	 * @throws EE_Error
557
+	 */
558
+	protected function _currency_support(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
559
+	{
560
+		if ($payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
561
+			return null;
562
+		}
563
+		return new EE_Form_Section_HTML(
564
+			EEH_HTML::table(
565
+				EEH_HTML::tr(
566
+					EEH_HTML::th(
567
+						EEH_HTML::label(
568
+							EEH_HTML::strong(
569
+								esc_html__('IMPORTANT', 'event_espresso'),
570
+								'',
571
+								'important-notice'
572
+							)
573
+						)
574
+					) .
575
+					EEH_HTML::td(
576
+						EEH_HTML::strong(
577
+							sprintf(
578
+								esc_html__(
579
+									'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.',
580
+									'event_espresso'
581
+								),
582
+								EE_Config::instance()->currency->code
583
+							)
584
+						)
585
+					)
586
+				)
587
+			)
588
+		);
589
+	}
590
+
591
+
592
+	/**
593
+	 * _update_payment_method_button
594
+	 *
595
+	 * @access protected
596
+	 * @param EE_Payment_Method $payment_method
597
+	 * @return EE_Payment_Method_Form
598
+	 * @throws EE_Error
599
+	 */
600
+	protected function _payment_method_settings(EE_Payment_Method $payment_method)
601
+	{
602
+		// modify the form, so we only have/show fields that will be implemented for this version
603
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
604
+	}
605
+
606
+
607
+	/**
608
+	 * Simplifies the form to merely reproduce 4.1's gateway settings functionality
609
+	 *
610
+	 * @param EE_Form_Section_Proper $form_section
611
+	 * @param string                 $payment_method_name
612
+	 * @return EE_Payment_Method_Form
613
+	 * @throws EE_Error
614
+	 */
615
+	protected function _simplify_form($form_section, $payment_method_name = '')
616
+	{
617
+		if ($form_section instanceof EE_Payment_Method_Form) {
618
+			$form_section->exclude(
619
+				array(
620
+					'PMD_type', // don't want them changing the type
621
+					'PMD_slug', // or the slug (probably never)
622
+					'PMD_wp_user', // or the user's ID
623
+					'Currency' // or the currency, until the rest of EE supports simultaneous currencies
624
+				)
625
+			);
626
+			return $form_section;
627
+		} else {
628
+			throw new EE_Error(
629
+				sprintf(
630
+					esc_html__(
631
+						'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.',
632
+						'event_espresso'
633
+					),
634
+					$payment_method_name
635
+				)
636
+			);
637
+		}
638
+	}
639
+
640
+
641
+	/**
642
+	 * _update_payment_method_button
643
+	 *
644
+	 * @access protected
645
+	 * @param EE_Payment_Method $payment_method
646
+	 * @return EE_Form_Section_HTML
647
+	 * @throws EE_Error
648
+	 */
649
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method)
650
+	{
651
+		$update_button = new EE_Submit_Input(
652
+			array(
653
+				'name'       => 'submit',
654
+				'html_id'    => 'save_' . $payment_method->slug() . '_settings',
655
+				'default'    => sprintf(
656
+					esc_html__('Update %s Payment Settings', 'event_espresso'),
657
+					$payment_method->admin_name()
658
+				),
659
+				'html_label' => EEH_HTML::nbsp(),
660
+			)
661
+		);
662
+		return new EE_Form_Section_HTML(
663
+			EEH_HTML::table(
664
+				EEH_HTML::no_row(EEH_HTML::br(2)) .
665
+				EEH_HTML::tr(
666
+					EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
667
+					EEH_HTML::td(
668
+						$update_button->get_html_for_input()
669
+					)
670
+				)
671
+			)
672
+		);
673
+	}
674
+
675
+
676
+	/**
677
+	 * _deactivate_payment_method_button
678
+	 *
679
+	 * @access protected
680
+	 * @param EE_Payment_Method $payment_method
681
+	 * @return EE_Form_Section_HTML
682
+	 */
683
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method)
684
+	{
685
+		$link_text_and_title = sprintf(
686
+			esc_html__('Deactivate %1$s Payments?', 'event_espresso'),
687
+			$payment_method->admin_name()
688
+		);
689
+		return new EE_Form_Section_HTML(
690
+			EEH_HTML::table(
691
+				EEH_HTML::tr(
692
+					EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
693
+					EEH_HTML::td(
694
+						EEH_HTML::link(
695
+							EE_Admin_Page::add_query_args_and_nonce(
696
+								array(
697
+									'action'         => 'deactivate_payment_method',
698
+									'payment_method' => $payment_method->slug(),
699
+								),
700
+								EE_PAYMENTS_ADMIN_URL
701
+							),
702
+							$link_text_and_title,
703
+							$link_text_and_title,
704
+							'deactivate_' . $payment_method->slug(),
705
+							'button button--secondary'
706
+						)
707
+					)
708
+				)
709
+			)
710
+		);
711
+	}
712
+
713
+
714
+	/**
715
+	 * _activate_payment_method_button
716
+	 *
717
+	 * @access protected
718
+	 * @param EE_Payment_Method $payment_method
719
+	 * @return EE_Form_Section_Proper
720
+	 * @throws EE_Error
721
+	 */
722
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method)
723
+	{
724
+		$link_text_and_title = sprintf(
725
+			esc_html__('Activate %1$s Payment Method?', 'event_espresso'),
726
+			$payment_method->admin_name()
727
+		);
728
+		return new EE_Form_Section_Proper(
729
+			array(
730
+				'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
731
+				'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
732
+				'action'          => '#',
733
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
734
+				'subsections'     => apply_filters(
735
+					'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections',
736
+					array(
737
+						new EE_Form_Section_HTML(
738
+							EEH_HTML::table(
739
+								EEH_HTML::tr(
740
+									EEH_HTML::td(
741
+										$payment_method->type_obj()->introductory_html(),
742
+										'',
743
+										'',
744
+										'',
745
+										'colspan="2"'
746
+									)
747
+								) .
748
+								EEH_HTML::tr(
749
+									EEH_HTML::th(
750
+										EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
751
+									) .
752
+									EEH_HTML::td(
753
+										EEH_HTML::link(
754
+											EE_Admin_Page::add_query_args_and_nonce(
755
+												array(
756
+													'action'              => 'activate_payment_method',
757
+													'payment_method_type' => $payment_method->type(),
758
+												),
759
+												EE_PAYMENTS_ADMIN_URL
760
+											),
761
+											$link_text_and_title,
762
+											$link_text_and_title,
763
+											'activate_' . $payment_method->slug(),
764
+											'button button--primary-alt'
765
+										)
766
+									)
767
+								)
768
+							)
769
+						),
770
+					),
771
+					$payment_method
772
+				),
773
+			)
774
+		);
775
+	}
776
+
777
+
778
+	/**
779
+	 * _fine_print
780
+	 *
781
+	 * @access protected
782
+	 * @return EE_Form_Section_HTML
783
+	 */
784
+	protected function _fine_print()
785
+	{
786
+		return new EE_Form_Section_HTML(
787
+			EEH_HTML::table(
788
+				EEH_HTML::tr(
789
+					EEH_HTML::th() .
790
+					EEH_HTML::td(
791
+						EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
792
+					)
793
+				)
794
+			)
795
+		);
796
+	}
797
+
798
+
799
+	/**
800
+	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
801
+	 *
802
+	 * @throws EE_Error
803
+	 * @throws ReflectionException
804
+	 * @global WP_User $current_user
805
+	 */
806
+	protected function _activate_payment_method()
807
+	{
808
+		if (isset($this->_req_data['payment_method_type'])) {
809
+			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
810
+			// see if one exists
811
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
812
+			$payment_method = EE_Payment_Method_Manager::instance()
813
+													   ->activate_a_payment_method_of_type($payment_method_type);
814
+			$this->_redirect_after_action(
815
+				1,
816
+				'Payment Method',
817
+				'activated',
818
+				array('action' => 'default', 'payment_method' => $payment_method->slug())
819
+			);
820
+		} else {
821
+			$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
822
+		}
823
+	}
824
+
825
+
826
+	/**
827
+	 * @throws EE_Error
828
+	 * @throws ReflectionException
829
+	 */
830
+	protected function _deactivate_payment_method()
831
+	{
832
+		if (isset($this->_req_data['payment_method'])) {
833
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
834
+			// deactivate it
835
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
836
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
837
+			$this->_redirect_after_action(
838
+				$count_updated,
839
+				'Payment Method',
840
+				'deactivated',
841
+				array('action' => 'default', 'payment_method' => $payment_method_slug)
842
+			);
843
+		} else {
844
+			$this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default'));
845
+		}
846
+	}
847
+
848
+
849
+	/**
850
+	 * Processes the payment method form that was submitted. This is slightly trickier than usual form
851
+	 * processing because we first need to identify WHICH form was processed and which payment method
852
+	 * it corresponds to. Once we have done that, we see if the form is valid. If it is, the
853
+	 * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method
854
+	 * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the
855
+	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
856
+	 *
857
+	 * @return void
858
+	 * @throws EE_Error
859
+	 * @throws ReflectionException
860
+	 */
861
+	protected function _update_payment_method()
862
+	{
863
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
864
+			// ok let's find which gateway form to use based on the form input
865
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
866
+			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
867
+			$correct_pmt_form_to_use = null;
868
+			$payment_method = null;
869
+			foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) {
870
+				if ($payment_method instanceof EE_Payment_Method) {
871
+					// get the form and simplify it, like what we do when we display it
872
+					$pmt_form = $this->_generate_payment_method_settings_form($payment_method);
873
+					if ($pmt_form->form_data_present_in($this->_req_data)) {
874
+						$correct_pmt_form_to_use = $pmt_form;
875
+						break;
876
+					}
877
+				}
878
+			}
879
+			// if we couldn't find the correct payment method type...
880
+			if (! $correct_pmt_form_to_use) {
881
+				EE_Error::add_error(
882
+					esc_html__(
883
+						"We could not find which payment method type your form submission related to. Please contact support",
884
+						'event_espresso'
885
+					),
886
+					__FILE__,
887
+					__FUNCTION__,
888
+					__LINE__
889
+				);
890
+				$this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default'));
891
+			}
892
+			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
893
+			if ($correct_pmt_form_to_use->is_valid()) {
894
+				$payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
895
+				if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
896
+					throw new EE_Error(
897
+						sprintf(
898
+							esc_html__(
899
+								'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.',
900
+								'event_espresso'
901
+							),
902
+							'payment_method_settings'
903
+						)
904
+					);
905
+				}
906
+				$payment_settings_subform->save();
907
+				/** @var $pm EE_Payment_Method */
908
+				$this->_redirect_after_action(
909
+					true,
910
+					'Payment Method',
911
+					'updated',
912
+					array('action' => 'default', 'payment_method' => $payment_method->slug())
913
+				);
914
+			} else {
915
+				EE_Error::add_error(
916
+					sprintf(
917
+						esc_html__(
918
+							'Payment method of type %s was not saved because there were validation errors. They have been marked in the form',
919
+							'event_espresso'
920
+						),
921
+						$payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name()
922
+							: esc_html__('"(unknown)"', 'event_espresso')
923
+					),
924
+					__FILE__,
925
+					__FUNCTION__,
926
+					__LINE__
927
+				);
928
+			}
929
+		}
930
+	}
931
+
932
+
933
+	/**
934
+	 * Displays payment settings (not payment METHOD settings, that's _payment_method_settings)
935
+	 * @throws DomainException
936
+	 * @throws EE_Error
937
+	 * @throws InvalidArgumentException
938
+	 * @throws InvalidDataTypeException
939
+	 * @throws InvalidInterfaceException
940
+	 */
941
+	protected function _payment_settings()
942
+	{
943
+		$form = $this->getPaymentSettingsForm();
944
+		$this->_set_add_edit_form_tags('update_payment_settings');
945
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
946
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
947
+			$form->get_html_and_js(),
948
+			'',
949
+			'padding'
950
+		);
951
+		$this->display_admin_page_with_sidebar();
952
+	}
953
+
954
+
955
+	/**
956
+	 *        _update_payment_settings
957
+	 *
958
+	 * @access protected
959
+	 * @return void
960
+	 * @throws EE_Error
961
+	 * @throws InvalidArgumentException
962
+	 * @throws InvalidDataTypeException
963
+	 * @throws InvalidInterfaceException
964
+	 */
965
+	protected function _update_payment_settings()
966
+	{
967
+		$form = $this->getPaymentSettingsForm();
968
+		if ($form->was_submitted($this->_req_data)) {
969
+			$form->receive_form_submission($this->_req_data);
970
+			if ($form->is_valid()) {
971
+				/**
972
+				 * @var $reg_config EE_Registration_Config
973
+				 */
974
+				$loader = LoaderFactory::getLoader();
975
+				$reg_config = $loader->getShared('EE_Registration_Config');
976
+				$valid_data = $form->valid_data();
977
+				$reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options'];
978
+				$reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan'];
979
+			}
980
+		}
981
+		EE_Registry::instance()->CFG = apply_filters(
982
+			'FHEE__Payments_Admin_Page___update_payment_settings__CFG',
983
+			EE_Registry::instance()->CFG
984
+		);
985
+
986
+		$what = esc_html__('Payment Settings', 'event_espresso');
987
+		$success = $this->_update_espresso_configuration(
988
+			$what,
989
+			EE_Registry::instance()->CFG,
990
+			__FILE__,
991
+			__FUNCTION__,
992
+			__LINE__
993
+		);
994
+		$this->_redirect_after_action(
995
+			$success,
996
+			$what,
997
+			esc_html__('updated', 'event_espresso'),
998
+			array('action' => 'payment_settings')
999
+		);
1000
+	}
1001
+
1002
+
1003
+	/**
1004
+	 * Gets the form used for updating payment settings
1005
+	 *
1006
+	 * @return EE_Form_Section_Proper
1007
+	 * @throws EE_Error
1008
+	 * @throws InvalidArgumentException
1009
+	 * @throws InvalidDataTypeException
1010
+	 * @throws InvalidInterfaceException
1011
+	 */
1012
+	protected function getPaymentSettingsForm()
1013
+	{
1014
+		/**
1015
+		 * @var $reg_config EE_Registration_Config
1016
+		 */
1017
+		$reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config');
1018
+		return new EE_Form_Section_Proper(
1019
+			array(
1020
+				'name' => 'payment-settings',
1021
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1022
+				'subsections' => array(
1023
+					'show_pending_payment_options' => new EE_Yes_No_Input(
1024
+						array(
1025
+							'html_name' => 'show_pending_payment_options',
1026
+							'default' => $reg_config->show_pending_payment_options,
1027
+							'html_help_text' => esc_html__(
1028
+								"If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ",
1029
+								'event_espresso'
1030
+							)
1031
+						)
1032
+					),
1033
+					'gateway_log_lifespan' => new EE_Select_Input(
1034
+						$reg_config->gatewayLogLifespanOptions(),
1035
+						array(
1036
+							'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'),
1037
+							'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'),
1038
+							'default' => $reg_config->gateway_log_lifespan,
1039
+						)
1040
+					)
1041
+				)
1042
+			)
1043
+		);
1044
+	}
1045
+
1046
+
1047
+	/**
1048
+	 * @throws EE_Error
1049
+	 */
1050
+	protected function _payment_log_overview_list_table()
1051
+	{
1052
+		$this->display_admin_list_table_page_with_sidebar();
1053
+	}
1054
+
1055
+
1056
+	protected function _set_list_table_views_payment_log()
1057
+	{
1058
+		$this->_views = array(
1059
+			'all' => array(
1060
+				'slug'  => 'all',
1061
+				'label' => esc_html__('View All Logs', 'event_espresso'),
1062
+				'count' => 0,
1063
+			),
1064
+		);
1065
+	}
1066
+
1067
+
1068
+	/**
1069
+	 * @param int  $per_page
1070
+	 * @param int  $current_page
1071
+	 * @param bool $count
1072
+	 * @return array|int
1073
+	 * @throws EE_Error
1074
+	 * @throws ReflectionException
1075
+	 */
1076
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false)
1077
+	{
1078
+		EE_Registry::instance()->load_model('Change_Log');
1079
+		// we may need to do multiple queries (joining differently), so we actually want an array of query params
1080
+		$query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway));
1081
+		// check if they've selected a specific payment method
1082
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
1083
+			$query_params[0]['OR*pm_or_pay_pm'] = array(
1084
+				'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'],
1085
+				'Payment_Method.PMD_ID'         => $this->_req_data['_payment_method'],
1086
+			);
1087
+		}
1088
+		// take into account search
1089
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1090
+			$similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1091
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1092
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1093
+			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
1094
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string;
1095
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string;
1096
+			$query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string;
1097
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1098
+			$query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string;
1099
+			$query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string;
1100
+			$query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string;
1101
+			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
1102
+		}
1103
+		if (
1104
+			isset($this->_req_data['payment-filter-start-date'])
1105
+			&& isset($this->_req_data['payment-filter-end-date'])
1106
+		) {
1107
+			// add date
1108
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1109
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1110
+			// make sure our timestamps start and end right at the boundaries for each day
1111
+			$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1112
+			$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1113
+			// convert to timestamps
1114
+			$start_date = strtotime($start_date);
1115
+			$end_date = strtotime($end_date);
1116
+			// makes sure start date is the lowest value and vice versa
1117
+			$start_date = min($start_date, $end_date);
1118
+			$end_date = max($start_date, $end_date);
1119
+			// convert for query
1120
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1121
+				'LOG_time',
1122
+				date('Y-m-d H:i:s', $start_date),
1123
+				'Y-m-d H:i:s'
1124
+			);
1125
+			$end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1126
+				'LOG_time',
1127
+				date('Y-m-d H:i:s', $end_date),
1128
+				'Y-m-d H:i:s'
1129
+			);
1130
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
1131
+		}
1132
+		if ($count) {
1133
+			return EEM_Change_Log::instance()->count($query_params);
1134
+		}
1135
+		if (isset($this->_req_data['order'])) {
1136
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1137
+				? $this->_req_data['order']
1138
+				: 'DESC';
1139
+			$query_params['order_by'] = array('LOG_time' => $sort);
1140
+		} else {
1141
+			$query_params['order_by'] = array('LOG_time' => 'DESC');
1142
+		}
1143
+		$offset = ($current_page - 1) * $per_page;
1144
+		if (! isset($this->_req_data['download_results'])) {
1145
+			$query_params['limit'] = array($offset, $per_page);
1146
+		}
1147
+		// now they've requested to instead just download the file instead of viewing it.
1148
+		if (isset($this->_req_data['download_results'])) {
1149
+			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1150
+			header('Content-Disposition: attachment');
1151
+			header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1152
+			echo '<h1> '
1153
+				. sprintf(
1154
+					esc_html__('Payment Logs for %1$s', 'event_espresso'),
1155
+					esc_url_raw(site_url())
1156
+				)
1157
+				. '</h1 >';
1158
+			echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1159
+			echo esc_html(var_export($query_params, true));
1160
+			echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1161
+			echo esc_html(var_export($wpdb_results, true));
1162
+			die;
1163
+		}
1164
+		return EEM_Change_Log::instance()->get_all($query_params);
1165
+	}
1166
+
1167
+
1168
+	/**
1169
+	 * Used by usort to RE-sort log query results, because we lose the ordering
1170
+	 * because we're possibly combining the results from two queries
1171
+	 *
1172
+	 * @param EE_Change_Log $logA
1173
+	 * @param EE_Change_Log $logB
1174
+	 * @return int
1175
+	 * @throws EE_Error
1176
+	 * @throws ReflectionException
1177
+	 */
1178
+	protected function _sort_logs_again($logA, $logB)
1179
+	{
1180
+		$timeA = $logA->get_raw('LOG_time');
1181
+		$timeB = $logB->get_raw('LOG_time');
1182
+		if ($timeA == $timeB) {
1183
+			return 0;
1184
+		}
1185
+		$comparison = $timeA < $timeB ? -1 : 1;
1186
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
1187
+			return $comparison * -1;
1188
+		}
1189
+		return $comparison;
1190
+	}
1191
+
1192
+
1193
+	/**
1194
+	 * @throws EE_Error
1195
+	 * @throws ReflectionException
1196
+	 */
1197
+	protected function _payment_log_details()
1198
+	{
1199
+		EE_Registry::instance()->load_model('Change_Log');
1200
+		/** @var $payment_log EE_Change_Log */
1201
+		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
1202
+		$payment_method = null;
1203
+		$transaction = null;
1204
+		if ($payment_log instanceof EE_Change_Log) {
1205
+			if ($payment_log->object() instanceof EE_Payment) {
1206
+				$payment_method = $payment_log->object()->payment_method();
1207
+				$transaction = $payment_log->object()->transaction();
1208
+			} elseif ($payment_log->object() instanceof EE_Payment_Method) {
1209
+				$payment_method = $payment_log->object();
1210
+			} elseif ($payment_log->object() instanceof EE_Transaction) {
1211
+				$transaction = $payment_log->object();
1212
+				$payment_method = $transaction->payment_method();
1213
+			}
1214
+		}
1215
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1216
+			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1217
+			array(
1218
+				'payment_log'    => $payment_log,
1219
+				'payment_method' => $payment_method,
1220
+				'transaction'    => $transaction,
1221
+			),
1222
+			true
1223
+		);
1224
+		$this->display_admin_page_with_no_sidebar();
1225
+	}
1226 1226
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
             foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
199 199
                 $template_args = isset($config['template_args']) ? $config['template_args'] : array();
200 200
                 $template_args['admin_page_obj'] = $this;
201
-                $all_pmt_help_tabs_config[ $help_tab_name ] = array(
201
+                $all_pmt_help_tabs_config[$help_tab_name] = array(
202 202
                     'title'   => $config['title'],
203 203
                     'content' => EEH_Template::display_template(
204
-                        $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php',
204
+                        $payment_method_type->file_folder().'help_tabs/'.$config['filename'].'.help_tab.php',
205 205
                         $template_args,
206 206
                         true
207 207
                     ),
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         wp_enqueue_style('ee-text-links-css');
246 246
         wp_register_style(
247 247
             'espresso_payments',
248
-            EE_PAYMENTS_ASSETS_URL . 'ee-payments.css',
248
+            EE_PAYMENTS_ASSETS_URL.'ee-payments.css',
249 249
             [],
250 250
             EVENT_ESPRESSO_VERSION
251 251
         );
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         wp_enqueue_script('ee-text-links-js');
255 255
         wp_enqueue_script(
256 256
             'espresso_payments',
257
-            EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js',
257
+            EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js',
258 258
             ['ee-datepicker'],
259 259
             EVENT_ESPRESSO_VERSION,
260 260
             true
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             }
310 310
             // check for any active pms of that type
311 311
             $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
312
-            if (! $payment_method instanceof EE_Payment_Method) {
312
+            if ( ! $payment_method instanceof EE_Payment_Method) {
313 313
                 $payment_method = EE_Payment_Method::new_instance(
314 314
                     array(
315 315
                         'PMD_slug'       => sanitize_key($pmt_obj->system_name()),
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                     )
320 320
                 );
321 321
             }
322
-            $payment_methods[ $payment_method->slug() ] = $payment_method;
322
+            $payment_methods[$payment_method->slug()] = $payment_method;
323 323
         }
324 324
         $payment_methods = apply_filters(
325 325
             'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods',
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             if ($payment_method instanceof EE_Payment_Method) {
330 330
                 $this->addMetaBox(
331 331
                     // html id
332
-                    'espresso_' . $payment_method->slug() . '_payment_settings',
332
+                    'espresso_'.$payment_method->slug().'_payment_settings',
333 333
                     // title
334 334
                     sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
335 335
                     // callback
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
                     array('payment_method' => $payment_method)
345 345
                 );
346 346
                 // setup for tabbed content
347
-                $tabs[ $payment_method->slug() ] = array(
347
+                $tabs[$payment_method->slug()] = array(
348 348
                     'label' => $payment_method->admin_name(),
349 349
                     'class' => $payment_method->active() ? 'gateway-active' : '',
350
-                    'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
350
+                    'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
351 351
                     'title' => esc_html__('Modify this Payment Method', 'event_espresso'),
352 352
                     'slug'  => $payment_method->slug(),
353 353
                     'icon'  => $payment_method->active()
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
         /** @var EE_Payment_Method $payment_method */
384 384
         $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
385 385
         // if that didn't work or wasn't provided, find another way to select the current pm
386
-        if (! $this->_verify_payment_method($payment_method)) {
386
+        if ( ! $this->_verify_payment_method($payment_method)) {
387 387
             // like, looking for an active one
388 388
             $payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
389 389
             // test that one as well
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
     {
436 436
         $payment_method = isset($metabox['args'], $metabox['args']['payment_method'])
437 437
             ? $metabox['args']['payment_method'] : null;
438
-        if (! $payment_method instanceof EE_Payment_Method) {
438
+        if ( ! $payment_method instanceof EE_Payment_Method) {
439 439
             throw new EE_Error(
440 440
                 esc_html__(
441 441
                     'Payment method metabox setup incorrectly. No Payment method object was supplied',
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
             if ($form->form_data_present_in($this->_req_data)) {
451 451
                 $form->receive_form_submission($this->_req_data);
452 452
             }
453
-            echo wp_kses($form->form_open() . $form->get_html_and_js() . $form->form_close(), AllowedTags::getWithFormTags());
453
+            echo wp_kses($form->form_open().$form->get_html_and_js().$form->form_close(), AllowedTags::getWithFormTags());
454 454
         } else {
455 455
             echo wp_kses($this->_activate_payment_method_button($payment_method)->get_html_and_js(), AllowedTags::getWithFormTags());
456 456
         }
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
      */
468 468
     protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null)
469 469
     {
470
-        if (! $payment_method instanceof EE_Payment_Method) {
470
+        if ( ! $payment_method instanceof EE_Payment_Method) {
471 471
             return new EE_Form_Section_Proper();
472 472
         }
473 473
         $subsections = apply_filters(
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
         );
485 485
         return new EE_Form_Section_Proper(
486 486
             array(
487
-                'name'            => $payment_method->slug() . '_settings_form',
488
-                'html_id'         => $payment_method->slug() . '_settings_form',
487
+                'name'            => $payment_method->slug().'_settings_form',
488
+                'html_id'         => $payment_method->slug().'_settings_form',
489 489
                 'action'          => EE_Admin_Page::add_query_args_and_nonce(
490 490
                     array(
491 491
                         'action'         => 'update_payment_method',
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
      */
511 511
     protected function _pci_dss_compliance(EE_Payment_Method $payment_method): ?EE_Form_Section_HTML
512 512
     {
513
-        if (!$payment_method->type_obj()->requires_https()) {
513
+        if ( ! $payment_method->type_obj()->requires_https()) {
514 514
             return null;
515 515
         }
516 516
         return new EE_Form_Section_HTML(
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                                 'important-notice'
525 525
                             )
526 526
                         )
527
-                    ) .
527
+                    ).
528 528
                     EEH_HTML::td(
529 529
                         EEH_HTML::strong(
530 530
                             esc_html__(
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
                                 'important-notice'
572 572
                             )
573 573
                         )
574
-                    ) .
574
+                    ).
575 575
                     EEH_HTML::td(
576 576
                         EEH_HTML::strong(
577 577
                             sprintf(
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
         $update_button = new EE_Submit_Input(
652 652
             array(
653 653
                 'name'       => 'submit',
654
-                'html_id'    => 'save_' . $payment_method->slug() . '_settings',
654
+                'html_id'    => 'save_'.$payment_method->slug().'_settings',
655 655
                 'default'    => sprintf(
656 656
                     esc_html__('Update %s Payment Settings', 'event_espresso'),
657 657
                     $payment_method->admin_name()
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
         );
662 662
         return new EE_Form_Section_HTML(
663 663
             EEH_HTML::table(
664
-                EEH_HTML::no_row(EEH_HTML::br(2)) .
664
+                EEH_HTML::no_row(EEH_HTML::br(2)).
665 665
                 EEH_HTML::tr(
666
-                    EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) .
666
+                    EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')).
667 667
                     EEH_HTML::td(
668 668
                         $update_button->get_html_for_input()
669 669
                     )
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
         return new EE_Form_Section_HTML(
690 690
             EEH_HTML::table(
691 691
                 EEH_HTML::tr(
692
-                    EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) .
692
+                    EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')).
693 693
                     EEH_HTML::td(
694 694
                         EEH_HTML::link(
695 695
                             EE_Admin_Page::add_query_args_and_nonce(
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
                             ),
702 702
                             $link_text_and_title,
703 703
                             $link_text_and_title,
704
-                            'deactivate_' . $payment_method->slug(),
704
+                            'deactivate_'.$payment_method->slug(),
705 705
                             'button button--secondary'
706 706
                         )
707 707
                     )
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
         );
728 728
         return new EE_Form_Section_Proper(
729 729
             array(
730
-                'name'            => 'activate_' . $payment_method->slug() . '_settings_form',
731
-                'html_id'         => 'activate_' . $payment_method->slug() . '_settings_form',
730
+                'name'            => 'activate_'.$payment_method->slug().'_settings_form',
731
+                'html_id'         => 'activate_'.$payment_method->slug().'_settings_form',
732 732
                 'action'          => '#',
733 733
                 'layout_strategy' => new EE_Admin_Two_Column_Layout(),
734 734
                 'subsections'     => apply_filters(
@@ -744,11 +744,11 @@  discard block
 block discarded – undo
744 744
                                         '',
745 745
                                         'colspan="2"'
746 746
                                     )
747
-                                ) .
747
+                                ).
748 748
                                 EEH_HTML::tr(
749 749
                                     EEH_HTML::th(
750 750
                                         EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso'))
751
-                                    ) .
751
+                                    ).
752 752
                                     EEH_HTML::td(
753 753
                                         EEH_HTML::link(
754 754
                                             EE_Admin_Page::add_query_args_and_nonce(
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
                                             ),
761 761
                                             $link_text_and_title,
762 762
                                             $link_text_and_title,
763
-                                            'activate_' . $payment_method->slug(),
763
+                                            'activate_'.$payment_method->slug(),
764 764
                                             'button button--primary-alt'
765 765
                                         )
766 766
                                     )
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
         return new EE_Form_Section_HTML(
787 787
             EEH_HTML::table(
788 788
                 EEH_HTML::tr(
789
-                    EEH_HTML::th() .
789
+                    EEH_HTML::th().
790 790
                     EEH_HTML::td(
791 791
                         EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
792 792
                     )
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
                 }
878 878
             }
879 879
             // if we couldn't find the correct payment method type...
880
-            if (! $correct_pmt_form_to_use) {
880
+            if ( ! $correct_pmt_form_to_use) {
881 881
                 EE_Error::add_error(
882 882
                     esc_html__(
883 883
                         "We could not find which payment method type your form submission related to. Please contact support",
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
             $correct_pmt_form_to_use->receive_form_submission($this->_req_data);
893 893
             if ($correct_pmt_form_to_use->is_valid()) {
894 894
                 $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings');
895
-                if (! $payment_settings_subform instanceof EE_Payment_Method_Form) {
895
+                if ( ! $payment_settings_subform instanceof EE_Payment_Method_Form) {
896 896
                     throw new EE_Error(
897 897
                         sprintf(
898 898
                             esc_html__(
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
         }
1088 1088
         // take into account search
1089 1089
         if (isset($this->_req_data['s']) && $this->_req_data['s']) {
1090
-            $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%');
1090
+            $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
1091 1091
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
1092 1092
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
1093 1093
             $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -1108,8 +1108,8 @@  discard block
 block discarded – undo
1108 1108
             $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
1109 1109
             $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
1110 1110
             // make sure our timestamps start and end right at the boundaries for each day
1111
-            $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
1112
-            $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
1111
+            $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1112
+            $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1113 1113
             // convert to timestamps
1114 1114
             $start_date = strtotime($start_date);
1115 1115
             $end_date = strtotime($end_date);
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
                 date('Y-m-d H:i:s', $start_date),
1123 1123
                 'Y-m-d H:i:s'
1124 1124
             );
1125
-            $end_date   = EEM_Change_Log::instance()->convert_datetime_for_query(
1125
+            $end_date = EEM_Change_Log::instance()->convert_datetime_for_query(
1126 1126
                 'LOG_time',
1127 1127
                 date('Y-m-d H:i:s', $end_date),
1128 1128
                 'Y-m-d H:i:s'
@@ -1141,23 +1141,23 @@  discard block
 block discarded – undo
1141 1141
             $query_params['order_by'] = array('LOG_time' => 'DESC');
1142 1142
         }
1143 1143
         $offset = ($current_page - 1) * $per_page;
1144
-        if (! isset($this->_req_data['download_results'])) {
1144
+        if ( ! isset($this->_req_data['download_results'])) {
1145 1145
             $query_params['limit'] = array($offset, $per_page);
1146 1146
         }
1147 1147
         // now they've requested to instead just download the file instead of viewing it.
1148 1148
         if (isset($this->_req_data['download_results'])) {
1149 1149
             $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
1150 1150
             header('Content-Disposition: attachment');
1151
-            header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url()));
1151
+            header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
1152 1152
             echo '<h1> '
1153 1153
                 . sprintf(
1154 1154
                     esc_html__('Payment Logs for %1$s', 'event_espresso'),
1155 1155
                     esc_url_raw(site_url())
1156 1156
                 )
1157 1157
                 . '</h1 >';
1158
-            echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>';
1158
+            echo '<h3>'.esc_html__('Query:', 'event_espresso').'</h3>';
1159 1159
             echo esc_html(var_export($query_params, true));
1160
-            echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>';
1160
+            echo '<h3>'.esc_html__('Results:', 'event_espresso').'</h3>';
1161 1161
             echo esc_html(var_export($wpdb_results, true));
1162 1162
             die;
1163 1163
         }
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
             }
1214 1214
         }
1215 1215
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1216
-            EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
1216
+            EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
1217 1217
             array(
1218 1218
                 'payment_log'    => $payment_log,
1219 1219
                 'payment_method' => $payment_method,
Please login to merge, or discard this patch.
core/services/graphql/connections/ConnectionCollection.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,86 +20,86 @@
 block discarded – undo
20 20
  */
21 21
 class ConnectionCollection extends Collection
22 22
 {
23
-    const COLLECTION_NAME = 'espresso_graphql_connections';
23
+	const COLLECTION_NAME = 'espresso_graphql_connections';
24 24
 
25
-    /**
26
-     * @var CollectionLoader $loader
27
-     */
28
-    protected $loader;
25
+	/**
26
+	 * @var CollectionLoader $loader
27
+	 */
28
+	protected $loader;
29 29
 
30
-    /**
31
-     * ConnectionCollection constructor
32
-     *
33
-     * @throws InvalidInterfaceException
34
-     */
35
-    public function __construct()
36
-    {
37
-        parent::__construct(
38
-            'EventEspresso\core\services\graphql\connections\ConnectionInterface',
39
-            ConnectionCollection::COLLECTION_NAME
40
-        );
41
-    }
30
+	/**
31
+	 * ConnectionCollection constructor
32
+	 *
33
+	 * @throws InvalidInterfaceException
34
+	 */
35
+	public function __construct()
36
+	{
37
+		parent::__construct(
38
+			'EventEspresso\core\services\graphql\connections\ConnectionInterface',
39
+			ConnectionCollection::COLLECTION_NAME
40
+		);
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @throws CollectionDetailsException
46
-     * @throws CollectionLoaderException
47
-     * @since $VID:$
48
-     */
49
-    private function loadCollection()
50
-    {
51
-        if (! $this->loader instanceof CollectionLoader) {
52
-            $this->loader = new CollectionLoader(
53
-                new CollectionDetails(
54
-                    // collection name
55
-                    ConnectionCollection::COLLECTION_NAME,
56
-                    // collection interface
57
-                    'EventEspresso\core\services\graphql\connections\ConnectionInterface',
58
-                    // FQCNs for classes to add (all classes within each namespace will be loaded)
59
-                    apply_filters(
60
-                        'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs',
61
-                        ['EventEspresso\core\domain\services\graphql\connections']
62
-                    ),
63
-                    // filepaths to classes to add
64
-                    array(),
65
-                    // file mask to use if parsing folder for files to add
66
-                    '',
67
-                    // what to use as identifier for collection entities
68
-                    // using CLASS NAME prevents duplicates (works like a singleton)
69
-                    CollectionDetails::ID_CLASS_NAME
70
-                ),
71
-                $this
72
-            );
73
-        }
74
-    }
44
+	/**
45
+	 * @throws CollectionDetailsException
46
+	 * @throws CollectionLoaderException
47
+	 * @since $VID:$
48
+	 */
49
+	private function loadCollection()
50
+	{
51
+		if (! $this->loader instanceof CollectionLoader) {
52
+			$this->loader = new CollectionLoader(
53
+				new CollectionDetails(
54
+					// collection name
55
+					ConnectionCollection::COLLECTION_NAME,
56
+					// collection interface
57
+					'EventEspresso\core\services\graphql\connections\ConnectionInterface',
58
+					// FQCNs for classes to add (all classes within each namespace will be loaded)
59
+					apply_filters(
60
+						'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs',
61
+						['EventEspresso\core\domain\services\graphql\connections']
62
+					),
63
+					// filepaths to classes to add
64
+					array(),
65
+					// file mask to use if parsing folder for files to add
66
+					'',
67
+					// what to use as identifier for collection entities
68
+					// using CLASS NAME prevents duplicates (works like a singleton)
69
+					CollectionDetails::ID_CLASS_NAME
70
+				),
71
+				$this
72
+			);
73
+		}
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * @return CollectionInterface
79
-     * @throws CollectionDetailsException
80
-     * @throws CollectionLoaderException
81
-     * @since $VID:$
82
-     */
83
-    public function loadConnections()
84
-    {
85
-        $this->loadCollection();
86
-        return $this->loader->getCollection();
87
-    }
77
+	/**
78
+	 * @return CollectionInterface
79
+	 * @throws CollectionDetailsException
80
+	 * @throws CollectionLoaderException
81
+	 * @since $VID:$
82
+	 */
83
+	public function loadConnections()
84
+	{
85
+		$this->loadCollection();
86
+		return $this->loader->getCollection();
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * getIdentifier
92
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
-     * If no $identifier is supplied, then the  fully qualified class name is used
94
-     *
95
-     * @param        $object
96
-     * @param mixed  $identifier
97
-     * @return string
98
-     */
99
-    public function getIdentifier($object, $identifier = null): string
100
-    {
101
-        return ! empty($identifier)
102
-            ? $identifier
103
-            : get_class($object);
104
-    }
90
+	/**
91
+	 * getIdentifier
92
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
+	 * If no $identifier is supplied, then the  fully qualified class name is used
94
+	 *
95
+	 * @param        $object
96
+	 * @param mixed  $identifier
97
+	 * @return string
98
+	 */
99
+	public function getIdentifier($object, $identifier = null): string
100
+	{
101
+		return ! empty($identifier)
102
+			? $identifier
103
+			: get_class($object);
104
+	}
105 105
 }
Please login to merge, or discard this patch.
core/services/graphql/enums/EnumCollection.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,86 +20,86 @@
 block discarded – undo
20 20
  */
21 21
 class EnumCollection extends Collection
22 22
 {
23
-    const COLLECTION_NAME = 'espresso_graphql_enums';
23
+	const COLLECTION_NAME = 'espresso_graphql_enums';
24 24
 
25
-    /**
26
-     * @var CollectionLoader $loader
27
-     */
28
-    protected $loader;
25
+	/**
26
+	 * @var CollectionLoader $loader
27
+	 */
28
+	protected $loader;
29 29
 
30
-    /**
31
-     * EnumCollection constructor
32
-     *
33
-     * @throws InvalidInterfaceException
34
-     */
35
-    public function __construct()
36
-    {
37
-        parent::__construct(
38
-            'EventEspresso\core\services\graphql\enums\EnumInterface',
39
-            EnumCollection::COLLECTION_NAME
40
-        );
41
-    }
30
+	/**
31
+	 * EnumCollection constructor
32
+	 *
33
+	 * @throws InvalidInterfaceException
34
+	 */
35
+	public function __construct()
36
+	{
37
+		parent::__construct(
38
+			'EventEspresso\core\services\graphql\enums\EnumInterface',
39
+			EnumCollection::COLLECTION_NAME
40
+		);
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @throws CollectionDetailsException
46
-     * @throws CollectionLoaderException
47
-     * @since $VID:$
48
-     */
49
-    private function loadCollection()
50
-    {
51
-        if (! $this->loader instanceof CollectionLoader) {
52
-            $this->loader = new CollectionLoader(
53
-                new CollectionDetails(
54
-                    // collection name
55
-                    EnumCollection::COLLECTION_NAME,
56
-                    // collection interface
57
-                    'EventEspresso\core\services\graphql\enums\EnumInterface',
58
-                    // FQCNs for classes to add (all classes within each namespace will be loaded)
59
-                    apply_filters(
60
-                        'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs',
61
-                        ['EventEspresso\core\domain\services\graphql\enums']
62
-                    ),
63
-                    // filepaths to classes to add
64
-                    array(),
65
-                    // file mask to use if parsing folder for files to add
66
-                    '',
67
-                    // what to use as identifier for collection entities
68
-                    // using CLASS NAME prevents duplicates (works like a singleton)
69
-                    CollectionDetails::ID_CLASS_NAME
70
-                ),
71
-                $this
72
-            );
73
-        }
74
-    }
44
+	/**
45
+	 * @throws CollectionDetailsException
46
+	 * @throws CollectionLoaderException
47
+	 * @since $VID:$
48
+	 */
49
+	private function loadCollection()
50
+	{
51
+		if (! $this->loader instanceof CollectionLoader) {
52
+			$this->loader = new CollectionLoader(
53
+				new CollectionDetails(
54
+					// collection name
55
+					EnumCollection::COLLECTION_NAME,
56
+					// collection interface
57
+					'EventEspresso\core\services\graphql\enums\EnumInterface',
58
+					// FQCNs for classes to add (all classes within each namespace will be loaded)
59
+					apply_filters(
60
+						'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs',
61
+						['EventEspresso\core\domain\services\graphql\enums']
62
+					),
63
+					// filepaths to classes to add
64
+					array(),
65
+					// file mask to use if parsing folder for files to add
66
+					'',
67
+					// what to use as identifier for collection entities
68
+					// using CLASS NAME prevents duplicates (works like a singleton)
69
+					CollectionDetails::ID_CLASS_NAME
70
+				),
71
+				$this
72
+			);
73
+		}
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * @return CollectionInterface
79
-     * @throws CollectionDetailsException
80
-     * @throws CollectionLoaderException
81
-     * @since $VID:$
82
-     */
83
-    public function loadEnums()
84
-    {
85
-        $this->loadCollection();
86
-        return $this->loader->getCollection();
87
-    }
77
+	/**
78
+	 * @return CollectionInterface
79
+	 * @throws CollectionDetailsException
80
+	 * @throws CollectionLoaderException
81
+	 * @since $VID:$
82
+	 */
83
+	public function loadEnums()
84
+	{
85
+		$this->loadCollection();
86
+		return $this->loader->getCollection();
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * getIdentifier
92
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
-     * If no $identifier is supplied, then the  fully qualified class name is used
94
-     *
95
-     * @param        $object
96
-     * @param mixed  $identifier
97
-     * @return string
98
-     */
99
-    public function getIdentifier($object, $identifier = null): string
100
-    {
101
-        return ! empty($identifier)
102
-            ? $identifier
103
-            : get_class($object);
104
-    }
90
+	/**
91
+	 * getIdentifier
92
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
+	 * If no $identifier is supplied, then the  fully qualified class name is used
94
+	 *
95
+	 * @param        $object
96
+	 * @param mixed  $identifier
97
+	 * @return string
98
+	 */
99
+	public function getIdentifier($object, $identifier = null): string
100
+	{
101
+		return ! empty($identifier)
102
+			? $identifier
103
+			: get_class($object);
104
+	}
105 105
 }
Please login to merge, or discard this patch.
core/services/graphql/types/TypeCollection.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -20,89 +20,89 @@
 block discarded – undo
20 20
  */
21 21
 class TypeCollection extends Collection
22 22
 {
23
-    const COLLECTION_NAME = 'espresso_graphql_types';
23
+	const COLLECTION_NAME = 'espresso_graphql_types';
24 24
 
25
-    const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface';
25
+	const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface';
26 26
 
27
-    /**
28
-     * @var CollectionLoader $loader
29
-     */
30
-    protected $loader;
27
+	/**
28
+	 * @var CollectionLoader $loader
29
+	 */
30
+	protected $loader;
31 31
 
32 32
 
33
-    /**
34
-     * TypeCollection constructor
35
-     *
36
-     * @throws InvalidInterfaceException
37
-     */
38
-    public function __construct()
39
-    {
40
-        parent::__construct(
41
-            TypeCollection::COLLECTION_INTERFACE,
42
-            TypeCollection::COLLECTION_NAME
43
-        );
44
-    }
33
+	/**
34
+	 * TypeCollection constructor
35
+	 *
36
+	 * @throws InvalidInterfaceException
37
+	 */
38
+	public function __construct()
39
+	{
40
+		parent::__construct(
41
+			TypeCollection::COLLECTION_INTERFACE,
42
+			TypeCollection::COLLECTION_NAME
43
+		);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * @throws CollectionDetailsException
49
-     * @throws CollectionLoaderException
50
-     * @since $VID:$
51
-     */
52
-    private function loadCollection()
53
-    {
54
-        if (! $this->loader instanceof CollectionLoader) {
55
-            $this->loader = new CollectionLoader(
56
-                new CollectionDetails(
57
-                    // collection name
58
-                    TypeCollection::COLLECTION_NAME,
59
-                    // collection interface
60
-                    TypeCollection::COLLECTION_INTERFACE,
61
-                    // FQCNs for classes to add (all classes within each namespace will be loaded)
62
-                    apply_filters(
63
-                        'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs',
64
-                        ['EventEspresso\core\domain\services\graphql\types']
65
-                    ),
66
-                    // filepaths to classes to add
67
-                    array(),
68
-                    // file mask to use if parsing folder for files to add
69
-                    '',
70
-                    // what to use as identifier for collection entities
71
-                    // using CLASS NAME prevents duplicates (works like a singleton)
72
-                    CollectionDetails::ID_CLASS_NAME
73
-                ),
74
-                $this
75
-            );
76
-        }
77
-    }
47
+	/**
48
+	 * @throws CollectionDetailsException
49
+	 * @throws CollectionLoaderException
50
+	 * @since $VID:$
51
+	 */
52
+	private function loadCollection()
53
+	{
54
+		if (! $this->loader instanceof CollectionLoader) {
55
+			$this->loader = new CollectionLoader(
56
+				new CollectionDetails(
57
+					// collection name
58
+					TypeCollection::COLLECTION_NAME,
59
+					// collection interface
60
+					TypeCollection::COLLECTION_INTERFACE,
61
+					// FQCNs for classes to add (all classes within each namespace will be loaded)
62
+					apply_filters(
63
+						'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs',
64
+						['EventEspresso\core\domain\services\graphql\types']
65
+					),
66
+					// filepaths to classes to add
67
+					array(),
68
+					// file mask to use if parsing folder for files to add
69
+					'',
70
+					// what to use as identifier for collection entities
71
+					// using CLASS NAME prevents duplicates (works like a singleton)
72
+					CollectionDetails::ID_CLASS_NAME
73
+				),
74
+				$this
75
+			);
76
+		}
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * @return CollectionInterface
82
-     * @throws CollectionDetailsException
83
-     * @throws CollectionLoaderException
84
-     * @since $VID:$
85
-     */
86
-    public function loadTypes()
87
-    {
88
-        $this->loadCollection();
89
-        return $this->loader->getCollection();
90
-    }
80
+	/**
81
+	 * @return CollectionInterface
82
+	 * @throws CollectionDetailsException
83
+	 * @throws CollectionLoaderException
84
+	 * @since $VID:$
85
+	 */
86
+	public function loadTypes()
87
+	{
88
+		$this->loadCollection();
89
+		return $this->loader->getCollection();
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * getIdentifier
95
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
96
-     * If no $identifier is supplied, then the  fully qualified class name is used
97
-     *
98
-     * @param        $object
99
-     * @param mixed  $identifier
100
-     * @return string
101
-     */
102
-    public function getIdentifier($object, $identifier = null): string
103
-    {
104
-        return ! empty($identifier)
105
-            ? $identifier
106
-            : get_class($object);
107
-    }
93
+	/**
94
+	 * getIdentifier
95
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
96
+	 * If no $identifier is supplied, then the  fully qualified class name is used
97
+	 *
98
+	 * @param        $object
99
+	 * @param mixed  $identifier
100
+	 * @return string
101
+	 */
102
+	public function getIdentifier($object, $identifier = null): string
103
+	{
104
+		return ! empty($identifier)
105
+			? $identifier
106
+			: get_class($object);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
core/services/graphql/inputs/InputCollection.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,86 +20,86 @@
 block discarded – undo
20 20
  */
21 21
 class InputCollection extends Collection
22 22
 {
23
-    const COLLECTION_NAME = 'espresso_graphql_inputs';
23
+	const COLLECTION_NAME = 'espresso_graphql_inputs';
24 24
 
25
-    /**
26
-     * @var CollectionLoader $loader
27
-     */
28
-    protected $loader;
25
+	/**
26
+	 * @var CollectionLoader $loader
27
+	 */
28
+	protected $loader;
29 29
 
30
-    /**
31
-     * InputCollection constructor
32
-     *
33
-     * @throws InvalidInterfaceException
34
-     */
35
-    public function __construct()
36
-    {
37
-        parent::__construct(
38
-            'EventEspresso\core\services\graphql\inputs\InputInterface',
39
-            InputCollection::COLLECTION_NAME
40
-        );
41
-    }
30
+	/**
31
+	 * InputCollection constructor
32
+	 *
33
+	 * @throws InvalidInterfaceException
34
+	 */
35
+	public function __construct()
36
+	{
37
+		parent::__construct(
38
+			'EventEspresso\core\services\graphql\inputs\InputInterface',
39
+			InputCollection::COLLECTION_NAME
40
+		);
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @throws CollectionDetailsException
46
-     * @throws CollectionLoaderException
47
-     * @since $VID:$
48
-     */
49
-    private function loadCollection()
50
-    {
51
-        if (! $this->loader instanceof CollectionLoader) {
52
-            $this->loader = new CollectionLoader(
53
-                new CollectionDetails(
54
-                    // collection name
55
-                    InputCollection::COLLECTION_NAME,
56
-                    // collection interface
57
-                    'EventEspresso\core\services\graphql\inputs\InputInterface',
58
-                    // FQCNs for classes to add (all classes within each namespace will be loaded)
59
-                    apply_filters(
60
-                        'FHEE__EventEspresso_core_services_graphql_InputCollection__loadCollection__collection_FQCNs',
61
-                        ['EventEspresso\core\domain\services\graphql\inputs']
62
-                    ),
63
-                    // filepaths to classes to add
64
-                    array(),
65
-                    // file mask to use if parsing folder for files to add
66
-                    '',
67
-                    // what to use as identifier for collection entities
68
-                    // using CLASS NAME prevents duplicates (works like a singleton)
69
-                    CollectionDetails::ID_CLASS_NAME
70
-                ),
71
-                $this
72
-            );
73
-        }
74
-    }
44
+	/**
45
+	 * @throws CollectionDetailsException
46
+	 * @throws CollectionLoaderException
47
+	 * @since $VID:$
48
+	 */
49
+	private function loadCollection()
50
+	{
51
+		if (! $this->loader instanceof CollectionLoader) {
52
+			$this->loader = new CollectionLoader(
53
+				new CollectionDetails(
54
+					// collection name
55
+					InputCollection::COLLECTION_NAME,
56
+					// collection interface
57
+					'EventEspresso\core\services\graphql\inputs\InputInterface',
58
+					// FQCNs for classes to add (all classes within each namespace will be loaded)
59
+					apply_filters(
60
+						'FHEE__EventEspresso_core_services_graphql_InputCollection__loadCollection__collection_FQCNs',
61
+						['EventEspresso\core\domain\services\graphql\inputs']
62
+					),
63
+					// filepaths to classes to add
64
+					array(),
65
+					// file mask to use if parsing folder for files to add
66
+					'',
67
+					// what to use as identifier for collection entities
68
+					// using CLASS NAME prevents duplicates (works like a singleton)
69
+					CollectionDetails::ID_CLASS_NAME
70
+				),
71
+				$this
72
+			);
73
+		}
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * @return CollectionInterface
79
-     * @throws CollectionDetailsException
80
-     * @throws CollectionLoaderException
81
-     * @since $VID:$
82
-     */
83
-    public function loadInputs()
84
-    {
85
-        $this->loadCollection();
86
-        return $this->loader->getCollection();
87
-    }
77
+	/**
78
+	 * @return CollectionInterface
79
+	 * @throws CollectionDetailsException
80
+	 * @throws CollectionLoaderException
81
+	 * @since $VID:$
82
+	 */
83
+	public function loadInputs()
84
+	{
85
+		$this->loadCollection();
86
+		return $this->loader->getCollection();
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * getIdentifier
92
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
-     * If no $identifier is supplied, then the  fully qualified class name is used
94
-     *
95
-     * @param        $object
96
-     * @param mixed  $identifier
97
-     * @return string
98
-     */
99
-    public function getIdentifier($object, $identifier = null): string
100
-    {
101
-        return ! empty($identifier)
102
-            ? $identifier
103
-            : get_class($object);
104
-    }
90
+	/**
91
+	 * getIdentifier
92
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
+	 * If no $identifier is supplied, then the  fully qualified class name is used
94
+	 *
95
+	 * @param        $object
96
+	 * @param mixed  $identifier
97
+	 * @return string
98
+	 */
99
+	public function getIdentifier($object, $identifier = null): string
100
+	{
101
+		return ! empty($identifier)
102
+			? $identifier
103
+			: get_class($object);
104
+	}
105 105
 }
Please login to merge, or discard this patch.
core/services/graphql/resolvers/ResolverCollection.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,86 +20,86 @@
 block discarded – undo
20 20
  */
21 21
 class ResolverCollection extends Collection
22 22
 {
23
-    const COLLECTION_NAME = 'espresso_graphql_resolvers';
23
+	const COLLECTION_NAME = 'espresso_graphql_resolvers';
24 24
 
25
-    /**
26
-     * @var CollectionLoader $loader
27
-     */
28
-    protected $loader;
25
+	/**
26
+	 * @var CollectionLoader $loader
27
+	 */
28
+	protected $loader;
29 29
 
30
-    /**
31
-     * ResolverCollection constructor
32
-     *
33
-     * @throws InvalidInterfaceException
34
-     */
35
-    public function __construct()
36
-    {
37
-        parent::__construct(
38
-            'EventEspresso\core\services\graphql\ResolverInterface',
39
-            ResolverCollection::COLLECTION_NAME
40
-        );
41
-    }
30
+	/**
31
+	 * ResolverCollection constructor
32
+	 *
33
+	 * @throws InvalidInterfaceException
34
+	 */
35
+	public function __construct()
36
+	{
37
+		parent::__construct(
38
+			'EventEspresso\core\services\graphql\ResolverInterface',
39
+			ResolverCollection::COLLECTION_NAME
40
+		);
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @throws CollectionDetailsException
46
-     * @throws CollectionLoaderException
47
-     * @since $VID:$
48
-     */
49
-    private function loadCollection()
50
-    {
51
-        if (! $this->loader instanceof CollectionLoader) {
52
-            $this->loader = new CollectionLoader(
53
-                new CollectionDetails(
54
-                    // collection name
55
-                    ResolverCollection::COLLECTION_NAME,
56
-                    // collection interface
57
-                    'EventEspresso\core\services\graphql\ResolverInterface',
58
-                    // FQCNs for classes to add (all classes within each namespace will be loaded)
59
-                    apply_filters(
60
-                        'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs',
61
-                        ['EventEspresso\core\domain\services\graphql\resolvers']
62
-                    ),
63
-                    // filepaths to classes to add
64
-                    array(),
65
-                    // file mask to use if parsing folder for files to add
66
-                    '',
67
-                    // what to use as identifier for collection entities
68
-                    // using CLASS NAME prevents duplicates (works like a singleton)
69
-                    CollectionDetails::ID_CLASS_NAME
70
-                ),
71
-                $this
72
-            );
73
-        }
74
-    }
44
+	/**
45
+	 * @throws CollectionDetailsException
46
+	 * @throws CollectionLoaderException
47
+	 * @since $VID:$
48
+	 */
49
+	private function loadCollection()
50
+	{
51
+		if (! $this->loader instanceof CollectionLoader) {
52
+			$this->loader = new CollectionLoader(
53
+				new CollectionDetails(
54
+					// collection name
55
+					ResolverCollection::COLLECTION_NAME,
56
+					// collection interface
57
+					'EventEspresso\core\services\graphql\ResolverInterface',
58
+					// FQCNs for classes to add (all classes within each namespace will be loaded)
59
+					apply_filters(
60
+						'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs',
61
+						['EventEspresso\core\domain\services\graphql\resolvers']
62
+					),
63
+					// filepaths to classes to add
64
+					array(),
65
+					// file mask to use if parsing folder for files to add
66
+					'',
67
+					// what to use as identifier for collection entities
68
+					// using CLASS NAME prevents duplicates (works like a singleton)
69
+					CollectionDetails::ID_CLASS_NAME
70
+				),
71
+				$this
72
+			);
73
+		}
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * @return CollectionInterface
79
-     * @throws CollectionDetailsException
80
-     * @throws CollectionLoaderException
81
-     * @since $VID:$
82
-     */
83
-    public function loadResolvers()
84
-    {
85
-        $this->loadCollection();
86
-        return $this->loader->getCollection();
87
-    }
77
+	/**
78
+	 * @return CollectionInterface
79
+	 * @throws CollectionDetailsException
80
+	 * @throws CollectionLoaderException
81
+	 * @since $VID:$
82
+	 */
83
+	public function loadResolvers()
84
+	{
85
+		$this->loadCollection();
86
+		return $this->loader->getCollection();
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * getIdentifier
92
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
-     * If no $identifier is supplied, then the  fully qualified class name is used
94
-     *
95
-     * @param        $object
96
-     * @param mixed  $identifier
97
-     * @return string
98
-     */
99
-    public function getIdentifier($object, $identifier = null): string
100
-    {
101
-        return ! empty($identifier)
102
-            ? $identifier
103
-            : get_class($object);
104
-    }
90
+	/**
91
+	 * getIdentifier
92
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
93
+	 * If no $identifier is supplied, then the  fully qualified class name is used
94
+	 *
95
+	 * @param        $object
96
+	 * @param mixed  $identifier
97
+	 * @return string
98
+	 */
99
+	public function getIdentifier($object, $identifier = null): string
100
+	{
101
+		return ! empty($identifier)
102
+			? $identifier
103
+			: get_class($object);
104
+	}
105 105
 }
Please login to merge, or discard this patch.
core/services/orm/ModelFieldFactory.php 1 patch
Indentation   +622 added lines, -622 removed lines patch added patch discarded remove patch
@@ -47,626 +47,626 @@
 block discarded – undo
47 47
  */
48 48
 class ModelFieldFactory implements InterminableInterface
49 49
 {
50
-    /**
51
-     * @var LoaderInterface $loader
52
-     */
53
-    private $loader;
54
-
55
-
56
-    /**
57
-     * ModelFieldFactory constructor.
58
-     *
59
-     * @param LoaderInterface $loader
60
-     */
61
-    public function __construct(LoaderInterface $loader)
62
-    {
63
-        $this->loader = $loader;
64
-    }
65
-
66
-
67
-    /**
68
-     * @param string     $table_column
69
-     * @param string     $nice_name
70
-     * @param bool       $nullable
71
-     * @param mixed|null $default_value
72
-     * @return EE_All_Caps_Text_Field
73
-     */
74
-    public function createAllCapsTextField(
75
-        string $table_column,
76
-        string $nice_name,
77
-        bool $nullable,
78
-        $default_value = null
79
-    ): EE_All_Caps_Text_Field {
80
-        return $this->loader->getNew(
81
-            'EE_All_Caps_Text_Field',
82
-            [$table_column, $nice_name, $nullable, $default_value]
83
-        );
84
-    }
85
-
86
-
87
-    /**
88
-     * @param string     $table_column
89
-     * @param string     $nice_name
90
-     * @param bool       $nullable
91
-     * @param mixed|null $default_value
92
-     * @param string     $model_name
93
-     * @return EE_Any_Foreign_Model_Name_Field
94
-     */
95
-    public function createAnyForeignModelNameField(
96
-        string $table_column,
97
-        string $nice_name,
98
-        bool $nullable,
99
-        $default_value = null,
100
-        string $model_name = ''
101
-    ): EE_Any_Foreign_Model_Name_Field {
102
-        return $this->loader->getNew(
103
-            'EE_Any_Foreign_Model_Name_Field',
104
-            [$table_column, $nice_name, $nullable, $default_value, $model_name]
105
-        );
106
-    }
107
-
108
-
109
-    /**
110
-     * @param string     $table_column
111
-     * @param string     $nice_name
112
-     * @param bool       $nullable
113
-     * @param mixed|null $default_value
114
-     * @return EE_Boolean_Field
115
-     */
116
-    public function createBooleanField(
117
-        string $table_column,
118
-        string $nice_name,
119
-        bool $nullable,
120
-        $default_value = null
121
-    ): EE_Boolean_Field {
122
-        return $this->loader->getNew(
123
-            'EE_Boolean_Field',
124
-            [$table_column, $nice_name, $nullable, $default_value]
125
-        );
126
-    }
127
-
128
-
129
-    /**
130
-     * @param string      $table_column
131
-     * @param string      $nice_name
132
-     * @param bool|null   $nullable
133
-     * @param string|null $default_value
134
-     * @return EE_Datetime_Field
135
-     */
136
-    public function createDatetimeField(
137
-        string $table_column,
138
-        string $nice_name,
139
-        ?bool $nullable = false,
140
-        ?string $default_value = EE_Datetime_Field::now
141
-    ): EE_Datetime_Field {
142
-        return $this->loader->getNew(
143
-            'EE_Datetime_Field',
144
-            [
145
-                $table_column,
146
-                $nice_name,
147
-                $nullable,
148
-                $default_value,
149
-            ]
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     * @param string     $table_column
156
-     * @param string     $nice_name
157
-     * @param bool       $nullable
158
-     * @param mixed|null $default_value
159
-     * @return EE_DB_Only_Float_Field
160
-     */
161
-    public function createDbOnlyFloatField(
162
-        string $table_column,
163
-        string $nice_name,
164
-        bool $nullable,
165
-        $default_value = null
166
-    ): EE_DB_Only_Float_Field {
167
-        return $this->loader->getNew(
168
-            'EE_DB_Only_Float_Field',
169
-            [$table_column, $nice_name, $nullable, $default_value]
170
-        );
171
-    }
172
-
173
-
174
-    /**
175
-     * @param string     $table_column
176
-     * @param string     $nice_name
177
-     * @param bool       $nullable
178
-     * @param mixed|null $default_value
179
-     * @return EE_DB_Only_Int_Field
180
-     */
181
-    public function createDbOnlyIntField(
182
-        string $table_column,
183
-        string $nice_name,
184
-        bool $nullable,
185
-        $default_value = null
186
-    ): EE_DB_Only_Int_Field {
187
-        return $this->loader->getNew(
188
-            'EE_DB_Only_Int_Field',
189
-            [$table_column, $nice_name, $nullable, $default_value]
190
-        );
191
-    }
192
-
193
-
194
-    /**
195
-     * @param string     $table_column
196
-     * @param string     $nice_name
197
-     * @param bool       $nullable
198
-     * @param mixed|null $default_value
199
-     * @return EE_DB_Only_Text_Field
200
-     */
201
-    public function createDbOnlyTextField(
202
-        string $table_column,
203
-        string $nice_name,
204
-        bool $nullable,
205
-        $default_value = null
206
-    ): EE_DB_Only_Text_Field {
207
-        return $this->loader->getNew(
208
-            'EE_DB_Only_Text_Field',
209
-            [$table_column, $nice_name, $nullable, $default_value]
210
-        );
211
-    }
212
-
213
-
214
-    /**
215
-     * @param string      $table_column
216
-     * @param string      $nice_name
217
-     * @param bool        $nullable
218
-     * @param string|null $default_value
219
-     * @return EE_Email_Field
220
-     */
221
-    public function createEmailField(
222
-        string $table_column,
223
-        string $nice_name,
224
-        bool $nullable = true,
225
-        string $default_value = ''
226
-    ): EE_Email_Field {
227
-        return $this->loader->getNew(
228
-            'EE_Email_Field',
229
-            [$table_column, $nice_name, $nullable, $default_value]
230
-        );
231
-    }
232
-
233
-
234
-    /**
235
-     * @param string     $table_column
236
-     * @param string     $nice_name
237
-     * @param bool       $nullable
238
-     * @param mixed|null $default_value
239
-     * @param array      $allowed_enum_values keys are values to be used in the DB,
240
-     *                                        values are how they should be displayed
241
-     * @return EE_Enum_Integer_Field
242
-     */
243
-    public function createEnumIntegerField(
244
-        string $table_column,
245
-        string $nice_name,
246
-        bool $nullable,
247
-        $default_value = null,
248
-        array $allowed_enum_values = []
249
-    ): EE_Enum_Integer_Field {
250
-        return $this->loader->getNew(
251
-            'EE_Enum_Integer_Field',
252
-            [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
253
-        );
254
-    }
255
-
256
-
257
-    /**
258
-     * @param string     $table_column
259
-     * @param string     $nice_name
260
-     * @param bool       $nullable
261
-     * @param mixed|null $default_value
262
-     * @param array      $allowed_enum_values keys are values to be used in the DB,
263
-     *                                        values are how they should be displayed
264
-     * @return EE_Enum_Text_Field
265
-     */
266
-    public function createEnumTextField(
267
-        string $table_column,
268
-        string $nice_name,
269
-        bool $nullable,
270
-        $default_value,
271
-        array $allowed_enum_values
272
-    ): EE_Enum_Text_Field {
273
-        return $this->loader->getNew(
274
-            'EE_Enum_Text_Field',
275
-            [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
276
-        );
277
-    }
278
-
279
-
280
-    /**
281
-     * @param string     $table_column
282
-     * @param string     $nice_name
283
-     * @param bool       $nullable
284
-     * @param mixed|null $default_value
285
-     * @return EE_Float_Field
286
-     */
287
-    public function createFloatField(
288
-        string $table_column,
289
-        string $nice_name,
290
-        bool $nullable,
291
-        $default_value = null
292
-    ): EE_Float_Field {
293
-        return $this->loader->getNew(
294
-            'EE_Float_Field',
295
-            [$table_column, $nice_name, $nullable, $default_value]
296
-        );
297
-    }
298
-
299
-
300
-    /**
301
-     * @param string     $table_column
302
-     * @param string     $nice_name
303
-     * @param bool       $nullable
304
-     * @param mixed|null $default_value
305
-     * @param string     $model_name
306
-     * @return EE_Foreign_Key_Int_Field
307
-     */
308
-    public function createForeignKeyIntField(
309
-        string $table_column,
310
-        string $nice_name,
311
-        bool $nullable,
312
-        $default_value,
313
-        string $model_name
314
-    ): EE_Foreign_Key_Int_Field {
315
-        return $this->loader->getNew(
316
-            'EE_Foreign_Key_Int_Field',
317
-            [$table_column, $nice_name, $nullable, $default_value, $model_name]
318
-        );
319
-    }
320
-
321
-
322
-    /**
323
-     * @param string     $table_column
324
-     * @param string     $nice_name
325
-     * @param bool       $nullable
326
-     * @param mixed|null $default_value
327
-     * @param string     $model_name
328
-     * @return EE_Foreign_Key_String_Field
329
-     */
330
-    public function createForeignKeyStringField(
331
-        string $table_column,
332
-        string $nice_name,
333
-        bool $nullable,
334
-        $default_value,
335
-        string $model_name
336
-    ): EE_Foreign_Key_String_Field {
337
-        return $this->loader->getNew(
338
-            'EE_Foreign_Key_String_Field',
339
-            [$table_column, $nice_name, $nullable, $default_value, $model_name]
340
-        );
341
-    }
342
-
343
-
344
-    /**
345
-     * @param string     $table_column
346
-     * @param string     $nice_name
347
-     * @param bool       $nullable
348
-     * @param mixed|null $default_value
349
-     * @return EE_Full_HTML_Field
350
-     */
351
-    public function createFullHtmlField(
352
-        string $table_column,
353
-        string $nice_name,
354
-        bool $nullable,
355
-        $default_value = null
356
-    ): EE_Full_HTML_Field {
357
-        return $this->loader->getNew(
358
-            'EE_Full_HTML_Field',
359
-            [$table_column, $nice_name, $nullable, $default_value]
360
-        );
361
-    }
362
-
363
-
364
-    /**
365
-     * @param string     $table_column
366
-     * @param string     $nice_name
367
-     * @param bool       $nullable
368
-     * @param mixed|null $default_value
369
-     * @return EE_Infinite_Integer_Field
370
-     */
371
-    public function createInfiniteIntegerField(
372
-        string $table_column,
373
-        string $nice_name,
374
-        bool $nullable,
375
-        $default_value = null
376
-    ): EE_Infinite_Integer_Field {
377
-        return $this->loader->getNew(
378
-            'EE_Infinite_Integer_Field',
379
-            [$table_column, $nice_name, $nullable, $default_value]
380
-        );
381
-    }
382
-
383
-
384
-    /**
385
-     * @param string $table_column
386
-     * @param string $nice_name
387
-     * @param bool   $nullable
388
-     * @param int    $default_value
389
-     * @return EE_Integer_Field
390
-     */
391
-    public function createIntegerField(
392
-        string $table_column,
393
-        string $nice_name,
394
-        bool $nullable = false,
395
-        int $default_value = 0
396
-    ): EE_Integer_Field {
397
-        return $this->loader->getNew(
398
-            'EE_Integer_Field',
399
-            [$table_column, $nice_name, $nullable, $default_value]
400
-        );
401
-    }
402
-
403
-
404
-    /**
405
-     * @param string     $table_column
406
-     * @param string     $nice_name
407
-     * @param bool       $nullable
408
-     * @param mixed|null $default_value
409
-     * @return EE_Maybe_Serialized_Simple_HTML_Field
410
-     */
411
-    public function createMaybeSerializedSimpleHtmlField(
412
-        string $table_column,
413
-        string $nice_name,
414
-        bool $nullable,
415
-        $default_value = null
416
-    ): EE_Maybe_Serialized_Simple_HTML_Field {
417
-        return $this->loader->getNew(
418
-            'EE_Maybe_Serialized_Simple_HTML_Field',
419
-            [$table_column, $nice_name, $nullable, $default_value]
420
-        );
421
-    }
422
-
423
-
424
-    /**
425
-     * @param string     $table_column
426
-     * @param string     $nice_name
427
-     * @param bool       $nullable
428
-     * @param mixed|null $default_value
429
-     * @return EE_Maybe_Serialized_Text_Field
430
-     */
431
-    public function createMaybeSerializedTextField(
432
-        string $table_column,
433
-        string $nice_name,
434
-        bool $nullable,
435
-        $default_value = null
436
-    ): EE_Maybe_Serialized_Text_Field {
437
-        return $this->loader->getNew(
438
-            'EE_Maybe_Serialized_Text_Field',
439
-            [$table_column, $nice_name, $nullable, $default_value]
440
-        );
441
-    }
442
-
443
-
444
-    /**
445
-     * @param string     $table_column
446
-     * @param string     $nice_name
447
-     * @param bool       $nullable
448
-     * @param mixed|null $default_value
449
-     * @return EE_Money_Field
450
-     */
451
-    public function createMoneyField(
452
-        string $table_column,
453
-        string $nice_name,
454
-        bool $nullable,
455
-        $default_value = null
456
-    ): EE_Money_Field {
457
-        return $this->loader->getNew(
458
-            'EE_Money_Field',
459
-            [$table_column, $nice_name, $nullable, $default_value]
460
-        );
461
-    }
462
-
463
-
464
-    /**
465
-     * @param string $table_column
466
-     * @param string $nice_name
467
-     * @param bool   $nullable
468
-     * @param string $default_value
469
-     * @return EE_Plain_Text_Field
470
-     */
471
-    public function createPlainTextField(
472
-        string $table_column,
473
-        string $nice_name,
474
-        bool $nullable = true,
475
-        string $default_value = ''
476
-    ): EE_Plain_Text_Field {
477
-        return $this->loader->getNew(
478
-            'EE_Plain_Text_Field',
479
-            [$table_column, $nice_name, $nullable, $default_value]
480
-        );
481
-    }
482
-
483
-
484
-    /**
485
-     * @param string     $table_column
486
-     * @param string     $nice_name
487
-     * @param bool       $nullable
488
-     * @param mixed|null $default_value
489
-     * @return EE_Post_Content_Field
490
-     */
491
-    public function createPostContentField(
492
-        string $table_column,
493
-        string $nice_name,
494
-        bool $nullable,
495
-        $default_value = null
496
-    ): EE_Post_Content_Field {
497
-        return $this->loader->getNew(
498
-            'EE_Post_Content_Field',
499
-            [$table_column, $nice_name, $nullable, $default_value]
500
-        );
501
-    }
502
-
503
-
504
-    /**
505
-     * @param string $table_column
506
-     * @param string $nice_name
507
-     * @return EE_Primary_Key_Int_Field
508
-     */
509
-    public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field
510
-    {
511
-        return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]);
512
-    }
513
-
514
-
515
-    /**
516
-     * @param string $table_column
517
-     * @param string $nice_name
518
-     * @return EE_Primary_Key_String_Field
519
-     */
520
-    public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field
521
-    {
522
-        return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]);
523
-    }
524
-
525
-
526
-    /**
527
-     * @param string     $table_column
528
-     * @param string     $nice_name
529
-     * @param bool       $nullable
530
-     * @param mixed|null $default_value
531
-     * @return EE_Serialized_Text_Field
532
-     */
533
-    public function createSerializedTextField(
534
-        string $table_column,
535
-        string $nice_name,
536
-        bool $nullable,
537
-        $default_value = null
538
-    ): EE_Serialized_Text_Field {
539
-        return $this->loader->getNew(
540
-            'EE_Serialized_Text_Field',
541
-            [$table_column, $nice_name, $nullable, $default_value]
542
-        );
543
-    }
544
-
545
-
546
-    /**
547
-     * @param string     $table_column
548
-     * @param string     $nice_name
549
-     * @param bool       $nullable
550
-     * @param mixed|null $default_value
551
-     * @return EE_Simple_HTML_Field
552
-     */
553
-    public function createSimpleHtmlField(
554
-        string $table_column,
555
-        string $nice_name,
556
-        bool $nullable,
557
-        $default_value = null
558
-    ): EE_Simple_HTML_Field {
559
-        return $this->loader->getNew(
560
-            'EE_Simple_HTML_Field',
561
-            [$table_column, $nice_name, $nullable, $default_value]
562
-        );
563
-    }
564
-
565
-
566
-    /**
567
-     * @param string     $table_column
568
-     * @param string     $nice_name
569
-     * @param bool       $nullable
570
-     * @param mixed|null $default_value
571
-     * @return EE_Slug_Field
572
-     */
573
-    public function createSlugField(
574
-        string $table_column,
575
-        string $nice_name,
576
-        bool $nullable = false,
577
-        $default_value = null
578
-    ): EE_Slug_Field {
579
-        return $this->loader->getNew(
580
-            'EE_Slug_Field',
581
-            [$table_column, $nice_name, $nullable, $default_value]
582
-        );
583
-    }
584
-
585
-
586
-    /**
587
-     * @param string     $table_column
588
-     * @param string     $nice_name
589
-     * @param bool       $nullable
590
-     * @param mixed|null $default_value
591
-     * @return EE_Trashed_Flag_Field
592
-     */
593
-    public function createTrashedFlagField(
594
-        string $table_column,
595
-        string $nice_name,
596
-        bool $nullable,
597
-        $default_value = null
598
-    ): EE_Trashed_Flag_Field {
599
-        return $this->loader->getNew(
600
-            'EE_Trashed_Flag_Field',
601
-            [$table_column, $nice_name, $nullable, $default_value]
602
-        );
603
-    }
604
-
605
-
606
-    /**
607
-     * @param string $table_column
608
-     * @param string $nice_name
609
-     * @param bool   $nullable
610
-     * @param mixed  $default_value
611
-     * @param array $values     If additional statuses are to be used other than the default WP statuses,
612
-     *                          then they can be registered via this property.
613
-     *                          The format of the array should be as follows:
614
-     *                          [
615
-     *                              'status_reference' => [
616
-     *                                  'label' => __('Status Reference Label', 'event_espresso'),
617
-     *                                  // whether status is shown on the frontend of the site
618
-     *                                  'public' => true,
619
-     *                                  // whether status is excluded from wp searches
620
-     *                                  'exclude_from_search' => false,
621
-     *                                  // whether status is included in queries
622
-     *                                  for the admin 'all' view in list table views.
623
-     *                                  'show_in_admin_all_list' => true,
624
-     *                                  // show in the list of statuses with post counts
625
-     *                                  // at the top of the admin list tables (i.e. Status Reference(2) )
626
-     *                                  'show_in_admin_status_list' => true,
627
-     *                                  // the text to display on the admin screen
628
-     *                                  // ( or you won't see your status count )
629
-     *                                  'label_count' => _n_noop(
630
-     *                                      'Status Reference <span class="count">(%s)</span>',
631
-     *                                      'Status References <span class="count">(%s)</span>'
632
-     *                                  ),
633
-     *                              ]
634
-     *                          ]
635
-     * @return EE_WP_Post_Status_Field
636
-     * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
637
-     */
638
-    public function createWpPostStatusField(
639
-        string $table_column,
640
-        string $nice_name,
641
-        bool $nullable,
642
-        $default_value = null,
643
-        array $values = []
644
-    ): EE_WP_Post_Status_Field {
645
-        return $this->loader->getNew(
646
-            'EE_WP_Post_Status_Field',
647
-            [$table_column, $nice_name, $nullable, $default_value, $values]
648
-        );
649
-    }
650
-
651
-
652
-    /**
653
-     * @param string $post_type
654
-     * @return EE_WP_Post_Type_Field
655
-     */
656
-    public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field
657
-    {
658
-        return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]);
659
-    }
660
-
661
-
662
-    /**
663
-     * @param string $table_column
664
-     * @param string $nice_name
665
-     * @param bool   $nullable
666
-     * @return EE_WP_User_Field
667
-     */
668
-    public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field
669
-    {
670
-        return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]);
671
-    }
50
+	/**
51
+	 * @var LoaderInterface $loader
52
+	 */
53
+	private $loader;
54
+
55
+
56
+	/**
57
+	 * ModelFieldFactory constructor.
58
+	 *
59
+	 * @param LoaderInterface $loader
60
+	 */
61
+	public function __construct(LoaderInterface $loader)
62
+	{
63
+		$this->loader = $loader;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param string     $table_column
69
+	 * @param string     $nice_name
70
+	 * @param bool       $nullable
71
+	 * @param mixed|null $default_value
72
+	 * @return EE_All_Caps_Text_Field
73
+	 */
74
+	public function createAllCapsTextField(
75
+		string $table_column,
76
+		string $nice_name,
77
+		bool $nullable,
78
+		$default_value = null
79
+	): EE_All_Caps_Text_Field {
80
+		return $this->loader->getNew(
81
+			'EE_All_Caps_Text_Field',
82
+			[$table_column, $nice_name, $nullable, $default_value]
83
+		);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param string     $table_column
89
+	 * @param string     $nice_name
90
+	 * @param bool       $nullable
91
+	 * @param mixed|null $default_value
92
+	 * @param string     $model_name
93
+	 * @return EE_Any_Foreign_Model_Name_Field
94
+	 */
95
+	public function createAnyForeignModelNameField(
96
+		string $table_column,
97
+		string $nice_name,
98
+		bool $nullable,
99
+		$default_value = null,
100
+		string $model_name = ''
101
+	): EE_Any_Foreign_Model_Name_Field {
102
+		return $this->loader->getNew(
103
+			'EE_Any_Foreign_Model_Name_Field',
104
+			[$table_column, $nice_name, $nullable, $default_value, $model_name]
105
+		);
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param string     $table_column
111
+	 * @param string     $nice_name
112
+	 * @param bool       $nullable
113
+	 * @param mixed|null $default_value
114
+	 * @return EE_Boolean_Field
115
+	 */
116
+	public function createBooleanField(
117
+		string $table_column,
118
+		string $nice_name,
119
+		bool $nullable,
120
+		$default_value = null
121
+	): EE_Boolean_Field {
122
+		return $this->loader->getNew(
123
+			'EE_Boolean_Field',
124
+			[$table_column, $nice_name, $nullable, $default_value]
125
+		);
126
+	}
127
+
128
+
129
+	/**
130
+	 * @param string      $table_column
131
+	 * @param string      $nice_name
132
+	 * @param bool|null   $nullable
133
+	 * @param string|null $default_value
134
+	 * @return EE_Datetime_Field
135
+	 */
136
+	public function createDatetimeField(
137
+		string $table_column,
138
+		string $nice_name,
139
+		?bool $nullable = false,
140
+		?string $default_value = EE_Datetime_Field::now
141
+	): EE_Datetime_Field {
142
+		return $this->loader->getNew(
143
+			'EE_Datetime_Field',
144
+			[
145
+				$table_column,
146
+				$nice_name,
147
+				$nullable,
148
+				$default_value,
149
+			]
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 * @param string     $table_column
156
+	 * @param string     $nice_name
157
+	 * @param bool       $nullable
158
+	 * @param mixed|null $default_value
159
+	 * @return EE_DB_Only_Float_Field
160
+	 */
161
+	public function createDbOnlyFloatField(
162
+		string $table_column,
163
+		string $nice_name,
164
+		bool $nullable,
165
+		$default_value = null
166
+	): EE_DB_Only_Float_Field {
167
+		return $this->loader->getNew(
168
+			'EE_DB_Only_Float_Field',
169
+			[$table_column, $nice_name, $nullable, $default_value]
170
+		);
171
+	}
172
+
173
+
174
+	/**
175
+	 * @param string     $table_column
176
+	 * @param string     $nice_name
177
+	 * @param bool       $nullable
178
+	 * @param mixed|null $default_value
179
+	 * @return EE_DB_Only_Int_Field
180
+	 */
181
+	public function createDbOnlyIntField(
182
+		string $table_column,
183
+		string $nice_name,
184
+		bool $nullable,
185
+		$default_value = null
186
+	): EE_DB_Only_Int_Field {
187
+		return $this->loader->getNew(
188
+			'EE_DB_Only_Int_Field',
189
+			[$table_column, $nice_name, $nullable, $default_value]
190
+		);
191
+	}
192
+
193
+
194
+	/**
195
+	 * @param string     $table_column
196
+	 * @param string     $nice_name
197
+	 * @param bool       $nullable
198
+	 * @param mixed|null $default_value
199
+	 * @return EE_DB_Only_Text_Field
200
+	 */
201
+	public function createDbOnlyTextField(
202
+		string $table_column,
203
+		string $nice_name,
204
+		bool $nullable,
205
+		$default_value = null
206
+	): EE_DB_Only_Text_Field {
207
+		return $this->loader->getNew(
208
+			'EE_DB_Only_Text_Field',
209
+			[$table_column, $nice_name, $nullable, $default_value]
210
+		);
211
+	}
212
+
213
+
214
+	/**
215
+	 * @param string      $table_column
216
+	 * @param string      $nice_name
217
+	 * @param bool        $nullable
218
+	 * @param string|null $default_value
219
+	 * @return EE_Email_Field
220
+	 */
221
+	public function createEmailField(
222
+		string $table_column,
223
+		string $nice_name,
224
+		bool $nullable = true,
225
+		string $default_value = ''
226
+	): EE_Email_Field {
227
+		return $this->loader->getNew(
228
+			'EE_Email_Field',
229
+			[$table_column, $nice_name, $nullable, $default_value]
230
+		);
231
+	}
232
+
233
+
234
+	/**
235
+	 * @param string     $table_column
236
+	 * @param string     $nice_name
237
+	 * @param bool       $nullable
238
+	 * @param mixed|null $default_value
239
+	 * @param array      $allowed_enum_values keys are values to be used in the DB,
240
+	 *                                        values are how they should be displayed
241
+	 * @return EE_Enum_Integer_Field
242
+	 */
243
+	public function createEnumIntegerField(
244
+		string $table_column,
245
+		string $nice_name,
246
+		bool $nullable,
247
+		$default_value = null,
248
+		array $allowed_enum_values = []
249
+	): EE_Enum_Integer_Field {
250
+		return $this->loader->getNew(
251
+			'EE_Enum_Integer_Field',
252
+			[$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
253
+		);
254
+	}
255
+
256
+
257
+	/**
258
+	 * @param string     $table_column
259
+	 * @param string     $nice_name
260
+	 * @param bool       $nullable
261
+	 * @param mixed|null $default_value
262
+	 * @param array      $allowed_enum_values keys are values to be used in the DB,
263
+	 *                                        values are how they should be displayed
264
+	 * @return EE_Enum_Text_Field
265
+	 */
266
+	public function createEnumTextField(
267
+		string $table_column,
268
+		string $nice_name,
269
+		bool $nullable,
270
+		$default_value,
271
+		array $allowed_enum_values
272
+	): EE_Enum_Text_Field {
273
+		return $this->loader->getNew(
274
+			'EE_Enum_Text_Field',
275
+			[$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values]
276
+		);
277
+	}
278
+
279
+
280
+	/**
281
+	 * @param string     $table_column
282
+	 * @param string     $nice_name
283
+	 * @param bool       $nullable
284
+	 * @param mixed|null $default_value
285
+	 * @return EE_Float_Field
286
+	 */
287
+	public function createFloatField(
288
+		string $table_column,
289
+		string $nice_name,
290
+		bool $nullable,
291
+		$default_value = null
292
+	): EE_Float_Field {
293
+		return $this->loader->getNew(
294
+			'EE_Float_Field',
295
+			[$table_column, $nice_name, $nullable, $default_value]
296
+		);
297
+	}
298
+
299
+
300
+	/**
301
+	 * @param string     $table_column
302
+	 * @param string     $nice_name
303
+	 * @param bool       $nullable
304
+	 * @param mixed|null $default_value
305
+	 * @param string     $model_name
306
+	 * @return EE_Foreign_Key_Int_Field
307
+	 */
308
+	public function createForeignKeyIntField(
309
+		string $table_column,
310
+		string $nice_name,
311
+		bool $nullable,
312
+		$default_value,
313
+		string $model_name
314
+	): EE_Foreign_Key_Int_Field {
315
+		return $this->loader->getNew(
316
+			'EE_Foreign_Key_Int_Field',
317
+			[$table_column, $nice_name, $nullable, $default_value, $model_name]
318
+		);
319
+	}
320
+
321
+
322
+	/**
323
+	 * @param string     $table_column
324
+	 * @param string     $nice_name
325
+	 * @param bool       $nullable
326
+	 * @param mixed|null $default_value
327
+	 * @param string     $model_name
328
+	 * @return EE_Foreign_Key_String_Field
329
+	 */
330
+	public function createForeignKeyStringField(
331
+		string $table_column,
332
+		string $nice_name,
333
+		bool $nullable,
334
+		$default_value,
335
+		string $model_name
336
+	): EE_Foreign_Key_String_Field {
337
+		return $this->loader->getNew(
338
+			'EE_Foreign_Key_String_Field',
339
+			[$table_column, $nice_name, $nullable, $default_value, $model_name]
340
+		);
341
+	}
342
+
343
+
344
+	/**
345
+	 * @param string     $table_column
346
+	 * @param string     $nice_name
347
+	 * @param bool       $nullable
348
+	 * @param mixed|null $default_value
349
+	 * @return EE_Full_HTML_Field
350
+	 */
351
+	public function createFullHtmlField(
352
+		string $table_column,
353
+		string $nice_name,
354
+		bool $nullable,
355
+		$default_value = null
356
+	): EE_Full_HTML_Field {
357
+		return $this->loader->getNew(
358
+			'EE_Full_HTML_Field',
359
+			[$table_column, $nice_name, $nullable, $default_value]
360
+		);
361
+	}
362
+
363
+
364
+	/**
365
+	 * @param string     $table_column
366
+	 * @param string     $nice_name
367
+	 * @param bool       $nullable
368
+	 * @param mixed|null $default_value
369
+	 * @return EE_Infinite_Integer_Field
370
+	 */
371
+	public function createInfiniteIntegerField(
372
+		string $table_column,
373
+		string $nice_name,
374
+		bool $nullable,
375
+		$default_value = null
376
+	): EE_Infinite_Integer_Field {
377
+		return $this->loader->getNew(
378
+			'EE_Infinite_Integer_Field',
379
+			[$table_column, $nice_name, $nullable, $default_value]
380
+		);
381
+	}
382
+
383
+
384
+	/**
385
+	 * @param string $table_column
386
+	 * @param string $nice_name
387
+	 * @param bool   $nullable
388
+	 * @param int    $default_value
389
+	 * @return EE_Integer_Field
390
+	 */
391
+	public function createIntegerField(
392
+		string $table_column,
393
+		string $nice_name,
394
+		bool $nullable = false,
395
+		int $default_value = 0
396
+	): EE_Integer_Field {
397
+		return $this->loader->getNew(
398
+			'EE_Integer_Field',
399
+			[$table_column, $nice_name, $nullable, $default_value]
400
+		);
401
+	}
402
+
403
+
404
+	/**
405
+	 * @param string     $table_column
406
+	 * @param string     $nice_name
407
+	 * @param bool       $nullable
408
+	 * @param mixed|null $default_value
409
+	 * @return EE_Maybe_Serialized_Simple_HTML_Field
410
+	 */
411
+	public function createMaybeSerializedSimpleHtmlField(
412
+		string $table_column,
413
+		string $nice_name,
414
+		bool $nullable,
415
+		$default_value = null
416
+	): EE_Maybe_Serialized_Simple_HTML_Field {
417
+		return $this->loader->getNew(
418
+			'EE_Maybe_Serialized_Simple_HTML_Field',
419
+			[$table_column, $nice_name, $nullable, $default_value]
420
+		);
421
+	}
422
+
423
+
424
+	/**
425
+	 * @param string     $table_column
426
+	 * @param string     $nice_name
427
+	 * @param bool       $nullable
428
+	 * @param mixed|null $default_value
429
+	 * @return EE_Maybe_Serialized_Text_Field
430
+	 */
431
+	public function createMaybeSerializedTextField(
432
+		string $table_column,
433
+		string $nice_name,
434
+		bool $nullable,
435
+		$default_value = null
436
+	): EE_Maybe_Serialized_Text_Field {
437
+		return $this->loader->getNew(
438
+			'EE_Maybe_Serialized_Text_Field',
439
+			[$table_column, $nice_name, $nullable, $default_value]
440
+		);
441
+	}
442
+
443
+
444
+	/**
445
+	 * @param string     $table_column
446
+	 * @param string     $nice_name
447
+	 * @param bool       $nullable
448
+	 * @param mixed|null $default_value
449
+	 * @return EE_Money_Field
450
+	 */
451
+	public function createMoneyField(
452
+		string $table_column,
453
+		string $nice_name,
454
+		bool $nullable,
455
+		$default_value = null
456
+	): EE_Money_Field {
457
+		return $this->loader->getNew(
458
+			'EE_Money_Field',
459
+			[$table_column, $nice_name, $nullable, $default_value]
460
+		);
461
+	}
462
+
463
+
464
+	/**
465
+	 * @param string $table_column
466
+	 * @param string $nice_name
467
+	 * @param bool   $nullable
468
+	 * @param string $default_value
469
+	 * @return EE_Plain_Text_Field
470
+	 */
471
+	public function createPlainTextField(
472
+		string $table_column,
473
+		string $nice_name,
474
+		bool $nullable = true,
475
+		string $default_value = ''
476
+	): EE_Plain_Text_Field {
477
+		return $this->loader->getNew(
478
+			'EE_Plain_Text_Field',
479
+			[$table_column, $nice_name, $nullable, $default_value]
480
+		);
481
+	}
482
+
483
+
484
+	/**
485
+	 * @param string     $table_column
486
+	 * @param string     $nice_name
487
+	 * @param bool       $nullable
488
+	 * @param mixed|null $default_value
489
+	 * @return EE_Post_Content_Field
490
+	 */
491
+	public function createPostContentField(
492
+		string $table_column,
493
+		string $nice_name,
494
+		bool $nullable,
495
+		$default_value = null
496
+	): EE_Post_Content_Field {
497
+		return $this->loader->getNew(
498
+			'EE_Post_Content_Field',
499
+			[$table_column, $nice_name, $nullable, $default_value]
500
+		);
501
+	}
502
+
503
+
504
+	/**
505
+	 * @param string $table_column
506
+	 * @param string $nice_name
507
+	 * @return EE_Primary_Key_Int_Field
508
+	 */
509
+	public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field
510
+	{
511
+		return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]);
512
+	}
513
+
514
+
515
+	/**
516
+	 * @param string $table_column
517
+	 * @param string $nice_name
518
+	 * @return EE_Primary_Key_String_Field
519
+	 */
520
+	public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field
521
+	{
522
+		return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]);
523
+	}
524
+
525
+
526
+	/**
527
+	 * @param string     $table_column
528
+	 * @param string     $nice_name
529
+	 * @param bool       $nullable
530
+	 * @param mixed|null $default_value
531
+	 * @return EE_Serialized_Text_Field
532
+	 */
533
+	public function createSerializedTextField(
534
+		string $table_column,
535
+		string $nice_name,
536
+		bool $nullable,
537
+		$default_value = null
538
+	): EE_Serialized_Text_Field {
539
+		return $this->loader->getNew(
540
+			'EE_Serialized_Text_Field',
541
+			[$table_column, $nice_name, $nullable, $default_value]
542
+		);
543
+	}
544
+
545
+
546
+	/**
547
+	 * @param string     $table_column
548
+	 * @param string     $nice_name
549
+	 * @param bool       $nullable
550
+	 * @param mixed|null $default_value
551
+	 * @return EE_Simple_HTML_Field
552
+	 */
553
+	public function createSimpleHtmlField(
554
+		string $table_column,
555
+		string $nice_name,
556
+		bool $nullable,
557
+		$default_value = null
558
+	): EE_Simple_HTML_Field {
559
+		return $this->loader->getNew(
560
+			'EE_Simple_HTML_Field',
561
+			[$table_column, $nice_name, $nullable, $default_value]
562
+		);
563
+	}
564
+
565
+
566
+	/**
567
+	 * @param string     $table_column
568
+	 * @param string     $nice_name
569
+	 * @param bool       $nullable
570
+	 * @param mixed|null $default_value
571
+	 * @return EE_Slug_Field
572
+	 */
573
+	public function createSlugField(
574
+		string $table_column,
575
+		string $nice_name,
576
+		bool $nullable = false,
577
+		$default_value = null
578
+	): EE_Slug_Field {
579
+		return $this->loader->getNew(
580
+			'EE_Slug_Field',
581
+			[$table_column, $nice_name, $nullable, $default_value]
582
+		);
583
+	}
584
+
585
+
586
+	/**
587
+	 * @param string     $table_column
588
+	 * @param string     $nice_name
589
+	 * @param bool       $nullable
590
+	 * @param mixed|null $default_value
591
+	 * @return EE_Trashed_Flag_Field
592
+	 */
593
+	public function createTrashedFlagField(
594
+		string $table_column,
595
+		string $nice_name,
596
+		bool $nullable,
597
+		$default_value = null
598
+	): EE_Trashed_Flag_Field {
599
+		return $this->loader->getNew(
600
+			'EE_Trashed_Flag_Field',
601
+			[$table_column, $nice_name, $nullable, $default_value]
602
+		);
603
+	}
604
+
605
+
606
+	/**
607
+	 * @param string $table_column
608
+	 * @param string $nice_name
609
+	 * @param bool   $nullable
610
+	 * @param mixed  $default_value
611
+	 * @param array $values     If additional statuses are to be used other than the default WP statuses,
612
+	 *                          then they can be registered via this property.
613
+	 *                          The format of the array should be as follows:
614
+	 *                          [
615
+	 *                              'status_reference' => [
616
+	 *                                  'label' => __('Status Reference Label', 'event_espresso'),
617
+	 *                                  // whether status is shown on the frontend of the site
618
+	 *                                  'public' => true,
619
+	 *                                  // whether status is excluded from wp searches
620
+	 *                                  'exclude_from_search' => false,
621
+	 *                                  // whether status is included in queries
622
+	 *                                  for the admin 'all' view in list table views.
623
+	 *                                  'show_in_admin_all_list' => true,
624
+	 *                                  // show in the list of statuses with post counts
625
+	 *                                  // at the top of the admin list tables (i.e. Status Reference(2) )
626
+	 *                                  'show_in_admin_status_list' => true,
627
+	 *                                  // the text to display on the admin screen
628
+	 *                                  // ( or you won't see your status count )
629
+	 *                                  'label_count' => _n_noop(
630
+	 *                                      'Status Reference <span class="count">(%s)</span>',
631
+	 *                                      'Status References <span class="count">(%s)</span>'
632
+	 *                                  ),
633
+	 *                              ]
634
+	 *                          ]
635
+	 * @return EE_WP_Post_Status_Field
636
+	 * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info
637
+	 */
638
+	public function createWpPostStatusField(
639
+		string $table_column,
640
+		string $nice_name,
641
+		bool $nullable,
642
+		$default_value = null,
643
+		array $values = []
644
+	): EE_WP_Post_Status_Field {
645
+		return $this->loader->getNew(
646
+			'EE_WP_Post_Status_Field',
647
+			[$table_column, $nice_name, $nullable, $default_value, $values]
648
+		);
649
+	}
650
+
651
+
652
+	/**
653
+	 * @param string $post_type
654
+	 * @return EE_WP_Post_Type_Field
655
+	 */
656
+	public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field
657
+	{
658
+		return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]);
659
+	}
660
+
661
+
662
+	/**
663
+	 * @param string $table_column
664
+	 * @param string $nice_name
665
+	 * @param bool   $nullable
666
+	 * @return EE_WP_User_Field
667
+	 */
668
+	public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field
669
+	{
670
+		return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]);
671
+	}
672 672
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapCore.php 1 patch
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -47,225 +47,225 @@
 block discarded – undo
47 47
  */
48 48
 class BootstrapCore implements InterminableInterface
49 49
 {
50
-    /**
51
-     * @type LoaderInterface $loader
52
-     */
53
-    private $loader;
50
+	/**
51
+	 * @type LoaderInterface $loader
52
+	 */
53
+	private $loader;
54 54
 
55
-    /**
56
-     * @var RequestInterface $request
57
-     */
58
-    protected $request;
55
+	/**
56
+	 * @var RequestInterface $request
57
+	 */
58
+	protected $request;
59 59
 
60
-    /**
61
-     * @var ResponseInterface $response
62
-     */
63
-    protected $response;
60
+	/**
61
+	 * @var ResponseInterface $response
62
+	 */
63
+	protected $response;
64 64
 
65
-    /**
66
-     * @var RequestStackBuilder $request_stack_builder
67
-     */
68
-    protected $request_stack_builder;
65
+	/**
66
+	 * @var RequestStackBuilder $request_stack_builder
67
+	 */
68
+	protected $request_stack_builder;
69 69
 
70
-    /**
71
-     * @var RequestStack $request_stack
72
-     */
73
-    protected $request_stack;
70
+	/**
71
+	 * @var RequestStack $request_stack
72
+	 */
73
+	protected $request_stack;
74 74
 
75 75
 
76
-    /**
77
-     * BootstrapCore constructor.
78
-     */
79
-    public function __construct()
80
-    {
81
-        do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
-        // construct request stack and run middleware apps as soon as all WP plugins are loaded
83
-        add_action('plugins_loaded', array($this, 'initialize'), 0);
84
-    }
76
+	/**
77
+	 * BootstrapCore constructor.
78
+	 */
79
+	public function __construct()
80
+	{
81
+		do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct');
82
+		// construct request stack and run middleware apps as soon as all WP plugins are loaded
83
+		add_action('plugins_loaded', array($this, 'initialize'), 0);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * @throws DomainException
89
-     * @throws EE_Error
90
-     * @throws Exception
91
-     * @throws InvalidArgumentException
92
-     * @throws InvalidClassException
93
-     * @throws InvalidDataTypeException
94
-     * @throws InvalidFilePathException
95
-     * @throws InvalidInterfaceException
96
-     * @throws InvalidRequestStackMiddlewareException
97
-     * @throws OutOfBoundsException
98
-     * @throws ReflectionException
99
-     */
100
-    public function initialize()
101
-    {
102
-        $this->bootstrapDependencyInjectionContainer();
103
-        $this->bootstrapDomain();
104
-        $bootstrap_request = $this->bootstrapRequestResponseObjects();
105
-        add_action(
106
-            'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
-            array($bootstrap_request, 'setupLegacyRequest')
108
-        );
109
-        $this->runRequestStack();
110
-    }
87
+	/**
88
+	 * @throws DomainException
89
+	 * @throws EE_Error
90
+	 * @throws Exception
91
+	 * @throws InvalidArgumentException
92
+	 * @throws InvalidClassException
93
+	 * @throws InvalidDataTypeException
94
+	 * @throws InvalidFilePathException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws InvalidRequestStackMiddlewareException
97
+	 * @throws OutOfBoundsException
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function initialize()
101
+	{
102
+		$this->bootstrapDependencyInjectionContainer();
103
+		$this->bootstrapDomain();
104
+		$bootstrap_request = $this->bootstrapRequestResponseObjects();
105
+		add_action(
106
+			'EE_Load_Espresso_Core__handle_request__initialize_core_loading',
107
+			array($bootstrap_request, 'setupLegacyRequest')
108
+		);
109
+		$this->runRequestStack();
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * @throws ReflectionException
115
-     * @throws EE_Error
116
-     * @throws InvalidArgumentException
117
-     * @throws InvalidDataTypeException
118
-     * @throws InvalidInterfaceException
119
-     * @throws OutOfBoundsException
120
-     */
121
-    private function bootstrapDependencyInjectionContainer()
122
-    {
123
-        $bootstrap_di = new BootstrapDependencyInjectionContainer();
124
-        $bootstrap_di->buildLegacyDependencyInjectionContainer();
125
-        $bootstrap_di->buildLoader();
126
-        $registry = $bootstrap_di->getRegistry();
127
-        $dependency_map = $bootstrap_di->getDependencyMap();
128
-        $dependency_map->initialize();
129
-        $registry->initialize();
130
-        $this->loader = $bootstrap_di->getLoader();
131
-    }
113
+	/**
114
+	 * @throws ReflectionException
115
+	 * @throws EE_Error
116
+	 * @throws InvalidArgumentException
117
+	 * @throws InvalidDataTypeException
118
+	 * @throws InvalidInterfaceException
119
+	 * @throws OutOfBoundsException
120
+	 */
121
+	private function bootstrapDependencyInjectionContainer()
122
+	{
123
+		$bootstrap_di = new BootstrapDependencyInjectionContainer();
124
+		$bootstrap_di->buildLegacyDependencyInjectionContainer();
125
+		$bootstrap_di->buildLoader();
126
+		$registry = $bootstrap_di->getRegistry();
127
+		$dependency_map = $bootstrap_di->getDependencyMap();
128
+		$dependency_map->initialize();
129
+		$registry->initialize();
130
+		$this->loader = $bootstrap_di->getLoader();
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * configures the Domain object for core
136
-     *
137
-     * @return void
138
-     * @throws DomainException
139
-     * @throws InvalidArgumentException
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidClassException
142
-     * @throws InvalidFilePathException
143
-     * @throws InvalidInterfaceException
144
-     */
145
-    private function bootstrapDomain()
146
-    {
147
-        DomainFactory::getEventEspressoCoreDomain();
148
-    }
134
+	/**
135
+	 * configures the Domain object for core
136
+	 *
137
+	 * @return void
138
+	 * @throws DomainException
139
+	 * @throws InvalidArgumentException
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidClassException
142
+	 * @throws InvalidFilePathException
143
+	 * @throws InvalidInterfaceException
144
+	 */
145
+	private function bootstrapDomain()
146
+	{
147
+		DomainFactory::getEventEspressoCoreDomain();
148
+	}
149 149
 
150 150
 
151
-    /**
152
-     * sets up the request and response objects
153
-     *
154
-     * @return BootstrapRequestResponseObjects
155
-     * @throws InvalidArgumentException
156
-     */
157
-    private function bootstrapRequestResponseObjects()
158
-    {
159
-        /** @var BootstrapRequestResponseObjects $bootstrap_request */
160
-        $bootstrap_request = $this->loader->getShared(
161
-            'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
-            array($this->loader)
163
-        );
164
-        $bootstrap_request->buildRequestResponse();
165
-        $bootstrap_request->shareRequestResponse();
166
-        $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
-        $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
-        return $bootstrap_request;
169
-    }
151
+	/**
152
+	 * sets up the request and response objects
153
+	 *
154
+	 * @return BootstrapRequestResponseObjects
155
+	 * @throws InvalidArgumentException
156
+	 */
157
+	private function bootstrapRequestResponseObjects()
158
+	{
159
+		/** @var BootstrapRequestResponseObjects $bootstrap_request */
160
+		$bootstrap_request = $this->loader->getShared(
161
+			'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects',
162
+			array($this->loader)
163
+		);
164
+		$bootstrap_request->buildRequestResponse();
165
+		$bootstrap_request->shareRequestResponse();
166
+		$this->request = $this->loader->getShared('EventEspresso\core\services\request\Request');
167
+		$this->response = $this->loader->getShared('EventEspresso\core\services\request\Response');
168
+		return $bootstrap_request;
169
+	}
170 170
 
171 171
 
172
-    /**
173
-     * run_request_stack
174
-     * construct request stack and run middleware apps
175
-     *
176
-     * @throws EE_Error
177
-     * @throws Exception
178
-     */
179
-    public function runRequestStack()
180
-    {
181
-        $this->loadAutoloader();
182
-        $this->setAutoloadersForRequiredFiles();
183
-        $this->request_stack_builder = $this->buildRequestStack();
184
-        $this->request_stack = $this->request_stack_builder->resolve(
185
-            new RequestStackCoreApp()
186
-        );
187
-        $this->request_stack->handleRequest($this->request, $this->response);
188
-        $this->request_stack->handleResponse();
189
-    }
172
+	/**
173
+	 * run_request_stack
174
+	 * construct request stack and run middleware apps
175
+	 *
176
+	 * @throws EE_Error
177
+	 * @throws Exception
178
+	 */
179
+	public function runRequestStack()
180
+	{
181
+		$this->loadAutoloader();
182
+		$this->setAutoloadersForRequiredFiles();
183
+		$this->request_stack_builder = $this->buildRequestStack();
184
+		$this->request_stack = $this->request_stack_builder->resolve(
185
+			new RequestStackCoreApp()
186
+		);
187
+		$this->request_stack->handleRequest($this->request, $this->response);
188
+		$this->request_stack->handleResponse();
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * load_autoloader
194
-     *
195
-     * @throws EE_Error
196
-     */
197
-    protected function loadAutoloader()
198
-    {
199
-        // load interfaces
200
-        espresso_load_required(
201
-            'EEH_Autoloader',
202
-            EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
-        );
204
-        EEH_Autoloader::instance();
205
-    }
192
+	/**
193
+	 * load_autoloader
194
+	 *
195
+	 * @throws EE_Error
196
+	 */
197
+	protected function loadAutoloader()
198
+	{
199
+		// load interfaces
200
+		espresso_load_required(
201
+			'EEH_Autoloader',
202
+			EE_CORE . 'helpers/EEH_Autoloader.helper.php'
203
+		);
204
+		EEH_Autoloader::instance();
205
+	}
206 206
 
207 207
 
208
-    /**
209
-     * load_required_files
210
-     *
211
-     * @throws EE_Error
212
-     */
213
-    protected function setAutoloadersForRequiredFiles()
214
-    {
215
-        // load interfaces
216
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
-        // load helpers
218
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
-        // register legacy request stack classes just in case
220
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
-        // register legacy middleware classes just in case
222
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
-    }
208
+	/**
209
+	 * load_required_files
210
+	 *
211
+	 * @throws EE_Error
212
+	 */
213
+	protected function setAutoloadersForRequiredFiles()
214
+	{
215
+		// load interfaces
216
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true);
217
+		// load helpers
218
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
219
+		// register legacy request stack classes just in case
220
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/');
221
+		// register legacy middleware classes just in case
222
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/');
223
+	}
224 224
 
225 225
 
226
-    /**
227
-     * build_request_stack
228
-     *
229
-     * @return RequestStackBuilder
230
-     */
231
-    public function buildRequestStack()
232
-    {
233
-        $request_stack_builder = new RequestStackBuilder($this->loader);
234
-        /**
235
-         * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
-         * so items at the beginning of the final middleware stack will run last.
237
-         * First parameter is the middleware classname, second is an array of arguments
238
-         */
239
-        $stack_apps = apply_filters(
240
-            'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
-            array(
242
-                // first in last out
243
-                'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
-                'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
-                'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
-                // last in first out
248
-                'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
-            )
250
-        );
251
-        // legacy filter for backwards compatibility
252
-        $stack_apps = apply_filters(
253
-            'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
-            $stack_apps
255
-        );
256
-        // load middleware onto stack : FILO (First In Last Out)
257
-        // items at the beginning of the $stack_apps array will run last
258
-        foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
-            $request_stack_builder->push(array($stack_app, $stack_app_args));
260
-        }
261
-        // finally, we'll add this on its own because we need it to always be part of the stack
262
-        // and we also need it to always run first because the rest of the system relies on it
263
-        $request_stack_builder->push(
264
-            array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
-        );
266
-        return apply_filters(
267
-            'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
-            $request_stack_builder
269
-        );
270
-    }
226
+	/**
227
+	 * build_request_stack
228
+	 *
229
+	 * @return RequestStackBuilder
230
+	 */
231
+	public function buildRequestStack()
232
+	{
233
+		$request_stack_builder = new RequestStackBuilder($this->loader);
234
+		/**
235
+		 * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT
236
+		 * so items at the beginning of the final middleware stack will run last.
237
+		 * First parameter is the middleware classname, second is an array of arguments
238
+		 */
239
+		$stack_apps = apply_filters(
240
+			'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps',
241
+			array(
242
+				// first in last out
243
+				'EventEspresso\core\services\request\middleware\BotDetector'                 => array(),
244
+				'EventEspresso\core\services\request\middleware\DetectFileEditorRequest'     => array(),
245
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(),
246
+				'EventEspresso\core\services\request\middleware\RecommendedVersions'         => array(),
247
+				// last in first out
248
+				'EventEspresso\core\services\request\middleware\DetectLogin'                 => array(),
249
+			)
250
+		);
251
+		// legacy filter for backwards compatibility
252
+		$stack_apps = apply_filters(
253
+			'FHEE__EE_Bootstrap__build_request_stack__stack_apps',
254
+			$stack_apps
255
+		);
256
+		// load middleware onto stack : FILO (First In Last Out)
257
+		// items at the beginning of the $stack_apps array will run last
258
+		foreach ((array) $stack_apps as $stack_app => $stack_app_args) {
259
+			$request_stack_builder->push(array($stack_app, $stack_app_args));
260
+		}
261
+		// finally, we'll add this on its own because we need it to always be part of the stack
262
+		// and we also need it to always run first because the rest of the system relies on it
263
+		$request_stack_builder->push(
264
+			array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array())
265
+		);
266
+		return apply_filters(
267
+			'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder',
268
+			$request_stack_builder
269
+		);
270
+	}
271 271
 }
Please login to merge, or discard this patch.
core/services/commands/CommandHandlerInterface.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@
 block discarded – undo
11 11
  */
12 12
 interface CommandHandlerInterface extends InterminableInterface
13 13
 {
14
-    /**
15
-     * verifies that the supplied command is the correct class for the handler.
16
-     *
17
-     * !!! IMPORTANT !!!
18
-     * Must return $this (ie: the handler itself)
19
-     * as the CommandBus utilizes method chaining
20
-     *
21
-     * @param CommandInterface $command
22
-     * @return CommandHandlerInterface
23
-     * @since 4.9.80.p
24
-     */
25
-    public function verify(CommandInterface $command): CommandHandlerInterface;
14
+	/**
15
+	 * verifies that the supplied command is the correct class for the handler.
16
+	 *
17
+	 * !!! IMPORTANT !!!
18
+	 * Must return $this (ie: the handler itself)
19
+	 * as the CommandBus utilizes method chaining
20
+	 *
21
+	 * @param CommandInterface $command
22
+	 * @return CommandHandlerInterface
23
+	 * @since 4.9.80.p
24
+	 */
25
+	public function verify(CommandInterface $command): CommandHandlerInterface;
26 26
 
27
-    /**
28
-     * Performs the command handler's logic.
29
-     *
30
-     * @param CommandInterface $command
31
-     * @return mixed
32
-     */
33
-    public function handle(CommandInterface $command);
27
+	/**
28
+	 * Performs the command handler's logic.
29
+	 *
30
+	 * @param CommandInterface $command
31
+	 * @return mixed
32
+	 */
33
+	public function handle(CommandInterface $command);
34 34
 }
Please login to merge, or discard this patch.