Completed
Branch master (59af22)
by
unknown
07:35 queued 03:06
created
core/domain/services/registration/form/v1/RegFormInputHandler.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $input_value
68 68
     ): bool {
69 69
         // check for critical inputs
70
-        if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) {
70
+        if ( ! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) {
71 71
             return false;
72 72
         }
73 73
         $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData(
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $form_input,
76 76
             $input_value
77 77
         );
78
-        if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) {
78
+        if ( ! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) {
79 79
             EE_Error::add_error(
80 80
                 sprintf(
81 81
                     esc_html_x(
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
138 138
          */
139 139
         $answer_cache_id   = $this->checkout_reg_url_link
140
-            ? $form_input . '-' . $reg_url_link
140
+            ? $form_input.'-'.$reg_url_link
141 141
             : $form_input;
142 142
         $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
143 143
         $answer_is_obj     = $registrant_answer instanceof EE_Answer;
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
                 break;
157 157
 
158 158
             default:
159
-                $ATT_input         = 'ATT_' . $form_input;
159
+                $ATT_input         = 'ATT_'.$form_input;
160 160
                 $attendee_property = $this->attendee_model->has_field($ATT_input);
161 161
                 $form_input        = $attendee_property
162
-                    ? 'ATT_' . $form_input
162
+                    ? 'ATT_'.$form_input
163 163
                     : $form_input;
164 164
         }
165 165
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     ): bool {
202 202
         if (empty($input_value)) {
203 203
             // if the form input isn't marked as being required, then just return
204
-            if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
204
+            if ( ! isset($this->required_questions[$form_input]) || ! $this->required_questions[$form_input]) {
205 205
                 return true;
206 206
             }
207 207
             switch ($form_input) {
Please login to merge, or discard this patch.
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -14,223 +14,223 @@
 block discarded – undo
14 14
 class RegFormInputHandler
15 15
 {
16 16
 
17
-    /**
18
-     * @var EEM_Attendee
19
-     */
20
-    private $attendee_model;
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    private $checkout_reg_url_link;
26
-
27
-    /**
28
-     * @var RegistrantData
29
-     */
30
-    private $registrant_data;
31
-
32
-    /**
33
-     * @var array
34
-     */
35
-    private $required_questions;
36
-
37
-
38
-    /**
39
-     * RegFormHandler constructor.
40
-     */
41
-    public function __construct(
42
-        string $checkout_reg_url_link,
43
-        array $required_questions,
44
-        EEM_Attendee $attendee_model,
45
-        RegistrantData $registrant_data
46
-    ) {
47
-        $this->attendee_model        = $attendee_model;
48
-        $this->checkout_reg_url_link = $checkout_reg_url_link;
49
-        $this->registrant_data       = $registrant_data;
50
-        $this->required_questions    = $required_questions;
51
-    }
52
-
53
-
54
-    /**
55
-     * @param EE_Registration  $registration
56
-     * @param string           $reg_url_link
57
-     * @param int|string       $form_input
58
-     * @param float|int|string $input_value
59
-     * @return bool
60
-     * @throws EE_Error
61
-     * @throws ReflectionException
62
-     */
63
-    public function processFormInput(
64
-        EE_Registration $registration,
65
-        string $reg_url_link,
66
-        $form_input,
67
-        $input_value
68
-    ): bool {
69
-        // check for critical inputs
70
-        if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) {
71
-            return false;
72
-        }
73
-        $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData(
74
-            $reg_url_link,
75
-            $form_input,
76
-            $input_value
77
-        );
78
-        if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) {
79
-            EE_Error::add_error(
80
-                sprintf(
81
-                    esc_html_x(
82
-                        'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
83
-                        'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
84
-                        'event_espresso'
85
-                    ),
86
-                    $form_input,
87
-                    $input_value
88
-                ),
89
-                __FILE__,
90
-                __FUNCTION__,
91
-                __LINE__
92
-            );
93
-            return false;
94
-        }
95
-        return true;
96
-    }
97
-
98
-
99
-    /**
100
-     * @param EE_Registration  $registration
101
-     * @param string           $reg_url_link
102
-     * @param int|string       $form_input
103
-     * @param float|int|string $input_value
104
-     * @return bool
105
-     * @throws EE_Error
106
-     * @throws InvalidArgumentException
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidInterfaceException
109
-     * @throws ReflectionException
110
-     */
111
-    private function saveRegistrationFormInput(
112
-        EE_Registration $registration,
113
-        string $reg_url_link,
114
-        $form_input = '',
115
-        $input_value = ''
116
-    ): bool {
117
-        // If email_confirm is sent it's not saved
118
-        if ((string) $form_input === 'email_confirm') {
119
-            return true;
120
-        }
121
-        // allow for plugins to hook in and do their own processing of the form input.
122
-        // For plugins to bypass normal processing here, they just need to return a truthy value.
123
-        if (
124
-            apply_filters(
125
-                'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput',
126
-                false,
127
-                $registration,
128
-                $form_input,
129
-                $input_value,
130
-                $this
131
-            )
132
-        ) {
133
-            return true;
134
-        }
135
-        /*
17
+	/**
18
+	 * @var EEM_Attendee
19
+	 */
20
+	private $attendee_model;
21
+
22
+	/**
23
+	 * @var string
24
+	 */
25
+	private $checkout_reg_url_link;
26
+
27
+	/**
28
+	 * @var RegistrantData
29
+	 */
30
+	private $registrant_data;
31
+
32
+	/**
33
+	 * @var array
34
+	 */
35
+	private $required_questions;
36
+
37
+
38
+	/**
39
+	 * RegFormHandler constructor.
40
+	 */
41
+	public function __construct(
42
+		string $checkout_reg_url_link,
43
+		array $required_questions,
44
+		EEM_Attendee $attendee_model,
45
+		RegistrantData $registrant_data
46
+	) {
47
+		$this->attendee_model        = $attendee_model;
48
+		$this->checkout_reg_url_link = $checkout_reg_url_link;
49
+		$this->registrant_data       = $registrant_data;
50
+		$this->required_questions    = $required_questions;
51
+	}
52
+
53
+
54
+	/**
55
+	 * @param EE_Registration  $registration
56
+	 * @param string           $reg_url_link
57
+	 * @param int|string       $form_input
58
+	 * @param float|int|string $input_value
59
+	 * @return bool
60
+	 * @throws EE_Error
61
+	 * @throws ReflectionException
62
+	 */
63
+	public function processFormInput(
64
+		EE_Registration $registration,
65
+		string $reg_url_link,
66
+		$form_input,
67
+		$input_value
68
+	): bool {
69
+		// check for critical inputs
70
+		if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) {
71
+			return false;
72
+		}
73
+		$input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData(
74
+			$reg_url_link,
75
+			$form_input,
76
+			$input_value
77
+		);
78
+		if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) {
79
+			EE_Error::add_error(
80
+				sprintf(
81
+					esc_html_x(
82
+						'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
83
+						'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
84
+						'event_espresso'
85
+					),
86
+					$form_input,
87
+					$input_value
88
+				),
89
+				__FILE__,
90
+				__FUNCTION__,
91
+				__LINE__
92
+			);
93
+			return false;
94
+		}
95
+		return true;
96
+	}
97
+
98
+
99
+	/**
100
+	 * @param EE_Registration  $registration
101
+	 * @param string           $reg_url_link
102
+	 * @param int|string       $form_input
103
+	 * @param float|int|string $input_value
104
+	 * @return bool
105
+	 * @throws EE_Error
106
+	 * @throws InvalidArgumentException
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidInterfaceException
109
+	 * @throws ReflectionException
110
+	 */
111
+	private function saveRegistrationFormInput(
112
+		EE_Registration $registration,
113
+		string $reg_url_link,
114
+		$form_input = '',
115
+		$input_value = ''
116
+	): bool {
117
+		// If email_confirm is sent it's not saved
118
+		if ((string) $form_input === 'email_confirm') {
119
+			return true;
120
+		}
121
+		// allow for plugins to hook in and do their own processing of the form input.
122
+		// For plugins to bypass normal processing here, they just need to return a truthy value.
123
+		if (
124
+			apply_filters(
125
+				'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput',
126
+				false,
127
+				$registration,
128
+				$form_input,
129
+				$input_value,
130
+				$this
131
+			)
132
+		) {
133
+			return true;
134
+		}
135
+		/*
136 136
          * $answer_cache_id is the key used to find the EE_Answer we want
137 137
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
138 138
          */
139
-        $answer_cache_id   = $this->checkout_reg_url_link
140
-            ? $form_input . '-' . $reg_url_link
141
-            : $form_input;
142
-        $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
143
-        $answer_is_obj     = $registrant_answer instanceof EE_Answer;
144
-        // rename form_inputs if they are EE_Attendee properties
145
-        switch ((string) $form_input) {
146
-            case 'state':
147
-            case 'STA_ID':
148
-                $attendee_property = true;
149
-                $form_input        = 'STA_ID';
150
-                break;
151
-
152
-            case 'country':
153
-            case 'CNT_ISO':
154
-                $attendee_property = true;
155
-                $form_input        = 'CNT_ISO';
156
-                break;
157
-
158
-            default:
159
-                $ATT_input         = 'ATT_' . $form_input;
160
-                $attendee_property = $this->attendee_model->has_field($ATT_input);
161
-                $form_input        = $attendee_property
162
-                    ? 'ATT_' . $form_input
163
-                    : $form_input;
164
-        }
165
-
166
-        // if this form input has a corresponding attendee property
167
-        if ($attendee_property) {
168
-            $this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value);
169
-            if ($answer_is_obj) {
170
-                // and delete the corresponding answer since we won't be storing this data in that object
171
-                $registration->_remove_relation_to($registrant_answer, 'Answer');
172
-                $registrant_answer->delete_permanently();
173
-            }
174
-            return true;
175
-        }
176
-        if ($answer_is_obj) {
177
-            // save this data to the answer object
178
-            $registrant_answer->set_value($input_value);
179
-            $result = $registrant_answer->save();
180
-            return $result !== false;
181
-        }
182
-        foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) {
183
-            if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
184
-                $answer->set_value($input_value);
185
-                $result = $answer->save();
186
-                return $result !== false;
187
-            }
188
-        }
189
-        return false;
190
-    }
191
-
192
-
193
-    /**
194
-     * @param int|string       $form_input
195
-     * @param float|int|string $input_value
196
-     * @return boolean
197
-     */
198
-    private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail(
199
-        $form_input = '',
200
-        $input_value = ''
201
-    ): bool {
202
-        if (empty($input_value)) {
203
-            // if the form input isn't marked as being required, then just return
204
-            if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
205
-                return true;
206
-            }
207
-            switch ($form_input) {
208
-                case 'fname':
209
-                    EE_Error::add_error(
210
-                        esc_html__('First Name is a required value.', 'event_espresso'),
211
-                        __FILE__,
212
-                        __FUNCTION__,
213
-                        __LINE__
214
-                    );
215
-                    return false;
216
-                case 'lname':
217
-                    EE_Error::add_error(
218
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
219
-                        __FILE__,
220
-                        __FUNCTION__,
221
-                        __LINE__
222
-                    );
223
-                    return false;
224
-                case 'email':
225
-                    EE_Error::add_error(
226
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
227
-                        __FILE__,
228
-                        __FUNCTION__,
229
-                        __LINE__
230
-                    );
231
-                    return false;
232
-            }
233
-        }
234
-        return true;
235
-    }
139
+		$answer_cache_id   = $this->checkout_reg_url_link
140
+			? $form_input . '-' . $reg_url_link
141
+			: $form_input;
142
+		$registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
143
+		$answer_is_obj     = $registrant_answer instanceof EE_Answer;
144
+		// rename form_inputs if they are EE_Attendee properties
145
+		switch ((string) $form_input) {
146
+			case 'state':
147
+			case 'STA_ID':
148
+				$attendee_property = true;
149
+				$form_input        = 'STA_ID';
150
+				break;
151
+
152
+			case 'country':
153
+			case 'CNT_ISO':
154
+				$attendee_property = true;
155
+				$form_input        = 'CNT_ISO';
156
+				break;
157
+
158
+			default:
159
+				$ATT_input         = 'ATT_' . $form_input;
160
+				$attendee_property = $this->attendee_model->has_field($ATT_input);
161
+				$form_input        = $attendee_property
162
+					? 'ATT_' . $form_input
163
+					: $form_input;
164
+		}
165
+
166
+		// if this form input has a corresponding attendee property
167
+		if ($attendee_property) {
168
+			$this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value);
169
+			if ($answer_is_obj) {
170
+				// and delete the corresponding answer since we won't be storing this data in that object
171
+				$registration->_remove_relation_to($registrant_answer, 'Answer');
172
+				$registrant_answer->delete_permanently();
173
+			}
174
+			return true;
175
+		}
176
+		if ($answer_is_obj) {
177
+			// save this data to the answer object
178
+			$registrant_answer->set_value($input_value);
179
+			$result = $registrant_answer->save();
180
+			return $result !== false;
181
+		}
182
+		foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) {
183
+			if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
184
+				$answer->set_value($input_value);
185
+				$result = $answer->save();
186
+				return $result !== false;
187
+			}
188
+		}
189
+		return false;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @param int|string       $form_input
195
+	 * @param float|int|string $input_value
196
+	 * @return boolean
197
+	 */
198
+	private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail(
199
+		$form_input = '',
200
+		$input_value = ''
201
+	): bool {
202
+		if (empty($input_value)) {
203
+			// if the form input isn't marked as being required, then just return
204
+			if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
205
+				return true;
206
+			}
207
+			switch ($form_input) {
208
+				case 'fname':
209
+					EE_Error::add_error(
210
+						esc_html__('First Name is a required value.', 'event_espresso'),
211
+						__FILE__,
212
+						__FUNCTION__,
213
+						__LINE__
214
+					);
215
+					return false;
216
+				case 'lname':
217
+					EE_Error::add_error(
218
+						esc_html__('Last Name is a required value.', 'event_espresso'),
219
+						__FILE__,
220
+						__FUNCTION__,
221
+						__LINE__
222
+					);
223
+					return false;
224
+				case 'email':
225
+					EE_Error::add_error(
226
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
227
+						__FILE__,
228
+						__FUNCTION__,
229
+						__LINE__
230
+					);
231
+					return false;
232
+			}
233
+		}
234
+		return true;
235
+	}
236 236
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/PrivacyConsentCheckboxForm.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 
10 10
 class PrivacyConsentCheckboxForm extends EE_Form_Section_Proper
