@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if ($units_processed >= $batch_size) { |
210 | 210 | break; |
211 | 211 | } |
212 | - if (!$root_node instanceof ModelObjNode) { |
|
212 | + if ( ! $root_node instanceof ModelObjNode) { |
|
213 | 213 | throw new InvalidClassException('ModelObjNode'); |
214 | 214 | } |
215 | 215 | if ($root_node->isComplete()) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $job_parameters->mark_processed($units_processed); |
221 | 221 | // If the most-recently processed root node is complete, we must be all done because we're doing them |
222 | 222 | // sequentially. |
223 | - if (! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) { |
|
223 | + if ( ! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) { |
|
224 | 224 | $job_parameters->set_status(JobParameters::status_complete); |
225 | 225 | // Show a full progress bar. |
226 | 226 | $job_parameters->set_units_processed($job_parameters->job_size()); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | 'event_espresso' |
264 | 264 | ), |
265 | 265 | '<span id="ee-redirect-timer">10</span>', |
266 | - '<a href="' . $job_parameters->request_datum('return_url') . '">', |
|
266 | + '<a href="'.$job_parameters->request_datum('return_url').'">', |
|
267 | 267 | '</a>' |
268 | 268 | ) |
269 | 269 | ) |
@@ -33,141 +33,141 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class PreviewEventDeletion extends JobHandler |
35 | 35 | { |
36 | - protected NodeGroupDao $model_obj_node_group_persister; |
|
36 | + protected NodeGroupDao $model_obj_node_group_persister; |
|
37 | 37 | |
38 | - public function __construct(NodeGroupDao $model_obj_node_group_persister) |
|
39 | - { |
|
40 | - $this->model_obj_node_group_persister = $model_obj_node_group_persister; |
|
41 | - } |
|
38 | + public function __construct(NodeGroupDao $model_obj_node_group_persister) |
|
39 | + { |
|
40 | + $this->model_obj_node_group_persister = $model_obj_node_group_persister; |
|
41 | + } |
|
42 | 42 | |
43 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
44 | 44 | |
45 | - /** |
|
46 | - * |
|
47 | - * @param JobParameters $job_parameters |
|
48 | - * @return JobStepResponse |
|
49 | - * @throws EE_Error |
|
50 | - * @throws InvalidDataTypeException |
|
51 | - * @throws InvalidInterfaceException |
|
52 | - * @throws InvalidArgumentException |
|
53 | - * @throws ReflectionException |
|
54 | - */ |
|
55 | - public function create_job(JobParameters $job_parameters): JobStepResponse |
|
56 | - { |
|
57 | - // Set the "root" model objects we will want to delete (record their ID and model) |
|
58 | - $event_ids = $job_parameters->request_datum('EVT_IDs', array()); |
|
59 | - // Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets, |
|
60 | - // prices, message templates, etc, whose model definition doesn't make them dependent on events. But, |
|
61 | - // we have no UI to access them independent of events, so they may as well get deleted too.) |
|
62 | - $roots = []; |
|
63 | - foreach ($event_ids as $event_id) { |
|
64 | - $roots[] = new ModelObjNode( |
|
65 | - $event_id, |
|
66 | - EEM_Event::instance() |
|
67 | - ); |
|
68 | - // Also, we want to delete their related, non-global, tickets, prices and message templates |
|
69 | - $related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
70 | - [ |
|
71 | - [ |
|
72 | - 'TKT_is_default' => false, |
|
73 | - 'Datetime.EVT_ID' => $event_id |
|
74 | - ] |
|
75 | - ] |
|
76 | - ); |
|
77 | - foreach ($related_non_global_tickets as $ticket) { |
|
78 | - $roots[] = new ModelObjNode( |
|
79 | - $ticket->ID(), |
|
80 | - $ticket->get_model(), |
|
81 | - ['Registration'] |
|
82 | - ); |
|
83 | - } |
|
84 | - $related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted( |
|
85 | - [ |
|
86 | - [ |
|
87 | - 'PRC_is_default' => false, |
|
88 | - 'Ticket.Datetime.EVT_ID' => $event_id |
|
89 | - ] |
|
90 | - ] |
|
91 | - ); |
|
92 | - foreach ($related_non_global_prices as $price) { |
|
93 | - $roots[] = new ModelObjNode( |
|
94 | - $price->ID(), |
|
95 | - $price->get_model() |
|
96 | - ); |
|
97 | - } |
|
98 | - } |
|
99 | - $transactions_ids = $this->getTransactionsToDelete($event_ids); |
|
100 | - foreach ($transactions_ids as $transaction_id) { |
|
101 | - $roots[] = new ModelObjNode( |
|
102 | - $transaction_id, |
|
103 | - EEM_Transaction::instance(), |
|
104 | - ['Registration'] |
|
105 | - ); |
|
106 | - } |
|
107 | - $job_parameters->add_extra_data('roots', $roots); |
|
108 | - // Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give |
|
109 | - // an accurate count.) |
|
110 | - $estimated_work_per_model_obj = 10; |
|
111 | - $count_regs = EEM_Registration::instance()->count( |
|
112 | - [ |
|
113 | - [ |
|
114 | - 'EVT_ID' => ['IN', $event_ids] |
|
115 | - ] |
|
116 | - ] |
|
117 | - ); |
|
118 | - $job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj); |
|
119 | - $this->updateTextHeader(esc_html__('Generating preview of data to be deleted...', 'event_espresso')); |
|
120 | - return new JobStepResponse($job_parameters, $this->feedback); |
|
121 | - } |
|
45 | + /** |
|
46 | + * |
|
47 | + * @param JobParameters $job_parameters |
|
48 | + * @return JobStepResponse |
|
49 | + * @throws EE_Error |
|
50 | + * @throws InvalidDataTypeException |
|
51 | + * @throws InvalidInterfaceException |
|
52 | + * @throws InvalidArgumentException |
|
53 | + * @throws ReflectionException |
|
54 | + */ |
|
55 | + public function create_job(JobParameters $job_parameters): JobStepResponse |
|
56 | + { |
|
57 | + // Set the "root" model objects we will want to delete (record their ID and model) |
|
58 | + $event_ids = $job_parameters->request_datum('EVT_IDs', array()); |
|
59 | + // Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets, |
|
60 | + // prices, message templates, etc, whose model definition doesn't make them dependent on events. But, |
|
61 | + // we have no UI to access them independent of events, so they may as well get deleted too.) |
|
62 | + $roots = []; |
|
63 | + foreach ($event_ids as $event_id) { |
|
64 | + $roots[] = new ModelObjNode( |
|
65 | + $event_id, |
|
66 | + EEM_Event::instance() |
|
67 | + ); |
|
68 | + // Also, we want to delete their related, non-global, tickets, prices and message templates |
|
69 | + $related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
70 | + [ |
|
71 | + [ |
|
72 | + 'TKT_is_default' => false, |
|
73 | + 'Datetime.EVT_ID' => $event_id |
|
74 | + ] |
|
75 | + ] |
|
76 | + ); |
|
77 | + foreach ($related_non_global_tickets as $ticket) { |
|
78 | + $roots[] = new ModelObjNode( |
|
79 | + $ticket->ID(), |
|
80 | + $ticket->get_model(), |
|
81 | + ['Registration'] |
|
82 | + ); |
|
83 | + } |
|
84 | + $related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted( |
|
85 | + [ |
|
86 | + [ |
|
87 | + 'PRC_is_default' => false, |
|
88 | + 'Ticket.Datetime.EVT_ID' => $event_id |
|
89 | + ] |
|
90 | + ] |
|
91 | + ); |
|
92 | + foreach ($related_non_global_prices as $price) { |
|
93 | + $roots[] = new ModelObjNode( |
|
94 | + $price->ID(), |
|
95 | + $price->get_model() |
|
96 | + ); |
|
97 | + } |
|
98 | + } |
|
99 | + $transactions_ids = $this->getTransactionsToDelete($event_ids); |
|
100 | + foreach ($transactions_ids as $transaction_id) { |
|
101 | + $roots[] = new ModelObjNode( |
|
102 | + $transaction_id, |
|
103 | + EEM_Transaction::instance(), |
|
104 | + ['Registration'] |
|
105 | + ); |
|
106 | + } |
|
107 | + $job_parameters->add_extra_data('roots', $roots); |
|
108 | + // Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give |
|
109 | + // an accurate count.) |
|
110 | + $estimated_work_per_model_obj = 10; |
|
111 | + $count_regs = EEM_Registration::instance()->count( |
|
112 | + [ |
|
113 | + [ |
|
114 | + 'EVT_ID' => ['IN', $event_ids] |
|
115 | + ] |
|
116 | + ] |
|
117 | + ); |
|
118 | + $job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj); |
|
119 | + $this->updateTextHeader(esc_html__('Generating preview of data to be deleted...', 'event_espresso')); |
|
120 | + return new JobStepResponse($job_parameters, $this->feedback); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @param EE_Base_Class[] $model_objs |
|
125 | - * @param array $dont_traverse_models |
|
126 | - * @return array |
|
127 | - * @throws EE_Error |
|
128 | - * @throws InvalidArgumentException |
|
129 | - * @throws InvalidDataTypeException |
|
130 | - * @throws InvalidInterfaceException |
|
131 | - * @throws ReflectionException |
|
132 | - * @since 4.10.12.p |
|
133 | - */ |
|
134 | - protected function createModelObjNodes(array $model_objs, array $dont_traverse_models = []): array |
|
135 | - { |
|
136 | - $nodes = []; |
|
137 | - foreach ($model_objs as $model_obj) { |
|
138 | - $nodes[] = new ModelObjNode( |
|
139 | - $model_obj->ID(), |
|
140 | - $model_obj->get_model(), |
|
141 | - $dont_traverse_models |
|
142 | - ); |
|
143 | - } |
|
144 | - return $nodes; |
|
145 | - } |
|
123 | + /** |
|
124 | + * @param EE_Base_Class[] $model_objs |
|
125 | + * @param array $dont_traverse_models |
|
126 | + * @return array |
|
127 | + * @throws EE_Error |
|
128 | + * @throws InvalidArgumentException |
|
129 | + * @throws InvalidDataTypeException |
|
130 | + * @throws InvalidInterfaceException |
|
131 | + * @throws ReflectionException |
|
132 | + * @since 4.10.12.p |
|
133 | + */ |
|
134 | + protected function createModelObjNodes(array $model_objs, array $dont_traverse_models = []): array |
|
135 | + { |
|
136 | + $nodes = []; |
|
137 | + foreach ($model_objs as $model_obj) { |
|
138 | + $nodes[] = new ModelObjNode( |
|
139 | + $model_obj->ID(), |
|
140 | + $model_obj->get_model(), |
|
141 | + $dont_traverse_models |
|
142 | + ); |
|
143 | + } |
|
144 | + return $nodes; |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too. |
|
149 | - * (Ones that are related to other events can stay around until those other events are deleted too.) |
|
150 | - * @since 4.10.12.p |
|
151 | - * @param array $event_ids |
|
152 | - * @return array of transaction IDs |
|
153 | - */ |
|
154 | - protected function getTransactionsToDelete(array $event_ids): array |
|
155 | - { |
|
156 | - if (empty($event_ids)) { |
|
157 | - return []; |
|
158 | - } |
|
159 | - global $wpdb; |
|
160 | - $event_ids = array_map('absint', $event_ids); |
|
161 | - $imploded_sanitized_event_ids = implode(',', $event_ids); |
|
162 | - // Select transactions with registrations for the events $event_ids which also don't have registrations |
|
163 | - // for any events NOT in $event_ids. |
|
164 | - // Notice the outer query searched for transactions whose registrations ARE in $event_ids, |
|
165 | - // whereas the inner query checks if the outer query's transaction has any registrations that are |
|
166 | - // NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.) |
|
167 | - return array_map( |
|
168 | - 'absint', |
|
169 | - $wpdb->get_col( |
|
170 | - "SELECT |
|
147 | + /** |
|
148 | + * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too. |
|
149 | + * (Ones that are related to other events can stay around until those other events are deleted too.) |
|
150 | + * @since 4.10.12.p |
|
151 | + * @param array $event_ids |
|
152 | + * @return array of transaction IDs |
|
153 | + */ |
|
154 | + protected function getTransactionsToDelete(array $event_ids): array |
|
155 | + { |
|
156 | + if (empty($event_ids)) { |
|
157 | + return []; |
|
158 | + } |
|
159 | + global $wpdb; |
|
160 | + $event_ids = array_map('absint', $event_ids); |
|
161 | + $imploded_sanitized_event_ids = implode(',', $event_ids); |
|
162 | + // Select transactions with registrations for the events $event_ids which also don't have registrations |
|
163 | + // for any events NOT in $event_ids. |
|
164 | + // Notice the outer query searched for transactions whose registrations ARE in $event_ids, |
|
165 | + // whereas the inner query checks if the outer query's transaction has any registrations that are |
|
166 | + // NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.) |
|
167 | + return array_map( |
|
168 | + 'absint', |
|
169 | + $wpdb->get_col( |
|
170 | + "SELECT |
|
171 | 171 | DISTINCT t.TXN_ID |
172 | 172 | FROM |
173 | 173 | {$wpdb->prefix}esp_transaction t INNER JOIN |
@@ -185,90 +185,90 @@ discard block |
||
185 | 185 | tsub.TXN_ID=t.TXN_ID AND |
186 | 186 | rsub.EVT_ID NOT IN ($imploded_sanitized_event_ids) |
187 | 187 | )" |
188 | - ) |
|
189 | - ); |
|
190 | - } |
|
188 | + ) |
|
189 | + ); |
|
190 | + } |
|
191 | 191 | |
192 | - /** |
|
193 | - * Performs another step of the job |
|
194 | - * @param JobParameters $job_parameters |
|
195 | - * @param int $batch_size |
|
196 | - * @return JobStepResponse |
|
197 | - */ |
|
198 | - public function continue_job(JobParameters $job_parameters, int $batch_size = 50): JobStepResponse |
|
199 | - { |
|
200 | - // Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took |
|
201 | - // about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like |
|
202 | - // 50% of the request is just serializing and unserializing.) So, make the batches much bigger. |
|
203 | - $batch_size *= 3; |
|
204 | - $units_processed = 0; |
|
205 | - foreach ($job_parameters->extra_datum('roots', array()) as $root_node) { |
|
206 | - if ($units_processed >= $batch_size) { |
|
207 | - break; |
|
208 | - } |
|
209 | - if (!$root_node instanceof ModelObjNode) { |
|
210 | - throw new InvalidClassException('ModelObjNode'); |
|
211 | - } |
|
212 | - if ($root_node->isComplete()) { |
|
213 | - continue; |
|
214 | - } |
|
215 | - $units_processed += $root_node->visit($batch_size - $units_processed); |
|
216 | - } |
|
217 | - $job_parameters->mark_processed($units_processed); |
|
218 | - // If the most-recently processed root node is complete, we must be all done because we're doing them |
|
219 | - // sequentially. |
|
220 | - if (! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) { |
|
221 | - $job_parameters->set_status(JobParameters::status_complete); |
|
222 | - // Show a full progress bar. |
|
223 | - $job_parameters->set_units_processed($job_parameters->job_size()); |
|
224 | - $deletion_job_code = $job_parameters->request_datum('deletion_job_code'); |
|
225 | - $this->model_obj_node_group_persister->persistModelObjNodesGroup( |
|
226 | - $job_parameters->extra_datum('roots'), |
|
227 | - $deletion_job_code |
|
228 | - ); |
|
229 | - return new JobStepResponse($job_parameters, $this->feedback); |
|
230 | - } |
|
231 | - // Because the job size was a guess, it may have likely been proven wrong. |
|
232 | - // We don't want to show more work done than we originally said there would be. |
|
233 | - // So adjust the estimate. |
|
234 | - if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) { |
|
235 | - $job_parameters->set_job_size($job_parameters->job_size() * 2); |
|
236 | - } |
|
237 | - $this->displayJobStepResults( |
|
238 | - $units_processed, |
|
239 | - esc_html__('Identified up to %d potential items for deletion.', 'event_espresso') |
|
240 | - ); |
|
241 | - return new JobStepResponse($job_parameters, $this->feedback); |
|
242 | - } |
|
192 | + /** |
|
193 | + * Performs another step of the job |
|
194 | + * @param JobParameters $job_parameters |
|
195 | + * @param int $batch_size |
|
196 | + * @return JobStepResponse |
|
197 | + */ |
|
198 | + public function continue_job(JobParameters $job_parameters, int $batch_size = 50): JobStepResponse |
|
199 | + { |
|
200 | + // Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took |
|
201 | + // about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like |
|
202 | + // 50% of the request is just serializing and unserializing.) So, make the batches much bigger. |
|
203 | + $batch_size *= 3; |
|
204 | + $units_processed = 0; |
|
205 | + foreach ($job_parameters->extra_datum('roots', array()) as $root_node) { |
|
206 | + if ($units_processed >= $batch_size) { |
|
207 | + break; |
|
208 | + } |
|
209 | + if (!$root_node instanceof ModelObjNode) { |
|
210 | + throw new InvalidClassException('ModelObjNode'); |
|
211 | + } |
|
212 | + if ($root_node->isComplete()) { |
|
213 | + continue; |
|
214 | + } |
|
215 | + $units_processed += $root_node->visit($batch_size - $units_processed); |
|
216 | + } |
|
217 | + $job_parameters->mark_processed($units_processed); |
|
218 | + // If the most-recently processed root node is complete, we must be all done because we're doing them |
|
219 | + // sequentially. |
|
220 | + if (! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) { |
|
221 | + $job_parameters->set_status(JobParameters::status_complete); |
|
222 | + // Show a full progress bar. |
|
223 | + $job_parameters->set_units_processed($job_parameters->job_size()); |
|
224 | + $deletion_job_code = $job_parameters->request_datum('deletion_job_code'); |
|
225 | + $this->model_obj_node_group_persister->persistModelObjNodesGroup( |
|
226 | + $job_parameters->extra_datum('roots'), |
|
227 | + $deletion_job_code |
|
228 | + ); |
|
229 | + return new JobStepResponse($job_parameters, $this->feedback); |
|
230 | + } |
|
231 | + // Because the job size was a guess, it may have likely been proven wrong. |
|
232 | + // We don't want to show more work done than we originally said there would be. |
|
233 | + // So adjust the estimate. |
|
234 | + if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) { |
|
235 | + $job_parameters->set_job_size($job_parameters->job_size() * 2); |
|
236 | + } |
|
237 | + $this->displayJobStepResults( |
|
238 | + $units_processed, |
|
239 | + esc_html__('Identified up to %d potential items for deletion.', 'event_espresso') |
|
240 | + ); |
|
241 | + return new JobStepResponse($job_parameters, $this->feedback); |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Performs any clean-up logic when we know the job is completed |
|
246 | - * @param JobParameters $job_parameters |
|
247 | - * @return JobStepResponse |
|
248 | - */ |
|
249 | - public function cleanup_job(JobParameters $job_parameters): JobStepResponse |
|
250 | - { |
|
251 | - $this->displayJobFinalResults( |
|
252 | - $job_parameters, |
|
253 | - esc_html__('found %d potential items for deletion.', 'event_espresso') |
|
254 | - ); |
|
255 | - $this->updateText( |
|
256 | - $this->infoWrapper( |
|
257 | - sprintf( |
|
258 | - esc_html__( |
|
259 | - 'If not automatically redirected in %1$s seconds, click here to %2$scontinue to the confirmation step%3$s', |
|
260 | - 'event_espresso' |
|
261 | - ), |
|
262 | - '<span id="ee-redirect-timer">10</span>', |
|
263 | - '<a href="' . $job_parameters->request_datum('return_url') . '">', |
|
264 | - '</a>' |
|
265 | - ) |
|
266 | - ) |
|
267 | - ); |
|
268 | - // Nothing much to do. |
|
269 | - // We can't delete the option with the built tree because we may need it in a moment for the deletion |
|
270 | - return new JobStepResponse($job_parameters, $this->feedback); |
|
271 | - } |
|
244 | + /** |
|
245 | + * Performs any clean-up logic when we know the job is completed |
|
246 | + * @param JobParameters $job_parameters |
|
247 | + * @return JobStepResponse |
|
248 | + */ |
|
249 | + public function cleanup_job(JobParameters $job_parameters): JobStepResponse |
|
250 | + { |
|
251 | + $this->displayJobFinalResults( |
|
252 | + $job_parameters, |
|
253 | + esc_html__('found %d potential items for deletion.', 'event_espresso') |
|
254 | + ); |
|
255 | + $this->updateText( |
|
256 | + $this->infoWrapper( |
|
257 | + sprintf( |
|
258 | + esc_html__( |
|
259 | + 'If not automatically redirected in %1$s seconds, click here to %2$scontinue to the confirmation step%3$s', |
|
260 | + 'event_espresso' |
|
261 | + ), |
|
262 | + '<span id="ee-redirect-timer">10</span>', |
|
263 | + '<a href="' . $job_parameters->request_datum('return_url') . '">', |
|
264 | + '</a>' |
|
265 | + ) |
|
266 | + ) |
|
267 | + ); |
|
268 | + // Nothing much to do. |
|
269 | + // We can't delete the option with the built tree because we may need it in a moment for the deletion |
|
270 | + return new JobStepResponse($job_parameters, $this->feedback); |
|
271 | + } |
|
272 | 272 | } |
273 | 273 | // End of file EventDeletion.php |
274 | 274 | // Location: EventEspresso\core\libraries\batch\JobHandlers/EventDeletion.php |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function getRequestData($key) |
134 | 134 | { |
135 | - return $this->request_data[ $key ] ?? null; |
|
135 | + return $this->request_data[$key] ?? null; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | : esc_html__('processed this batch: %d', 'event_espresso'), |
187 | 187 | $processed |
188 | 188 | ) |
189 | - ) . ' |
|
189 | + ).' |
|
190 | 190 | </div>'; |
191 | 191 | } |
192 | 192 | |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | : esc_html__('total units processed: %d', 'event_espresso'), |
204 | 204 | $job_parameters->units_processed() |
205 | 205 | ) |
206 | - ) . ' |
|
207 | - ' . $this->jobStatusNotice($job_parameters) . ' |
|
206 | + ).' |
|
207 | + ' . $this->jobStatusNotice($job_parameters).' |
|
208 | 208 | </div>'; |
209 | 209 | } |
210 | 210 | } |
@@ -17,264 +17,264 @@ |
||
17 | 17 | */ |
18 | 18 | abstract class JobHandler implements JobHandlerInterface |
19 | 19 | { |
20 | - protected array $feedback = []; |
|
21 | - |
|
22 | - protected array $request_data = []; |
|
23 | - |
|
24 | - /** |
|
25 | - * Extra data to include as part of the response, literally gets set as JobStepResponse::$_extra_data |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected array $response_data = []; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
34 | - * Performs any necessary setup for starting the job. This is also a good |
|
35 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
36 | - * when continue_job will be called |
|
37 | - * |
|
38 | - * @param JobParameters $job_parameters |
|
39 | - * @return JobStepResponse |
|
40 | - * @throws BatchRequestException |
|
41 | - * @since 5.0.0.p |
|
42 | - */ |
|
43 | - public function createJob(JobParameters $job_parameters): JobStepResponse |
|
44 | - { |
|
45 | - return $this->create_job($job_parameters); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
51 | - * Performs another step of the job |
|
52 | - * |
|
53 | - * @param JobParameters $job_parameters |
|
54 | - * @param int $batch_size |
|
55 | - * @return JobStepResponse |
|
56 | - * @throws BatchRequestException |
|
57 | - * @since 5.0.0.p |
|
58 | - */ |
|
59 | - public function continueJob(JobParameters $job_parameters, int $batch_size = 50): JobStepResponse |
|
60 | - { |
|
61 | - return $this->continue_job($job_parameters, $batch_size); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
67 | - * used to advance from one batch job to another |
|
68 | - * primarily used for executing a job assessment phase where an accurate count of items to update can be made, |
|
69 | - * followed by the actual update job. |
|
70 | - * |
|
71 | - * @param JobParameters $job_parameters |
|
72 | - * @return JobStepResponse |
|
73 | - * @since 5.0.0.p |
|
74 | - */ |
|
75 | - public function advanceJob(JobParameters $job_parameters): JobStepResponse |
|
76 | - { |
|
77 | - return $this->advance_job($job_parameters); |
|
78 | - } |
|
79 | - |
|
80 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
81 | - /** |
|
82 | - * used to advance from one batch job to another |
|
83 | - * primarily used for executing a job assessment phase where an accurate count of items to update can be made, |
|
84 | - * followed by the actual update job. |
|
85 | - * By default, this function won't do anything until overridden in a chile class. |
|
86 | - * |
|
87 | - * @param JobParameters $job_parameters |
|
88 | - * @return JobStepResponse |
|
89 | - * @since 5.0.0.p |
|
90 | - */ |
|
91 | - public function advance_job(JobParameters $job_parameters): JobStepResponse |
|
92 | - { |
|
93 | - $job_parameters->set_status(JobParameters::status_continue); |
|
94 | - return new JobStepResponse($job_parameters, $this->feedback); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
100 | - * Performs any clean-up logic when we know the job is completed |
|
101 | - * |
|
102 | - * @param JobParameters $job_parameters |
|
103 | - * @return JobStepResponse |
|
104 | - * @throws BatchRequestException |
|
105 | - * @since 5.0.0.p |
|
106 | - */ |
|
107 | - public function cleanupJob(JobParameters $job_parameters): JobStepResponse |
|
108 | - { |
|
109 | - return $this->cleanup_job($job_parameters); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @return array |
|
115 | - */ |
|
116 | - public function requestData(): array |
|
117 | - { |
|
118 | - return $this->request_data; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string|int $key |
|
124 | - * @return mixed |
|
125 | - */ |
|
126 | - public function getRequestData($key) |
|
127 | - { |
|
128 | - return $this->request_data[ $key ] ?? null; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @param array $request_data |
|
134 | - */ |
|
135 | - public function setRequestData(array $request_data): void |
|
136 | - { |
|
137 | - $this->request_data = $request_data; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @return array |
|
143 | - */ |
|
144 | - public function responseData(): array |
|
145 | - { |
|
146 | - return $this->response_data; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @param array $response_data |
|
152 | - */ |
|
153 | - public function addResponseData(array $response_data): void |
|
154 | - { |
|
155 | - $this->response_data += $response_data; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @param array $response_data |
|
162 | - */ |
|
163 | - public function setResponseData(array $response_data): void |
|
164 | - { |
|
165 | - $this->response_data = $response_data; |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - protected function displayJobStepResults(int $processed, string $custom_message = '') |
|
172 | - { |
|
173 | - $this->feedback[] = ' |
|
20 | + protected array $feedback = []; |
|
21 | + |
|
22 | + protected array $request_data = []; |
|
23 | + |
|
24 | + /** |
|
25 | + * Extra data to include as part of the response, literally gets set as JobStepResponse::$_extra_data |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected array $response_data = []; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
34 | + * Performs any necessary setup for starting the job. This is also a good |
|
35 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
36 | + * when continue_job will be called |
|
37 | + * |
|
38 | + * @param JobParameters $job_parameters |
|
39 | + * @return JobStepResponse |
|
40 | + * @throws BatchRequestException |
|
41 | + * @since 5.0.0.p |
|
42 | + */ |
|
43 | + public function createJob(JobParameters $job_parameters): JobStepResponse |
|
44 | + { |
|
45 | + return $this->create_job($job_parameters); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
51 | + * Performs another step of the job |
|
52 | + * |
|
53 | + * @param JobParameters $job_parameters |
|
54 | + * @param int $batch_size |
|
55 | + * @return JobStepResponse |
|
56 | + * @throws BatchRequestException |
|
57 | + * @since 5.0.0.p |
|
58 | + */ |
|
59 | + public function continueJob(JobParameters $job_parameters, int $batch_size = 50): JobStepResponse |
|
60 | + { |
|
61 | + return $this->continue_job($job_parameters, $batch_size); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
67 | + * used to advance from one batch job to another |
|
68 | + * primarily used for executing a job assessment phase where an accurate count of items to update can be made, |
|
69 | + * followed by the actual update job. |
|
70 | + * |
|
71 | + * @param JobParameters $job_parameters |
|
72 | + * @return JobStepResponse |
|
73 | + * @since 5.0.0.p |
|
74 | + */ |
|
75 | + public function advanceJob(JobParameters $job_parameters): JobStepResponse |
|
76 | + { |
|
77 | + return $this->advance_job($job_parameters); |
|
78 | + } |
|
79 | + |
|
80 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
81 | + /** |
|
82 | + * used to advance from one batch job to another |
|
83 | + * primarily used for executing a job assessment phase where an accurate count of items to update can be made, |
|
84 | + * followed by the actual update job. |
|
85 | + * By default, this function won't do anything until overridden in a chile class. |
|
86 | + * |
|
87 | + * @param JobParameters $job_parameters |
|
88 | + * @return JobStepResponse |
|
89 | + * @since 5.0.0.p |
|
90 | + */ |
|
91 | + public function advance_job(JobParameters $job_parameters): JobStepResponse |
|
92 | + { |
|
93 | + $job_parameters->set_status(JobParameters::status_continue); |
|
94 | + return new JobStepResponse($job_parameters, $this->feedback); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * utilized in newer batch job implementations, but forwarding to existing methods for now. |
|
100 | + * Performs any clean-up logic when we know the job is completed |
|
101 | + * |
|
102 | + * @param JobParameters $job_parameters |
|
103 | + * @return JobStepResponse |
|
104 | + * @throws BatchRequestException |
|
105 | + * @since 5.0.0.p |
|
106 | + */ |
|
107 | + public function cleanupJob(JobParameters $job_parameters): JobStepResponse |
|
108 | + { |
|
109 | + return $this->cleanup_job($job_parameters); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @return array |
|
115 | + */ |
|
116 | + public function requestData(): array |
|
117 | + { |
|
118 | + return $this->request_data; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string|int $key |
|
124 | + * @return mixed |
|
125 | + */ |
|
126 | + public function getRequestData($key) |
|
127 | + { |
|
128 | + return $this->request_data[ $key ] ?? null; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @param array $request_data |
|
134 | + */ |
|
135 | + public function setRequestData(array $request_data): void |
|
136 | + { |
|
137 | + $this->request_data = $request_data; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @return array |
|
143 | + */ |
|
144 | + public function responseData(): array |
|
145 | + { |
|
146 | + return $this->response_data; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @param array $response_data |
|
152 | + */ |
|
153 | + public function addResponseData(array $response_data): void |
|
154 | + { |
|
155 | + $this->response_data += $response_data; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @param array $response_data |
|
162 | + */ |
|
163 | + public function setResponseData(array $response_data): void |
|
164 | + { |
|
165 | + $this->response_data = $response_data; |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + protected function displayJobStepResults(int $processed, string $custom_message = '') |
|
172 | + { |
|
173 | + $this->feedback[] = ' |
|
174 | 174 | <div class="ee-batch-job-step-results"> |
175 | 175 | ' . $this->infoWrapper( |
176 | - sprintf( |
|
177 | - $custom_message !== '' |
|
178 | - ? $custom_message |
|
179 | - : esc_html__('processed this batch: %d', 'event_espresso'), |
|
180 | - $processed |
|
181 | - ) |
|
182 | - ) . ' |
|
176 | + sprintf( |
|
177 | + $custom_message !== '' |
|
178 | + ? $custom_message |
|
179 | + : esc_html__('processed this batch: %d', 'event_espresso'), |
|
180 | + $processed |
|
181 | + ) |
|
182 | + ) . ' |
|
183 | 183 | </div>'; |
184 | - } |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | - protected function displayJobFinalResults(JobParameters $job_parameters, string $custom_message = '') |
|
188 | - { |
|
189 | - if ($job_parameters->status() === JobParameters::status_complete) { |
|
190 | - $this->feedback[] = ' |
|
187 | + protected function displayJobFinalResults(JobParameters $job_parameters, string $custom_message = '') |
|
188 | + { |
|
189 | + if ($job_parameters->status() === JobParameters::status_complete) { |
|
190 | + $this->feedback[] = ' |
|
191 | 191 | <div class="ee-batch-job-final-results"> |
192 | 192 | ' . $this->okWrapper( |
193 | - sprintf( |
|
194 | - $custom_message !== '' |
|
195 | - ? $custom_message |
|
196 | - : esc_html__('total units processed: %d', 'event_espresso'), |
|
197 | - $job_parameters->units_processed() |
|
198 | - ) |
|
199 | - ) . ' |
|
193 | + sprintf( |
|
194 | + $custom_message !== '' |
|
195 | + ? $custom_message |
|
196 | + : esc_html__('total units processed: %d', 'event_espresso'), |
|
197 | + $job_parameters->units_processed() |
|
198 | + ) |
|
199 | + ) . ' |
|
200 | 200 | ' . $this->jobStatusNotice($job_parameters) . ' |
201 | 201 | </div>'; |
202 | - } |
|
203 | - } |
|
202 | + } |
|
203 | + } |
|
204 | 204 | |
205 | 205 | |
206 | - protected function jobStatusNotice(JobParameters $job_parameters): string |
|
207 | - { |
|
208 | - switch ($job_parameters->status()) { |
|
209 | - case JobParameters::status_cleaned_up: |
|
210 | - case JobParameters::status_continue: |
|
211 | - case JobParameters::status_pause: |
|
212 | - break; |
|
213 | - case JobParameters::status_complete: |
|
214 | - return $this->successWrapper('job status: COMPLETE'); |
|
215 | - case JobParameters::status_error: |
|
216 | - return $this->errorWrapper('job status: ERROR'); |
|
217 | - } |
|
218 | - return ''; |
|
219 | - } |
|
206 | + protected function jobStatusNotice(JobParameters $job_parameters): string |
|
207 | + { |
|
208 | + switch ($job_parameters->status()) { |
|
209 | + case JobParameters::status_cleaned_up: |
|
210 | + case JobParameters::status_continue: |
|
211 | + case JobParameters::status_pause: |
|
212 | + break; |
|
213 | + case JobParameters::status_complete: |
|
214 | + return $this->successWrapper('job status: COMPLETE'); |
|
215 | + case JobParameters::status_error: |
|
216 | + return $this->errorWrapper('job status: ERROR'); |
|
217 | + } |
|
218 | + return ''; |
|
219 | + } |
|
220 | 220 | |
221 | 221 | |
222 | - /** |
|
223 | - * @param string $update_text |
|
224 | - */ |
|
225 | - protected function updateText(string $update_text) |
|
226 | - { |
|
227 | - $this->feedback[] = "<p class='ee-batch-job-update'>$update_text</p>"; |
|
228 | - } |
|
222 | + /** |
|
223 | + * @param string $update_text |
|
224 | + */ |
|
225 | + protected function updateText(string $update_text) |
|
226 | + { |
|
227 | + $this->feedback[] = "<p class='ee-batch-job-update'>$update_text</p>"; |
|
228 | + } |
|
229 | 229 | |
230 | 230 | |
231 | - protected function updateTextHeader(string $update_text) |
|
232 | - { |
|
233 | - $this->feedback[] = "<h4 class='ee-batch-job-update-heading'>$update_text</h4>"; |
|
234 | - } |
|
231 | + protected function updateTextHeader(string $update_text) |
|
232 | + { |
|
233 | + $this->feedback[] = "<h4 class='ee-batch-job-update-heading'>$update_text</h4>"; |
|
234 | + } |
|
235 | 235 | |
236 | 236 | |
237 | - protected function attentionWrapper(string $update_text): string |
|
238 | - { |
|
239 | - return "<span class='ee-status-outline ee-status-bg--attention'>$update_text</span>"; |
|
240 | - } |
|
237 | + protected function attentionWrapper(string $update_text): string |
|
238 | + { |
|
239 | + return "<span class='ee-status-outline ee-status-bg--attention'>$update_text</span>"; |
|
240 | + } |
|
241 | 241 | |
242 | 242 | |
243 | - protected function errorWrapper(string $update_text): string |
|
244 | - { |
|
245 | - return "<span class='ee-status-outline ee-status-bg--error'>$update_text</span>"; |
|
246 | - } |
|
243 | + protected function errorWrapper(string $update_text): string |
|
244 | + { |
|
245 | + return "<span class='ee-status-outline ee-status-bg--error'>$update_text</span>"; |
|
246 | + } |
|
247 | 247 | |
248 | 248 | |
249 | - protected function infoWrapper(string $update_text): string |
|
250 | - { |
|
251 | - return "<span class='ee-status-outline ee-status-bg--info'>$update_text</span>"; |
|
252 | - } |
|
249 | + protected function infoWrapper(string $update_text): string |
|
250 | + { |
|
251 | + return "<span class='ee-status-outline ee-status-bg--info'>$update_text</span>"; |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | - protected function okWrapper(string $update_text): string |
|
256 | - { |
|
257 | - return "<span class='ee-status-outline ee-status-bg--ok'>$update_text</span>"; |
|
258 | - } |
|
255 | + protected function okWrapper(string $update_text): string |
|
256 | + { |
|
257 | + return "<span class='ee-status-outline ee-status-bg--ok'>$update_text</span>"; |
|
258 | + } |
|
259 | 259 | |
260 | 260 | |
261 | - protected function successWrapper(string $update_text): string |
|
262 | - { |
|
263 | - return "<span class='ee-status-outline ee-status-bg--success'>$update_text</span>"; |
|
264 | - } |
|
261 | + protected function successWrapper(string $update_text): string |
|
262 | + { |
|
263 | + return "<span class='ee-status-outline ee-status-bg--success'>$update_text</span>"; |
|
264 | + } |
|
265 | 265 | |
266 | 266 | |
267 | - protected function warningWrapper(string $update_text): string |
|
268 | - { |
|
269 | - return "<span class='ee-status-outline ee-status-bg--warning'>$update_text</span>"; |
|
270 | - } |
|
267 | + protected function warningWrapper(string $update_text): string |
|
268 | + { |
|
269 | + return "<span class='ee-status-outline ee-status-bg--warning'>$update_text</span>"; |
|
270 | + } |
|
271 | 271 | |
272 | 272 | |
273 | - /** |
|
274 | - * @return string |
|
275 | - */ |
|
276 | - protected function spinner(): string |
|
277 | - { |
|
278 | - return '<span class="spinner"></span>'; |
|
279 | - } |
|
273 | + /** |
|
274 | + * @return string |
|
275 | + */ |
|
276 | + protected function spinner(): string |
|
277 | + { |
|
278 | + return '<span class="spinner"></span>'; |
|
279 | + } |
|
280 | 280 | } |
@@ -30,121 +30,121 @@ |
||
30 | 30 | */ |
31 | 31 | class PreviewDeletion |
32 | 32 | { |
33 | - /** |
|
34 | - * @var NodeGroupDao |
|
35 | - */ |
|
36 | - protected $dao; |
|
33 | + /** |
|
34 | + * @var NodeGroupDao |
|
35 | + */ |
|
36 | + protected $dao; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var EEM_Event |
|
40 | - */ |
|
41 | - protected $event_model; |
|
38 | + /** |
|
39 | + * @var EEM_Event |
|
40 | + */ |
|
41 | + protected $event_model; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var EEM_Datetime |
|
45 | - */ |
|
46 | - protected $datetime_model; |
|
43 | + /** |
|
44 | + * @var EEM_Datetime |
|
45 | + */ |
|
46 | + protected $datetime_model; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @var EEM_Registration |
|
50 | - */ |
|
51 | - protected $registration_model; |
|
48 | + /** |
|
49 | + * @var EEM_Registration |
|
50 | + */ |
|
51 | + protected $registration_model; |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * PreviewDeletion constructor. |
|
56 | - * |
|
57 | - * @param NodeGroupDao $dao |
|
58 | - * @param EEM_Event $event_model |
|
59 | - * @param EEM_Datetime $datetime_model |
|
60 | - * @param EEM_Registration $registration_model |
|
61 | - */ |
|
62 | - public function __construct( |
|
63 | - NodeGroupDao $dao, |
|
64 | - EEM_Event $event_model, |
|
65 | - EEM_Datetime $datetime_model, |
|
66 | - EEM_Registration $registration_model |
|
67 | - ) { |
|
68 | - $this->dao = $dao; |
|
69 | - $this->event_model = $event_model; |
|
70 | - $this->datetime_model = $datetime_model; |
|
71 | - $this->registration_model = $registration_model; |
|
72 | - } |
|
54 | + /** |
|
55 | + * PreviewDeletion constructor. |
|
56 | + * |
|
57 | + * @param NodeGroupDao $dao |
|
58 | + * @param EEM_Event $event_model |
|
59 | + * @param EEM_Datetime $datetime_model |
|
60 | + * @param EEM_Registration $registration_model |
|
61 | + */ |
|
62 | + public function __construct( |
|
63 | + NodeGroupDao $dao, |
|
64 | + EEM_Event $event_model, |
|
65 | + EEM_Datetime $datetime_model, |
|
66 | + EEM_Registration $registration_model |
|
67 | + ) { |
|
68 | + $this->dao = $dao; |
|
69 | + $this->event_model = $event_model; |
|
70 | + $this->datetime_model = $datetime_model; |
|
71 | + $this->registration_model = $registration_model; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * Renders the preview deletion page. |
|
77 | - * |
|
78 | - * @param array $request_data |
|
79 | - * @param string $admin_base_url |
|
80 | - * @return array |
|
81 | - * @throws UnexpectedEntityException |
|
82 | - * @throws DomainException |
|
83 | - * @throws EE_Error |
|
84 | - * @throws InvalidDataTypeException |
|
85 | - * @throws InvalidInterfaceException |
|
86 | - * @throws InvalidArgumentException |
|
87 | - * @throws ReflectionException |
|
88 | - * @since 4.10.12.p |
|
89 | - */ |
|
90 | - public function handle(array $request_data, string $admin_base_url): array |
|
91 | - { |
|
92 | - $deletion_job_code = isset($request_data['deletion_job_code']) |
|
93 | - ? sanitize_key($request_data['deletion_job_code']) |
|
94 | - : ''; |
|
95 | - $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
96 | - $event_ids = $models_and_ids_to_delete['Event'] ?? []; |
|
97 | - if (empty($event_ids) || ! is_array($event_ids)) { |
|
98 | - throw new EE_Error( |
|
99 | - esc_html__('No Events were found to delete.', 'event_espresso') |
|
100 | - ); |
|
101 | - } |
|
102 | - $datetime_ids = $models_and_ids_to_delete['Datetime'] ?? []; |
|
103 | - if (! is_array($datetime_ids)) { |
|
104 | - throw new UnexpectedEntityException($datetime_ids, 'array'); |
|
105 | - } |
|
106 | - $registration_ids = $models_and_ids_to_delete['Registration'] ?? []; |
|
107 | - if (! is_array($registration_ids)) { |
|
108 | - throw new UnexpectedEntityException($registration_ids, 'array'); |
|
109 | - } |
|
110 | - $num_registrations_to_show = 10; |
|
111 | - $reg_count = count($registration_ids); |
|
112 | - if ($reg_count > $num_registrations_to_show) { |
|
113 | - $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show); |
|
114 | - } |
|
115 | - $form = new ConfirmEventDeletionForm($event_ids); |
|
116 | - $events = $this->event_model->get_all_deleted_and_undeleted( |
|
117 | - [['EVT_ID' => ['IN', $event_ids]]] |
|
118 | - ); |
|
119 | - $datetimes = $this->datetime_model->get_all_deleted_and_undeleted( |
|
120 | - [['DTT_ID' => ['IN', $datetime_ids]]] |
|
121 | - ); |
|
122 | - $registrations = $this->registration_model->get_all_deleted_and_undeleted( |
|
123 | - [['REG_ID' => ['IN', $registration_ids]]] |
|
124 | - ); |
|
125 | - $confirm_deletion_args = [ |
|
126 | - 'action' => 'confirm_deletion', |
|
127 | - 'deletion_job_code' => $deletion_job_code, |
|
128 | - ]; |
|
129 | - return [ |
|
130 | - 'admin_page_content' => EEH_Template::display_template( |
|
131 | - EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
132 | - [ |
|
133 | - 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
|
134 | - $confirm_deletion_args, |
|
135 | - $admin_base_url |
|
136 | - ), |
|
137 | - 'form' => $form, |
|
138 | - 'events' => $events, |
|
139 | - 'datetimes' => $datetimes, |
|
140 | - 'registrations' => $registrations, |
|
141 | - 'reg_count' => $reg_count, |
|
142 | - 'num_registrations_to_show' => $num_registrations_to_show, |
|
143 | - ], |
|
144 | - true |
|
145 | - ), |
|
146 | - ]; |
|
147 | - } |
|
75 | + /** |
|
76 | + * Renders the preview deletion page. |
|
77 | + * |
|
78 | + * @param array $request_data |
|
79 | + * @param string $admin_base_url |
|
80 | + * @return array |
|
81 | + * @throws UnexpectedEntityException |
|
82 | + * @throws DomainException |
|
83 | + * @throws EE_Error |
|
84 | + * @throws InvalidDataTypeException |
|
85 | + * @throws InvalidInterfaceException |
|
86 | + * @throws InvalidArgumentException |
|
87 | + * @throws ReflectionException |
|
88 | + * @since 4.10.12.p |
|
89 | + */ |
|
90 | + public function handle(array $request_data, string $admin_base_url): array |
|
91 | + { |
|
92 | + $deletion_job_code = isset($request_data['deletion_job_code']) |
|
93 | + ? sanitize_key($request_data['deletion_job_code']) |
|
94 | + : ''; |
|
95 | + $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
96 | + $event_ids = $models_and_ids_to_delete['Event'] ?? []; |
|
97 | + if (empty($event_ids) || ! is_array($event_ids)) { |
|
98 | + throw new EE_Error( |
|
99 | + esc_html__('No Events were found to delete.', 'event_espresso') |
|
100 | + ); |
|
101 | + } |
|
102 | + $datetime_ids = $models_and_ids_to_delete['Datetime'] ?? []; |
|
103 | + if (! is_array($datetime_ids)) { |
|
104 | + throw new UnexpectedEntityException($datetime_ids, 'array'); |
|
105 | + } |
|
106 | + $registration_ids = $models_and_ids_to_delete['Registration'] ?? []; |
|
107 | + if (! is_array($registration_ids)) { |
|
108 | + throw new UnexpectedEntityException($registration_ids, 'array'); |
|
109 | + } |
|
110 | + $num_registrations_to_show = 10; |
|
111 | + $reg_count = count($registration_ids); |
|
112 | + if ($reg_count > $num_registrations_to_show) { |
|
113 | + $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show); |
|
114 | + } |
|
115 | + $form = new ConfirmEventDeletionForm($event_ids); |
|
116 | + $events = $this->event_model->get_all_deleted_and_undeleted( |
|
117 | + [['EVT_ID' => ['IN', $event_ids]]] |
|
118 | + ); |
|
119 | + $datetimes = $this->datetime_model->get_all_deleted_and_undeleted( |
|
120 | + [['DTT_ID' => ['IN', $datetime_ids]]] |
|
121 | + ); |
|
122 | + $registrations = $this->registration_model->get_all_deleted_and_undeleted( |
|
123 | + [['REG_ID' => ['IN', $registration_ids]]] |
|
124 | + ); |
|
125 | + $confirm_deletion_args = [ |
|
126 | + 'action' => 'confirm_deletion', |
|
127 | + 'deletion_job_code' => $deletion_job_code, |
|
128 | + ]; |
|
129 | + return [ |
|
130 | + 'admin_page_content' => EEH_Template::display_template( |
|
131 | + EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
132 | + [ |
|
133 | + 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
|
134 | + $confirm_deletion_args, |
|
135 | + $admin_base_url |
|
136 | + ), |
|
137 | + 'form' => $form, |
|
138 | + 'events' => $events, |
|
139 | + 'datetimes' => $datetimes, |
|
140 | + 'registrations' => $registrations, |
|
141 | + 'reg_count' => $reg_count, |
|
142 | + 'num_registrations_to_show' => $num_registrations_to_show, |
|
143 | + ], |
|
144 | + true |
|
145 | + ), |
|
146 | + ]; |
|
147 | + } |
|
148 | 148 | } |
149 | 149 | // End of file PreviewDeletion.php |
150 | 150 | // Location: EventEspresso\core\domain\services\admin\events\data/PreviewDeletion.php |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | ); |
101 | 101 | } |
102 | 102 | $datetime_ids = $models_and_ids_to_delete['Datetime'] ?? []; |
103 | - if (! is_array($datetime_ids)) { |
|
103 | + if ( ! is_array($datetime_ids)) { |
|
104 | 104 | throw new UnexpectedEntityException($datetime_ids, 'array'); |
105 | 105 | } |
106 | 106 | $registration_ids = $models_and_ids_to_delete['Registration'] ?? []; |
107 | - if (! is_array($registration_ids)) { |
|
107 | + if ( ! is_array($registration_ids)) { |
|
108 | 108 | throw new UnexpectedEntityException($registration_ids, 'array'); |
109 | 109 | } |
110 | 110 | $num_registrations_to_show = 10; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | ]; |
129 | 129 | return [ |
130 | 130 | 'admin_page_content' => EEH_Template::display_template( |
131 | - EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php', |
|
131 | + EVENTS_TEMPLATE_PATH.'event_preview_deletion.template.php', |
|
132 | 132 | [ |
133 | 133 | 'form_url' => EE_Admin_Page::add_query_args_and_nonce( |
134 | 134 | $confirm_deletion_args, |
@@ -25,67 +25,67 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class ConfirmEventDeletionForm extends EE_Form_Section_Proper |
27 | 27 | { |
28 | - /** |
|
29 | - * @throws ReflectionException |
|
30 | - * @throws EE_Error |
|
31 | - */ |
|
32 | - public function __construct($event_ids, $options_array = array()) |
|
33 | - { |
|
34 | - if (! isset($options_array['subsections'])) { |
|
35 | - $options_array['subsections'] = []; |
|
36 | - } |
|
37 | - if ( |
|
38 | - ! ( |
|
39 | - isset($options_array['subsections']['events']) |
|
40 | - && $options_array['subsections']['events'] instanceof EE_Form_Section_Proper |
|
41 | - ) |
|
42 | - ) { |
|
43 | - $options_array['subsections']['events'] = new EE_Form_Section_Proper(); |
|
44 | - } |
|
45 | - $events_subsection = $options_array['subsections']['events']; |
|
46 | - $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
|
47 | - [ |
|
48 | - [ |
|
49 | - 'EVT_ID' => ['IN',$event_ids] |
|
50 | - ] |
|
51 | - ] |
|
52 | - ); |
|
53 | - if (! is_array($events)) { |
|
54 | - throw new UnexpectedEntityException($event_ids, 'array'); |
|
55 | - } |
|
56 | - $events_inputs = []; |
|
57 | - foreach ($events as $event) { |
|
58 | - if ($event instanceof EE_Event) { |
|
59 | - $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
60 | - [ |
|
61 | - 'yes' => $event->name(), |
|
62 | - ], |
|
63 | - [ |
|
64 | - 'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'), |
|
65 | - 'required' => true |
|
66 | - ] |
|
67 | - ); |
|
68 | - } |
|
69 | - } |
|
70 | - $events_subsection->add_subsections($events_inputs); |
|
71 | - $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input( |
|
72 | - [ |
|
73 | - 'yes' => esc_html__('I have backed up my database.', 'event_espresso') |
|
74 | - ], |
|
75 | - [ |
|
76 | - 'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'), |
|
77 | - 'required' => true |
|
78 | - ] |
|
79 | - ); |
|
80 | - $events_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
81 | - [ |
|
82 | - 'status' => 'trash', |
|
83 | - 'return' => 'default', |
|
84 | - ], |
|
85 | - EVENTS_ADMIN_URL |
|
86 | - ); |
|
87 | - $options_array['subsections']['buttons'] = new EE_Form_Section_HTML( |
|
88 | - " |
|
28 | + /** |
|
29 | + * @throws ReflectionException |
|
30 | + * @throws EE_Error |
|
31 | + */ |
|
32 | + public function __construct($event_ids, $options_array = array()) |
|
33 | + { |
|
34 | + if (! isset($options_array['subsections'])) { |
|
35 | + $options_array['subsections'] = []; |
|
36 | + } |
|
37 | + if ( |
|
38 | + ! ( |
|
39 | + isset($options_array['subsections']['events']) |
|
40 | + && $options_array['subsections']['events'] instanceof EE_Form_Section_Proper |
|
41 | + ) |
|
42 | + ) { |
|
43 | + $options_array['subsections']['events'] = new EE_Form_Section_Proper(); |
|
44 | + } |
|
45 | + $events_subsection = $options_array['subsections']['events']; |
|
46 | + $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
|
47 | + [ |
|
48 | + [ |
|
49 | + 'EVT_ID' => ['IN',$event_ids] |
|
50 | + ] |
|
51 | + ] |
|
52 | + ); |
|
53 | + if (! is_array($events)) { |
|
54 | + throw new UnexpectedEntityException($event_ids, 'array'); |
|
55 | + } |
|
56 | + $events_inputs = []; |
|
57 | + foreach ($events as $event) { |
|
58 | + if ($event instanceof EE_Event) { |
|
59 | + $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
60 | + [ |
|
61 | + 'yes' => $event->name(), |
|
62 | + ], |
|
63 | + [ |
|
64 | + 'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'), |
|
65 | + 'required' => true |
|
66 | + ] |
|
67 | + ); |
|
68 | + } |
|
69 | + } |
|
70 | + $events_subsection->add_subsections($events_inputs); |
|
71 | + $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input( |
|
72 | + [ |
|
73 | + 'yes' => esc_html__('I have backed up my database.', 'event_espresso') |
|
74 | + ], |
|
75 | + [ |
|
76 | + 'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'), |
|
77 | + 'required' => true |
|
78 | + ] |
|
79 | + ); |
|
80 | + $events_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
81 | + [ |
|
82 | + 'status' => 'trash', |
|
83 | + 'return' => 'default', |
|
84 | + ], |
|
85 | + EVENTS_ADMIN_URL |
|
86 | + ); |
|
87 | + $options_array['subsections']['buttons'] = new EE_Form_Section_HTML( |
|
88 | + " |
|
89 | 89 | <div class='ee-admin-button-row ee-admin-button-row--align-start'> |
90 | 90 | <input type='submit' |
91 | 91 | class='button button--primary' |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | " . esc_html__('Cancel', 'event_espresso') . " |
96 | 96 | </a> |
97 | 97 | </div>" |
98 | - ); |
|
99 | - parent::__construct($options_array); |
|
100 | - } |
|
98 | + ); |
|
99 | + parent::__construct($options_array); |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | // End of file ConfirmEventDeletionForm.php |
103 | 103 | // Location: EventEspresso\admin_pages\events\form_sections/ConfirmEventDeletionForm.php |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($event_ids, $options_array = array()) |
33 | 33 | { |
34 | - if (! isset($options_array['subsections'])) { |
|
34 | + if ( ! isset($options_array['subsections'])) { |
|
35 | 35 | $options_array['subsections'] = []; |
36 | 36 | } |
37 | 37 | if ( |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | $events = EEM_Event::instance()->get_all_deleted_and_undeleted( |
47 | 47 | [ |
48 | 48 | [ |
49 | - 'EVT_ID' => ['IN',$event_ids] |
|
49 | + 'EVT_ID' => ['IN', $event_ids] |
|
50 | 50 | ] |
51 | 51 | ] |
52 | 52 | ); |
53 | - if (! is_array($events)) { |
|
53 | + if ( ! is_array($events)) { |
|
54 | 54 | throw new UnexpectedEntityException($event_ids, 'array'); |
55 | 55 | } |
56 | 56 | $events_inputs = []; |
57 | 57 | foreach ($events as $event) { |
58 | 58 | if ($event instanceof EE_Event) { |
59 | - $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input( |
|
59 | + $events_inputs[$event->ID()] = new EE_Checkbox_Multi_Input( |
|
60 | 60 | [ |
61 | 61 | 'yes' => $event->name(), |
62 | 62 | ], |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | <div class='ee-admin-button-row ee-admin-button-row--align-start'> |
90 | 90 | <input type='submit' |
91 | 91 | class='button button--primary' |
92 | - value='" . esc_attr__('Confirm', 'event_espresso') . "' |
|
92 | + value='" . esc_attr__('Confirm', 'event_espresso')."' |
|
93 | 93 | /> |
94 | - <a href='" . esc_url_raw($events_list_url) . ";' class='button button--secondary'> |
|
95 | - " . esc_html__('Cancel', 'event_espresso') . " |
|
94 | + <a href='" . esc_url_raw($events_list_url).";' class='button button--secondary'> |
|
95 | + " . esc_html__('Cancel', 'event_espresso')." |
|
96 | 96 | </a> |
97 | 97 | </div>" |
98 | 98 | ); |
@@ -18,101 +18,101 @@ |
||
18 | 18 | </h2> |
19 | 19 | <h3> |
20 | 20 | <?php echo esc_html( |
21 | - sprintf( |
|
22 | - // translators: 1: number of events |
|
23 | - _n('%1$d Event', '%1$d Events', count($events), 'event_espresso'), |
|
24 | - count($events) |
|
25 | - ) |
|
26 | - ); |
|
21 | + sprintf( |
|
22 | + // translators: 1: number of events |
|
23 | + _n('%1$d Event', '%1$d Events', count($events), 'event_espresso'), |
|
24 | + count($events) |
|
25 | + ) |
|
26 | + ); |
|
27 | 27 | ?> |
28 | 28 | </h3> |
29 | 29 | <ul> |
30 | 30 | <?php |
31 | - foreach ($events as $event) { |
|
32 | - ?> |
|
31 | + foreach ($events as $event) { |
|
32 | + ?> |
|
33 | 33 | <li> |
34 | 34 | <?php echo esc_html($event->name()); ?> |
35 | 35 | </li> |
36 | 36 | <?php |
37 | - } |
|
38 | - ?> |
|
37 | + } |
|
38 | + ?> |
|
39 | 39 | </ul> |
40 | 40 | <h3> |
41 | 41 | <?php echo esc_html( |
42 | - sprintf( |
|
43 | - // translators: 1: number of datetimes |
|
44 | - _n('%1$d Datetime', '%1$d Datetimes', count($datetimes), 'event_espresso'), |
|
45 | - count($datetimes) |
|
46 | - ) |
|
47 | - ); |
|
42 | + sprintf( |
|
43 | + // translators: 1: number of datetimes |
|
44 | + _n('%1$d Datetime', '%1$d Datetimes', count($datetimes), 'event_espresso'), |
|
45 | + count($datetimes) |
|
46 | + ) |
|
47 | + ); |
|
48 | 48 | ?> |
49 | 49 | </h3> |
50 | 50 | <ul> |
51 | 51 | <?php |
52 | - foreach ($datetimes as $datetime) { |
|
53 | - ?> |
|
52 | + foreach ($datetimes as $datetime) { |
|
53 | + ?> |
|
54 | 54 | <li> |
55 | 55 | <?php echo esc_html($datetime->get_dtt_display_name(true)); ?> |
56 | 56 | </li> |
57 | 57 | <?php |
58 | - } |
|
59 | - ?> |
|
58 | + } |
|
59 | + ?> |
|
60 | 60 | </ul> |
61 | 61 | <h3> |
62 | 62 | <?php echo esc_html( |
63 | - sprintf( |
|
64 | - _n('%1$d Registration', '%1$d Registrations', $reg_count, 'event_espresso'), |
|
65 | - $reg_count |
|
66 | - ) |
|
67 | - ); |
|
63 | + sprintf( |
|
64 | + _n('%1$d Registration', '%1$d Registrations', $reg_count, 'event_espresso'), |
|
65 | + $reg_count |
|
66 | + ) |
|
67 | + ); |
|
68 | 68 | ?> |
69 | 69 | </h3> |
70 | 70 | <?php |
71 | 71 | if ($reg_count > count($registrations)) { |
72 | - ?> |
|
72 | + ?> |
|
73 | 73 | <p class="notice"> |
74 | 74 | <?php printf( |
75 | - esc_html__('Only showing first %1$d.', 'event_espresso'), |
|
76 | - count($registrations) |
|
77 | - ); |
|
78 | - ?> |
|
75 | + esc_html__('Only showing first %1$d.', 'event_espresso'), |
|
76 | + count($registrations) |
|
77 | + ); |
|
78 | + ?> |
|
79 | 79 | </p> |
80 | 80 | <?php |
81 | 81 | } |
82 | 82 | ?> |
83 | 83 | <?php |
84 | 84 | if ($reg_count > 0) { |
85 | - ?> |
|
85 | + ?> |
|
86 | 86 | <p> |
87 | 87 | <?php esc_html_e( |
88 | - 'Note: contacts will not be deleted, only their registrations for the enumerated events.', |
|
89 | - 'event_espresso' |
|
90 | - ); ?> |
|
88 | + 'Note: contacts will not be deleted, only their registrations for the enumerated events.', |
|
89 | + 'event_espresso' |
|
90 | + ); ?> |
|
91 | 91 | </p> |
92 | 92 | <?php |
93 | 93 | } |
94 | 94 | ?> |
95 | 95 | <ul> |
96 | 96 | <?php |
97 | - foreach ($registrations as $registration) { |
|
98 | - ?> |
|
97 | + foreach ($registrations as $registration) { |
|
98 | + ?> |
|
99 | 99 | <li> |
100 | 100 | <?php echo esc_html( |
101 | - sprintf( |
|
102 | - _x('%1$s (%2$d of %3$d)', 'Registration name (number of count)', 'event_espresso'), |
|
103 | - $registration->attendeeName(true), |
|
104 | - $registration->count(), |
|
105 | - $registration->group_size() |
|
106 | - ) |
|
107 | - ); ?> |
|
101 | + sprintf( |
|
102 | + _x('%1$s (%2$d of %3$d)', 'Registration name (number of count)', 'event_espresso'), |
|
103 | + $registration->attendeeName(true), |
|
104 | + $registration->count(), |
|
105 | + $registration->group_size() |
|
106 | + ) |
|
107 | + ); ?> |
|
108 | 108 | </li> |
109 | 109 | <?php |
110 | - } |
|
111 | - ?> |
|
110 | + } |
|
111 | + ?> |
|
112 | 112 | </ul> |
113 | 113 | <?php |
114 | 114 | |
115 | 115 | echo wp_kses( |
116 | - $form->form_open($form_url) . $form->get_html_and_js() . $form->form_close(), |
|
117 | - AllowedTags::getWithFormTags() |
|
116 | + $form->form_open($form_url) . $form->get_html_and_js() . $form->form_close(), |
|
117 | + AllowedTags::getWithFormTags() |
|
118 | 118 | ); |
@@ -113,6 +113,6 @@ |
||
113 | 113 | <?php |
114 | 114 | |
115 | 115 | echo wp_kses( |
116 | - $form->form_open($form_url) . $form->get_html_and_js() . $form->form_close(), |
|
116 | + $form->form_open($form_url).$form->get_html_and_js().$form->form_close(), |
|
117 | 117 | AllowedTags::getWithFormTags() |
118 | 118 | ); |
@@ -56,7 +56,7 @@ |
||
56 | 56 | </label> |
57 | 57 | </th> |
58 | 58 | <td> |
59 | - <span class="base-url"><?php echo site_url() . '/ ';?></span> |
|
59 | + <span class="base-url"><?php echo site_url().'/ '; ?></span> |
|
60 | 60 | <?php echo EEH_Form_Fields::text( |
61 | 61 | 'not_used', |
62 | 62 | EE_Registry::instance()->CFG->core->event_cpt_slug, |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
24 | 24 | |
25 | 25 | $values = EEH_Form_Fields::prep_answer_options( |
26 | - array( |
|
27 | - array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')), |
|
28 | - array('id' => 0, 'text' => esc_html__('No', 'event_espresso')), |
|
29 | - ) |
|
26 | + array( |
|
27 | + array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')), |
|
28 | + array('id' => 0, 'text' => esc_html__('No', 'event_espresso')), |
|
29 | + ) |
|
30 | 30 | ); |
31 | 31 | |
32 | 32 | $description = EEH_Form_Fields::prep_answer_options( |
33 | - array( |
|
34 | - array('id' => 0, 'text' => esc_html__('none', 'event_espresso')), |
|
35 | - array('id' => 1, 'text' => esc_html__('excerpt (short desc)', 'event_espresso')), |
|
36 | - array('id' => 2, 'text' => esc_html__('full description', 'event_espresso')), |
|
37 | - ) |
|
33 | + array( |
|
34 | + array('id' => 0, 'text' => esc_html__('none', 'event_espresso')), |
|
35 | + array('id' => 1, 'text' => esc_html__('excerpt (short desc)', 'event_espresso')), |
|
36 | + array('id' => 2, 'text' => esc_html__('full description', 'event_espresso')), |
|
37 | + ) |
|
38 | 38 | ); |
39 | 39 | |
40 | 40 | ?> |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | <th> |
54 | 54 | <label for="event_listings_url"> |
55 | 55 | <?php esc_html_e('Events List URL', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
56 | - 'event_listings_url_info' |
|
57 | - ); ?> |
|
56 | + 'event_listings_url_info' |
|
57 | + ); ?> |
|
58 | 58 | </label> |
59 | 59 | </th> |
60 | 60 | <td> |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | <span class="dashicons dashicons-external"></span> |
64 | 64 | </a> |
65 | 65 | <p class="description"><?php |
66 | - esc_html_e( |
|
67 | - 'This is the URL where all events will be displayed. You can change the slug below.', |
|
68 | - 'event_espresso' |
|
69 | - ); ?></p> |
|
66 | + esc_html_e( |
|
67 | + 'This is the URL where all events will be displayed. You can change the slug below.', |
|
68 | + 'event_espresso' |
|
69 | + ); ?></p> |
|
70 | 70 | </td> |
71 | 71 | </tr> |
72 | 72 | |
@@ -79,29 +79,29 @@ discard block |
||
79 | 79 | <td> |
80 | 80 | <span class="base-url"><?php echo site_url() . '/ ';?></span> |
81 | 81 | <?php echo EEH_Form_Fields::text( |
82 | - 'not_used', |
|
83 | - EE_Registry::instance()->CFG->core->event_cpt_slug, |
|
84 | - 'event_cpt_slug', |
|
85 | - 'event_cpt_slug', |
|
86 | - 'regular' |
|
87 | - ); ?> |
|
82 | + 'not_used', |
|
83 | + EE_Registry::instance()->CFG->core->event_cpt_slug, |
|
84 | + 'event_cpt_slug', |
|
85 | + 'event_cpt_slug', |
|
86 | + 'regular' |
|
87 | + ); ?> |
|
88 | 88 | <p class="description"><?php |
89 | - esc_html_e( |
|
90 | - 'This allows you to configure what slug is used for the url of all event pages.', |
|
91 | - 'event_espresso' |
|
92 | - ); ?></p> |
|
89 | + esc_html_e( |
|
90 | + 'This allows you to configure what slug is used for the url of all event pages.', |
|
91 | + 'event_espresso' |
|
92 | + ); ?></p> |
|
93 | 93 | <?php if (has_filter('FHEE__EE_Register_CPTs__register_CPT__rewrite')) : ?> |
94 | 94 | <p class="important-notice"> |
95 | 95 | <?php |
96 | - sprintf( |
|
97 | - esc_html__( |
|
98 | - 'Usage of the %1$s FHEE__EE_Register_CPTs__register_CPT__rewrite %2$s filter has been detected. Please be aware that while this filter is being used, this setting has no affect.', |
|
99 | - 'event_espresso' |
|
100 | - ), |
|
101 | - '<code>', |
|
102 | - '</code>' |
|
103 | - ); |
|
104 | - ?> |
|
96 | + sprintf( |
|
97 | + esc_html__( |
|
98 | + 'Usage of the %1$s FHEE__EE_Register_CPTs__register_CPT__rewrite %2$s filter has been detected. Please be aware that while this filter is being used, this setting has no affect.', |
|
99 | + 'event_espresso' |
|
100 | + ), |
|
101 | + '<code>', |
|
102 | + '</code>' |
|
103 | + ); |
|
104 | + ?> |
|
105 | 105 | </p> |
106 | 106 | <?php endif; ?> |
107 | 107 | </td> |
@@ -115,20 +115,20 @@ discard block |
||
115 | 115 | </th> |
116 | 116 | <td> |
117 | 117 | <?php echo wp_kses( |
118 | - EEH_Form_Fields::select( |
|
119 | - 'display_status_banner', |
|
120 | - (int) $display_status_banner, |
|
121 | - $values, |
|
122 | - 'EED_Events_Archive_display_status_banner', |
|
123 | - 'EED_Events_Archive_display_status_banner' |
|
124 | - ), |
|
125 | - AllowedTags::getWithFormTags() |
|
126 | - ); ?> |
|
118 | + EEH_Form_Fields::select( |
|
119 | + 'display_status_banner', |
|
120 | + (int) $display_status_banner, |
|
121 | + $values, |
|
122 | + 'EED_Events_Archive_display_status_banner', |
|
123 | + 'EED_Events_Archive_display_status_banner' |
|
124 | + ), |
|
125 | + AllowedTags::getWithFormTags() |
|
126 | + ); ?> |
|
127 | 127 | <p class="description"><?php |
128 | - esc_html_e( |
|
129 | - 'Whether the status banner should be shown on the events list page next to the Event title. The status banner is the banner that shows the status of the event (e.g. "Upcoming", "Expired", etc.).', |
|
130 | - 'event_espresso' |
|
131 | - ); ?></p> |
|
128 | + esc_html_e( |
|
129 | + 'Whether the status banner should be shown on the events list page next to the Event title. The status banner is the banner that shows the status of the event (e.g. "Upcoming", "Expired", etc.).', |
|
130 | + 'event_espresso' |
|
131 | + ); ?></p> |
|
132 | 132 | </td> |
133 | 133 | </tr> |
134 | 134 | |
@@ -136,26 +136,26 @@ discard block |
||
136 | 136 | <th> |
137 | 137 | <label for="EED_Events_Archive_display_description"> |
138 | 138 | <?php esc_html_e('Display Description', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
139 | - 'display_description_info' |
|
140 | - ); ?> |
|
139 | + 'display_description_info' |
|
140 | + ); ?> |
|
141 | 141 | </label> |
142 | 142 | </th> |
143 | 143 | <td> |
144 | 144 | <?php echo wp_kses( |
145 | - EEH_Form_Fields::select( |
|
146 | - 'description', |
|
147 | - (int) $display_description, |
|
148 | - $description, |
|
149 | - 'EED_Events_Archive_display_description', |
|
150 | - 'EED_Events_Archive_display_description' |
|
151 | - ), |
|
152 | - AllowedTags::getWithFormTags() |
|
153 | - ); ?> |
|
145 | + EEH_Form_Fields::select( |
|
146 | + 'description', |
|
147 | + (int) $display_description, |
|
148 | + $description, |
|
149 | + 'EED_Events_Archive_display_description', |
|
150 | + 'EED_Events_Archive_display_description' |
|
151 | + ), |
|
152 | + AllowedTags::getWithFormTags() |
|
153 | + ); ?> |
|
154 | 154 | <p class="description"><?php |
155 | - esc_html_e( |
|
156 | - 'Whether the event description should be shown on the events list page. If you choose "none" then the description will not be shown. If you choose "excerpt" then the short description will be shown. If you choose "full description" then the full description will be shown.', |
|
157 | - 'event_espresso' |
|
158 | - ); ?></p> |
|
155 | + esc_html_e( |
|
156 | + 'Whether the event description should be shown on the events list page. If you choose "none" then the description will not be shown. If you choose "excerpt" then the short description will be shown. If you choose "full description" then the full description will be shown.', |
|
157 | + 'event_espresso' |
|
158 | + ); ?></p> |
|
159 | 159 | </td> |
160 | 160 | </tr> |
161 | 161 | |
@@ -163,26 +163,26 @@ discard block |
||
163 | 163 | <th> |
164 | 164 | <label for="EED_Events_Archive_display_ticket_selector"> |
165 | 165 | <?php esc_html_e('Display Ticket Selector', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
166 | - 'display_ticket_selector_info' |
|
167 | - ); ?> |
|
166 | + 'display_ticket_selector_info' |
|
167 | + ); ?> |
|
168 | 168 | </label> |
169 | 169 | </th> |
170 | 170 | <td> |
171 | 171 | <?php echo wp_kses( |
172 | - EEH_Form_Fields::select( |
|
173 | - 'ticket_selector', |
|
174 | - (int) $display_ticket_selector, |
|
175 | - $values, |
|
176 | - 'EED_Events_Archive_display_ticket_selector', |
|
177 | - 'EED_Events_Archive_display_ticket_selector' |
|
178 | - ), |
|
179 | - AllowedTags::getWithFormTags() |
|
180 | - ); ?> |
|
172 | + EEH_Form_Fields::select( |
|
173 | + 'ticket_selector', |
|
174 | + (int) $display_ticket_selector, |
|
175 | + $values, |
|
176 | + 'EED_Events_Archive_display_ticket_selector', |
|
177 | + 'EED_Events_Archive_display_ticket_selector' |
|
178 | + ), |
|
179 | + AllowedTags::getWithFormTags() |
|
180 | + ); ?> |
|
181 | 181 | <p class="description"><?php |
182 | - esc_html_e( |
|
183 | - 'Whether the ticket selector should be shown on the events list page.', |
|
184 | - 'event_espresso' |
|
185 | - ); ?></p> |
|
182 | + esc_html_e( |
|
183 | + 'Whether the ticket selector should be shown on the events list page.', |
|
184 | + 'event_espresso' |
|
185 | + ); ?></p> |
|
186 | 186 | </td> |
187 | 187 | </tr> |
188 | 188 | |
@@ -190,26 +190,26 @@ discard block |
||
190 | 190 | <th> |
191 | 191 | <label for="EED_Events_Archive_display_datetimes"> |
192 | 192 | <?php esc_html_e('Display Datetimes', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
193 | - 'display_datetimes_info' |
|
194 | - ); ?> |
|
193 | + 'display_datetimes_info' |
|
194 | + ); ?> |
|
195 | 195 | </label> |
196 | 196 | </th> |
197 | 197 | <td> |
198 | 198 | <?php echo wp_kses( |
199 | - EEH_Form_Fields::select( |
|
200 | - 'venue_details', |
|
201 | - (int) $display_datetimes, |
|
202 | - $values, |
|
203 | - 'EED_Events_Archive_display_datetimes', |
|
204 | - 'EED_Events_Archive_display_datetimes' |
|
205 | - ), |
|
206 | - AllowedTags::getWithFormTags() |
|
207 | - ); ?> |
|
199 | + EEH_Form_Fields::select( |
|
200 | + 'venue_details', |
|
201 | + (int) $display_datetimes, |
|
202 | + $values, |
|
203 | + 'EED_Events_Archive_display_datetimes', |
|
204 | + 'EED_Events_Archive_display_datetimes' |
|
205 | + ), |
|
206 | + AllowedTags::getWithFormTags() |
|
207 | + ); ?> |
|
208 | 208 | <p class="description"><?php |
209 | - esc_html_e( |
|
210 | - 'Whether the date and time details should be shown on the events list page.', |
|
211 | - 'event_espresso' |
|
212 | - ); ?></p> |
|
209 | + esc_html_e( |
|
210 | + 'Whether the date and time details should be shown on the events list page.', |
|
211 | + 'event_espresso' |
|
212 | + ); ?></p> |
|
213 | 213 | </td> |
214 | 214 | </tr> |
215 | 215 | |
@@ -217,26 +217,26 @@ discard block |
||
217 | 217 | <th> |
218 | 218 | <label for="EED_Events_Archive_display_venue"> |
219 | 219 | <?php esc_html_e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
220 | - 'display_venue_details_info' |
|
221 | - ); ?> |
|
220 | + 'display_venue_details_info' |
|
221 | + ); ?> |
|
222 | 222 | </label> |
223 | 223 | </th> |
224 | 224 | <td> |
225 | 225 | <?php echo wp_kses( |
226 | - EEH_Form_Fields::select( |
|
227 | - 'display_venue', |
|
228 | - (int) $display_venue, |
|
229 | - $values, |
|
230 | - 'EED_Events_Archive_display_venue', |
|
231 | - 'EED_Events_Archive_display_venue' |
|
232 | - ), |
|
233 | - AllowedTags::getWithFormTags() |
|
234 | - ); ?> |
|
226 | + EEH_Form_Fields::select( |
|
227 | + 'display_venue', |
|
228 | + (int) $display_venue, |
|
229 | + $values, |
|
230 | + 'EED_Events_Archive_display_venue', |
|
231 | + 'EED_Events_Archive_display_venue' |
|
232 | + ), |
|
233 | + AllowedTags::getWithFormTags() |
|
234 | + ); ?> |
|
235 | 235 | <p class="description"><?php |
236 | - esc_html_e( |
|
237 | - 'Whether the venue details should be shown on the events list page.', |
|
238 | - 'event_espresso' |
|
239 | - ); ?></p> |
|
236 | + esc_html_e( |
|
237 | + 'Whether the venue details should be shown on the events list page.', |
|
238 | + 'event_espresso' |
|
239 | + ); ?></p> |
|
240 | 240 | </td> |
241 | 241 | </tr> |
242 | 242 | |
@@ -244,26 +244,26 @@ discard block |
||
244 | 244 | <th> |
245 | 245 | <label for="EED_Events_Archive_display_expired_events"> |
246 | 246 | <?php esc_html_e('Display Expired Events', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
247 | - 'display_expired_events_info' |
|
248 | - ); ?> |
|
247 | + 'display_expired_events_info' |
|
248 | + ); ?> |
|
249 | 249 | </label> |
250 | 250 | </th> |
251 | 251 | <td> |
252 | 252 | <?php echo wp_kses( |
253 | - EEH_Form_Fields::select( |
|
254 | - 'expired_events', |
|
255 | - (int) $display_expired_events, |
|
256 | - $values, |
|
257 | - 'EED_Events_Archive_display_expired_events', |
|
258 | - 'EED_Events_Archive_display_expired_events' |
|
259 | - ), |
|
260 | - AllowedTags::getWithFormTags() |
|
261 | - ); ?> |
|
253 | + EEH_Form_Fields::select( |
|
254 | + 'expired_events', |
|
255 | + (int) $display_expired_events, |
|
256 | + $values, |
|
257 | + 'EED_Events_Archive_display_expired_events', |
|
258 | + 'EED_Events_Archive_display_expired_events' |
|
259 | + ), |
|
260 | + AllowedTags::getWithFormTags() |
|
261 | + ); ?> |
|
262 | 262 | <p class="description"><?php |
263 | - esc_html_e( |
|
264 | - 'Whether expired events should be shown on the events list page.', |
|
265 | - 'event_espresso' |
|
266 | - ); ?></p> |
|
263 | + esc_html_e( |
|
264 | + 'Whether expired events should be shown on the events list page.', |
|
265 | + 'event_espresso' |
|
266 | + ); ?></p> |
|
267 | 267 | </td> |
268 | 268 | </tr> |
269 | 269 | |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | </th> |
276 | 276 | <td> |
277 | 277 | <?php echo wp_kses( |
278 | - EEH_Form_Fields::select( |
|
279 | - 'expired_tickets', |
|
280 | - (int) $display_events_with_expired_tickets, |
|
281 | - $values, |
|
282 | - 'EED_Events_Archive_display_events_with_expired_tickets', |
|
283 | - 'EED_Events_Archive_display_events_with_expired_tickets' |
|
284 | - ), |
|
285 | - AllowedTags::getWithFormTags() |
|
286 | - ); ?> |
|
278 | + EEH_Form_Fields::select( |
|
279 | + 'expired_tickets', |
|
280 | + (int) $display_events_with_expired_tickets, |
|
281 | + $values, |
|
282 | + 'EED_Events_Archive_display_events_with_expired_tickets', |
|
283 | + 'EED_Events_Archive_display_events_with_expired_tickets' |
|
284 | + ), |
|
285 | + AllowedTags::getWithFormTags() |
|
286 | + ); ?> |
|
287 | 287 | <p class="description"> |
288 | 288 | <?php esc_html_e( |
289 | - 'Whether events where ALL tickets are expired should be shown on the events list page.', |
|
290 | - 'event_espresso' |
|
291 | - ); ?> |
|
289 | + 'Whether events where ALL tickets are expired should be shown on the events list page.', |
|
290 | + 'event_espresso' |
|
291 | + ); ?> |
|
292 | 292 | </p> |
293 | 293 | <span class="ee-feature-highlight-2024-notice"> |
294 | 294 | ✨ <?php esc_html_e('NEW', 'event_espresso'); ?> |
@@ -300,51 +300,51 @@ discard block |
||
300 | 300 | <th> |
301 | 301 | <label for="EED_Events_Archive_use_sortable_display_order"> |
302 | 302 | <?php esc_html_e( |
303 | - 'Use Custom Display Order?', |
|
304 | - 'event_espresso' |
|
305 | - ); ?><?php // echo EEH_Template::get_help_tab_link('use_sortable_display_order_info');?> |
|
303 | + 'Use Custom Display Order?', |
|
304 | + 'event_espresso' |
|
305 | + ); ?><?php // echo EEH_Template::get_help_tab_link('use_sortable_display_order_info');?> |
|
306 | 306 | </label> |
307 | 307 | </th> |
308 | 308 | <td> |
309 | 309 | <?php echo wp_kses( |
310 | - EEH_Form_Fields::select( |
|
311 | - 'use_sortable_display_order', |
|
312 | - (int) $use_sortable_display_order, |
|
313 | - $values, |
|
314 | - 'EED_Events_Archive_use_sortable_display_order', |
|
315 | - 'EED_Events_Archive_use_sortable_display_order' |
|
316 | - ), |
|
317 | - AllowedTags::getWithFormTags() |
|
318 | - ); ?> |
|
310 | + EEH_Form_Fields::select( |
|
311 | + 'use_sortable_display_order', |
|
312 | + (int) $use_sortable_display_order, |
|
313 | + $values, |
|
314 | + 'EED_Events_Archive_use_sortable_display_order', |
|
315 | + 'EED_Events_Archive_use_sortable_display_order' |
|
316 | + ), |
|
317 | + AllowedTags::getWithFormTags() |
|
318 | + ); ?> |
|
319 | 319 | <p class="description"><?php |
320 | - esc_html_e( |
|
321 | - 'Selecting "Yes" will allow you to drag and drop the order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.', |
|
322 | - 'event_espresso' |
|
323 | - ); ?></p> |
|
320 | + esc_html_e( |
|
321 | + 'Selecting "Yes" will allow you to drag and drop the order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.', |
|
322 | + 'event_espresso' |
|
323 | + ); ?></p> |
|
324 | 324 | </td> |
325 | 325 | </tr> |
326 | 326 | |
327 | 327 | <tr> |
328 | 328 | <th> |
329 | 329 | <?php esc_html_e( |
330 | - 'Display Order', |
|
331 | - 'event_espresso' |
|
332 | - ); ?><?php // echo EEH_Template::get_help_tab_link( 'event_archive_order_info' ); ?> |
|
330 | + 'Display Order', |
|
331 | + 'event_espresso' |
|
332 | + ); ?><?php // echo EEH_Template::get_help_tab_link( 'event_archive_order_info' ); ?> |
|
333 | 333 | </th> |
334 | 334 | <td> |
335 | 335 | |
336 | 336 | <?php wp_nonce_field( |
337 | - 'espresso_update_event_archive_order', |
|
338 | - 'espresso_update_event_archive_order_nonce', |
|
339 | - false |
|
340 | - ); ?> |
|
337 | + 'espresso_update_event_archive_order', |
|
338 | + 'espresso_update_event_archive_order_nonce', |
|
339 | + false |
|
340 | + ); ?> |
|
341 | 341 | <?php echo wp_kses($event_archive_display_order, AllowedTags::getWithFormTags()); ?> |
342 | 342 | |
343 | 343 | <p class="description"><?php |
344 | - esc_html_e( |
|
345 | - 'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.', |
|
346 | - 'event_espresso' |
|
347 | - ); ?></p> |
|
344 | + esc_html_e( |
|
345 | + 'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.', |
|
346 | + 'event_espresso' |
|
347 | + ); ?></p> |
|
348 | 348 | |
349 | 349 | </td> |
350 | 350 | </tr> |
@@ -357,20 +357,20 @@ discard block |
||
357 | 357 | </th> |
358 | 358 | <td> |
359 | 359 | <?php echo wp_kses( |
360 | - EEH_Form_Fields::select( |
|
361 | - 'reset_event_list_settings', |
|
362 | - 0, |
|
363 | - $values, |
|
364 | - 'EED_Events_Archive_reset_event_list_settings', |
|
365 | - 'EED_Events_Archive_reset_event_list_settings' |
|
366 | - ), |
|
367 | - AllowedTags::getWithFormTags() |
|
368 | - ); ?> |
|
360 | + EEH_Form_Fields::select( |
|
361 | + 'reset_event_list_settings', |
|
362 | + 0, |
|
363 | + $values, |
|
364 | + 'EED_Events_Archive_reset_event_list_settings', |
|
365 | + 'EED_Events_Archive_reset_event_list_settings' |
|
366 | + ), |
|
367 | + AllowedTags::getWithFormTags() |
|
368 | + ); ?> |
|
369 | 369 | <p class="description"><?php |
370 | - esc_html_e( |
|
371 | - 'Selecting "Yes" will reset the Event List Settings to their default values.', |
|
372 | - 'event_espresso' |
|
373 | - ); ?></p> |
|
370 | + esc_html_e( |
|
371 | + 'Selecting "Yes" will reset the Event List Settings to their default values.', |
|
372 | + 'event_espresso' |
|
373 | + ); ?></p> |
|
374 | 374 | </td> |
375 | 375 | </tr> |
376 | 376 |
@@ -25,49 +25,49 @@ |
||
25 | 25 | */ |
26 | 26 | class CreateTransactionCommandHandler extends CommandHandler |
27 | 27 | { |
28 | - public function __construct() |
|
29 | - { |
|
30 | - defined('EVENT_ESPRESSO_VERSION') || exit; |
|
31 | - } |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + defined('EVENT_ESPRESSO_VERSION') || exit; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @param CommandInterface|CreateTransactionCommand $command |
|
36 | - * @return mixed |
|
37 | - * @throws EE_Error |
|
38 | - * @throws InvalidEntityException |
|
39 | - * @throws InvalidDataTypeException |
|
40 | - * @throws InvalidInterfaceException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws ReflectionException |
|
43 | - * @throws RuntimeException |
|
44 | - */ |
|
45 | - public function handle(CommandInterface $command) |
|
46 | - { |
|
47 | - $transaction_details = $command->transactionDetails(); |
|
48 | - $cart_total = null; |
|
49 | - if ($command->checkout() instanceof EE_Checkout) { |
|
50 | - // ensure cart totals have been calculated |
|
51 | - $command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
52 | - // grab the cart grand total |
|
53 | - $cart_total = $command->checkout()->cart->get_cart_grand_total(); |
|
54 | - $transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array(); |
|
55 | - $transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0; |
|
56 | - } |
|
57 | - // create new TXN and save it so it has an ID |
|
58 | - $transaction = EE_Transaction::new_instance($transaction_details); |
|
59 | - if (! $transaction instanceof EE_Transaction) { |
|
60 | - throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
|
61 | - } |
|
62 | - $transaction->save(); |
|
63 | - // ensure grand total line item created |
|
64 | - $cart_total = $cart_total instanceof EE_Line_Item |
|
65 | - ? $cart_total |
|
66 | - : EEH_Line_Item::create_total_line_item($transaction); |
|
67 | - if (! $cart_total instanceof EE_Line_Item) { |
|
68 | - throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
|
69 | - } |
|
70 | - $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
|
71 | - return $transaction; |
|
72 | - } |
|
34 | + /** |
|
35 | + * @param CommandInterface|CreateTransactionCommand $command |
|
36 | + * @return mixed |
|
37 | + * @throws EE_Error |
|
38 | + * @throws InvalidEntityException |
|
39 | + * @throws InvalidDataTypeException |
|
40 | + * @throws InvalidInterfaceException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws ReflectionException |
|
43 | + * @throws RuntimeException |
|
44 | + */ |
|
45 | + public function handle(CommandInterface $command) |
|
46 | + { |
|
47 | + $transaction_details = $command->transactionDetails(); |
|
48 | + $cart_total = null; |
|
49 | + if ($command->checkout() instanceof EE_Checkout) { |
|
50 | + // ensure cart totals have been calculated |
|
51 | + $command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
52 | + // grab the cart grand total |
|
53 | + $cart_total = $command->checkout()->cart->get_cart_grand_total(); |
|
54 | + $transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array(); |
|
55 | + $transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0; |
|
56 | + } |
|
57 | + // create new TXN and save it so it has an ID |
|
58 | + $transaction = EE_Transaction::new_instance($transaction_details); |
|
59 | + if (! $transaction instanceof EE_Transaction) { |
|
60 | + throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
|
61 | + } |
|
62 | + $transaction->save(); |
|
63 | + // ensure grand total line item created |
|
64 | + $cart_total = $cart_total instanceof EE_Line_Item |
|
65 | + ? $cart_total |
|
66 | + : EEH_Line_Item::create_total_line_item($transaction); |
|
67 | + if (! $cart_total instanceof EE_Line_Item) { |
|
68 | + throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
|
69 | + } |
|
70 | + $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
|
71 | + return $transaction; |
|
72 | + } |
|
73 | 73 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | // create new TXN and save it so it has an ID |
53 | 53 | $transaction = EE_Transaction::new_instance($transaction_details); |
54 | - if (! $transaction instanceof EE_Transaction) { |
|
54 | + if ( ! $transaction instanceof EE_Transaction) { |
|
55 | 55 | throw new InvalidEntityException(get_class($transaction), 'EE_Transaction'); |
56 | 56 | } |
57 | 57 | $transaction->save(); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $cart_total = $cart_total instanceof EE_Line_Item |
60 | 60 | ? $cart_total |
61 | 61 | : EEH_Line_Item::create_total_line_item($transaction); |
62 | - if (! $cart_total instanceof EE_Line_Item) { |
|
62 | + if ( ! $cart_total instanceof EE_Line_Item) { |
|
63 | 63 | throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item'); |
64 | 64 | } |
65 | 65 | $cart_total->save_this_and_descendants_to_txn($transaction->ID()); |
@@ -21,36 +21,36 @@ |
||
21 | 21 | */ |
22 | 22 | class CopyRegistrationPaymentsCommandHandler extends CommandHandler |
23 | 23 | { |
24 | - /** |
|
25 | - * @var CopyRegistrationService $copy_registration_service |
|
26 | - */ |
|
27 | - private $copy_registration_service; |
|
24 | + /** |
|
25 | + * @var CopyRegistrationService $copy_registration_service |
|
26 | + */ |
|
27 | + private $copy_registration_service; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Command constructor |
|
32 | - * |
|
33 | - * @param CopyRegistrationService $copy_registration_service |
|
34 | - */ |
|
35 | - public function __construct(CopyRegistrationService $copy_registration_service) |
|
36 | - { |
|
37 | - defined('EVENT_ESPRESSO_VERSION') || exit; |
|
38 | - $this->copy_registration_service = $copy_registration_service; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Command constructor |
|
32 | + * |
|
33 | + * @param CopyRegistrationService $copy_registration_service |
|
34 | + */ |
|
35 | + public function __construct(CopyRegistrationService $copy_registration_service) |
|
36 | + { |
|
37 | + defined('EVENT_ESPRESSO_VERSION') || exit; |
|
38 | + $this->copy_registration_service = $copy_registration_service; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @param CommandInterface|CopyRegistrationPaymentsCommand $command |
|
44 | - * @return boolean |
|
45 | - * @throws EE_Error |
|
46 | - * @throws UnexpectedEntityException |
|
47 | - * @throws RuntimeException |
|
48 | - */ |
|
49 | - public function handle(CommandInterface $command) |
|
50 | - { |
|
51 | - return $this->copy_registration_service->copyPaymentDetails( |
|
52 | - $command->targetRegistration(), |
|
53 | - $command->registrationToCopy() |
|
54 | - ); |
|
55 | - } |
|
42 | + /** |
|
43 | + * @param CommandInterface|CopyRegistrationPaymentsCommand $command |
|
44 | + * @return boolean |
|
45 | + * @throws EE_Error |
|
46 | + * @throws UnexpectedEntityException |
|
47 | + * @throws RuntimeException |
|
48 | + */ |
|
49 | + public function handle(CommandInterface $command) |
|
50 | + { |
|
51 | + return $this->copy_registration_service->copyPaymentDetails( |
|
52 | + $command->targetRegistration(), |
|
53 | + $command->registrationToCopy() |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | } |
@@ -15,47 +15,47 @@ |
||
15 | 15 | */ |
16 | 16 | class CopyRegistrationDetailsCommand extends Command |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EE_Registration $target_registration |
|
20 | - */ |
|
21 | - private $target_registration; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var EE_Registration $registration_to_copy |
|
25 | - */ |
|
26 | - private $registration_to_copy; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * CopyRegistrationDetailsCommand constructor. |
|
31 | - * |
|
32 | - * @param EE_Registration $target_registration |
|
33 | - * @param EE_Registration $registration_to_copy |
|
18 | + /** |
|
19 | + * @var EE_Registration $target_registration |
|
20 | + */ |
|
21 | + private $target_registration; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var EE_Registration $registration_to_copy |
|
25 | + */ |
|
26 | + private $registration_to_copy; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * CopyRegistrationDetailsCommand constructor. |
|
31 | + * |
|
32 | + * @param EE_Registration $target_registration |
|
33 | + * @param EE_Registration $registration_to_copy |
|
34 | 34 | v |
35 | - */ |
|
36 | - public function __construct( |
|
37 | - EE_Registration $target_registration, |
|
38 | - EE_Registration $registration_to_copy |
|
39 | - ) { |
|
40 | - $this->target_registration = $target_registration; |
|
41 | - $this->registration_to_copy = $registration_to_copy; |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @return EE_Registration |
|
47 | - */ |
|
48 | - public function targetRegistration() |
|
49 | - { |
|
50 | - return $this->target_registration; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @return EE_Registration |
|
56 | - */ |
|
57 | - public function registrationToCopy() |
|
58 | - { |
|
59 | - return $this->registration_to_copy; |
|
60 | - } |
|
35 | + */ |
|
36 | + public function __construct( |
|
37 | + EE_Registration $target_registration, |
|
38 | + EE_Registration $registration_to_copy |
|
39 | + ) { |
|
40 | + $this->target_registration = $target_registration; |
|
41 | + $this->registration_to_copy = $registration_to_copy; |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @return EE_Registration |
|
47 | + */ |
|
48 | + public function targetRegistration() |
|
49 | + { |
|
50 | + return $this->target_registration; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @return EE_Registration |
|
56 | + */ |
|
57 | + public function registrationToCopy() |
|
58 | + { |
|
59 | + return $this->registration_to_copy; |
|
60 | + } |
|
61 | 61 | } |