Completed
Branch dependabot/composer/tijsverkoy... (491ea6)
by
unknown
32:00 queued 25:42
created
core/domain/services/registration/form/v1/RegFormAttendeeFactory.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -16,113 +16,113 @@
 block discarded – undo
16 16
 class RegFormAttendeeFactory
17 17
 {
18 18
 
19
-    /**
20
-     * @var CommandBusInterface
21
-     */
22
-    public $command_bus;
19
+	/**
20
+	 * @var CommandBusInterface
21
+	 */
22
+	public $command_bus;
23 23
 
24
-    /**
25
-     * @var RegistrantData
26
-     */
27
-    private $registrant_data;
24
+	/**
25
+	 * @var RegistrantData
26
+	 */
27
+	private $registrant_data;
28 28
 
29 29
 
30
-    /**
31
-     * RegFormAttendeeFactory constructor.
32
-     *
33
-     * @param CommandBusInterface $command_bus
34
-     * @param RegistrantData      $registrant_data
35
-     */
36
-    public function __construct(CommandBusInterface $command_bus, RegistrantData $registrant_data)
37
-    {
38
-        $this->command_bus     = $command_bus;
39
-        $this->registrant_data = $registrant_data;
40
-    }
30
+	/**
31
+	 * RegFormAttendeeFactory constructor.
32
+	 *
33
+	 * @param CommandBusInterface $command_bus
34
+	 * @param RegistrantData      $registrant_data
35
+	 */
36
+	public function __construct(CommandBusInterface $command_bus, RegistrantData $registrant_data)
37
+	{
38
+		$this->command_bus     = $command_bus;
39
+		$this->registrant_data = $registrant_data;
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @param EE_Registration $registration
45
-     * @param string          $reg_url_link
46
-     * @return bool
47
-     * @throws EE_Error
48
-     * @throws ReflectionException
49
-     */
50
-    public function create(EE_Registration $registration, string $reg_url_link): bool
51
-    {
52
-        // this registration does not require additional attendee information ?
53
-        if (
54
-            $this->registrant_data->copyPrimary()
55
-            && $this->registrant_data->attendeeCount() > 1
56
-            && $this->registrant_data->primaryRegistrantIsValid()
57
-        ) {
58
-            // just copy the primary registrant
59
-            $attendee = $this->registrant_data->primaryRegistrant();
60
-        } else {
61
-            // ensure critical details are set for additional attendees
62
-            // raw form data was already set during call to processRegFormData()
63
-            $this->registrant_data->ensureCriticalRegistrantDataIsSet($reg_url_link);
64
-            // execute create attendee command (which may return an existing attendee)
65
-            $attendee = $this->command_bus->execute(
66
-                new CreateAttendeeCommand(
67
-                    $this->registrant_data->getRegistrantData($reg_url_link),
68
-                    $registration
69
-                )
70
-            );
71
-            // who's #1 ?
72
-            if ($this->registrant_data->currentRegistrantIsPrimary()) {
73
-                $this->registrant_data->setPrimaryRegistrant($attendee);
74
-            }
75
-        }
76
-        // add relation to registration, set attendee ID, and cache attendee
77
-        $this->associateAttendeeWithRegistration($registration, $attendee);
78
-        return $this->isValidAttendee($registration, $reg_url_link);
79
-    }
43
+	/**
44
+	 * @param EE_Registration $registration
45
+	 * @param string          $reg_url_link
46
+	 * @return bool
47
+	 * @throws EE_Error
48
+	 * @throws ReflectionException
49
+	 */
50
+	public function create(EE_Registration $registration, string $reg_url_link): bool
51
+	{
52
+		// this registration does not require additional attendee information ?
53
+		if (
54
+			$this->registrant_data->copyPrimary()
55
+			&& $this->registrant_data->attendeeCount() > 1
56
+			&& $this->registrant_data->primaryRegistrantIsValid()
57
+		) {
58
+			// just copy the primary registrant
59
+			$attendee = $this->registrant_data->primaryRegistrant();
60
+		} else {
61
+			// ensure critical details are set for additional attendees
62
+			// raw form data was already set during call to processRegFormData()
63
+			$this->registrant_data->ensureCriticalRegistrantDataIsSet($reg_url_link);
64
+			// execute create attendee command (which may return an existing attendee)
65
+			$attendee = $this->command_bus->execute(
66
+				new CreateAttendeeCommand(
67
+					$this->registrant_data->getRegistrantData($reg_url_link),
68
+					$registration
69
+				)
70
+			);
71
+			// who's #1 ?
72
+			if ($this->registrant_data->currentRegistrantIsPrimary()) {
73
+				$this->registrant_data->setPrimaryRegistrant($attendee);
74
+			}
75
+		}
76
+		// add relation to registration, set attendee ID, and cache attendee
77
+		$this->associateAttendeeWithRegistration($registration, $attendee);
78
+		return $this->isValidAttendee($registration, $reg_url_link);
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * @param EE_Registration $registration
84
-     * @param string          $reg_url_link
85
-     * @return bool
86
-     * @throws EE_Error
87
-     */
88
-    private function isValidAttendee(EE_Registration $registration, string $reg_url_link): bool
89
-    {
90
-        if ($registration->attendee() instanceof EE_Attendee) {
91
-            return true;
92
-        }
93
-        EE_Error::add_error(
94
-            sprintf(
95
-                esc_html_x(
96
-                    'Registration %s has an invalid or missing Attendee object.',
97
-                    'Registration 123-456-789 has an invalid or missing Attendee object.',
98
-                    'event_espresso'
99
-                ),
100
-                $reg_url_link
101
-            ),
102
-            __FILE__,
103
-            __FUNCTION__,
104
-            __LINE__
105
-        );
106
-        return false;
107
-    }
82
+	/**
83
+	 * @param EE_Registration $registration
84
+	 * @param string          $reg_url_link
85
+	 * @return bool
86
+	 * @throws EE_Error
87
+	 */
88
+	private function isValidAttendee(EE_Registration $registration, string $reg_url_link): bool
89
+	{
90
+		if ($registration->attendee() instanceof EE_Attendee) {
91
+			return true;
92
+		}
93
+		EE_Error::add_error(
94
+			sprintf(
95
+				esc_html_x(
96
+					'Registration %s has an invalid or missing Attendee object.',
97
+					'Registration 123-456-789 has an invalid or missing Attendee object.',
98
+					'event_espresso'
99
+				),
100
+				$reg_url_link
101
+			),
102
+			__FILE__,
103
+			__FUNCTION__,
104
+			__LINE__
105
+		);
106
+		return false;
107
+	}
108 108
 
109 109
 
110
-    /**
111
-     * @param EE_Registration $registration
112
-     * @param EE_Attendee     $attendee
113
-     * @return void
114
-     * @throws EE_Error
115
-     * @throws InvalidArgumentException
116
-     * @throws ReflectionException
117
-     * @throws RuntimeException
118
-     * @throws InvalidDataTypeException
119
-     * @throws InvalidInterfaceException
120
-     */
121
-    private function associateAttendeeWithRegistration(EE_Registration $registration, EE_Attendee $attendee)
122
-    {
123
-        // add relation to attendee
124
-        $registration->_add_relation_to($attendee, 'Attendee');
125
-        $registration->set_attendee_id($attendee->ID());
126
-        $registration->update_cache_after_object_save('Attendee', $attendee);
127
-    }
110
+	/**
111
+	 * @param EE_Registration $registration
112
+	 * @param EE_Attendee     $attendee
113
+	 * @return void
114
+	 * @throws EE_Error
115
+	 * @throws InvalidArgumentException
116
+	 * @throws ReflectionException
117
+	 * @throws RuntimeException
118
+	 * @throws InvalidDataTypeException
119
+	 * @throws InvalidInterfaceException
120
+	 */
121
+	private function associateAttendeeWithRegistration(EE_Registration $registration, EE_Attendee $attendee)
122
+	{
123
+		// add relation to attendee
124
+		$registration->_add_relation_to($attendee, 'Attendee');
125
+		$registration->set_attendee_id($attendee->ID());
126
+		$registration->update_cache_after_object_save('Attendee', $attendee);
127
+	}
128 128
 }
Please login to merge, or discard this patch.
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   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -13,211 +13,211 @@
 block discarded – undo
13 13
 
14 14
 class RegFormInputHandler
15 15
 {
16
-    private EEM_Attendee $attendee_model;
17
-
18
-    private string $checkout_reg_url_link;
19
-
20
-    private RegistrantData $registrant_data;
21
-
22
-    private array $required_questions;
23
-
24
-
25
-    /**
26
-     * RegFormHandler constructor.
27
-     */
28
-    public function __construct(
29
-        string $checkout_reg_url_link,
30
-        array $required_questions,
31
-        EEM_Attendee $attendee_model,
32
-        RegistrantData $registrant_data
33
-    ) {
34
-        $this->attendee_model        = $attendee_model;
35
-        $this->checkout_reg_url_link = $checkout_reg_url_link;
36
-        $this->registrant_data       = $registrant_data;
37
-        $this->required_questions    = $required_questions;
38
-    }
39
-
40
-
41
-    /**
42
-     * @param EE_Registration  $registration
43
-     * @param string           $reg_url_link
44
-     * @param int|string       $form_input
45
-     * @param float|int|string $input_value
46
-     * @return bool
47
-     * @throws EE_Error
48
-     * @throws ReflectionException
49
-     */
50
-    public function processFormInput(
51
-        EE_Registration $registration,
52
-        string $reg_url_link,
53
-        $form_input,
54
-        $input_value
55
-    ): bool {
56
-        // check for critical inputs
57
-        if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) {
58
-            return false;
59
-        }
60
-        $input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData(
61
-            $reg_url_link,
62
-            $form_input,
63
-            $input_value
64
-        );
65
-        if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) {
66
-            EE_Error::add_error(
67
-                sprintf(
68
-                    esc_html_x(
69
-                        'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
70
-                        'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
71
-                        'event_espresso'
72
-                    ),
73
-                    $form_input,
74
-                    $input_value
75
-                ),
76
-                __FILE__,
77
-                __FUNCTION__,
78
-                __LINE__
79
-            );
80
-            return false;
81
-        }
82
-        return true;
83
-    }
84
-
85
-
86
-    /**
87
-     * @param EE_Registration  $registration
88
-     * @param string           $reg_url_link
89
-     * @param int|string       $form_input
90
-     * @param float|int|string $input_value
91
-     * @return bool
92
-     * @throws EE_Error
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidDataTypeException
95
-     * @throws InvalidInterfaceException
96
-     * @throws ReflectionException
97
-     */
98
-    private function saveRegistrationFormInput(
99
-        EE_Registration $registration,
100
-        string $reg_url_link,
101
-        $form_input = '',
102
-        $input_value = ''
103
-    ): bool {
104
-        // If email_confirm is sent it's not saved
105
-        if ((string) $form_input === 'email_confirm') {
106
-            return true;
107
-        }
108
-        // allow for plugins to hook in and do their own processing of the form input.
109
-        // For plugins to bypass normal processing here, they just need to return a truthy value.
110
-        if (
111
-            apply_filters(
112
-                'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput',
113
-                false,
114
-                $registration,
115
-                $form_input,
116
-                $input_value,
117
-                $this
118
-            )
119
-        ) {
120
-            return true;
121
-        }
122
-        /*
16
+	private EEM_Attendee $attendee_model;
17
+
18
+	private string $checkout_reg_url_link;
19
+
20
+	private RegistrantData $registrant_data;
21
+
22
+	private array $required_questions;
23
+
24
+
25
+	/**
26
+	 * RegFormHandler constructor.
27
+	 */
28
+	public function __construct(
29
+		string $checkout_reg_url_link,
30
+		array $required_questions,
31
+		EEM_Attendee $attendee_model,
32
+		RegistrantData $registrant_data
33
+	) {
34
+		$this->attendee_model        = $attendee_model;
35
+		$this->checkout_reg_url_link = $checkout_reg_url_link;
36
+		$this->registrant_data       = $registrant_data;
37
+		$this->required_questions    = $required_questions;
38
+	}
39
+
40
+
41
+	/**
42
+	 * @param EE_Registration  $registration
43
+	 * @param string           $reg_url_link
44
+	 * @param int|string       $form_input
45
+	 * @param float|int|string $input_value
46
+	 * @return bool
47
+	 * @throws EE_Error
48
+	 * @throws ReflectionException
49
+	 */
50
+	public function processFormInput(
51
+		EE_Registration $registration,
52
+		string $reg_url_link,
53
+		$form_input,
54
+		$input_value
55
+	): bool {
56
+		// check for critical inputs
57
+		if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($form_input, $input_value)) {
58
+			return false;
59
+		}
60
+		$input_value = $this->registrant_data->saveOrCopyPrimaryRegistrantData(
61
+			$reg_url_link,
62
+			$form_input,
63
+			$input_value
64
+		);
65
+		if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $form_input, $input_value)) {
66
+			EE_Error::add_error(
67
+				sprintf(
68
+					esc_html_x(
69
+						'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
70
+						'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
71
+						'event_espresso'
72
+					),
73
+					$form_input,
74
+					$input_value
75
+				),
76
+				__FILE__,
77
+				__FUNCTION__,
78
+				__LINE__
79
+			);
80
+			return false;
81
+		}
82
+		return true;
83
+	}
84
+
85
+
86
+	/**
87
+	 * @param EE_Registration  $registration
88
+	 * @param string           $reg_url_link
89
+	 * @param int|string       $form_input
90
+	 * @param float|int|string $input_value
91
+	 * @return bool
92
+	 * @throws EE_Error
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws ReflectionException
97
+	 */
98
+	private function saveRegistrationFormInput(
99
+		EE_Registration $registration,
100
+		string $reg_url_link,
101
+		$form_input = '',
102
+		$input_value = ''
103
+	): bool {
104
+		// If email_confirm is sent it's not saved
105
+		if ((string) $form_input === 'email_confirm') {
106
+			return true;
107
+		}
108
+		// allow for plugins to hook in and do their own processing of the form input.
109
+		// For plugins to bypass normal processing here, they just need to return a truthy value.
110
+		if (
111
+			apply_filters(
112
+				'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput',
113
+				false,
114
+				$registration,
115
+				$form_input,
116
+				$input_value,
117
+				$this
118
+			)
119
+		) {
120
+			return true;
121
+		}
122
+		/*
123 123
          * $answer_cache_id is the key used to find the EE_Answer we want
124 124
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
125 125
          */
126
-        $answer_cache_id   = $this->checkout_reg_url_link
127
-            ? $form_input . '-' . $reg_url_link
128
-            : $form_input;
129
-        $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
130
-        $answer_is_obj     = $registrant_answer instanceof EE_Answer;
131
-        // rename form_inputs if they are EE_Attendee properties
132
-        switch ((string) $form_input) {
133
-            case 'state':
134
-            case 'STA_ID':
135
-                $attendee_property = true;
136
-                $form_input        = 'STA_ID';
137
-                break;
138
-
139
-            case 'country':
140
-            case 'CNT_ISO':
141
-                $attendee_property = true;
142
-                $form_input        = 'CNT_ISO';
143
-                break;
144
-
145
-            default:
146
-                $ATT_input         = 'ATT_' . $form_input;
147
-                $attendee_property = $this->attendee_model->has_field($ATT_input);
148
-                $form_input        = $attendee_property
149
-                    ? 'ATT_' . $form_input
150
-                    : $form_input;
151
-        }
152
-
153
-        // if this form input has a corresponding attendee property
154
-        if ($attendee_property) {
155
-            $this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value);
156
-            if ($answer_is_obj) {
157
-                // and delete the corresponding answer since we won't be storing this data in that object
158
-                $registration->_remove_relation_to($registrant_answer, 'Answer');
159
-                $registrant_answer->delete_permanently();
160
-            }
161
-            return true;
162
-        }
163
-        if ($answer_is_obj) {
164
-            // save this data to the answer object
165
-            $registrant_answer->set_value($input_value);
166
-            $result = $registrant_answer->save();
167
-            return $result !== false;
168
-        }
169
-        foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) {
170
-            if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
171
-                $answer->set_value($input_value);
172
-                $result = $answer->save();
173
-                return $result !== false;
174
-            }
175
-        }
176
-        return false;
177
-    }
178
-
179
-
180
-    /**
181
-     * @param int|string       $form_input
182
-     * @param float|int|string $input_value
183
-     * @return boolean
184
-     */
185
-    private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail(
186
-        $form_input = '',
187
-        $input_value = ''
188
-    ): bool {
189
-        if (empty($input_value)) {
190
-            // if the form input isn't marked as being required, then just return
191
-            if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
192
-                return true;
193
-            }
194
-            switch ($form_input) {
195
-                case 'fname':
196
-                    EE_Error::add_error(
197
-                        esc_html__('First Name is a required value.', 'event_espresso'),
198
-                        __FILE__,
199
-                        __FUNCTION__,
200
-                        __LINE__
201
-                    );
202
-                    return false;
203
-                case 'lname':
204
-                    EE_Error::add_error(
205
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
206
-                        __FILE__,
207
-                        __FUNCTION__,
208
-                        __LINE__
209
-                    );
210
-                    return false;
211
-                case 'email':
212
-                    EE_Error::add_error(
213
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
214
-                        __FILE__,
215
-                        __FUNCTION__,
216
-                        __LINE__
217
-                    );
218
-                    return false;
219
-            }
220
-        }
221
-        return true;
222
-    }
126
+		$answer_cache_id   = $this->checkout_reg_url_link
127
+			? $form_input . '-' . $reg_url_link
128
+			: $form_input;
129
+		$registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
130
+		$answer_is_obj     = $registrant_answer instanceof EE_Answer;
131
+		// rename form_inputs if they are EE_Attendee properties
132
+		switch ((string) $form_input) {
133
+			case 'state':
134
+			case 'STA_ID':
135
+				$attendee_property = true;
136
+				$form_input        = 'STA_ID';
137
+				break;
138
+
139
+			case 'country':
140
+			case 'CNT_ISO':
141
+				$attendee_property = true;
142
+				$form_input        = 'CNT_ISO';
143
+				break;
144
+
145
+			default:
146
+				$ATT_input         = 'ATT_' . $form_input;
147
+				$attendee_property = $this->attendee_model->has_field($ATT_input);
148
+				$form_input        = $attendee_property
149
+					? 'ATT_' . $form_input
150
+					: $form_input;
151
+		}
152
+
153
+		// if this form input has a corresponding attendee property
154
+		if ($attendee_property) {
155
+			$this->registrant_data->addRegistrantDataValue($reg_url_link, $form_input, $input_value);
156
+			if ($answer_is_obj) {
157
+				// and delete the corresponding answer since we won't be storing this data in that object
158
+				$registration->_remove_relation_to($registrant_answer, 'Answer');
159
+				$registrant_answer->delete_permanently();
160
+			}
161
+			return true;
162
+		}
163
+		if ($answer_is_obj) {
164
+			// save this data to the answer object
165
+			$registrant_answer->set_value($input_value);
166
+			$result = $registrant_answer->save();
167
+			return $result !== false;
168
+		}
169
+		foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) {
170
+			if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
171
+				$answer->set_value($input_value);
172
+				$result = $answer->save();
173
+				return $result !== false;
174
+			}
175
+		}
176
+		return false;
177
+	}
178
+
179
+
180
+	/**
181
+	 * @param int|string       $form_input
182
+	 * @param float|int|string $input_value
183
+	 * @return boolean
184
+	 */
185
+	private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail(
186
+		$form_input = '',
187
+		$input_value = ''
188
+	): bool {
189
+		if (empty($input_value)) {
190
+			// if the form input isn't marked as being required, then just return
191
+			if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
192
+				return true;
193
+			}
194
+			switch ($form_input) {
195
+				case 'fname':
196
+					EE_Error::add_error(
197
+						esc_html__('First Name is a required value.', 'event_espresso'),
198
+						__FILE__,
199
+						__FUNCTION__,
200
+						__LINE__
201
+					);
202
+					return false;
203
+				case 'lname':
204
+					EE_Error::add_error(
205
+						esc_html__('Last Name is a required value.', 'event_espresso'),
206
+						__FILE__,
207
+						__FUNCTION__,
208
+						__LINE__
209
+					);
210
+					return false;
211
+				case 'email':
212
+					EE_Error::add_error(
213
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
214
+						__FILE__,
215
+						__FUNCTION__,
216
+						__LINE__
217
+					);
218
+					return false;
219
+			}
220
+		}
221
+		return true;
222
+	}
223 223
 }
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.
core/domain/services/graphql/mutators/VenueUpdate.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   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,63 +14,63 @@
 block discarded – undo