11 11
 {
12
-    /**
13
-     * @param string $reg_step_slug
14
-     * @param string $consent_checkbox_label_text
15
-     * @throws EE_Error
16
-     */
17
-    public function __construct(string $reg_step_slug, string $consent_checkbox_label_text)
18
-    {
19
-        parent::__construct(
20
-            [
21
-                'layout_strategy' =>
22
-                    new EE_Template_Layout(
23
-                        [
24
-                            'input_template_file' => SPCO_REG_STEPS_PATH
25
-                                                     . $reg_step_slug
26
-                                                     . '/privacy_consent.template.php',
27
-                        ]
28
-                    ),
29
-                'subsections'     => [
30
-                    'consent' => new EE_Checkbox_Multi_Input(
31
-                        [
32
-                            'consent' => $consent_checkbox_label_text,
33
-                        ],
34
-                        [
35
-                            'required'                          => true,
36
-                            'required_validation_error_message' => esc_html__(
37
-                                'You must consent to these terms in order to register.',
38
-                                'event_espresso'
39
-                            ),
40
-                            'html_label_text'                   => '',
41
-                        ]
42
-                    ),
43
-                ],
44
-            ]
45
-        );
46
-    }
12
+	/**
13
+	 * @param string $reg_step_slug
14
+	 * @param string $consent_checkbox_label_text
15
+	 * @throws EE_Error
16
+	 */
17
+	public function __construct(string $reg_step_slug, string $consent_checkbox_label_text)
18
+	{
19
+		parent::__construct(
20
+			[
21
+				'layout_strategy' =>
22
+					new EE_Template_Layout(
23
+						[
24
+							'input_template_file' => SPCO_REG_STEPS_PATH
25
+													 . $reg_step_slug
26
+													 . '/privacy_consent.template.php',
27
+						]
28
+					),
29
+				'subsections'     => [
30
+					'consent' => new EE_Checkbox_Multi_Input(
31
+						[
32
+							'consent' => $consent_checkbox_label_text,
33
+						],
34
+						[
35
+							'required'                          => true,
36
+							'required_validation_error_message' => esc_html__(
37
+								'You must consent to these terms in order to register.',
38
+								'event_espresso'
39
+							),
40
+							'html_label_text'                   => '',
41
+						]
42
+					),
43
+				],
44
+			]
45
+		);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/RegistrantData.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function __construct()
71 71
     {
72
-        $this->primary_registrant_data = ['line_item_id' => null,];
72
+        $this->primary_registrant_data = ['line_item_id' => null, ];
73 73
     }
74 74
 
75 75
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
     public function initializeRegistrantData(EE_Registration $registration): void
81 81
     {
82 82
         $reg_url_link = $registration->reg_url_link();
83
-        $this->registrations[ $reg_url_link ] = $registration;
84
-        $this->registrant_answers[ $reg_url_link ] = $registration->answers();
85
-        $this->registrant_data[ $reg_url_link ] = [];
83
+        $this->registrations[$reg_url_link] = $registration;
84
+        $this->registrant_answers[$reg_url_link] = $registration->answers();
85
+        $this->registrant_data[$reg_url_link] = [];
86 86
         $this->attendee_counter++;
87 87
     }
88 88
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function getRegistrant(string $reg_url_link): ?EE_Registration
122 122
     {
123
-        return $this->registrations[ $reg_url_link ] ?? null;
123
+        return $this->registrations[$reg_url_link] ?? null;
124 124
     }
125 125
 
126 126
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function getRegistrantData(string $reg_url_link): ?array
132 132
     {
133
-        return $this->registrant_data[ $reg_url_link ] ?? null;
133
+        return $this->registrant_data[$reg_url_link] ?? null;
134 134
     }
135 135
 
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void
143 143
     {
144
-        $this->registrant_data[ $reg_url_link ][ $key ] = $value;
144
+        $this->registrant_data[$reg_url_link][$key] = $value;
145 145
     }
146 146
 
147 147
 
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
         }
178 178
         foreach ($critical_attendee_details as $critical_attendee_detail) {
179 179
             if (
180
-                ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
181
-                || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
180
+                ! isset($this->registrant_data[$reg_url_link][$critical_attendee_detail])
181
+                || empty($this->registrant_data[$reg_url_link][$critical_attendee_detail])
182 182
             ) {
183
-                $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get(
183
+                $this->registrant_data[$reg_url_link][$critical_attendee_detail] = $this->primary_registrant->get(
184 184
                     $critical_attendee_detail
185 185
                 );
186 186
             }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     public function setRegistrantData(string $reg_url_link, array $registrant_data): void
196 196
     {
197
-        $this->registrant_data[ $reg_url_link ] = $registrant_data;
197
+        $this->registrant_data[$reg_url_link] = $registrant_data;
198 198
     }
199 199
 
200 200
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function addRequiredQuestion(string $identifier, string $required_question): void
215 215
     {
216
-        $this->required_questions[ $identifier ] = $required_question;
216
+        $this->required_questions[$identifier] = $required_question;
217 217
     }
218 218
 
219 219
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function registrantAnswers(string $reg_url_link): array
224 224
     {
225
-        return $this->registrant_answers[ $reg_url_link ] ?? [];
225
+        return $this->registrant_answers[$reg_url_link] ?? [];
226 226
     }
227 227
 
228 228
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      */
234 234
     public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void
235 235
     {
236
-        $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer;
236
+        $this->registrant_answers[$reg_url_link][$identifier] = $answer;
237 237
     }
238 238
 
239 239
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer
246 246
     {
247
-        return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null;
247
+        return $this->registrant_answers[$reg_url_link][$identifier] ?? null;
248 248
     }
249 249
 
250 250
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function addPrimaryRegistrantDataValue(string $key, $value): void
278 278
     {
279
-        $this->primary_registrant_data[ $key ] = $value;
279
+        $this->primary_registrant_data[$key] = $value;
280 280
     }
281 281
 
282 282
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      */
287 287
     public function getPrimaryRegistrantDataValue(string $key)
288 288
     {
289
-        return $this->primary_registrant_data[ $key ] ?? null;
289
+        return $this->primary_registrant_data[$key] ?? null;
290 290
     }
291 291
 
292 292
 
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
     public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value)
360 360
     {
361 361
         // store a bit of data about the primary attendee
362
-        if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
363
-            $this->primary_registrant_data[ $form_input ] = $input_value;
362
+        if ( ! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
363
+            $this->primary_registrant_data[$form_input] = $input_value;
364 364
             return $input_value;
365 365
         }
366 366
         // or copy value from primary if incoming value is not set
Please login to merge, or discard this patch.
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -18,355 +18,355 @@
 block discarded – undo
18 18
  */
19 19
 class RegistrantData
20 20
 {
21
-    /**
22
-     * @var int
23
-     */
24
-    private $attendee_counter = 0;
25
-
26
-    /**
27
-     * @var array
28
-     */
29
-    private $registrant_data = [];
30
-
31
-    /**
32
-     * @var bool
33
-     */
34
-    private $copy_primary = false;
35
-
36
-    /**
37
-     * @var array
38
-     */
39
-    private $required_questions = [];
40
-
41
-    /**
42
-     * @var EE_Registration[]
43
-     */
44
-    private $registrations = [];
45
-
46
-    /**
47
-     * @var EE_Answer[][]
48
-     */
49
-    private $registrant_answers = [];
50
-
51
-    /**
52
-     * array for tracking reg form data for the primary registrant
53
-     *
54
-     * @var array
55
-     */
56
-    private $primary_registrant_data;
57
-
58
-    /**
59
-     * the attendee object created for the primary registrant
60
-     *
61
-     * @var EE_Attendee
62
-     */
63
-    private $primary_registrant;
64
-
65
-
66
-    /**
67
-     * RegistrantData constructor.
68
-     */
69
-    public function __construct()
70
-    {
71
-        $this->primary_registrant_data = ['line_item_id' => null,];
72
-    }
73
-
74
-
75
-    /**
76
-     * @param EE_Registration $registration
77
-     * @throws EE_Error
78
-     */
79
-    public function initializeRegistrantData(EE_Registration $registration): void
80
-    {
81
-        $reg_url_link = $registration->reg_url_link();
82
-        $this->registrations[ $reg_url_link ] = $registration;
83
-        $this->registrant_answers[ $reg_url_link ] = $registration->answers();
84
-        $this->registrant_data[ $reg_url_link ] = [];
85
-        $this->attendee_counter++;
86
-    }
87
-
88
-
89
-    /**
90
-     * @return int
91
-     */
92
-    public function attendeeCount(): int
93
-    {
94
-        return $this->attendee_counter;
95
-    }
96
-
97
-
98
-    /**
99
-     * @return bool
100
-     */
101
-    public function copyPrimary(): bool
102
-    {
103
-        return $this->copy_primary;
104
-    }
105
-
106
-
107
-    /**
108
-     * @param bool $copy_primary
109
-     */
110
-    public function setCopyPrimary(bool $copy_primary): void
111
-    {
112
-        $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN);
113
-    }
114
-
115
-
116
-    /**
117
-     * @param string $reg_url_link
118
-     * @return array|null
119
-     */
120
-    public function getRegistrant(string $reg_url_link): ?EE_Registration
121
-    {
122
-        return $this->registrations[ $reg_url_link ] ?? null;
123
-    }
124
-
125
-
126
-    /**
127
-     * @param string $reg_url_link
128
-     * @return array|null
129
-     */
130
-    public function getRegistrantData(string $reg_url_link): ?array
131
-    {
132
-        return $this->registrant_data[ $reg_url_link ] ?? null;
133
-    }
134
-
135
-
136
-    /**
137
-     * @param string $reg_url_link
138
-     * @param string $key
139
-     * @param mixed $value
140
-     */
141
-    public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void
142
-    {
143
-        $this->registrant_data[ $reg_url_link ][ $key ] = $value;
144
-    }
145
-
146
-
147
-    /**
148
-     * ensures that all attendees at least have data for first name, last name, and email address
149
-     *
150
-     * @param string $reg_url_link
151
-     * @throws EE_Error
152
-     * @throws ReflectionException
153
-     */
154
-    public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void
155
-    {
156
-        if ($this->currentRegistrantIsPrimary()) {
157
-            return;
158
-        }
159
-        // bare minimum critical details include first name, last name, email address
160
-        $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email'];
161
-        // add address info to critical details?
162
-        if (
163
-            apply_filters(
164
-                'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet',
165
-                false
166
-            )
167
-        ) {
168
-            $critical_attendee_details += [
169
-                'ATT_address',
170
-                'ATT_address2',
171
-                'ATT_city',
172
-                'STA_ID',
173
-                'CNT_ISO',
174
-                'ATT_zip',
175
-                'ATT_phone',
176
-            ];
177
-        }
178
-        foreach ($critical_attendee_details as $critical_attendee_detail) {
179
-            if (
180
-                ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
181
-                || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
182
-            ) {
183
-                $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get(
184
-                    $critical_attendee_detail
185
-                );
186
-            }
187
-        }
188
-    }
189
-
190
-
191
-    /**
192
-     * @param string $reg_url_link
193
-     * @param array $registrant_data
194
-     */
195
-    public function setRegistrantData(string $reg_url_link, array $registrant_data): void
196
-    {
197
-        $this->registrant_data[ $reg_url_link ] = $registrant_data;
198
-    }
199
-
200
-
201
-    /**
202
-     * @return array
203
-     */
204
-    public function getRequiredQuestions(): array
205
-    {
206
-        return $this->required_questions;
207
-    }
208
-
209
-
210
-    /**
211
-     * @param string $identifier
212
-     * @param string $required_question
213
-     */
214
-    public function addRequiredQuestion(string $identifier, string $required_question): void
215
-    {
216
-        $this->required_questions[ $identifier ] = $required_question;
217
-    }
218
-
219
-
220
-    /**
221
-     * @return EE_Answer[]
222
-     */
223
-    public function registrantAnswers(string $reg_url_link): array
224
-    {
225
-        return $this->registrant_answers[ $reg_url_link ] ?? [];
226
-    }
227
-
228
-
229
-    /**
230
-     * @param string $reg_url_link
231
-     * @param string $identifier  the answer cache ID
232
-     * @param EE_Answer $answer
233
-     */
234
-    public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void
235
-    {
236
-        $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer;
237
-    }
238
-
239
-
240
-    /**
241
-     * @param string $reg_url_link
242
-     * @param string $identifier
243
-     * @return EE_Answer|null
244
-     */
245
-    public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer
246
-    {
247
-        return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @param string $reg_url_link
254
-     * @param string $identifier
255
-     * @return bool
256
-     */
257
-    public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool
258
-    {
259
-        $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier);
260
-        return $registrant_answer instanceof EE_Answer;
261
-    }
262
-
263
-
264
-    /**
265
-     * @return array
266
-     */
267
-    public function primaryRegistrantData(): array
268
-    {
269
-        return $this->primary_registrant_data;
270
-    }
271
-
272
-
273
-    /**
274
-     * @param string $key
275
-     * @param mixed  $value
276
-     */
277
-    public function addPrimaryRegistrantDataValue(string $key, $value): void
278
-    {
279
-        $this->primary_registrant_data[ $key ] = $value;
280
-    }
281
-
282
-
283
-    /**
284
-     * @param string $key
285
-     * @return mixed
286
-     */
287
-    public function getPrimaryRegistrantDataValue(string $key)
288
-    {
289
-        return $this->primary_registrant_data[ $key ] ?? null;
290
-    }
291
-
292
-
293
-    /**
294
-     * @param array $primary_registrant_data
295
-     */
296
-    public function setPrimaryRegistrantData(array $primary_registrant_data): void
297
-    {
298
-        $this->primary_registrant_data = $primary_registrant_data;
299
-    }
300
-
301
-
302
-    /**
303
-     * @return EE_Attendee
304
-     */
305
-    public function primaryRegistrant(): EE_Attendee
306
-    {
307
-        return $this->primary_registrant;
308
-    }
309
-
310
-
311
-    /**
312
-     * @return bool
313
-     */
314
-    public function primaryRegistrantIsValid(): bool
315
-    {
316
-        return $this->primary_registrant instanceof EE_Attendee;
317
-    }
318
-
319
-
320
-    /**
321
-     * @param EE_Attendee $primary_registrant
322
-     */
323
-    public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void
324
-    {
325
-        $this->primary_registrant = $primary_registrant;
326
-    }
327
-
328
-
329
-    /**
330
-     * @param string $reg_url_link
331
-     * @return bool
332
-     */
333
-    public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool
334
-    {
335
-        return $this->attendeeCount() === 1
336
-            || (
337
-                $this->attendeeCount() === 1
338
-                && $reg_url_link !== ''
339
-                && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link
340
-            );
341
-    }
342
-
343
-
344
-    /**
345
-     * @return bool
346
-     */
347
-    public function currentRegistrantIsNotPrimary(): bool
348
-    {
349
-        return $this->attendeeCount() > 1;
350
-    }
351
-
352
-
353
-    /**
354
-     * @param string $reg_url_link
355
-     * @param string $form_input
356
-     * @param mixed  $input_value
357
-     * @return mixed|null
358
-     */
359
-    public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value)
360
-    {
361
-        // store a bit of data about the primary attendee
362
-        if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
363
-            $this->primary_registrant_data[ $form_input ] = $input_value;
364
-            return $input_value;
365
-        }
366
-        // or copy value from primary if incoming value is not set
367
-        if ($input_value === null && $this->copyPrimary()) {
368
-            $input_value = $this->getPrimaryRegistrantDataValue($form_input);
369
-        }
370
-        return $input_value;
371
-    }
21
+	/**
22
+	 * @var int
23
+	 */
24
+	private $attendee_counter = 0;
25
+
26
+	/**
27
+	 * @var array
28
+	 */
29
+	private $registrant_data = [];
30
+
31
+	/**
32
+	 * @var bool
33
+	 */
34
+	private $copy_primary = false;
35
+
36
+	/**
37
+	 * @var array
38
+	 */
39
+	private $required_questions = [];
40
+
41
+	/**
42
+	 * @var EE_Registration[]
43
+	 */
44
+	private $registrations = [];
45
+
46
+	/**
47
+	 * @var EE_Answer[][]
48
+	 */
49
+	private $registrant_answers = [];
50
+
51
+	/**
52
+	 * array for tracking reg form data for the primary registrant
53
+	 *
54
+	 * @var array
55
+	 */
56
+	private $primary_registrant_data;
57
+
58
+	/**
59
+	 * the attendee object created for the primary registrant
60
+	 *
61
+	 * @var EE_Attendee
62
+	 */
63
+	private $primary_registrant;
64
+
65
+
66
+	/**
67
+	 * RegistrantData constructor.
68
+	 */
69
+	public function __construct()
70
+	{
71
+		$this->primary_registrant_data = ['line_item_id' => null,];
72
+	}
73
+
74
+
75
+	/**
76
+	 * @param EE_Registration $registration
77
+	 * @throws EE_Error
78
+	 */
79
+	public function initializeRegistrantData(EE_Registration $registration): void
80
+	{
81
+		$reg_url_link = $registration->reg_url_link();
82
+		$this->registrations[ $reg_url_link ] = $registration;
83
+		$this->registrant_answers[ $reg_url_link ] = $registration->answers();
84
+		$this->registrant_data[ $reg_url_link ] = [];
85
+		$this->attendee_counter++;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return int
91
+	 */
92
+	public function attendeeCount(): int
93
+	{
94
+		return $this->attendee_counter;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return bool
100
+	 */
101
+	public function copyPrimary(): bool
102
+	{
103
+		return $this->copy_primary;
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param bool $copy_primary
109
+	 */
110
+	public function setCopyPrimary(bool $copy_primary): void
111
+	{
112
+		$this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN);
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param string $reg_url_link
118
+	 * @return array|null
119
+	 */
120
+	public function getRegistrant(string $reg_url_link): ?EE_Registration
121
+	{
122
+		return $this->registrations[ $reg_url_link ] ?? null;
123
+	}
124
+
125
+
126
+	/**
127
+	 * @param string $reg_url_link
128
+	 * @return array|null
129
+	 */
130
+	public function getRegistrantData(string $reg_url_link): ?array
131
+	{
132
+		return $this->registrant_data[ $reg_url_link ] ?? null;
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param string $reg_url_link
138
+	 * @param string $key
139
+	 * @param mixed $value
140
+	 */
141
+	public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void
142
+	{
143
+		$this->registrant_data[ $reg_url_link ][ $key ] = $value;
144
+	}
145
+
146
+
147
+	/**
148
+	 * ensures that all attendees at least have data for first name, last name, and email address
149
+	 *
150
+	 * @param string $reg_url_link
151
+	 * @throws EE_Error
152
+	 * @throws ReflectionException
153
+	 */
154
+	public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void
155
+	{
156
+		if ($this->currentRegistrantIsPrimary()) {
157
+			return;
158
+		}
159
+		// bare minimum critical details include first name, last name, email address
160
+		$critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email'];
161
+		// add address info to critical details?
162
+		if (
163
+			apply_filters(
164
+				'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet',
165
+				false
166
+			)
167
+		) {
168
+			$critical_attendee_details += [
169
+				'ATT_address',
170
+				'ATT_address2',
171
+				'ATT_city',
172
+				'STA_ID',
173
+				'CNT_ISO',
174
+				'ATT_zip',
175
+				'ATT_phone',
176
+			];
177
+		}
178
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
179
+			if (
180
+				! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
181
+				|| empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
182
+			) {
183
+				$this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get(
184
+					$critical_attendee_detail
185
+				);
186
+			}
187
+		}
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param string $reg_url_link
193
+	 * @param array $registrant_data
194
+	 */
195
+	public function setRegistrantData(string $reg_url_link, array $registrant_data): void
196
+	{
197
+		$this->registrant_data[ $reg_url_link ] = $registrant_data;
198
+	}
199
+
200
+
201
+	/**
202
+	 * @return array
203
+	 */
204
+	public function getRequiredQuestions(): array
205
+	{
206
+		return $this->required_questions;
207
+	}
208
+
209
+
210
+	/**
211
+	 * @param string $identifier
212
+	 * @param string $required_question
213
+	 */
214
+	public function addRequiredQuestion(string $identifier, string $required_question): void
215
+	{
216
+		$this->required_questions[ $identifier ] = $required_question;
217
+	}
218
+
219
+
220
+	/**
221
+	 * @return EE_Answer[]
222
+	 */
223
+	public function registrantAnswers(string $reg_url_link): array
224
+	{
225
+		return $this->registrant_answers[ $reg_url_link ] ?? [];
226
+	}
227
+
228
+
229
+	/**
230
+	 * @param string $reg_url_link
231
+	 * @param string $identifier  the answer cache ID
232
+	 * @param EE_Answer $answer
233
+	 */
234
+	public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void
235
+	{
236
+		$this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer;
237
+	}
238
+
239
+
240
+	/**
241
+	 * @param string $reg_url_link
242
+	 * @param string $identifier
243
+	 * @return EE_Answer|null
244
+	 */
245
+	public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer
246
+	{
247
+		return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @param string $reg_url_link
254
+	 * @param string $identifier
255
+	 * @return bool
256
+	 */
257
+	public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool
258
+	{
259
+		$registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier);
260
+		return $registrant_answer instanceof EE_Answer;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @return array
266
+	 */
267
+	public function primaryRegistrantData(): array
268
+	{
269
+		return $this->primary_registrant_data;
270
+	}
271
+
272
+
273
+	/**
274
+	 * @param string $key
275
+	 * @param mixed  $value
276
+	 */
277
+	public function addPrimaryRegistrantDataValue(string $key, $value): void
278
+	{
279
+		$this->primary_registrant_data[ $key ] = $value;
280
+	}
281
+
282
+
283
+	/**
284
+	 * @param string $key
285
+	 * @return mixed
286
+	 */
287
+	public function getPrimaryRegistrantDataValue(string $key)
288
+	{
289
+		return $this->primary_registrant_data[ $key ] ?? null;
290
+	}
291
+
292
+
293
+	/**
294
+	 * @param array $primary_registrant_data
295
+	 */
296
+	public function setPrimaryRegistrantData(array $primary_registrant_data): void
297
+	{
298
+		$this->primary_registrant_data = $primary_registrant_data;
299
+	}
300
+
301
+
302
+	/**
303
+	 * @return EE_Attendee
304
+	 */
305
+	public function primaryRegistrant(): EE_Attendee
306
+	{
307
+		return $this->primary_registrant;
308
+	}
309
+
310
+
311
+	/**
312
+	 * @return bool
313
+	 */
314
+	public function primaryRegistrantIsValid(): bool
315
+	{
316
+		return $this->primary_registrant instanceof EE_Attendee;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @param EE_Attendee $primary_registrant
322
+	 */
323
+	public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void
324
+	{
325
+		$this->primary_registrant = $primary_registrant;
326
+	}
327
+
328
+
329
+	/**
330
+	 * @param string $reg_url_link
331
+	 * @return bool
332
+	 */
333
+	public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool
334
+	{
335
+		return $this->attendeeCount() === 1
336
+			|| (
337
+				$this->attendeeCount() === 1
338
+				&& $reg_url_link !== ''
339
+				&& $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link
340
+			);
341
+	}
342
+
343
+
344
+	/**
345
+	 * @return bool
346
+	 */
347
+	public function currentRegistrantIsNotPrimary(): bool
348
+	{
349
+		return $this->attendeeCount() > 1;
350
+	}
351
+
352
+
353
+	/**
354
+	 * @param string $reg_url_link
355
+	 * @param string $form_input
356
+	 * @param mixed  $input_value
357
+	 * @return mixed|null
358
+	 */
359
+	public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value)
360
+	{
361
+		// store a bit of data about the primary attendee
362
+		if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
363
+			$this->primary_registrant_data[ $form_input ] = $input_value;
364
+			return $input_value;
365
+		}
366
+		// or copy value from primary if incoming value is not set
367
+		if ($input_value === null && $this->copyPrimary()) {
368
+			$input_value = $this->getPrimaryRegistrantDataValue($form_input);
369
+		}
370
+		return $input_value;
371
+	}
372 372
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/TicketUpdate.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
          * @throws EE_Error
35 35
          * @throws ReflectionException
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Ticket $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
                 $entity->save($args);
57 57
 
58
-                if (! empty($datetimes)) {
58
+                if ( ! empty($datetimes)) {
59 59
                     TicketMutation::setRelatedDatetimes($entity, $datetimes);
60 60
                 }
61 61
                 // if prices array is passed.
Please login to merge, or discard this patch.
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -14,68 +14,68 @@
 block discarded – undo
14 14
 
15 15
 class TicketUpdate extends EntityMutator
16 16
 {
17
-    /**
18
-     * Defines the mutation data modification closure.
19
-     *
20
-     * @param EEM_Ticket $model
21
-     * @param Ticket     $type
22
-     * @return callable
23
-     */
24
-    public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
25
-    {
26
-        /**
27
-         * Updates an entity.
28
-         *
29
-         * @param array       $input   The input for the mutation
30
-         * @param AppContext  $context The AppContext passed down to all resolvers
31
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
32
-         * @return array
33
-         * @throws EE_Error
34
-         * @throws ReflectionException
35
-         */
36
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
-            try {
38
-                /** @var EE_Ticket $entity */
39
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
17
+	/**
18
+	 * Defines the mutation data modification closure.
19
+	 *
20
+	 * @param EEM_Ticket $model
21
+	 * @param Ticket     $type
22
+	 * @return callable
23
+	 */
24
+	public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
25
+	{
26
+		/**
27
+		 * Updates an entity.
28
+		 *
29
+		 * @param array       $input   The input for the mutation
30
+		 * @param AppContext  $context The AppContext passed down to all resolvers
31
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
32
+		 * @return array
33
+		 * @throws EE_Error
34
+		 * @throws ReflectionException
35
+		 */
36
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+			try {
38
+				/** @var EE_Ticket $entity */
39
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
40 40
 
41
-                $datetimes = [];
42
-                $prices = null;
41
+				$datetimes = [];
42
+				$prices = null;
43 43
 
44
-                $args = TicketMutation::prepareFields($input);
44
+				$args = TicketMutation::prepareFields($input);
45 45
 
46
-                if (isset($args['datetimes'])) {
47
-                    $datetimes = $args['datetimes'];
48
-                    unset($args['datetimes']);
49
-                }
50
-                if (array_key_exists('prices', $args)) {
51
-                    $prices = $args['prices'];
52
-                    unset($args['prices']);
53
-                }
46
+				if (isset($args['datetimes'])) {
47
+					$datetimes = $args['datetimes'];
48
+					unset($args['datetimes']);
49
+				}
50
+				if (array_key_exists('prices', $args)) {
51
+					$prices = $args['prices'];
52
+					unset($args['prices']);
53
+				}
54 54
 
55
-                $entity->save($args);
55
+				$entity->save($args);
56 56
 
57
-                if (! empty($datetimes)) {
58
-                    TicketMutation::setRelatedDatetimes($entity, $datetimes);
59
-                }
60
-                // if prices array is passed.
61
-                if (is_array($prices)) {
62
-                    TicketMutation::setRelatedPrices($entity, $prices);
63
-                }
57
+				if (! empty($datetimes)) {
58
+					TicketMutation::setRelatedDatetimes($entity, $datetimes);
59
+				}
60
+				// if prices array is passed.
61
+				if (is_array($prices)) {
62
+					TicketMutation::setRelatedPrices($entity, $prices);
63
+				}
64 64
 
65
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input);
66
-            } catch (Exception $exception) {
67
-                EntityMutator::handleExceptions(
68
-                    $exception,
69
-                    esc_html__(
70
-                        'The ticket could not be updated because of the following error(s)',
71
-                        'event_espresso'
72
-                    )
73
-                );
74
-            }
65
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input);
66
+			} catch (Exception $exception) {
67
+				EntityMutator::handleExceptions(
68
+					$exception,
69
+					esc_html__(
70
+						'The ticket could not be updated because of the following error(s)',
71
+						'event_espresso'
72
+					)
73
+				);
74
+			}
75 75
 
76
-            return [
77
-                'id' => $entity->ID(),
78
-            ];
79
-        };
80
-    }
76
+			return [
77
+				'id' => $entity->ID(),
78
+			];
79
+		};
80
+	}
81 81
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeBulkUpdate.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@
 block discarded – undo
8 8
 class DatetimeBulkUpdate extends EntityMutator
9 9
 {
10 10
 
11
-    /**
12
-     * Defines the mutation data modification closure.
13
-     *
14
-     * @param EEM_Datetime $model
15
-     * @param Datetime     $type
16
-     * @return callable
17
-     */
18
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable
19
-    {
20
-        $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type);
21
-        $bulkMutator = new BulkEntityMutator($entityMutator);
22
-        return array($bulkMutator, 'updateEntities');
23
-    }
11
+	/**
12
+	 * Defines the mutation data modification closure.
13
+	 *
14
+	 * @param EEM_Datetime $model
15
+	 * @param Datetime     $type
16
+	 * @return callable
17
+	 */
18
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable
19
+	{
20
+		$entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type);
21
+		$bulkMutator = new BulkEntityMutator($entityMutator);
22
+		return array($bulkMutator, 'updateEntities');
23
+	}
24 24
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/EventUpdate.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
          * @param ResolveInfo  $info             The ResolveInfo passed down to all resolvers
35 35
          * @return void
36 36
          */
37
-        return static function (
37
+        return static function(
38 38
             int $id,
39 39
             array $input,
40 40
             WP_Post_Type $post_type_object,
Please login to merge, or discard this patch.
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -14,73 +14,73 @@
 block discarded – undo
14 14
 class EventUpdate extends EntityMutator
15 15
 {
16 16
 
17
-    /**
18
-     * Defines the mutation data modification closure.
19
-     *
20
-     * @param EEM_Event $model
21
-     * @param Event     $type
22
-     * @return callable
23
-     */
24
-    public static function mutateFields(EEM_Event $model, Event $type)
25
-    {
26
-        /**
27
-         * Update additional data related to the entity.
28
-         *
29
-         * @param int          $id               The ID of the postObject being mutated
30
-         * @param array        $input            The input for the mutation
31
-         * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated
32
-         * @param string       $mutation_name    The name of the mutation (ex: create, update, delete)
33
-         * @param AppContext   $context          The AppContext passed down to all resolvers
34
-         * @param ResolveInfo  $info             The ResolveInfo passed down to all resolvers
35
-         * @return void
36
-         */
37
-        return static function (
38
-            int $id,
39
-            array $input,
40
-            WP_Post_Type $post_type_object,
41
-            string $mutation_name,
42
-            AppContext $context,
43
-            ResolveInfo $info
44
-        ) use (
45
-            $model,
46
-            $type
47
-        ) {
48
-            try {
49
-                // Make sure we are dealing with the right entity.
50
-                if (
51
-                    ! property_exists($post_type_object, 'graphql_single_name')
52
-                    || $post_type_object->graphql_single_name !== $type->name()
53
-                ) {
54
-                    return;
55
-                }
17
+	/**
18
+	 * Defines the mutation data modification closure.
19
+	 *
20
+	 * @param EEM_Event $model
21
+	 * @param Event     $type
22
+	 * @return callable
23
+	 */
24
+	public static function mutateFields(EEM_Event $model, Event $type)
25
+	{
26
+		/**
27
+		 * Update additional data related to the entity.
28
+		 *
29
+		 * @param int          $id               The ID of the postObject being mutated
30
+		 * @param array        $input            The input for the mutation
31
+		 * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated
32
+		 * @param string       $mutation_name    The name of the mutation (ex: create, update, delete)
33
+		 * @param AppContext   $context          The AppContext passed down to all resolvers
34
+		 * @param ResolveInfo  $info             The ResolveInfo passed down to all resolvers
35
+		 * @return void
36
+		 */
37
+		return static function (
38
+			int $id,
39
+			array $input,
40
+			WP_Post_Type $post_type_object,
41
+			string $mutation_name,
42
+			AppContext $context,
43
+			ResolveInfo $info
44
+		) use (
45
+			$model,
46
+			$type
47
+		) {
48
+			try {
49
+				// Make sure we are dealing with the right entity.
50
+				if (
51
+					! property_exists($post_type_object, 'graphql_single_name')
52
+					|| $post_type_object->graphql_single_name !== $type->name()
53
+				) {
54
+					return;
55
+				}
56 56
 
57
-                /** @var EE_Event $entity */
58
-                $entity = EntityMutator::getEntityFromID($model, $id);
59
-                $args = EventMutation::prepareFields($input);
57
+				/** @var EE_Event $entity */
58
+				$entity = EntityMutator::getEntityFromID($model, $id);
59
+				$args = EventMutation::prepareFields($input);
60 60
 
61
-                $venue = 'NO_VENUE_SET';
62
-                if (array_key_exists('venue', $args)) {
63
-                    $venue = $args['venue'];
64
-                    unset($args['venue']);
65
-                }
61
+				$venue = 'NO_VENUE_SET';
62
+				if (array_key_exists('venue', $args)) {
63
+					$venue = $args['venue'];
64
+					unset($args['venue']);
65
+				}
66 66
 
67
-                // Update the entity
68
-                $entity->save($args);
67
+				// Update the entity
68
+				$entity->save($args);
69 69
 
70
-                if ($venue !== 'NO_VENUE_SET') {
71
-                    EventMutation::setEventVenue($entity, $venue);
72
-                }
70
+				if ($venue !== 'NO_VENUE_SET') {
71
+					EventMutation::setEventVenue($entity, $venue);
72
+				}
73 73
 
74
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input);
75
-            } catch (Exception $exception) {
76
-                EntityMutator::handleExceptions(
77
-                    $exception,
78
-                    esc_html__(
79
-                        'The event could not be updated because of the following error(s)',
80
-                        'event_espresso'
81
-                    )
82
-                );
83
-            }
84
-        };
85
-    }
74
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input);
75
+			} catch (Exception $exception) {
76
+				EntityMutator::handleExceptions(
77
+					$exception,
78
+					esc_html__(
79
+						'The event could not be updated because of the following error(s)',
80
+						'event_espresso'
81
+					)
82
+				);
83
+			}
84
+		};
85
+	}
86 86
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/TicketCreate.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -13,68 +13,68 @@
 block discarded – undo
13 13
 class TicketCreate extends EntityMutator
14 14
 {
15 15
 
16
-    /**
17
-     * Defines the mutation data modification closure.
18
-     *
19
-     * @param EEM_Ticket $model
20
-     * @param Ticket     $type
21
-     * @return callable
22
-     */
23
-    public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
24
-    {
25
-        /**
26
-         * Creates an entity.
27
-         *
28
-         * @param array       $input   The input for the mutation
29
-         * @param AppContext  $context The AppContext passed down to all resolvers
30
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31
-         * @return array
32
-         */
33
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34
-            $id = null;
35
-            try {
36
-                EntityMutator::checkPermissions($model);
16
+	/**
17
+	 * Defines the mutation data modification closure.
18
+	 *
19
+	 * @param EEM_Ticket $model
20
+	 * @param Ticket     $type
21
+	 * @return callable
22
+	 */
23
+	public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
24
+	{
25
+		/**
26
+		 * Creates an entity.
27
+		 *
28
+		 * @param array       $input   The input for the mutation
29
+		 * @param AppContext  $context The AppContext passed down to all resolvers
30
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31
+		 * @return array
32
+		 */
33
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34
+			$id = null;
35
+			try {
36
+				EntityMutator::checkPermissions($model);
37 37
 
38
-                $datetimes = [];
39
-                $prices = [];
38
+				$datetimes = [];
39
+				$prices = [];
40 40
 
41
-                $args = TicketMutation::prepareFields($input);
41
+				$args = TicketMutation::prepareFields($input);
42 42
 
43
-                if (isset($args['datetimes'])) {
44
-                    $datetimes = $args['datetimes'];
45
-                    unset($args['datetimes']);
46
-                }
47
-                if (isset($args['prices'])) {
48
-                    $prices = $args['prices'];
49
-                    unset($args['prices']);
50
-                }
43
+				if (isset($args['datetimes'])) {
44
+					$datetimes = $args['datetimes'];
45
+					unset($args['datetimes']);
46
+				}
47
+				if (isset($args['prices'])) {
48
+					$prices = $args['prices'];
49
+					unset($args['prices']);
50
+				}
51 51
 
52
-                $entity = EE_Ticket::new_instance($args);
53
-                $id = $entity->save();
54
-                EntityMutator::validateResults($id);
52
+				$entity = EE_Ticket::new_instance($args);
53
+				$id = $entity->save();
54
+				EntityMutator::validateResults($id);
55 55
 
56
-                if (! empty($datetimes)) {
57
-                    TicketMutation::setRelatedDatetimes($entity, $datetimes);
58
-                }
59
-                // if prices are passed.
60
-                if (! empty($prices)) {
61
-                    TicketMutation::setRelatedPrices($entity, $prices);
62
-                }
56
+				if (! empty($datetimes)) {
57
+					TicketMutation::setRelatedDatetimes($entity, $datetimes);
58
+				}
59
+				// if prices are passed.
60
+				if (! empty($prices)) {
61
+					TicketMutation::setRelatedPrices($entity, $prices);
62
+				}
63 63
 
64
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input);
65
-            } catch (Exception $exception) {
66
-                EntityMutator::handleExceptions(
67
-                    $exception,
68
-                    esc_html__(
69
-                        'The ticket could not be created because of the following error(s)',
70
-                        'event_espresso'
71
-                    )
72
-                );
73
-            }
64
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input);
65
+			} catch (Exception $exception) {
66
+				EntityMutator::handleExceptions(
67
+					$exception,
68
+					esc_html__(
69
+						'The ticket could not be created because of the following error(s)',
70
+						'event_espresso'
71
+					)
72
+				);
73
+			}
74 74
 
75
-            return [
76
-                'id' => $id,
77
-            ];
78
-        };
79
-    }
75
+			return [
76
+				'id' => $id,
77
+			];
78
+		};
79
+	}
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31 31
          * @return array
