Completed
Branch dependabot/npm_and_yarn/wordpr... (e552b3)
by
unknown
84:27 queued 76:28
created
core/services/commands/ticket/CancelTicketLineItemCommand.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -16,112 +16,112 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @var \EE_Transaction $transaction
21
-     */
22
-    private $transaction;
23
-
24
-    /**
25
-     * @var \EE_Ticket $ticket
26
-     */
27
-    private $ticket;
28
-
29
-    /**
30
-     * @var \EE_Line_Item $ticket_line_item
31
-     */
32
-    protected $ticket_line_item;
33
-
34
-    /**
35
-     * @var int $quantity
36
-     */
37
-    protected $quantity;
38
-
39
-
40
-    /**
41
-     * @param \EE_Registration $registration
42
-     * @param int              $quantity
43
-     */
44
-    public static function fromRegistration(\EE_Registration $registration, $quantity = 1)
45
-    {
46
-        new self(
47
-            $registration->transaction(),
48
-            $registration->ticket(),
49
-            1,
50
-            $registration->ticket_line_item()
51
-        );
52
-    }
53
-
54
-
55
-    /**
56
-     * @param \EE_Line_Item $ticket_line_item
57
-     * @param int           $quantity
58
-     */
59
-    public static function fromTicketLineItem(
60
-        \EE_Line_Item $ticket_line_item,
61
-        $quantity = 1
62
-    ) {
63
-        new self(
64
-            $ticket_line_item->transaction(),
65
-            $ticket_line_item->ticket(),
66
-            $quantity,
67
-            $ticket_line_item
68
-        );
69
-    }
70
-
71
-
72
-    /**
73
-     * CancelTicketLineItemCommand constructor.
74
-     *
75
-     * @param \EE_Transaction $transaction
76
-     * @param \EE_Ticket      $ticket
77
-     * @param int             $quantity
78
-     * @param \EE_Line_Item   $ticket_line_item
79
-     */
80
-    public function __construct(
81
-        \EE_Transaction $transaction,
82
-        \EE_Ticket $ticket,
83
-        $quantity = 1,
84
-        \EE_Line_Item $ticket_line_item = null
85
-    ) {
86
-        $this->transaction = $transaction;
87
-        $this->ticket = $ticket;
88
-        $this->quantity = min(1, absint($quantity));
89
-        $this->ticket_line_item = $ticket_line_item;
90
-    }
91
-
92
-
93
-    /**
94
-     * @return \EE_Transaction
95
-     */
96
-    public function transaction()
97
-    {
98
-        return $this->transaction;
99
-    }
100
-
101
-
102
-    /**
103
-     * @return \EE_Ticket
104
-     */
105
-    public function ticket()
106
-    {
107
-        return $this->ticket;
108
-    }
109
-
110
-
111
-    /**
112
-     * @return \EE_Line_Item
113
-     */
114
-    public function ticketLineItem()
115
-    {
116
-        return $this->ticket_line_item;
117
-    }
118
-
119
-
120
-    /**
121
-     * @return int
122
-     */
123
-    public function quantity()
124
-    {
125
-        return $this->quantity;
126
-    }
19
+	/**
20
+	 * @var \EE_Transaction $transaction
21
+	 */
22
+	private $transaction;
23
+
24
+	/**
25
+	 * @var \EE_Ticket $ticket
26
+	 */
27
+	private $ticket;
28
+
29
+	/**
30
+	 * @var \EE_Line_Item $ticket_line_item
31
+	 */
32
+	protected $ticket_line_item;
33
+
34
+	/**
35
+	 * @var int $quantity
36
+	 */
37
+	protected $quantity;
38
+
39
+
40
+	/**
41
+	 * @param \EE_Registration $registration
42
+	 * @param int              $quantity
43
+	 */
44
+	public static function fromRegistration(\EE_Registration $registration, $quantity = 1)
45
+	{
46
+		new self(
47
+			$registration->transaction(),
48
+			$registration->ticket(),
49
+			1,
50
+			$registration->ticket_line_item()
51
+		);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param \EE_Line_Item $ticket_line_item
57
+	 * @param int           $quantity
58
+	 */
59
+	public static function fromTicketLineItem(
60
+		\EE_Line_Item $ticket_line_item,
61
+		$quantity = 1
62
+	) {
63
+		new self(
64
+			$ticket_line_item->transaction(),
65
+			$ticket_line_item->ticket(),
66
+			$quantity,
67
+			$ticket_line_item
68
+		);
69
+	}
70
+
71
+
72
+	/**
73
+	 * CancelTicketLineItemCommand constructor.
74
+	 *
75
+	 * @param \EE_Transaction $transaction
76
+	 * @param \EE_Ticket      $ticket
77
+	 * @param int             $quantity
78
+	 * @param \EE_Line_Item   $ticket_line_item
79
+	 */
80
+	public function __construct(
81
+		\EE_Transaction $transaction,
82
+		\EE_Ticket $ticket,
83
+		$quantity = 1,
84
+		\EE_Line_Item $ticket_line_item = null
85
+	) {
86
+		$this->transaction = $transaction;
87
+		$this->ticket = $ticket;
88
+		$this->quantity = min(1, absint($quantity));
89
+		$this->ticket_line_item = $ticket_line_item;
90
+	}
91
+
92
+
93
+	/**
94
+	 * @return \EE_Transaction
95
+	 */
96
+	public function transaction()
97
+	{
98
+		return $this->transaction;
99
+	}
100
+
101
+
102
+	/**
103
+	 * @return \EE_Ticket
104
+	 */
105
+	public function ticket()
106
+	{
107
+		return $this->ticket;
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return \EE_Line_Item
113
+	 */
114
+	public function ticketLineItem()
115
+	{
116
+		return $this->ticket_line_item;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return int
122
+	 */
123
+	public function quantity()
124
+	{
125
+		return $this->quantity;
126
+	}
127 127
 }
Please login to merge, or discard this patch.
core/services/commands/ticket/CreateTicketLineItemCommand.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -16,77 +16,77 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @var \EE_Transaction $transaction
21
-     */
22
-    private $transaction;
23
-
24
-    /**
25
-     * @var \EE_Ticket $ticket
26
-     */
27
-    private $ticket;
28
-
29
-    /**
30
-     * @var int $quantity
31
-     */
32
-    private $quantity = 1;
33
-
34
-    /**
35
-     * @var \EE_Line_Item $ticket_line_item
36
-     */
37
-    protected $ticket_line_item;
38
-
39
-
40
-    /**
41
-     * CreateTicketLineItemCommand constructor.
42
-     *
43
-     * @param \EE_Transaction $transaction
44
-     * @param \EE_Ticket      $ticket
45
-     * @param int             $quantity
46
-     */
47
-    public function __construct(
48
-        \EE_Transaction $transaction,
49
-        \EE_Ticket $ticket,
50
-        $quantity = 1
51
-    ) {
52
-        $this->transaction = $transaction;
53
-        $this->ticket = $ticket;
54
-        $this->quantity = $quantity;
55
-    }
56
-
57
-
58
-    /**
59
-     * @return \EE_Transaction
60
-     */
61
-    public function transaction()
62
-    {
63
-        return $this->transaction;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return \EE_Ticket
69
-     */
70
-    public function ticket()
71
-    {
72
-        return $this->ticket;
73
-    }
74
-
75
-
76
-    /**
77
-     * @return int
78
-     */
79
-    public function quantity()
80
-    {
81
-        return $this->quantity;
82
-    }
83
-
84
-
85
-    /**
86
-     * @return \EE_Line_Item
87
-     */
88
-    public function ticketLineItem()
89
-    {
90
-        return $this->ticket_line_item;
91
-    }
19
+	/**
20
+	 * @var \EE_Transaction $transaction
21
+	 */
22
+	private $transaction;
23
+
24
+	/**
25
+	 * @var \EE_Ticket $ticket
26
+	 */
27
+	private $ticket;
28
+
29
+	/**
30
+	 * @var int $quantity
31
+	 */
32
+	private $quantity = 1;
33
+
34
+	/**
35
+	 * @var \EE_Line_Item $ticket_line_item
36
+	 */
37
+	protected $ticket_line_item;
38
+
39
+
40
+	/**
41
+	 * CreateTicketLineItemCommand constructor.
42
+	 *
43
+	 * @param \EE_Transaction $transaction
44
+	 * @param \EE_Ticket      $ticket
45
+	 * @param int             $quantity
46
+	 */
47
+	public function __construct(
48
+		\EE_Transaction $transaction,
49
+		\EE_Ticket $ticket,
50
+		$quantity = 1
51
+	) {
52
+		$this->transaction = $transaction;
53
+		$this->ticket = $ticket;
54
+		$this->quantity = $quantity;
55
+	}
56
+
57
+
58
+	/**
59
+	 * @return \EE_Transaction
60
+	 */
61
+	public function transaction()
62
+	{
63
+		return $this->transaction;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return \EE_Ticket
69
+	 */
70
+	public function ticket()
71
+	{
72
+		return $this->ticket;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @return int
78
+	 */
79
+	public function quantity()
80
+	{
81
+		return $this->quantity;
82
+	}
83
+
84
+
85
+	/**
86
+	 * @return \EE_Line_Item
87
+	 */
88
+	public function ticketLineItem()
89
+	{
90
+		return $this->ticket_line_item;
91
+	}
92 92
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/FormHandler.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function form($for_display = false)
172 172
     {
173
-        if (! $this->formIsValid()) {
173
+        if ( ! $this->formIsValid()) {
174 174
             return null;
175 175
         }
176 176
         if ($for_display) {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      */
273 273
     public function setFormName($form_name)
274 274
     {
275
-        if (! is_string($form_name)) {
275
+        if ( ! is_string($form_name)) {
276 276
             throw new InvalidDataTypeException('$form_name', $form_name, 'string');
277 277
         }
278 278
         $this->form_name = $form_name;
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public function setAdminName($admin_name)
298 298
     {
299
-        if (! is_string($admin_name)) {
299
+        if ( ! is_string($admin_name)) {
300 300
             throw new InvalidDataTypeException('$admin_name', $admin_name, 'string');
301 301
         }
302 302
         $this->admin_name = $admin_name;
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
      */
321 321
     public function setSlug($slug)
322 322
     {
323
-        if (! is_string($slug)) {
323
+        if ( ! is_string($slug)) {
324 324
             throw new InvalidDataTypeException('$slug', $slug, 'string');
325 325
         }
326 326
         $this->slug = $slug;
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
      */
344 344
     public function setSubmitBtnText($submit_btn_text)
345 345
     {
346
-        if (! is_string($submit_btn_text)) {
346
+        if ( ! is_string($submit_btn_text)) {
347 347
             throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string');
348 348
         }
349 349
         if (empty($submit_btn_text)) {
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function setFormAction($form_action)
374 374
     {
375
-        if (! is_string($form_action)) {
375
+        if ( ! is_string($form_action)) {
376 376
             throw new InvalidDataTypeException('$form_action', $form_action, 'string');
377 377
         }
378 378
         $this->form_action = $form_action;
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
      */
418 418
     public function setFormConfig($form_config)
419 419
     {
420
-        if (! in_array(
420
+        if ( ! in_array(
421 421
             $form_config,
422 422
             array(
423 423
                 FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
         $text = ! empty($text) ? $text : $this->submitBtnText();
491 491
         return new EE_Submit_Input(
492 492
             array(
493
-                'html_name'             => 'ee-form-submit-' . $this->slug(),
494
-                'html_id'               => 'ee-form-submit-' . $this->slug(),
493
+                'html_name'             => 'ee-form-submit-'.$this->slug(),
494
+                'html_id'               => 'ee-form-submit-'.$this->slug(),
495 495
                 'html_class'            => 'ee-form-submit',
496 496
                 'html_label'            => ' ',
497
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
497
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
498 498
                 'default'               => $text,
499 499
             )
500 500
         );
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
      */
511 511
     public function appendSubmitButton($text = '')
512 512
     {
513
-        if ($this->form->subsection_exists($this->slug() . '-submit-btn')) {
513
+        if ($this->form->subsection_exists($this->slug().'-submit-btn')) {
514 514
             return;
515 515
         }
516 516
         $this->form->add_subsections(
517
-            array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)),
517
+            array($this->slug().'-submit-btn' => $this->generateSubmitButton($text)),
518 518
             null,
519 519
             false
520 520
         );
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
     {
532 532
         $cancel_button = new EE_Submit_Input(
533 533
             array(
534
-                'html_name'             => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!!
535
-                'html_id'               => 'ee-cancel-form-' . $this->slug(),
534
+                'html_name'             => 'ee-form-submit-'.$this->slug(), // YES! Same name as submit !!!
535
+                'html_id'               => 'ee-cancel-form-'.$this->slug(),
536 536
                 'html_class'            => 'ee-cancel-form',
537 537
                 'html_label'            => ' ',
538
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
538
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
539 539
                 'default'               => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'),
540 540
             )
541 541
         );
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
         $this->form->add_subsections(
556 556
             array(
557 557
                 'clear-submit-btn-float' => new EE_Form_Section_HTML(
558
-                    EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx()
558
+                    EEH_HTML::div('', '', 'clear-float').EEH_HTML::divx()
559 559
                 ),
560 560
             ),
561 561
             null,
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
      */
617 617
     public function process($submitted_form_data = array())
618 618
     {
619
-        if (! $this->form()->was_submitted($submitted_form_data)) {
619
+        if ( ! $this->form()->was_submitted($submitted_form_data)) {
620 620
             throw new InvalidFormSubmissionException($this->form_name);
621 621
         }
622 622
         $this->form(true)->receive_form_submission($submitted_form_data);
623
-        if (! $this->form()->is_valid()) {
623
+        if ( ! $this->form()->is_valid()) {
624 624
             throw new InvalidFormSubmissionException(
625 625
                 $this->form_name,
626 626
                 sprintf(
Please login to merge, or discard this patch.
Indentation   +635 added lines, -635 removed lines patch added patch discarded remove patch
@@ -29,639 +29,639 @@
 block discarded – undo
29 29
 abstract class FormHandler implements FormHandlerInterface
30 30
 {
31 31
 
32
-    /**
33
-     * will add opening and closing HTML form tags as well as a submit button
34
-     */
35
-    const ADD_FORM_TAGS_AND_SUBMIT = 'add_form_tags_and_submit';
36
-
37
-    /**
38
-     * will add opening and closing HTML form tags but NOT a submit button
39
-     */
40
-    const ADD_FORM_TAGS_ONLY = 'add_form_tags_only';
41
-
42
-    /**
43
-     * will NOT add opening and closing HTML form tags but will add a submit button
44
-     */
45
-    const ADD_FORM_SUBMIT_ONLY = 'add_form_submit_only';
46
-
47
-    /**
48
-     * will NOT add opening and closing HTML form tags NOR a submit button
49
-     */
50
-    const DO_NOT_SETUP_FORM = 'do_not_setup_form';
51
-
52
-    /**
53
-     * if set to false, then this form has no displayable content,
54
-     * and will only be used for processing data sent passed via GET or POST
55
-     * defaults to true ( ie: form has displayable content )
56
-     *
57
-     * @var boolean $displayable
58
-     */
59
-    private $displayable = true;
60
-
61
-    /**
62
-     * @var string $form_name
63
-     */
64
-    private $form_name;
65
-
66
-    /**
67
-     * @var string $admin_name
68
-     */
69
-    private $admin_name;
70
-
71
-    /**
72
-     * @var string $slug
73
-     */
74
-    private $slug;
75
-
76
-    /**
77
-     * @var string $submit_btn_text
78
-     */
79
-    private $submit_btn_text;
80
-
81
-    /**
82
-     * @var string $form_action
83
-     */
84
-    private $form_action;
85
-
86
-    /**
87
-     * form params in key value pairs
88
-     * can be added to form action URL or as hidden inputs
89
-     *
90
-     * @var array $form_args
91
-     */
92
-    private $form_args = array();
93
-
94
-    /**
95
-     * value of one of the string constant above
96
-     *
97
-     * @var string $form_config
98
-     */
99
-    private $form_config;
100
-
101
-    /**
102
-     * whether or not the form was determined to be invalid
103
-     *
104
-     * @var boolean $form_has_errors
105
-     */
106
-    private $form_has_errors;
107
-
108
-    /**
109
-     * the absolute top level form section being used on the page
110
-     *
111
-     * @var EE_Form_Section_Proper $form
112
-     */
113
-    private $form;
114
-
115
-    /**
116
-     * @var EE_Registry $registry
117
-     */
118
-    protected $registry;
119
-
120
-    // phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
121
-    /**
122
-     * Form constructor.
123
-     *
124
-     * @param string      $form_name
125
-     * @param string      $admin_name
126
-     * @param string      $slug
127
-     * @param string      $form_action
128
-     * @param string      $form_config
129
-     * @param EE_Registry $registry
130
-     * @throws InvalidDataTypeException
131
-     * @throws DomainException
132
-     * @throws InvalidArgumentException
133
-     */
134
-    public function __construct(
135
-        $form_name,
136
-        $admin_name,
137
-        $slug,
138
-        $form_action = '',
139
-        $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
140
-        EE_Registry $registry
141
-    ) {
142
-        $this->setFormName($form_name);
143
-        $this->setAdminName($admin_name);
144
-        $this->setSlug($slug);
145
-        $this->setFormAction($form_action);
146
-        $this->setFormConfig($form_config);
147
-        $this->setSubmitBtnText(esc_html__('Submit', 'event_espresso'));
148
-        $this->registry = $registry;
149
-    }
150
-
151
-
152
-    /**
153
-     * @return array
154
-     */
155
-    public static function getFormConfigConstants()
156
-    {
157
-        return array(
158
-            FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
159
-            FormHandler::ADD_FORM_TAGS_ONLY,
160
-            FormHandler::ADD_FORM_SUBMIT_ONLY,
161
-            FormHandler::DO_NOT_SETUP_FORM,
162
-        );
163
-    }
164
-
165
-
166
-    /**
167
-     * @param bool $for_display
168
-     * @return EE_Form_Section_Proper
169
-     * @throws EE_Error
170
-     * @throws LogicException
171
-     */
172
-    public function form($for_display = false)
173
-    {
174
-        if (! $this->formIsValid()) {
175
-            return null;
176
-        }
177
-        if ($for_display) {
178
-            $form_config = $this->formConfig();
179
-            if ($form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
180
-                || $form_config === FormHandler::ADD_FORM_SUBMIT_ONLY
181
-            ) {
182
-                $this->appendSubmitButton();
183
-                $this->clearFormButtonFloats();
184
-            }
185
-        }
186
-        return $this->form;
187
-    }
188
-
189
-
190
-    /**
191
-     * @return boolean
192
-     * @throws LogicException
193
-     */
194
-    public function formIsValid()
195
-    {
196
-        if ($this->form instanceof EE_Form_Section_Proper) {
197
-            return true;
198
-        }
199
-        $form = apply_filters(
200
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object',
201
-            $this->generate(),
202
-            $this
203
-        );
204
-        if ($this->verifyForm($form)) {
205
-            $this->setForm($form);
206
-        }
207
-        return true;
208
-    }
209
-
210
-
211
-    /**
212
-     * @param EE_Form_Section_Proper|null $form
213
-     * @return bool
214
-     * @throws LogicException
215
-     */
216
-    public function verifyForm(EE_Form_Section_Proper $form = null)
217
-    {
218
-        $form = $form !== null ? $form : $this->form;
219
-        if ($form instanceof EE_Form_Section_Proper) {
220
-            return true;
221
-        }
222
-        throw new LogicException(
223
-            sprintf(
224
-                esc_html__('The "%1$s" form is invalid or missing. %2$s', 'event_espresso'),
225
-                $this->form_name,
226
-                var_export($form, true)
227
-            )
228
-        );
229
-    }
230
-
231
-
232
-    /**
233
-     * @param EE_Form_Section_Proper $form
234
-     */
235
-    public function setForm(EE_Form_Section_Proper $form)
236
-    {
237
-        $this->form = $form;
238
-    }
239
-
240
-
241
-    /**
242
-     * @return boolean
243
-     */
244
-    public function displayable()
245
-    {
246
-        return $this->displayable;
247
-    }
248
-
249
-
250
-    /**
251
-     * @param boolean $displayable
252
-     */
253
-    public function setDisplayable($displayable = false)
254
-    {
255
-        $this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN);
256
-    }
257
-
258
-
259
-    /**
260
-     * a public name for the form that can be displayed on the frontend of a site
261
-     *
262
-     * @return string
263
-     */
264
-    public function formName()
265
-    {
266
-        return $this->form_name;
267
-    }
268
-
269
-
270
-    /**
271
-     * @param string $form_name
272
-     * @throws InvalidDataTypeException
273
-     */
274
-    public function setFormName($form_name)
275
-    {
276
-        if (! is_string($form_name)) {
277
-            throw new InvalidDataTypeException('$form_name', $form_name, 'string');
278
-        }
279
-        $this->form_name = $form_name;
280
-    }
281
-
282
-
283
-    /**
284
-     * a public name for the form that can be displayed, but only in the admin
285
-     *
286
-     * @return string
287
-     */
288
-    public function adminName()
289
-    {
290
-        return $this->admin_name;
291
-    }
292
-
293
-
294
-    /**
295
-     * @param string $admin_name
296
-     * @throws InvalidDataTypeException
297
-     */
298
-    public function setAdminName($admin_name)
299
-    {
300
-        if (! is_string($admin_name)) {
301
-            throw new InvalidDataTypeException('$admin_name', $admin_name, 'string');
302
-        }
303
-        $this->admin_name = $admin_name;
304
-    }
305
-
306
-
307
-    /**
308
-     * a URL friendly string that can be used for identifying the form
309
-     *
310
-     * @return string
311
-     */
312
-    public function slug()
313
-    {
314
-        return $this->slug;
315
-    }
316
-
317
-
318
-    /**
319
-     * @param string $slug
320
-     * @throws InvalidDataTypeException
321
-     */
322
-    public function setSlug($slug)
323
-    {
324
-        if (! is_string($slug)) {
325
-            throw new InvalidDataTypeException('$slug', $slug, 'string');
326
-        }
327
-        $this->slug = $slug;
328
-    }
329
-
330
-
331
-    /**
332
-     * @return string
333
-     */
334
-    public function submitBtnText()
335
-    {
336
-        return $this->submit_btn_text;
337
-    }
338
-
339
-
340
-    /**
341
-     * @param string $submit_btn_text
342
-     * @throws InvalidDataTypeException
343
-     * @throws InvalidArgumentException
344
-     */
345
-    public function setSubmitBtnText($submit_btn_text)
346
-    {
347
-        if (! is_string($submit_btn_text)) {
348
-            throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string');
349
-        }
350
-        if (empty($submit_btn_text)) {
351
-            throw new InvalidArgumentException(
352
-                esc_html__('Can not set Submit button text because an empty string was provided.', 'event_espresso')
353
-            );
354
-        }
355
-        $this->submit_btn_text = $submit_btn_text;
356
-    }
357
-
358
-
359
-    /**
360
-     * @return string
361
-     */
362
-    public function formAction()
363
-    {
364
-        return ! empty($this->form_args)
365
-            ? add_query_arg($this->form_args, $this->form_action)
366
-            : $this->form_action;
367
-    }
368
-
369
-
370
-    /**
371
-     * @param string $form_action
372
-     * @throws InvalidDataTypeException
373
-     */
374
-    public function setFormAction($form_action)
375
-    {
376
-        if (! is_string($form_action)) {
377
-            throw new InvalidDataTypeException('$form_action', $form_action, 'string');
378
-        }
379
-        $this->form_action = $form_action;
380
-    }
381
-
382
-
383
-    /**
384
-     * @param array $form_args
385
-     * @throws InvalidDataTypeException
386
-     * @throws InvalidArgumentException
387
-     */
388
-    public function addFormActionArgs($form_args = array())
389
-    {
390
-        if (is_object($form_args)) {
391
-            throw new InvalidDataTypeException(
392
-                '$form_args',
393
-                $form_args,
394
-                'anything other than an object was expected.'
395
-            );
396
-        }
397
-        if (empty($form_args)) {
398
-            throw new InvalidArgumentException(
399
-                esc_html__('The redirect arguments can not be an empty array.', 'event_espresso')
400
-            );
401
-        }
402
-        $this->form_args = array_merge($this->form_args, $form_args);
403
-    }
404
-
405
-
406
-    /**
407
-     * @return string
408
-     */
409
-    public function formConfig()
410
-    {
411
-        return $this->form_config;
412
-    }
413
-
414
-
415
-    /**
416
-     * @param string $form_config
417
-     * @throws DomainException
418
-     */
419
-    public function setFormConfig($form_config)
420
-    {
421
-        if (! in_array(
422
-            $form_config,
423
-            array(
424
-                FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
425
-                FormHandler::ADD_FORM_TAGS_ONLY,
426
-                FormHandler::ADD_FORM_SUBMIT_ONLY,
427
-                FormHandler::DO_NOT_SETUP_FORM,
428
-            ),
429
-            true
430
-        )
431
-        ) {
432
-            throw new DomainException(
433
-                sprintf(
434
-                    esc_html__(
435
-                        '"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form',
436
-                        'event_espresso'
437
-                    ),
438
-                    $form_config
439
-                )
440
-            );
441
-        }
442
-        $this->form_config = $form_config;
443
-    }
444
-
445
-
446
-    /**
447
-     * called after the form is instantiated
448
-     * and used for performing any logic that needs to occur early
449
-     * before any of the other methods are called.
450
-     * returns true if everything is ok to proceed,
451
-     * and false if no further form logic should be implemented
452
-     *
453
-     * @return boolean
454
-     */
455
-    public function initialize()
456
-    {
457
-        $this->form_has_errors = EE_Error::has_error(true);
458
-        return true;
459
-    }
460
-
461
-
462
-    /**
463
-     * used for setting up css and js
464
-     *
465
-     * @return void
466
-     * @throws LogicException
467
-     * @throws EE_Error
468
-     */
469
-    public function enqueueStylesAndScripts()
470
-    {
471
-        $this->form()->enqueue_js();
472
-    }
473
-
474
-
475
-    /**
476
-     * creates and returns the actual form
477
-     *
478
-     * @return EE_Form_Section_Proper
479
-     */
480
-    abstract public function generate();
481
-
482
-
483
-    /**
484
-     * creates and returns an EE_Submit_Input labeled "Submit"
485
-     *
486
-     * @param string $text
487
-     * @return EE_Submit_Input
488
-     */
489
-    public function generateSubmitButton($text = '')
490
-    {
491
-        $text = ! empty($text) ? $text : $this->submitBtnText();
492
-        return new EE_Submit_Input(
493
-            array(
494
-                'html_name'             => 'ee-form-submit-' . $this->slug(),
495
-                'html_id'               => 'ee-form-submit-' . $this->slug(),
496
-                'html_class'            => 'ee-form-submit',
497
-                'html_label'            => ' ',
498
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
499
-                'default'               => $text,
500
-            )
501
-        );
502
-    }
503
-
504
-
505
-    /**
506
-     * calls generateSubmitButton() and appends it onto the form along with a float clearing div
507
-     *
508
-     * @param string $text
509
-     * @return void
510
-     * @throws EE_Error
511
-     */
512
-    public function appendSubmitButton($text = '')
513
-    {
514
-        if ($this->form->subsection_exists($this->slug() . '-submit-btn')) {
515
-            return;
516
-        }
517
-        $this->form->add_subsections(
518
-            array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)),
519
-            null,
520
-            false
521
-        );
522
-    }
523
-
524
-
525
-    /**
526
-     * creates and returns an EE_Submit_Input labeled "Cancel"
527
-     *
528
-     * @param string $text
529
-     * @return EE_Submit_Input
530
-     */
531
-    public function generateCancelButton($text = '')
532
-    {
533
-        $cancel_button = new EE_Submit_Input(
534
-            array(
535
-                'html_name'             => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!!
536
-                'html_id'               => 'ee-cancel-form-' . $this->slug(),
537
-                'html_class'            => 'ee-cancel-form',
538
-                'html_label'            => ' ',
539
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
540
-                'default'               => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'),
541
-            )
542
-        );
543
-        $cancel_button->set_button_css_attributes(false);
544
-        return $cancel_button;
545
-    }
546
-
547
-
548
-    /**
549
-     * appends a float clearing div onto end of form
550
-     *
551
-     * @return void
552
-     * @throws EE_Error
553
-     */
554
-    public function clearFormButtonFloats()
555
-    {
556
-        $this->form->add_subsections(
557
-            array(
558
-                'clear-submit-btn-float' => new EE_Form_Section_HTML(
559
-                    EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx()
560
-                ),
561
-            ),
562
-            null,
563
-            false
564
-        );
565
-    }
566
-
567
-
568
-    /**
569
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
570
-     * returns a string of HTML that can be directly echoed in a template
571
-     *
572
-     * @return string
573
-     * @throws \InvalidArgumentException
574
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
575
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
576
-     * @throws LogicException
577
-     * @throws EE_Error
578
-     */
579
-    public function display()
580
-    {
581
-        $form_html = apply_filters(
582
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form',
583
-            ''
584
-        );
585
-        $form_config = $this->formConfig();
586
-        if ($form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
587
-            || $form_config === FormHandler::ADD_FORM_TAGS_ONLY
588
-        ) {
589
-            $additional_props = $this->requiresMultipartEnctype()
590
-                ? 'enctype="multipart/form-data"'
591
-                : '';
592
-            $form_html .= $this->form()->form_open(
593
-                $this->formAction(),
594
-                'POST',
595
-                $additional_props
596
-            );
597
-        }
598
-        $form_html .= $this->form(true)->get_html();
599
-        if ($form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
600
-            || $form_config === FormHandler::ADD_FORM_TAGS_ONLY
601
-        ) {
602
-            $form_html .= $this->form()->form_close();
603
-        }
604
-        $form_html .= apply_filters(
605
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__after_form',
606
-            ''
607
-        );
608
-        return $form_html;
609
-    }
610
-
611
-    /**
612
-     * Determines if this form needs "enctype='multipart/form-data'" or not.
613
-     * @since 4.9.80.p
614
-     * @return bool
615
-     * @throws EE_Error
616
-     */
617
-    public function requiresMultipartEnctype()
618
-    {
619
-        foreach ($this->form()->inputs_in_subsections() as $input) {
620
-            if ($input instanceof EE_File_Input) {
621
-                return true;
622
-            }
623
-        }
624
-        return false;
625
-    }
626
-
627
-
628
-    /**
629
-     * handles processing the form submission
630
-     * returns true or false depending on whether the form was processed successfully or not
631
-     *
632
-     * @param array $submitted_form_data
633
-     * @return array
634
-     * @throws \InvalidArgumentException
635
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
636
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
637
-     * @throws EE_Error
638
-     * @throws LogicException
639
-     * @throws InvalidFormSubmissionException
640
-     */
641
-    public function process($submitted_form_data = array())
642
-    {
643
-        if (! $this->form()->was_submitted($submitted_form_data)) {
644
-            throw new InvalidFormSubmissionException($this->form_name);
645
-        }
646
-        $this->form(true)->receive_form_submission($submitted_form_data);
647
-        if (! $this->form()->is_valid()) {
648
-            throw new InvalidFormSubmissionException(
649
-                $this->form_name,
650
-                sprintf(
651
-                    esc_html__(
652
-                        'The "%1$s" form is invalid. Please correct the following errors and resubmit: %2$s %3$s',
653
-                        'event_espresso'
654
-                    ),
655
-                    $this->form_name,
656
-                    '<br />',
657
-                    implode('<br />', $this->form()->get_validation_errors_accumulated())
658
-                )
659
-            );
660
-        }
661
-        return apply_filters(
662
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__process__valid_data',
663
-            $this->form()->valid_data(),
664
-            $this
665
-        );
666
-    }
32
+	/**
33
+	 * will add opening and closing HTML form tags as well as a submit button
34
+	 */
35
+	const ADD_FORM_TAGS_AND_SUBMIT = 'add_form_tags_and_submit';
36
+
37
+	/**
38
+	 * will add opening and closing HTML form tags but NOT a submit button
39
+	 */
40
+	const ADD_FORM_TAGS_ONLY = 'add_form_tags_only';
41
+
42
+	/**
43
+	 * will NOT add opening and closing HTML form tags but will add a submit button
44
+	 */
45
+	const ADD_FORM_SUBMIT_ONLY = 'add_form_submit_only';
46
+
47
+	/**
48
+	 * will NOT add opening and closing HTML form tags NOR a submit button
49
+	 */
50
+	const DO_NOT_SETUP_FORM = 'do_not_setup_form';
51
+
52
+	/**
53
+	 * if set to false, then this form has no displayable content,
54
+	 * and will only be used for processing data sent passed via GET or POST
55
+	 * defaults to true ( ie: form has displayable content )
56
+	 *
57
+	 * @var boolean $displayable
58
+	 */
59
+	private $displayable = true;
60
+
61
+	/**
62
+	 * @var string $form_name
63
+	 */
64
+	private $form_name;
65
+
66
+	/**
67
+	 * @var string $admin_name
68
+	 */
69
+	private $admin_name;
70
+
71
+	/**
72
+	 * @var string $slug
73
+	 */
74
+	private $slug;
75
+
76
+	/**
77
+	 * @var string $submit_btn_text
78
+	 */
79
+	private $submit_btn_text;
80
+
81
+	/**
82
+	 * @var string $form_action
83
+	 */
84
+	private $form_action;
85
+
86
+	/**
87
+	 * form params in key value pairs
88
+	 * can be added to form action URL or as hidden inputs
89
+	 *
90
+	 * @var array $form_args
91
+	 */
92
+	private $form_args = array();
93
+
94
+	/**
95
+	 * value of one of the string constant above
96
+	 *
97
+	 * @var string $form_config
98
+	 */
99
+	private $form_config;
100
+
101
+	/**
102
+	 * whether or not the form was determined to be invalid
103
+	 *
104
+	 * @var boolean $form_has_errors
105
+	 */
106
+	private $form_has_errors;
107
+
108
+	/**
109
+	 * the absolute top level form section being used on the page
110
+	 *
111
+	 * @var EE_Form_Section_Proper $form
112
+	 */
113
+	private $form;
114
+
115
+	/**
116
+	 * @var EE_Registry $registry
117
+	 */
118
+	protected $registry;
119
+
120
+	// phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
121
+	/**
122
+	 * Form constructor.
123
+	 *
124
+	 * @param string      $form_name
125
+	 * @param string      $admin_name
126
+	 * @param string      $slug
127
+	 * @param string      $form_action
128
+	 * @param string      $form_config
129
+	 * @param EE_Registry $registry
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws DomainException
132
+	 * @throws InvalidArgumentException
133
+	 */
134
+	public function __construct(
135
+		$form_name,
136
+		$admin_name,
137
+		$slug,
138
+		$form_action = '',
139
+		$form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
140
+		EE_Registry $registry
141
+	) {
142
+		$this->setFormName($form_name);
143
+		$this->setAdminName($admin_name);
144
+		$this->setSlug($slug);
145
+		$this->setFormAction($form_action);
146
+		$this->setFormConfig($form_config);
147
+		$this->setSubmitBtnText(esc_html__('Submit', 'event_espresso'));
148
+		$this->registry = $registry;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return array
154
+	 */
155
+	public static function getFormConfigConstants()
156
+	{
157
+		return array(
158
+			FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
159
+			FormHandler::ADD_FORM_TAGS_ONLY,
160
+			FormHandler::ADD_FORM_SUBMIT_ONLY,
161
+			FormHandler::DO_NOT_SETUP_FORM,
162
+		);
163
+	}
164
+
165
+
166
+	/**
167
+	 * @param bool $for_display
168
+	 * @return EE_Form_Section_Proper
169
+	 * @throws EE_Error
170
+	 * @throws LogicException
171
+	 */
172
+	public function form($for_display = false)
173
+	{
174
+		if (! $this->formIsValid()) {
175
+			return null;
176
+		}
177
+		if ($for_display) {
178
+			$form_config = $this->formConfig();
179
+			if ($form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
180
+				|| $form_config === FormHandler::ADD_FORM_SUBMIT_ONLY
181
+			) {
182
+				$this->appendSubmitButton();
183
+				$this->clearFormButtonFloats();
184
+			}
185
+		}
186
+		return $this->form;
187
+	}
188
+
189
+
190
+	/**
191
+	 * @return boolean
192
+	 * @throws LogicException
193
+	 */
194
+	public function formIsValid()
195
+	{
196
+		if ($this->form instanceof EE_Form_Section_Proper) {
197
+			return true;
198
+		}
199
+		$form = apply_filters(
200
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object',
201
+			$this->generate(),
202
+			$this
203
+		);
204
+		if ($this->verifyForm($form)) {
205
+			$this->setForm($form);
206
+		}
207
+		return true;
208
+	}
209
+
210
+
211
+	/**
212
+	 * @param EE_Form_Section_Proper|null $form
213
+	 * @return bool
214
+	 * @throws LogicException
215
+	 */
216
+	public function verifyForm(EE_Form_Section_Proper $form = null)
217
+	{
218
+		$form = $form !== null ? $form : $this->form;
219
+		if ($form instanceof EE_Form_Section_Proper) {
220
+			return true;
221
+		}
222
+		throw new LogicException(
223
+			sprintf(
224
+				esc_html__('The "%1$s" form is invalid or missing. %2$s', 'event_espresso'),
225
+				$this->form_name,
226
+				var_export($form, true)
227
+			)
228
+		);
229
+	}
230
+
231
+
232
+	/**
233
+	 * @param EE_Form_Section_Proper $form
234
+	 */
235
+	public function setForm(EE_Form_Section_Proper $form)
236
+	{
237
+		$this->form = $form;
238
+	}
239
+
240
+
241
+	/**
242
+	 * @return boolean
243
+	 */
244
+	public function displayable()
245
+	{
246
+		return $this->displayable;
247
+	}
248
+
249
+
250
+	/**
251
+	 * @param boolean $displayable
252
+	 */
253
+	public function setDisplayable($displayable = false)
254
+	{
255
+		$this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN);
256
+	}
257
+
258
+
259
+	/**
260
+	 * a public name for the form that can be displayed on the frontend of a site
261
+	 *
262
+	 * @return string
263
+	 */
264
+	public function formName()
265
+	{
266
+		return $this->form_name;
267
+	}
268
+
269
+
270
+	/**
271
+	 * @param string $form_name
272
+	 * @throws InvalidDataTypeException
273
+	 */
274
+	public function setFormName($form_name)
275
+	{
276
+		if (! is_string($form_name)) {
277
+			throw new InvalidDataTypeException('$form_name', $form_name, 'string');
278
+		}
279
+		$this->form_name = $form_name;
280
+	}
281
+
282
+
283
+	/**
284
+	 * a public name for the form that can be displayed, but only in the admin
285
+	 *
286
+	 * @return string
287
+	 */
288
+	public function adminName()
289
+	{
290
+		return $this->admin_name;
291
+	}
292
+
293
+
294
+	/**
295
+	 * @param string $admin_name
296
+	 * @throws InvalidDataTypeException
297
+	 */
298
+	public function setAdminName($admin_name)
299
+	{
300
+		if (! is_string($admin_name)) {
301
+			throw new InvalidDataTypeException('$admin_name', $admin_name, 'string');
302
+		}
303
+		$this->admin_name = $admin_name;
304
+	}
305
+
306
+
307
+	/**
308
+	 * a URL friendly string that can be used for identifying the form
309
+	 *
310
+	 * @return string
311
+	 */
312
+	public function slug()
313
+	{
314
+		return $this->slug;
315
+	}
316
+
317
+
318
+	/**
319
+	 * @param string $slug
320
+	 * @throws InvalidDataTypeException
321
+	 */
322
+	public function setSlug($slug)
323
+	{
324
+		if (! is_string($slug)) {
325
+			throw new InvalidDataTypeException('$slug', $slug, 'string');
326
+		}
327
+		$this->slug = $slug;
328
+	}
329
+
330
+
331
+	/**
332
+	 * @return string
333
+	 */
334
+	public function submitBtnText()
335
+	{
336
+		return $this->submit_btn_text;
337
+	}
338
+
339
+
340
+	/**
341
+	 * @param string $submit_btn_text
342
+	 * @throws InvalidDataTypeException
343
+	 * @throws InvalidArgumentException
344
+	 */
345
+	public function setSubmitBtnText($submit_btn_text)
346
+	{
347
+		if (! is_string($submit_btn_text)) {
348
+			throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string');
349
+		}
350
+		if (empty($submit_btn_text)) {
351
+			throw new InvalidArgumentException(
352
+				esc_html__('Can not set Submit button text because an empty string was provided.', 'event_espresso')
353
+			);
354
+		}
355
+		$this->submit_btn_text = $submit_btn_text;
356
+	}
357
+
358
+
359
+	/**
360
+	 * @return string
361
+	 */
362
+	public function formAction()
363
+	{
364
+		return ! empty($this->form_args)
365
+			? add_query_arg($this->form_args, $this->form_action)
366
+			: $this->form_action;
367
+	}
368
+
369
+
370
+	/**
371
+	 * @param string $form_action
372
+	 * @throws InvalidDataTypeException
373
+	 */
374
+	public function setFormAction($form_action)
375
+	{
376
+		if (! is_string($form_action)) {
377
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
378
+		}
379
+		$this->form_action = $form_action;
380
+	}
381
+
382
+
383
+	/**
384
+	 * @param array $form_args
385
+	 * @throws InvalidDataTypeException
386
+	 * @throws InvalidArgumentException
387
+	 */
388
+	public function addFormActionArgs($form_args = array())
389
+	{
390
+		if (is_object($form_args)) {
391
+			throw new InvalidDataTypeException(
392
+				'$form_args',
393
+				$form_args,
394
+				'anything other than an object was expected.'
395
+			);
396
+		}
397
+		if (empty($form_args)) {
398
+			throw new InvalidArgumentException(
399
+				esc_html__('The redirect arguments can not be an empty array.', 'event_espresso')
400
+			);
401
+		}
402
+		$this->form_args = array_merge($this->form_args, $form_args);
403
+	}
404
+
405
+
406
+	/**
407
+	 * @return string
408
+	 */
409
+	public function formConfig()
410
+	{
411
+		return $this->form_config;
412
+	}
413
+
414
+
415
+	/**
416
+	 * @param string $form_config
417
+	 * @throws DomainException
418
+	 */
419
+	public function setFormConfig($form_config)
420
+	{
421
+		if (! in_array(
422
+			$form_config,
423
+			array(
424
+				FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
425
+				FormHandler::ADD_FORM_TAGS_ONLY,
426
+				FormHandler::ADD_FORM_SUBMIT_ONLY,
427
+				FormHandler::DO_NOT_SETUP_FORM,
428
+			),
429
+			true
430
+		)
431
+		) {
432
+			throw new DomainException(
433
+				sprintf(
434
+					esc_html__(
435
+						'"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form',
436
+						'event_espresso'
437
+					),
438
+					$form_config
439
+				)
440
+			);
441
+		}
442
+		$this->form_config = $form_config;
443
+	}
444
+
445
+
446
+	/**
447
+	 * called after the form is instantiated
448
+	 * and used for performing any logic that needs to occur early
449
+	 * before any of the other methods are called.
450
+	 * returns true if everything is ok to proceed,
451
+	 * and false if no further form logic should be implemented
452
+	 *
453
+	 * @return boolean
454
+	 */
455
+	public function initialize()
456
+	{
457
+		$this->form_has_errors = EE_Error::has_error(true);
458
+		return true;
459
+	}
460
+
461
+
462
+	/**
463
+	 * used for setting up css and js
464
+	 *
465
+	 * @return void
466
+	 * @throws LogicException
467
+	 * @throws EE_Error
468
+	 */
469
+	public function enqueueStylesAndScripts()
470
+	{
471
+		$this->form()->enqueue_js();
472
+	}
473
+
474
+
475
+	/**
476
+	 * creates and returns the actual form
477
+	 *
478
+	 * @return EE_Form_Section_Proper
479
+	 */
480
+	abstract public function generate();
481
+
482
+
483
+	/**
484
+	 * creates and returns an EE_Submit_Input labeled "Submit"
485
+	 *
486
+	 * @param string $text
487
+	 * @return EE_Submit_Input
488
+	 */
489
+	public function generateSubmitButton($text = '')
490
+	{
491
+		$text = ! empty($text) ? $text : $this->submitBtnText();
492
+		return new EE_Submit_Input(
493
+			array(
494
+				'html_name'             => 'ee-form-submit-' . $this->slug(),
495
+				'html_id'               => 'ee-form-submit-' . $this->slug(),
496
+				'html_class'            => 'ee-form-submit',
497
+				'html_label'            => '&nbsp;',
498
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
499
+				'default'               => $text,
500
+			)
501
+		);
502
+	}
503
+
504
+
505
+	/**
506
+	 * calls generateSubmitButton() and appends it onto the form along with a float clearing div
507
+	 *
508
+	 * @param string $text
509
+	 * @return void
510
+	 * @throws EE_Error
511
+	 */
512
+	public function appendSubmitButton($text = '')
513
+	{
514
+		if ($this->form->subsection_exists($this->slug() . '-submit-btn')) {
515
+			return;
516
+		}
517
+		$this->form->add_subsections(
518
+			array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)),
519
+			null,
520
+			false
521
+		);
522
+	}
523
+
524
+
525
+	/**
526
+	 * creates and returns an EE_Submit_Input labeled "Cancel"
527
+	 *
528
+	 * @param string $text
529
+	 * @return EE_Submit_Input
530
+	 */
531
+	public function generateCancelButton($text = '')
532
+	{
533
+		$cancel_button = new EE_Submit_Input(
534
+			array(
535
+				'html_name'             => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!!
536
+				'html_id'               => 'ee-cancel-form-' . $this->slug(),
537
+				'html_class'            => 'ee-cancel-form',
538
+				'html_label'            => '&nbsp;',
539
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
540
+				'default'               => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'),
541
+			)
542
+		);
543
+		$cancel_button->set_button_css_attributes(false);
544
+		return $cancel_button;
545
+	}
546
+
547
+
548
+	/**
549
+	 * appends a float clearing div onto end of form
550
+	 *
551
+	 * @return void
552
+	 * @throws EE_Error
553
+	 */
554
+	public function clearFormButtonFloats()
555
+	{
556
+		$this->form->add_subsections(
557
+			array(
558
+				'clear-submit-btn-float' => new EE_Form_Section_HTML(
559
+					EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx()
560
+				),
561
+			),
562
+			null,
563
+			false
564
+		);
565
+	}
566
+
567
+
568
+	/**
569
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
570
+	 * returns a string of HTML that can be directly echoed in a template
571
+	 *
572
+	 * @return string
573
+	 * @throws \InvalidArgumentException
574
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
575
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
576
+	 * @throws LogicException
577
+	 * @throws EE_Error
578
+	 */
579
+	public function display()
580
+	{
581
+		$form_html = apply_filters(
582
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form',
583
+			''
584
+		);
585
+		$form_config = $this->formConfig();
586
+		if ($form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
587
+			|| $form_config === FormHandler::ADD_FORM_TAGS_ONLY
588
+		) {
589
+			$additional_props = $this->requiresMultipartEnctype()
590
+				? 'enctype="multipart/form-data"'
591
+				: '';
592
+			$form_html .= $this->form()->form_open(
593
+				$this->formAction(),
594
+				'POST',
595
+				$additional_props
596
+			);
597
+		}
598
+		$form_html .= $this->form(true)->get_html();
599
+		if ($form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
600
+			|| $form_config === FormHandler::ADD_FORM_TAGS_ONLY
601
+		) {
602
+			$form_html .= $this->form()->form_close();
603
+		}
604
+		$form_html .= apply_filters(
605
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__after_form',
606
+			''
607
+		);
608
+		return $form_html;
609
+	}
610
+
611
+	/**
612
+	 * Determines if this form needs "enctype='multipart/form-data'" or not.
613
+	 * @since 4.9.80.p
614
+	 * @return bool
615
+	 * @throws EE_Error
616
+	 */
617
+	public function requiresMultipartEnctype()
618
+	{
619
+		foreach ($this->form()->inputs_in_subsections() as $input) {
620
+			if ($input instanceof EE_File_Input) {
621
+				return true;
622
+			}
623
+		}
624
+		return false;
625
+	}
626
+
627
+
628
+	/**
629
+	 * handles processing the form submission
630
+	 * returns true or false depending on whether the form was processed successfully or not
631
+	 *
632
+	 * @param array $submitted_form_data
633
+	 * @return array
634
+	 * @throws \InvalidArgumentException
635
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
636
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
637
+	 * @throws EE_Error
638
+	 * @throws LogicException
639
+	 * @throws InvalidFormSubmissionException
640
+	 */
641
+	public function process($submitted_form_data = array())
642
+	{
643
+		if (! $this->form()->was_submitted($submitted_form_data)) {
644
+			throw new InvalidFormSubmissionException($this->form_name);
645
+		}
646
+		$this->form(true)->receive_form_submission($submitted_form_data);
647
+		if (! $this->form()->is_valid()) {
648
+			throw new InvalidFormSubmissionException(
649
+				$this->form_name,
650
+				sprintf(
651
+					esc_html__(
652
+						'The "%1$s" form is invalid. Please correct the following errors and resubmit: %2$s %3$s',
653
+						'event_espresso'
654
+					),
655
+					$this->form_name,
656
+					'<br />',
657
+					implode('<br />', $this->form()->get_validation_errors_accumulated())
658
+				)
659
+			);
660
+		}
661
+		return apply_filters(
662
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__process__valid_data',
663
+			$this->form()->valid_data(),
664
+			$this
665
+		);
666
+	}
667 667
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/InvalidFormHandlerException.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
 class InvalidFormHandlerException extends \UnexpectedValueException
14 14
 {
15 15
 
16
-    /**
17
-     * InvalidFormHandlerException constructor.
18
-     *
19
-     * @param string     $actual the FormHandler object that was received
20
-     * @param string     $message
21
-     * @param int        $code
22
-     * @param \Exception $previous
23
-     */
24
-    public function __construct($actual, $message = '', $code = 0, \Exception $previous = null)
25
-    {
26
-        if (empty($message)) {
27
-            $message = sprintf(
28
-                __(
29
-                    'A valid Form Handler was expected but instead "%1$s" was received.',
30
-                    'event_espresso'
31
-                ),
32
-                $actual
33
-            );
34
-        }
35
-        parent::__construct($message, $code, $previous);
36
-    }
16
+	/**
17
+	 * InvalidFormHandlerException constructor.
18
+	 *
19
+	 * @param string     $actual the FormHandler object that was received
20
+	 * @param string     $message
21
+	 * @param int        $code
22
+	 * @param \Exception $previous
23
+	 */
24
+	public function __construct($actual, $message = '', $code = 0, \Exception $previous = null)
25
+	{
26
+		if (empty($message)) {
27
+			$message = sprintf(
28
+				__(
29
+					'A valid Form Handler was expected but instead "%1$s" was received.',
30
+					'event_espresso'
31
+				),
32
+				$actual
33
+			);
34
+		}
35
+		parent::__construct($message, $code, $previous);
36
+	}
37 37
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/strategies/filter/FormHtmlFilter.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@
 block discarded – undo
14 14
 abstract class FormHtmlFilter
15 15
 {
16 16
 
17
-    /**
18
-     * @param                             $html
19
-     * @param EE_Form_Section_Validatable $form_section
20
-     * @return string
21
-     */
22
-    abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section);
17
+	/**
18
+	 * @param                             $html
19
+	 * @param EE_Form_Section_Validatable $form_section
20
+	 * @return string
21
+	 */
22
+	abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section);
23 23
 }
Please login to merge, or discard this patch.
core/libraries/iframe_display/EventListIframeEmbedButton.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@
 block discarded – undo
12 12
 class EventListIframeEmbedButton extends IframeEmbedButton
13 13
 {
14 14
 
15
-    /**
16
-     * EventListIframeEmbedButton constructor.
17
-     */
18
-    public function __construct()
19
-    {
20
-        parent::__construct(
21
-            esc_html__('Upcoming Event List', 'event_espresso'),
22
-            'event_list'
23
-        );
24
-    }
15
+	/**
16
+	 * EventListIframeEmbedButton constructor.
17
+	 */
18
+	public function __construct()
19
+	{
20
+		parent::__construct(
21
+			esc_html__('Upcoming Event List', 'event_espresso'),
22
+			'event_list'
23
+		);
24
+	}
25 25
 
26 26
 
27
-    public function addEmbedButton()
28
-    {
29
-        add_filter(
30
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
31
-            array($this, 'addEventListIframeEmbedButtonSection')
32
-        );
33
-        add_action(
34
-            'admin_enqueue_scripts',
35
-            array($this, 'embedButtonAssets'),
36
-            10
37
-        );
38
-    }
27
+	public function addEmbedButton()
28
+	{
29
+		add_filter(
30
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
31
+			array($this, 'addEventListIframeEmbedButtonSection')
32
+		);
33
+		add_action(
34
+			'admin_enqueue_scripts',
35
+			array($this, 'embedButtonAssets'),
36
+			10
37
+		);
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * Adds an iframe embed code button to the Event editor.
43
-     * return string
44
-     *
45
-     * @param array $after_list_table
46
-     * @return array
47
-     */
48
-    public function addEventListIframeEmbedButtonSection(array $after_list_table)
49
-    {
50
-        return \EEH_Array::insert_into_array(
51
-            $after_list_table,
52
-            array(
53
-                'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection(
54
-                    array('event_list' => $this->embedButtonHtml())
55
-                ),
56
-            ),
57
-            'legend'
58
-        );
59
-    }
41
+	/**
42
+	 * Adds an iframe embed code button to the Event editor.
43
+	 * return string
44
+	 *
45
+	 * @param array $after_list_table
46
+	 * @return array
47
+	 */
48
+	public function addEventListIframeEmbedButtonSection(array $after_list_table)
49
+	{
50
+		return \EEH_Array::insert_into_array(
51
+			$after_list_table,
52
+			array(
53
+				'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection(
54
+					array('event_list' => $this->embedButtonHtml())
55
+				),
56
+			),
57
+			'legend'
58
+		);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/RestException.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,54 +14,54 @@
 block discarded – undo
14 14
 class RestException extends \EE_Error
15 15
 {
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $wp_error_data = array();
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $wp_error_data = array();
21 21
 
22
-    protected $wp_error_code = '';
22
+	protected $wp_error_code = '';
23 23
 
24 24
 
25 25
 
26
-    public function __construct($string_code, $message, $wp_error_data = array(), $previous = null)
27
-    {
28
-        if (is_array($wp_error_data)
29
-            && isset($wp_error_data['status'])
30
-        ) {
31
-            $http_status_number = $wp_error_data['status'];
32
-        } else {
33
-            $http_status_number = 500;
34
-        }
35
-        parent::__construct(
36
-            $message,
37
-            $http_status_number,
38
-            $previous
39
-        );
40
-        $this->wp_error_data = $wp_error_data;
41
-        $this->wp_error_code = $string_code;
42
-    }
26
+	public function __construct($string_code, $message, $wp_error_data = array(), $previous = null)
27
+	{
28
+		if (is_array($wp_error_data)
29
+			&& isset($wp_error_data['status'])
30
+		) {
31
+			$http_status_number = $wp_error_data['status'];
32
+		} else {
33
+			$http_status_number = 500;
34
+		}
35
+		parent::__construct(
36
+			$message,
37
+			$http_status_number,
38
+			$previous
39
+		);
40
+		$this->wp_error_data = $wp_error_data;
41
+		$this->wp_error_code = $string_code;
42
+	}
43 43
 
44 44
 
45 45
 
46
-    /**
47
-     * Array of data that may have been set during the constructor, intended for WP_Error's data
48
-     *
49
-     * @return array
50
-     */
51
-    public function getData()
52
-    {
53
-        return $this->wp_error_data;
54
-    }
46
+	/**
47
+	 * Array of data that may have been set during the constructor, intended for WP_Error's data
48
+	 *
49
+	 * @return array
50
+	 */
51
+	public function getData()
52
+	{
53
+		return $this->wp_error_data;
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     * Gets the error string
60
-     *
61
-     * @return string
62
-     */
63
-    public function getStringCode()
64
-    {
65
-        return $this->wp_error_code;
66
-    }
58
+	/**
59
+	 * Gets the error string
60
+	 *
61
+	 * @return string
62
+	 */
63
+	public function getStringCode()
64
+	{
65
+		return $this->wp_error_code;
66
+	}
67 67
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/ChangesIn40834.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -10,38 +10,38 @@
 block discarded – undo
10 10
 class ChangesIn40834 extends ChangesInBase
11 11
 {
12 12
 
13
-    /**
14
-     * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
15
-     */
16
-    public function setHooks()
17
-    {
18
-        // set a hook to remove the checkout/checkout endpoints if the request
19
-        // is for lower than 4.8.33
20
-        add_filter(
21
-            'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
22
-            array($this, 'removeResponseHeaders'),
23
-            10,
24
-            3
25
-        );
26
-    }
13
+	/**
14
+	 * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
15
+	 */
16
+	public function setHooks()
17
+	{
18
+		// set a hook to remove the checkout/checkout endpoints if the request
19
+		// is for lower than 4.8.33
20
+		add_filter(
21
+			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
22
+			array($this, 'removeResponseHeaders'),
23
+			10,
24
+			3
25
+		);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * Removes the checkin and checkout endpoints from the index for requests
31
-     * to api versions lowers than 4.8.33
32
-     *
33
-     * @param array  $response_headers
34
-     * @param Base   $controller
35
-     * @param string $requested_version
36
-     * @return array like $routes_on_this_version
37
-     */
38
-    public function removeResponseHeaders($response_headers, $controller, $requested_version)
39
-    {
40
-        if ($controller instanceof Base
41
-            && $this->appliesToVersion($requested_version)
42
-        ) {
43
-            return array();
44
-        }
45
-        return $response_headers;
46
-    }
29
+	/**
30
+	 * Removes the checkin and checkout endpoints from the index for requests
31
+	 * to api versions lowers than 4.8.33
32
+	 *
33
+	 * @param array  $response_headers
34
+	 * @param Base   $controller
35
+	 * @param string $requested_version
36
+	 * @return array like $routes_on_this_version
37
+	 */
38
+	public function removeResponseHeaders($response_headers, $controller, $requested_version)
39
+	{
40
+		if ($controller instanceof Base
41
+			&& $this->appliesToVersion($requested_version)
42
+		) {
43
+			return array();
44
+		}
45
+		return $response_headers;
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/ChangesIn40833.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -7,57 +7,57 @@
 block discarded – undo
7 7
 class ChangesIn40833 extends ChangesInBase
8 8
 {
9 9
 
10
-    /**
11
-     * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
12
-     */
13
-    public function setHooks()
14
-    {
15
-        // set a hook to remove the checkout/checkout endpoints if the request
16
-        // is for lower than 4.8.33
17
-        add_filter(
18
-            'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
19
-            array($this, 'removeCheckinRoutesEarlierThan4833'),
20
-            10,
21
-            2
22
-        );
23
-        add_filter(
24
-            'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return',
25
-            array($this, 'dontAddHeadersFromEeNotices'),
26
-            10,
27
-            2
28
-        );
29
-    }
10
+	/**
11
+	 * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
12
+	 */
13
+	public function setHooks()
14
+	{
15
+		// set a hook to remove the checkout/checkout endpoints if the request
16
+		// is for lower than 4.8.33
17
+		add_filter(
18
+			'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
19
+			array($this, 'removeCheckinRoutesEarlierThan4833'),
20
+			10,
21
+			2
22
+		);
23
+		add_filter(
24
+			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return',
25
+			array($this, 'dontAddHeadersFromEeNotices'),
26
+			10,
27
+			2
28
+		);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Removes the checkin and checkout endpoints from the index for requests
34
-     * to api versions lowers than 4.8.33
35
-     *
36
-     * @param array  $routes_on_this_version
37
-     * @param string $version
38
-     * @return array like $routes_on_this_version
39
-     */
40
-    public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version)
41
-    {
42
-        if ($this->appliesToVersion($version)) {
43
-            unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']);
44
-        }
45
-        return $routes_on_this_version;
46
-    }
32
+	/**
33
+	 * Removes the checkin and checkout endpoints from the index for requests
34
+	 * to api versions lowers than 4.8.33
35
+	 *
36
+	 * @param array  $routes_on_this_version
37
+	 * @param string $version
38
+	 * @return array like $routes_on_this_version
39
+	 */
40
+	public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version)
41
+	{
42
+		if ($this->appliesToVersion($version)) {
43
+			unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']);
44
+		}
45
+		return $routes_on_this_version;
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * We just added headers for notices in this version
51
-     *
52
-     * @param array  $headers_from_ee_notices
53
-     * @param string $requested_version
54
-     * @return array
55
-     */
56
-    public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version)
57
-    {
58
-        if ($this->appliesToVersion($requested_version)) {
59
-            return array();
60
-        }
61
-        return $headers_from_ee_notices;
62
-    }
49
+	/**
50
+	 * We just added headers for notices in this version
51
+	 *
52
+	 * @param array  $headers_from_ee_notices
53
+	 * @param string $requested_version
54
+	 * @return array
55
+	 */
56
+	public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version)
57
+	{
58
+		if ($this->appliesToVersion($requested_version)) {
59
+			return array();
60
+		}
61
+		return $headers_from_ee_notices;
62
+	}
63 63
 }
Please login to merge, or discard this patch.