14 14
 class VenueUpdate extends EntityMutator
15 15
 {
16 16
 
17
-    /**
18
-     * Defines the mutation data modification closure.
19
-     *
20
-     * @param EEM_Venue $model
21
-     * @param Venue     $type
22
-     * @return callable
23
-     */
24
-    public static function mutateFields(EEM_Venue $model, Venue $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_Venue $model
21
+	 * @param Venue     $type
22
+	 * @return callable
23
+	 */
24
+	public static function mutateFields(EEM_Venue $model, Venue $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_Venue $entity */
58
-                $entity = EntityMutator::getEntityFromID($model, $id);
59
-                $args = VenueMutation::prepareFields($input);
57
+				/** @var EE_Venue $entity */
58
+				$entity = EntityMutator::getEntityFromID($model, $id);
59
+				$args = VenueMutation::prepareFields($input);
60 60
 
61
-                // Update the entity
62
-                $entity->save($args);
61
+				// Update the entity
62
+				$entity->save($args);
63 63
 
64
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_venue_update', $entity, $input);
65
-            } catch (Exception $exception) {
66
-                EntityMutator::handleExceptions(
67
-                    $exception,
68
-                    esc_html__(
69
-                        'The venue could not be updated because of the following error(s)',
70
-                        'event_espresso'
71
-                    )
72
-                );
73
-            }
74
-        };
75
-    }
64
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_venue_update', $entity, $input);
65
+			} catch (Exception $exception) {
66
+				EntityMutator::handleExceptions(
67
+					$exception,
68
+					esc_html__(
69
+						'The venue could not be updated because of the following error(s)',
70
+						'event_espresso'
71
+					)
72
+				);
73
+			}
74
+		};
75
+	}
76 76
 }
Please login to merge, or discard this patch.