32 32
          */
33
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
33
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34 34
             $id = null;
35 35
             try {
36 36
                 EntityMutator::checkPermissions($model);
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
                 $id = $entity->save();
54 54
                 EntityMutator::validateResults($id);
55 55
 
56
-                if (! empty($datetimes)) {
56
+                if ( ! empty($datetimes)) {
57 57
                     TicketMutation::setRelatedDatetimes($entity, $datetimes);
58 58
                 }
59 59
                 // if prices are passed.
60
-                if (! empty($prices)) {
60
+                if ( ! empty($prices)) {
61 61
                     TicketMutation::setRelatedPrices($entity, $prices);
62 62
                 }
63 63
 
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeDelete.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -17,107 +17,107 @@
 block discarded – undo
17 17
 class DatetimeDelete extends EntityMutator
18 18
 {
19 19
 
20
-    /**
21
-     * Defines the mutation data modification closure.
22
-     *
23
-     * @param EEM_Datetime $model
24
-     * @param Datetime     $type
25
-     * @return callable
26
-     */
27
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
28
-    {
29
-        /**
30
-         * Deletes an entity.
31
-         *
32
-         * @param array       $input   The input for the mutation
33
-         * @param AppContext  $context The AppContext passed down to all resolvers
34
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35
-         * @return array
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Datetime $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
20
+	/**
21
+	 * Defines the mutation data modification closure.
22
+	 *
23
+	 * @param EEM_Datetime $model
24
+	 * @param Datetime     $type
25
+	 * @return callable
26
+	 */
27
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
28
+	{
29
+		/**
30
+		 * Deletes an entity.
31
+		 *
32
+		 * @param array       $input   The input for the mutation
33
+		 * @param AppContext  $context The AppContext passed down to all resolvers
34
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35
+		 * @return array
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Datetime $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
44
-                    $result = DatetimeDelete::deleteDatetimeAndRelations($entity);
45
-                } else {
46
-                    $result = DatetimeDelete::trashDatetimeAndRelations($entity);
47
-                }
48
-                EntityMutator::validateResults($result);
42
+				// Delete the entity
43
+				if (! empty($input['deletePermanently'])) {
44
+					$result = DatetimeDelete::deleteDatetimeAndRelations($entity);
45
+				} else {
46
+					$result = DatetimeDelete::trashDatetimeAndRelations($entity);
47
+				}
48
+				EntityMutator::validateResults($result);
49 49
 
50
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input);
51
-            } catch (Exception $exception) {
52
-                EntityMutator::handleExceptions(
53
-                    $exception,
54
-                    esc_html__(
55
-                        'The datetime could not be deleted because of the following error(s)',
56
-                        'event_espresso'
57
-                    )
58
-                );
59
-            }
50
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input);
51
+			} catch (Exception $exception) {
52
+				EntityMutator::handleExceptions(
53
+					$exception,
54
+					esc_html__(
55
+						'The datetime could not be deleted because of the following error(s)',
56
+						'event_espresso'
57
+					)
58
+				);
59
+			}
60 60
 
61
-            return [
62
-                'deleted' => $entity,
63
-            ];
64
-        };
65
-    }
61
+			return [
62
+				'deleted' => $entity,
63
+			];
64
+		};
65
+	}
66 66
 
67
-    /**
68
-     * Deletes a datetime permanently along with its relations.
69
-     *
70
-     * @param EE_Datetime $entity
71
-     * @return bool | int
72
-     * @throws ReflectionException
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidInterfaceException
75
-     * @throws InvalidDataTypeException
76
-     * @throws EE_Error
77
-     */
78
-    public static function deleteDatetimeAndRelations(EE_Datetime $entity)
79
-    {
80
-        // all related tickets
81
-        $tickets = $entity->tickets();
82
-        foreach ($tickets as $ticket) {
83
-            // if the ticket is related to only one datetime
84
-            if ($ticket->count_related('Datetime') === 1) {
85
-                TicketDelete::deleteTicketAndRelations($ticket);
86
-            }
87
-        }
67
+	/**
68
+	 * Deletes a datetime permanently along with its relations.
69
+	 *
70
+	 * @param EE_Datetime $entity
71
+	 * @return bool | int
72
+	 * @throws ReflectionException
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidInterfaceException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws EE_Error
77
+	 */
78
+	public static function deleteDatetimeAndRelations(EE_Datetime $entity)
79
+	{
80
+		// all related tickets
81
+		$tickets = $entity->tickets();
82
+		foreach ($tickets as $ticket) {
83
+			// if the ticket is related to only one datetime
84
+			if ($ticket->count_related('Datetime') === 1) {
85
+				TicketDelete::deleteTicketAndRelations($ticket);
86
+			}
87
+		}
88 88
 
89
-        // Remove relations with tickets
90
-        $entity->_remove_relations('Ticket');
91
-        // Now delete the datetime permanently
92
-        return $entity->delete_permanently();
93
-    }
89
+		// Remove relations with tickets
90
+		$entity->_remove_relations('Ticket');
91
+		// Now delete the datetime permanently
92
+		return $entity->delete_permanently();
93
+	}
94 94
 
95
-    /**
96
-     * Trashes a datetime along with its lone relations.
97
-     *
98
-     * @param EE_Datetime $entity
99
-     * @return bool | int
100
-     * @throws ReflectionException
101
-     * @throws InvalidArgumentException
102
-     * @throws InvalidInterfaceException
103
-     * @throws InvalidDataTypeException
104
-     * @throws EE_Error
105
-     */
106
-    public static function trashDatetimeAndRelations(EE_Datetime $entity)
107
-    {
108
-        // non trashed related tickets
109
-        $tickets = $entity->tickets([[
110
-            'TKT_deleted' => false,
111
-        ]]);
112
-        // loop though all tickets to check if we need to trash any
113
-        foreach ($tickets as $ticket) {
114
-            // if the ticket is related to only one datetime
115
-            if ($ticket->count_related('Datetime') === 1) {
116
-                // trash the ticket
117
-                $ticket->delete();
118
-            }
119
-        }
120
-        // trash the datetime
121
-        return $entity->delete();
122
-    }
95
+	/**
96
+	 * Trashes a datetime along with its lone relations.
97
+	 *
98
+	 * @param EE_Datetime $entity
99
+	 * @return bool | int
100
+	 * @throws ReflectionException
101
+	 * @throws InvalidArgumentException
102
+	 * @throws InvalidInterfaceException
103
+	 * @throws InvalidDataTypeException
104
+	 * @throws EE_Error
105
+	 */
106
+	public static function trashDatetimeAndRelations(EE_Datetime $entity)
107
+	{
108
+		// non trashed related tickets
109
+		$tickets = $entity->tickets([[
110
+			'TKT_deleted' => false,
111
+		]]);
112
+		// loop though all tickets to check if we need to trash any
113
+		foreach ($tickets as $ticket) {
114
+			// if the ticket is related to only one datetime
115
+			if ($ticket->count_related('Datetime') === 1) {
116
+				// trash the ticket
117
+				$ticket->delete();
118
+			}
119
+		}
120
+		// trash the datetime
121
+		return $entity->delete();
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35 35
          * @return array
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Datetime $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42 42
                 // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
43
+                if ( ! empty($input['deletePermanently'])) {
44 44
                     $result = DatetimeDelete::deleteDatetimeAndRelations($entity);
45 45
                 } else {
46 46
                     $result = DatetimeDelete::trashDatetimeAndRelations($entity);
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/PriceDelete.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -17,70 +17,70 @@
 block discarded – undo
17 17
 class PriceDelete extends EntityMutator
18 18
 {
19 19
 
20
-    /**
21
-     * Defines the mutation data modification closure.
22
-     *
23
-     * @param EEM_Price $model
24
-     * @param Price     $type
25
-     * @return callable
26
-     */
27
-    public static function mutateAndGetPayload(EEM_Price $model, Price $type)
28
-    {
29
-        /**
30
-         * Deletes an entity.
31
-         *
32
-         * @param array       $input   The input for the mutation
33
-         * @param AppContext  $context The AppContext passed down to all resolvers
34
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35
-         * @return array
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Price $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
20
+	/**
21
+	 * Defines the mutation data modification closure.
22
+	 *
23
+	 * @param EEM_Price $model
24
+	 * @param Price     $type
25
+	 * @return callable
26
+	 */
27
+	public static function mutateAndGetPayload(EEM_Price $model, Price $type)
28
+	{
29
+		/**
30
+		 * Deletes an entity.
31
+		 *
32
+		 * @param array       $input   The input for the mutation
33
+		 * @param AppContext  $context The AppContext passed down to all resolvers
34
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35
+		 * @return array
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Price $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
44
-                    $result = PriceDelete::deletePriceAndRelations($entity);
45
-                } else {
46
-                    // trash the price
47
-                    $result = $entity->delete();
48
-                }
49
-                EntityMutator::validateResults($result);
42
+				// Delete the entity
43
+				if (! empty($input['deletePermanently'])) {
44
+					$result = PriceDelete::deletePriceAndRelations($entity);
45
+				} else {
46
+					// trash the price
47
+					$result = $entity->delete();
48
+				}
49
+				EntityMutator::validateResults($result);
50 50
 
51
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_delete', $entity, $input);
52
-            } catch (Exception $exception) {
53
-                EntityMutator::handleExceptions(
54
-                    $exception,
55
-                    esc_html__(
56
-                        'The price could not be deleted because of the following error(s)',
57
-                        'event_espresso'
58
-                    )
59
-                );
60
-            }
51
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_delete', $entity, $input);
52
+			} catch (Exception $exception) {
53
+				EntityMutator::handleExceptions(
54
+					$exception,
55
+					esc_html__(
56
+						'The price could not be deleted because of the following error(s)',
57
+						'event_espresso'
58
+					)
59
+				);
60
+			}
61 61
 
62
-            return [
63
-                'deleted' => $entity,
64
-            ];
65
-        };
66
-    }
62
+			return [
63
+				'deleted' => $entity,
64
+			];
65
+		};
66
+	}
67 67
 
68
-    /**
69
-     * Deletes a price permanently along with its relations.
70
-     *
71
-     * @param EE_Price $entity
72
-     * @return bool | int
73
-     * @throws ReflectionException
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidInterfaceException
76
-     * @throws InvalidDataTypeException
77
-     * @throws EE_Error
78
-     */
79
-    public static function deletePriceAndRelations(EE_Price $entity)
80
-    {
81
-        // Remove relation with ticket
82
-        $entity->_remove_relations('Ticket');
83
-        // Now delete the price permanently
84
-        return $entity->delete_permanently();
85
-    }
68
+	/**
69
+	 * Deletes a price permanently along with its relations.
70
+	 *
71
+	 * @param EE_Price $entity
72
+	 * @return bool | int
73
+	 * @throws ReflectionException
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidInterfaceException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws EE_Error
78
+	 */
79
+	public static function deletePriceAndRelations(EE_Price $entity)
80
+	{
81
+		// Remove relation with ticket
82
+		$entity->_remove_relations('Ticket');
83
+		// Now delete the price permanently
84
+		return $entity->delete_permanently();
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35 35
          * @return array
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Price $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42 42
                 // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
43
+                if ( ! empty($input['deletePermanently'])) {
44 44
                     $result = PriceDelete::deletePriceAndRelations($entity);
45 45
                 } else {
46 46
                     // trash the price
Please login to merge, or discard this patch.